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

Snap/merge range and proof #1913

Closed
wants to merge 39 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
5cd826f
updating verify proof range to handle empty proof keys
Jun 7, 2024
3ecb395
test non set proof key - wip
Jun 7, 2024
d2fe491
wip - proof to Path doesn't work
Jun 7, 2024
2cd3157
store the hashes of children in ProofToPath
Jun 8, 2024
3603e28
ProoftoPath update to handle unset proof key
Jun 8, 2024
d8f5811
test - wip
Jun 8, 2024
40a3d04
test - wip
Jun 9, 2024
fb6c899
test passes! :D
Jun 10, 2024
07e99f5
lint
Jun 10, 2024
c0b933a
tidy
Jun 10, 2024
529aef2
fixing tests that broke wip
Jun 10, 2024
ca360e9
build4keyTrie passes again!
Jun 11, 2024
fdf6af2
fixed more tests
Jun 11, 2024
9f9f2fe
fix test wip
Jun 11, 2024
bad7267
fix more tests
Jun 11, 2024
92a98df
fix test -wip
Jun 11, 2024
727801b
fix tests wip
Jun 11, 2024
b4ae2b6
wip
Jun 11, 2024
a123730
all tests passgit add .
Jun 12, 2024
d249186
lint
Jun 12, 2024
21f9453
tidy
Jun 12, 2024
2d7c6e8
tidy logic
Jun 12, 2024
46c7b8a
tidy logic
Jun 12, 2024
0bb2edc
tidy logic
Jun 12, 2024
ce20e08
comment: update getLeftRightHash
Jun 12, 2024
ec2f917
update ProofToPath comment
Jun 12, 2024
dd21cc0
bubble up getLeftRightHash err
Jun 12, 2024
571eb6e
Trie iterate
asdacap Jun 14, 2024
b614c2e
Address comment
asdacap Jun 14, 2024
89cf035
Merge branch 'feature/trie-iterate' into snap/merge-range-and-proof
asdacap Jun 19, 2024
20e2aa0
Snap support
asdacap Jun 20, 2024
faa0884
Finished is needed internally
asdacap Jun 20, 2024
59440ac
Missed a printf
asdacap Jun 20, 2024
35b46d0
Format
asdacap Jun 20, 2024
cb26dd7
Fix lint
asdacap Jun 20, 2024
1454ad5
Update core/trie/key.go
asdacap Jun 25, 2024
d4b4232
Update core/trie/snap_support.go
asdacap Jun 25, 2024
4f4940f
address keys
asdacap Jun 27, 2024
909914d
Fix lint
asdacap Jun 27, 2024
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
Prev Previous commit
Next Next commit
Update core/trie/snap_support.go
Co-authored-by: Pawel Nowosielski <pnowosie@users.noreply.github.com>
  • Loading branch information
asdacap and pnowosie committed Jun 25, 2024
commit d4b4232645a98cf4eb20d615eb91153888329f55
6 changes: 2 additions & 4 deletions core/trie/snap_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
return consumer(key, value)
})
if err != nil {
return nil, false, err

Check warning on line 17 in core/trie/snap_support.go

View check run for this annotation

Codecov / codecov/patch

core/trie/snap_support.go#L17

Added line #L17 was not covered by tests
}

proofset := map[felt.Felt]ProofNode{}
Expand All @@ -27,7 +27,7 @@
// actually check that the server did not skip leafs.
leftProof, err := GetProof(&startKey, t)
if err != nil {
return nil, false, err

Check warning on line 30 in core/trie/snap_support.go

View check run for this annotation

Codecov / codecov/patch

core/trie/snap_support.go#L30

Added line #L30 was not covered by tests
}
for _, proof := range leftProof {
// Well.. using the trie hash here is kinda slow... but I just need it to work right now.
Expand All @@ -40,7 +40,7 @@
lastKey := NewKey(t.height, feltBts[:])
rightProof, err := GetProof(&lastKey, t)
if err != nil {
return nil, false, err

Check warning on line 43 in core/trie/snap_support.go

View check run for this annotation

Codecov / codecov/patch

core/trie/snap_support.go#L43

Added line #L43 was not covered by tests
}

for _, proof := range rightProof {
Expand Down Expand Up @@ -71,26 +71,24 @@

tempTrie, err := newTrie(newMemStorage(), treeHeight, hash)
if err != nil {
return false, false, err

Check warning on line 74 in core/trie/snap_support.go

View check run for this annotation

Codecov / codecov/patch

core/trie/snap_support.go#L74

Added line #L74 was not covered by tests
}

for i, key := range keys {
_, err = tempTrie.Put(key, values[i])
if err != nil {
return false, false, err

Check warning on line 80 in core/trie/snap_support.go

View check run for this annotation

Codecov / codecov/patch

core/trie/snap_support.go#L80

Added line #L80 was not covered by tests
}
}

recalculatedRoot, err := tempTrie.Root()
if err != nil {
return false, false, err

Check warning on line 86 in core/trie/snap_support.go

View check run for this annotation

Codecov / codecov/patch

core/trie/snap_support.go#L86

Added line #L86 was not covered by tests
}

if !root.Equal(recalculatedRoot) {
return false, false, nil
}
rootMatched := root.Equal(recalculatedRoot)

return false, true, nil
return false, rootMatched, nil
}

if _, ok := proofMap[*root]; !ok {
Expand All @@ -101,7 +99,7 @@
proofKeys := map[felt.Felt]Key{}
err := buildKeys(NewKey(0, []byte{}), root, proofMap, proofKeys, 0)
asdacap marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return false, false, err

Check warning on line 102 in core/trie/snap_support.go

View check run for this annotation

Codecov / codecov/patch

core/trie/snap_support.go#L102

Added line #L102 was not covered by tests
}

// TODO: Verify here proof here
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to 1) verify the left and right proofs here (assuming both exist), and, 2) calculate the root hash of the new trie built from the keys and boundary proofs right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly, I don't know what you have in mind for this. IMO, last time, I just add the leaves first, then add the proof one by one (key->hash, not key->proffnode), unless the exact key already have a node.

Expand Down Expand Up @@ -138,7 +136,7 @@
ch := proofNode.Edge.Child
err := buildKeys(chKey, ch, proofMap, keys, depth+1)
if err != nil {
return err

Check warning on line 139 in core/trie/snap_support.go

View check run for this annotation

Codecov / codecov/patch

core/trie/snap_support.go#L139

Added line #L139 was not covered by tests
}
} else {
binary := proofNode.Binary
Expand All @@ -147,14 +145,14 @@
ch := binary.LeftHash
err := buildKeys(chKey, ch, proofMap, keys, depth+1)
if err != nil {
return err

Check warning on line 148 in core/trie/snap_support.go

View check run for this annotation

Codecov / codecov/patch

core/trie/snap_support.go#L148

Added line #L148 was not covered by tests
}

chKey = currentKey.AppendBit(true)
ch = binary.RightHash
err = buildKeys(chKey, ch, proofMap, keys, depth+1)
if err != nil {
return err

Check warning on line 155 in core/trie/snap_support.go

View check run for this annotation

Codecov / codecov/patch

core/trie/snap_support.go#L155

Added line #L155 was not covered by tests
}
}

Expand Down
Loading