-
Notifications
You must be signed in to change notification settings - Fork 20.1k
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
trie: make rhs-proof align with last key in range proofs #28311
Conversation
43bb679
to
f641ef7
Compare
@@ -576,7 +487,7 @@ func TestBadRangeProof(t *testing.T) { | |||
case 2: | |||
// Gapped entry slice | |||
index = mrand.Intn(end - start) | |||
if (index == 0 && start < 100) || (index == end-start-1 && end <= 100) { | |||
if (index == 0 && start < 100) || (index == end-start-1) { |
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.
@rjl493456442 what was the significance of end <= 100
there?
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.
honestly I don't remember why I put the 100 there.
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.
// Gapped entry slice
index = mrand.Intn(end - start)
if index == 0 || index == end-start-1 {
continue
}
should be fine to drop the 100.
@@ -520,6 +520,7 @@ func VerifyRangeProof(rootHash common.Hash, firstKey []byte, lastKey []byte, key | |||
} | |||
return false, nil | |||
} | |||
var lastKey = keys[len(keys)-1] |
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 move this line after the comment.
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.
Are you sure? The comment refers to the clause that follows it, it does not refer to the lastKey
variable?
@@ -576,7 +487,7 @@ func TestBadRangeProof(t *testing.T) { | |||
case 2: | |||
// Gapped entry slice | |||
index = mrand.Intn(end - start) | |||
if (index == 0 && start < 100) || (index == end-start-1 && end <= 100) { | |||
if (index == 0 && start < 100) || (index == end-start-1) { |
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.
honestly I don't remember why I put the 100 there.
please fix the conflicting files |
3924dec
to
11703d9
Compare
) During snap-sync, we request ranges of values: either a range of accounts or a range of storage values. For any large trie, e.g. the main account trie or a large storage trie, we cannot fetch everything at once. Short version; we split it up and request in multiple stages. To do so, we use an origin field, to say "Give me all storage key/values where key > 0x20000000000000000". When the server fulfils this, the server provides the first key after origin, let's say 0x2e030000000000000 -- never providing the exact origin. However, the client-side needs to be able to verify that the 0x2e03.. indeed is the first one after 0x2000.., and therefore the attached proof concerns the origin, not the first key. So, short-short version: the left-hand side of the proof relates to the origin, and is free-standing from the first leaf. On the other hand, (pun intended), the right-hand side, there's no such 'gap' between "along what path does the proof walk" and the last provided leaf. The proof must prove the last element (unless there are no elements). Therefore, we can simplify the semantics for trie.VerifyRangeProof by removing an argument. This doesn't make much difference in practice, but makes it so that we can remove some tests. The reason I am raising this is that the upcoming stacktrie-based verifier does not support such fancy features as standalone right-hand borders.
…ereum#28311)" This reverts commit 51d0547.
…ereum#28311)" This reverts commit 51d0547.
During snap-sync, we request ranges of values: either a range of accounts or a range of storage values. For any large trie, e.g. the main account trie or a large storage trie, we cannot fetch everything at once.
Short version; we split it up and request in multiple stages. To do so, we use an
origin
field, to say "Give me all storage key/values where key >0x20000000000000000
". When the server fulfils this, the server provides the first key afterorigin
, let's say0x2e030000000000000
-- never providing the exact origin. However, the client-side needs to be able to verify that the0x2e03..
indeed is the first one after0x2000..
, and therefore the attached proof concerns theorigin
, not the first key.So, short-short version: the left-hand side of the proof relates to the
origin
, and is free-standing from the first leaf.On the other hand, (pun intended), the right-hand side, there's no such 'gap' between "along what path does the proof walk" and the last provided leaf. The proof must prove the last element (unless there are no elements).
Therefore, we can simplify the semantics for
trie.VerifyRangeProof
by removing an argument. This doesn't make much difference in practice, but makes it so that we can remove some tests. The reason I am raising this is that the upcoming stacktrie-based verifier does not support such fancy features as standalone right-hand borders.