-
Notifications
You must be signed in to change notification settings - Fork 588
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
imp: cleanup verifcation arg code for 23-commitment #7493
base: main
Are you sure you want to change the base?
Conversation
@@ -234,16 +226,8 @@ func (proof *MerkleProof) Empty() bool { | |||
return proof == nil || proto.Equal(proof, blankMerkleProof) || proto.Equal(proof, blankProofOps) |
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.
blankProofOps
check? This can be deleted right?? I don't understand the context of when one could provide that type as MerkleProof
?
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.
Agree, doesn't seem to make sense to me
// validateVerificationArgs verifies the proof arguments are valid | ||
func (proof MerkleProof) validateVerificationArgs(specs []*ics23.ProofSpec, root exported.Root) error { | ||
func validateVerificationArgs(proof MerkleProof, path v2.MerklePath, specs []*ics23.ProofSpec, root exported.Root) error { | ||
if proof.Empty() { |
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.
maybe this should be if proof == nil || proof.GetProofs() == nil
. I don't feel like the proof.Empty()
is very effective and creates extra space in this file
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.
Support this 👍🏻
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.
Could also just call this Validate(specs)
as method on merkle proof and move root nil checks to where its being used.
This is also totally fine, and happy to move along with it! 🙏🏻
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.
made the change, but left off the Validate(specs)
suggestion. Happy to approve a followup, but wasn't exactly sure what changes you had in mind
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 clean up!
@@ -234,16 +226,8 @@ func (proof *MerkleProof) Empty() bool { | |||
return proof == nil || proto.Equal(proof, blankMerkleProof) || proto.Equal(proof, blankProofOps) |
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.
Agree, doesn't seem to make sense to me
// validateVerificationArgs verifies the proof arguments are valid | ||
func (proof MerkleProof) validateVerificationArgs(specs []*ics23.ProofSpec, root exported.Root) error { | ||
func validateVerificationArgs(proof MerkleProof, path v2.MerklePath, specs []*ics23.ProofSpec, root exported.Root) error { | ||
if proof.Empty() { |
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.
Support this 👍🏻
if len(specs) != len(proof.Proofs) { | ||
return errorsmod.Wrapf(ErrInvalidMerkleProof, | ||
"length of specs: %d not equal to length of proof: %d", | ||
len(specs), len(proof.Proofs)) | ||
return errorsmod.Wrapf(ErrInvalidMerkleProof, "length of specs: %d not equal to length of proof: %d", len(specs), len(proof.Proofs)) | ||
} | ||
|
||
if len(path.KeyPath) != len(specs) { | ||
return errorsmod.Wrapf(ErrInvalidProof, "path length %d not same as proof %d", len(path.KeyPath), len(specs)) |
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.
Maybe we could indicate in godoc why this is. e.g. key path of length > 1 is expected to be a chained proof.
Every path element inside path.KeyPath
is expected to have a corresponding proofSpec, right? In the normal case first we calculate subroots for inclusion/non-inclusion and then inclusion of the subroot in commitment root.
Only in the case of path.KeyPath == 1
, would we be able to do a single inclusion or non-inclusion proof.
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.
Correct. This code is expecting to receive a list of keys which corresponds to different trees (which is why it must be a list of specs, 1 per tree)
// validateVerificationArgs verifies the proof arguments are valid | ||
func (proof MerkleProof) validateVerificationArgs(specs []*ics23.ProofSpec, root exported.Root) error { | ||
func validateVerificationArgs(proof MerkleProof, path v2.MerklePath, specs []*ics23.ProofSpec, root exported.Root) error { | ||
if proof.Empty() { |
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.
Could also just call this Validate(specs)
as method on merkle proof and move root nil checks to where its being used.
This is also totally fine, and happy to move along with it! 🙏🏻
…o into colin/23-commitment-cleanup
Quality Gate passed for 'ibc-go'Issues Measures |
Description
couldn't help myself 😄
closes: #XXXX
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
).godoc
comments.Files changed
in the GitHub PR explorer.SonarCloud Report
in the comment section below once CI passes.