-
Notifications
You must be signed in to change notification settings - Fork 856
Extension into branch #1756
base: main
Are you sure you want to change the base?
Extension into branch #1756
Conversation
484cb7a
to
39a8743
Compare
… constructedLeaf in witness generator used now only for wrong row
…et added to storage leaf
nibbles = append(nibbles, leafKeyRow[2]-48) | ||
var keyLen int | ||
if leafKeyRow[1] > 128 { | ||
keyLen = int(leafKeyRow[1] - 128) |
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.
A question about the keyLen
.
In this if
condition, leafKeyRow
is not 248, let's say it's 249, then the length of the payload should be leafKeyRow[1]*256 + leafKeyRow[2]
. I don't get why the keyLen
here is int(leafKeyRow[1] - 128)
. Besides, leafKeyRow[2]
in below (L160) should be also part of the length.
I also found that the keyLen
in the else
case in L178 is using leafKeyRow[2]
instead of leafKeyRow[1]
. I guess the implementation in if
and else
should be swithced?
I made this fix in my PR bcs the drifted position is incorrect in my case.
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.
The reason this might seem confusing is because for the account and storage leaves I think the length is never big enough for the first byte to be 249
, it's at most 248
.
It would be more clear if the first condition would say leafKeyRow[0] < 248
instead of leafKeyRow[0] != 248
(and the second block would need to say leafKeyRow[0] == 248
).
The first if block handles the cases when leafKeyRow[0] < 248
, the second block handles the cases for leafKeyRow[0] == 248
. It works ok for account and storage leaves, but not for the transaction leaves which can be very long and can have the first byte 249
. Another block is needed for these cases.
…aling-explorations/zkevm-circuits into extension-into-branch
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.
First round (witness generation) pass, only left some minor suggestions.
geth-utils/gethutil/mpt/witness/gen_witness_from_infura_blockchain_test.go
Show resolved
Hide resolved
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.
LGTM!
Description
Light client mainnet test with block 18363441 revealed some issues:
getDriftedPosition
inbranch.go
issuegetProof/getStorageProof
inmodified_extension_node.go
when the short extension node is a branch and there is no trie node at this address/keyFurthermore, the test revealed a case which was not envisioned before - when proving that the leaf doesn't exist one might get a "wrong" extension node (so there are three scenarios for does-not-exist proofs: nil object in a branch, wrong leaf, wrong extension node), so
WrongGadget
needs to be extended to cover this case.Issue Link
#1738
Type of change
Test
TestExtensionIntoBranch
,TestAccountWrongExtensionNode
ingen_witness_from_local_blockchain_test.go
.TestStorageWrongExtensionNode
,TestStorageWrongExtensionNode1
ingen_witness_from_infura_blockchain_test.go
.