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
Show file tree
Hide file tree
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
wip - proof to Path doesn't work
  • Loading branch information
rian committed Jun 12, 2024
commit d2fe4911d298692c2044d291e706e08e05d6adad
6 changes: 3 additions & 3 deletions core/trie/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func VerifyRangeProof(root *felt.Felt, keys, values []*felt.Felt, proofKeys [2]*
return false, fmt.Errorf("invalid proof for key %x", proofKeys[i].String())
}

proofPaths[i], err = ProofToPath(proofs[i], proofKeys[i], hash)
proofPaths[i], err = ProofToPath(proofs[i], proofKeys[i], hash) // Todo: incorrect for both paths :(
if err != nil {
return false, err
}
Expand Down Expand Up @@ -430,7 +430,7 @@ func BuildTrie(leftProofPath, rightProofPath []StorageNode, keys, values []*felt
}

// merge proof paths
for i := range min(len(leftProofPath), len(rightProofPath)) {
for i := range min(len(leftProofPath), len(rightProofPath)) { //
if leftProofPath[i].key.Equal(rightProofPath[i].key) {
leftProofPath[i].node.Right = rightProofPath[i].node.Right
rightProofPath[i].node.Left = leftProofPath[i].node.Left
Expand All @@ -447,7 +447,7 @@ func BuildTrie(leftProofPath, rightProofPath []StorageNode, keys, values []*felt
}

for _, sNode := range rightProofPath {
_, err := tempTrie.PutInner(sNode.key, sNode.node)
_, err := tempTrie.PutInner(sNode.key, sNode.node) // Todo: incorrectly sets the proof key
if err != nil {
return nil, err
}
Expand Down
17 changes: 13 additions & 4 deletions core/trie/proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,17 @@ func build4KeyTrie(t *testing.T) *trie.Trie {
// 249 \
// / \ \
// 250 \ \
// / \ \ \
// 0 1 2 4
// / \ /\ /\
// 0 1 2 4

// Juno - should be able to reconstruct this from proofs
// 248
// / \
// 249
// / \
// 250 \
// / \ /\
// 0

// Pathfinder (???)
// 0 Edge
Expand Down Expand Up @@ -850,9 +859,9 @@ func TestVerifyRangeProof(t *testing.T) {
values := []*felt.Felt{new(felt.Felt).SetUint64(5), new(felt.Felt).SetUint64(6)}
proofKeys := [2]*trie.Key{&zeroLeafkey, &threeLeafkey}
proofValues := [2]*felt.Felt{new(felt.Felt).SetUint64(4), nil}
leftProof, err := trie.GetProof(proofKeys[0], tri)
leftProof, err := trie.GetProof(proofKeys[0], tri) // Looks correct in terms of binary and edges
require.NoError(t, err)
rightProof, err := trie.GetProof(proofKeys[1], tri)
rightProof, err := trie.GetProof(proofKeys[1], tri) // Looks correct in terms of binary and edges
require.NoError(t, err)
proofs := [2][]trie.ProofNode{leftProof, rightProof}
rootCommitment, err := tri.Root()
Expand Down