Skip to content
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

feat: merge dev into main #123

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions funding.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"opRetro": {
"projectId": "0x8c76c13d8d0e63a7de499d47b9da5a4495d1151c0b2003c92379f41f14e404c0"
}
}
2 changes: 1 addition & 1 deletion trie/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ func zkMerkleTreeNodeBlobFunctions(findBlobByHash func(key []byte) ([]byte, erro
) {
return func(hash common.Hash) ([]byte, error) {
if bytes.Equal(hash.Bytes(), zkt.HashZero[:]) {
return nil, nil
return zk.EmptyNodeValue.CanonicalValue(), nil
}
return findBlobByHash(zkt.ReverseByteOrder(hash.Bytes()))
},
Expand Down
23 changes: 23 additions & 0 deletions trie/iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,29 @@ func TestMerkleTreeIterator(t *testing.T) {
return tree, db
}

t.Run("empty root", func(t *testing.T) {
t.Run("zk merkle tree", func(t *testing.T) {
trie := NewEmptyMerkleTrie(NewZkDatabase(rawdb.NewMemoryDatabase()))
it, _ := trie.NodeIterator(nil)
for it.Next(true) {
Comment on lines +667 to +668
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Check NodeIterator errors before proceeding with iteration.

The error returned from NodeIterator() should be checked before starting iteration.

Apply this pattern to both test cases:

-        it, _ := trie.NodeIterator(nil)
+        it, err := trie.NodeIterator(nil)
+        if err != nil {
+            t.Fatalf("failed to create iterator: %v", err)
+        }
         for it.Next(true) {

Also applies to: 677-678

t.Fail()
}
if it.Error() != nil {
t.Error(it.Error())
}
})
t.Run("zk trie", func(t *testing.T) {
trie, _ := NewZkTrie(common.Hash{}, NewZkDatabase(rawdb.NewDatabase(memorydb.New())))
it, _ := trie.NodeIterator(nil)
for it.Next(true) {
t.Fail()
}
if it.Error() != nil {
t.Error(it.Error())
}
})
})

t.Run("zk merkle tree", func(t *testing.T) {
tree, db := makeMerkleTreeWithData(testdata1)
expected := db.Len()
Expand Down
Loading