Skip to content

Conversation

@technicallyty
Copy link
Contributor

Description

Closes: #25573

Implements membership and non-membership proofs on IAVLX tree

@github-actions
Copy link
Contributor

@technicallyty your pull request is missing a changelog!

return nil, err
}
if rightNode != nil {
rightKey, err := rightNode.Key()

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of err is never used.

Copilot Autofix

AI about 6 hours ago

The best way to fix this problem is to properly check and handle the error from the call to rightNode.Key(). Specifically, after line 137, add an error check: if err is not nil, return the error, mirroring how errors are treated after similar lines above (like for leftNode.Key() and others). This ensures any error from Key() does not go unnoticed, aligning with good Go error-handling practice.

  • Change required in file iavlx/immutable_tree.go, lines 137–139:
    • After assigning rightKey, err := rightNode.Key(), check if err is non-nil, and return as appropriate.
  • No new imports or definitions are needed; simply add the error check.

Suggested changeset 1
iavlx/immutable_tree.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/iavlx/immutable_tree.go b/iavlx/immutable_tree.go
--- a/iavlx/immutable_tree.go
+++ b/iavlx/immutable_tree.go
@@ -135,7 +135,9 @@
 	}
 	if rightNode != nil {
 		rightKey, err := rightNode.Key()
-
+		if err != nil {
+			return nil, err
+		}
 		if rightKey != nil {
 			nonexist.Right, err = createExistenceProof(root, rightKey)
 			if err != nil {
EOF
@@ -135,7 +135,9 @@
}
if rightNode != nil {
rightKey, err := rightNode.Key()

if err != nil {
return nil, err
}
if rightKey != nil {
nonexist.Right, err = createExistenceProof(root, rightKey)
if err != nil {
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't look at the implementation logic in thorough detail yet, but I see there are a few tests. It would be nice to have some tests that generate lots of random cases like the rapid tests we have with TestIAVLXSims. Maybe we could even integrate some proof tests there?

Also for full integration, we need the ABCI Query methods implemented like this:

func (st *Store) Query(req *types.RequestQuery) (res *types.ResponseQuery, err error) {

return NewImmutableTree(rootPtr), nil
}

func (c *CommitTree) GetImmutableImpl(version int64) (*ImmutableTree, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just change the return type for the existing GetImmutable method to *ImmutableTree

iavlx/proof.go Outdated
// NextIndex returns the index that would be assigned to the key.
// This method assumes the key does not exist.
// Callers are expected to check that t.Has(key) == false.
func NextIndex(node Node, key []byte) (int64, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func NextIndex(node Node, key []byte) (int64, error) {
func nextIndex(node Node, key []byte) (int64, error) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

iavlx: implement ICS23 proofs

3 participants