-
Notifications
You must be signed in to change notification settings - Fork 170
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
Starknet's getStorageProof
rpc method
#2194
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2194 +/- ##
==========================================
- Coverage 75.31% 74.46% -0.85%
==========================================
Files 106 108 +2
Lines 11237 11388 +151
==========================================
+ Hits 8463 8480 +17
- Misses 2135 2286 +151
+ Partials 639 622 -17 ☔ View full report in Codecov by Sentry. |
301250f
to
d383531
Compare
1ef09de
to
a33464e
Compare
b292454
to
1e50ea2
Compare
f9089bc
to
f3ded4a
Compare
Differences / Issues spotted comparing with PF1. Params are not optional (why?)Request
Response 2. Response does not filter out duplicate nodes in hash HashToNode mappingRequest
Response
|
core/trie/proof.go
Outdated
proofHash := proofNode.Hash(hash) | ||
fmt.Println("Proof verification failure", "node", proofHash, "expected", expectedHash) | ||
fmt.Printf("%v\n", proofNode) |
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.
please remove these debugging lines
core/trie/proof.go
Outdated
@@ -345,7 +348,8 @@ func VerifyProof(root *felt.Felt, key *Key, value *felt.Felt, proofs []ProofNode | |||
return true | |||
} | |||
|
|||
if !proofNode.Path.Equal(subKey) { | |||
if !proofNode.Path.Equal(subKey) && !subKey.Equal(&Key{}) { | |||
fmt.Println("Proof verification failure", "node", proofNode.Path, "expected", subKey) |
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.
please remove these debugging lines
core/trie/key.go
Outdated
if n == k.len { | ||
return &Key{}, nil | ||
} |
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.
why is this check needed?
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.
I found a bug in proof-verification here in the test:
Line 166 in 7252e10
require.True(t, trie.VerifyProof(root, &kKey, value, proof, tempTrie.HashFunc())) |
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.
I see, that actually doesn't fix the other test cases. It'll be clearer in my VerifyProof
implementation.
So there are 2 approaches we can take:
For the 1st approach, we can agree on the architecture such that a Blockchain For the 2nd approach, the architecture makes sense, the issue is that we have an unsupported feature for historical trie access. It's unsure when we will support historical trie access as it's a huge refactor on the state, trie and db modules. I'd rather go with an unsupported feature and detect it early rather than incur technical debts and make the modules even more coupled and harder to refactor. |
7252e10
to
5200b6d
Compare
getStorageProof
rpc method
e0e6727
to
59ca331
Compare
@@ -134,153 +165,6 @@ func transformNode(tri *Trie, parentKey *Key, sNode StorageNode) (*Edge, *Binary | |||
return edge, binary, nil | |||
} | |||
|
|||
// pathSplitOccurredCheck checks if there happens at most one split in the merged path |
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.
Note: These functions are reported unused by linter, hence I deleted them.
Maybe further PR #2252 will bring them back.
// If the trie is constructed incorrectly then the root will have an incorrect key(len,path), and value, | ||
// and therefore it's hash won't match the expected root. | ||
// ref: https://github.com/ethereum/go-ethereum/blob/v1.14.3/trie/proof.go#L484 | ||
func VerifyRangeProof(root *felt.Felt, keys, values []*felt.Felt, proofKeys [2]*Key, proofValues [2]*felt.Felt, |
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.
Will be added back as of #2252 with proper test coverage. It isn't used anywhere and hence ongoing proof refactor it is safe to drop for now.
72d964e
to
82cf7a9
Compare
@@ -183,113 +184,270 @@ func build3KeyTrie(t *testing.T) *trie.Trie { | |||
return tempTrie | |||
} | |||
|
|||
func build4KeyTrie(t *testing.T) *trie.Trie { |
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.
Some of these deleted functions will be bring back with #2252.
For this PR they are unused.
721c56c
to
3af5c47
Compare
3af5c47
to
084e874
Compare
Fixes #2180
Tests are based on proof-refactor PR