-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rpc+tapcli: Implement method to decode proofs into human-readable format #181
Conversation
dbd8496
to
0a3cf18
Compare
Totally! I think in addition to the basic decode method, it also makes sense to return this information (the last snapshot) from the verify proof command as well. |
Answering the questions you posted:
I think so. It's also possible to pass in an index, then we can seek to the desired index using this method: https://github.com/lightninglabs/taro/blob/main/proof/file.go#L203-L205
I think the block header/height information would be useful. Then maybe a verbose option to include the serialized Bitcoin merkle proof as well as the series of inclusion (and exclusion) proofs?
Yeah, this commits the set of dependancies.
If you do I'd leave those versions the same, since we pin to the same version so everyone generates the same set of protos. |
@habibitcoin Any update on when we can expect this? |
Thanks for the review @Roasbeef ! All makes sense @dstadulis expecting to complete this over Thanksgiving holiday at latest |
0a3cf18
to
29ff7db
Compare
@Roasbeef I'm having a bit of trouble on
I believe everything else is implemented! Example output below: |
The field
Yes, that looks good. Seems like all the fields mentioned (
Yes,
Yes, the |
Latest output:
|
Also thinking to just remove block height because there doesnt appear to be any easy way to extract this information |
Should just be available as a field: https://github.com/lightninglabs/taro/blob/f6a581b6395fe779db7cbb5a4536a39bb0440dbe/proof/file.go#L317-L318 |
Is this ready for another round @habibitcoin ? |
29ff7db
to
cbf1ef3
Compare
Same issue #230 for AnchorBlockHash. Included that. Ready for final review @Roasbeef !
|
Also 1 last question, wondering if I should include this is the same or a new PR: meta should not be displayed as bytes. It is sent in via CLI as a string, so should be output as the string:
String seems much more useful? |
I think for now can have it assume things are displayed as bytes, I'm making some changes to how the meta bytes are presented/transmitted in this PR: #249. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! This should be super useful for future UIs and also general debugging and tinkering. I think the only thing this is missing is a basic integration tests, which can cover things like:
- the error paths (no proof, index too large, etc)
- proof matching up with the same proof decoded externally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good @habibitcoin 🎉
I left some doubts and a couple of nits
rpcserver.go
Outdated
err error | ||
) | ||
|
||
if index < 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for "partially verified" we could do it in a reverse way
if len(proofs) >= index {
// return err
}
// Proofs are store from older to newer.
proofIdx := proofFile.NumProofs() - 1 - idx
decodedProof, err = proofFile.ProofAt(proofIdx)
if err != nil {
return nil, err
}
In that case you get by default the last proof, that is what you will usually want.
@habibitcoin can you check positiveblue's comments? Would love to include your PR in the |
@dstadulis almost done! Have addressed most comments locally. Mainly just need to add comments and tests now. @positiveblue @Roasbeef any guidance on tests you can provide? My initial plan was to create a proofs_test.go file in itest and use assets_test as a bit of inspiration. Mint an asset, export it, verify the proof, and confirm the output matches that of the assets list CLI. Thoughts? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, LGTM, just a couple of nits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution with this! left some notes re: metadata and input verification.
rpcserver.go
Outdated
) | ||
|
||
// Default to latest proof | ||
index = int64(proofFile.NumProofs()) - 1 - index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should check that index >= 0 && index < proofFile.NumProofs()
if index is going to be an int, to reject invalid indexes and make sure this never goes below 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be a superior UX?
[tapcli] unable to verify file: rpc error: code = Unknown desc = unable to marshal proof: invalid index 4294967295
The above is the current error message returned. I modified it so it returns the index you actually input, and I think this is most helpful to the user instead of making any assumptions about the proper index:
[tapcli] unable to verify file: rpc error: code = Unknown desc = unable to marshal proof: invalid index 2 is greater than latest proof index of 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's okay the way it is, but maybe we should make the proof_at_depth
field uint32
to avoid it being negative? And I don't think files with more than 2 billion proofs will ever exist, so 32bit should be enough.
@habibitcoin we're shaping the queue of PRs for |
@Roasbeef: review reminder |
@habibitcoin sorry to bother you, do you think you will be able to finish it ? thx again for your great work ! |
Believe this PR is being worked on for v0.2.1 |
409e7ce
to
ebe5717
Compare
@dstadulis ready for final review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for the update!
Did a final pass, mostly nits, nothing major. So this is very close IMO.
rpcserver.go
Outdated
) | ||
|
||
// Default to latest proof | ||
index = int64(proofFile.NumProofs()) - 1 - index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's okay the way it is, but maybe we should make the proof_at_depth
field uint32
to avoid it being negative? And I don't think files with more than 2 billion proofs will ever exist, so 32bit should be enough.
ebe5717
to
f51ce2d
Compare
@dstadulis ready for review again 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pushing this to the end @habibitcoin 🎉
LGTM. I see that you added some of the fields that @guggero proposed to the grpc messages but they are not used anywhere. Do you plan to populate the num_additional_inputs
/challenge_witness
fields in your responses too??
@positiveblue thanks for the review! Not sure I understand your comment re; the addtl fields, they should be returned properly I believe, attached a sample output:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! Just two more small nits then we're good to go.
taprpc: use string everywhere for blockhash itest: update for anchor blockhash given as a string
taprpc: create DecodeProofRequest and DecodeProofResponse objects rpc: Implement DecodeProof + include into VerifyProof
f51ce2d
to
dc1f762
Compare
@guggero think this should be ready! |
|
||
// The merkle proof for AnchorTx used to prove its | ||
// inclusion within BlockHeader. | ||
bytes tx_merkle_proof = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, as we only have the block hash in there. But with the block hash someone wanting to verify the proof outside of tapd
could fetch the whole block and do it that way, so I guess it's okay for now.
Related to #180
Would be nice to be able to view proofs in human readable format (https://github.com/lightninglabs/taro/blob/main/proof/proof_test.go#L127); this will make it easier for individuals to wrap their mind around the mental model of proofs, and what they contain, and ideally accelerate universe development
Able to access some of the raw data!
edit: here is sample output as of now: