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

fix: use tracer when generating storage proofs #1093

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
5 changes: 0 additions & 5 deletions rollup/tracing/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,6 @@ func (t *ProofTracer) Prove(key []byte, proofDb ethdb.KeyValueWriter) error {

switch n.Type {
case trie.NodeTypeLeaf_New:
preImage := t.trie.GetKey(n.NodeKey.Bytes())
if len(preImage) > 0 {
n.KeyPreimage = &trie.Byte32{}
copy(n.KeyPreimage[:], preImage)
}
case trie.NodeTypeBranch_0, trie.NodeTypeBranch_1,
trie.NodeTypeBranch_2, trie.NodeTypeBranch_3:
mptPath = append(mptPath, n)
Expand Down
2 changes: 1 addition & 1 deletion rollup/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ func (env *TraceEnv) getTxResult(state *state.StateDB, index int, block *types.B
env.sMu.Unlock()

var proof zkproof.ProofList
if err = env.ZkTrieTracer[addrStr].Prove(key.Bytes(), &proof); err != nil {
if err = zktrieTracer.Prove(key.Bytes(), &proof); err != nil {
log.Error("Storage proof not available", "error", err, "address", addrStr, "key", keyStr)
// but we still mark the proofs map with nil array
}
Expand Down
5 changes: 5 additions & 0 deletions trie/zk_trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,11 @@ func (mt *ZkTrie) prove(kHash *Hash, fromLevel uint, writeNode func(*Node) error
case NodeTypeLeaf_New:
// notice even we found a leaf whose entry didn't match the expected k,
// we still include it as the proof of absence
preImage := mt.getKey(n.NodeKey.Bytes())
if len(preImage) > 0 {
n.KeyPreimage = &Byte32{}
copy(n.KeyPreimage[:], preImage)
}
case NodeTypeBranch_0, NodeTypeBranch_1, NodeTypeBranch_2, NodeTypeBranch_3:
finished = false
if path[i] {
Expand Down
Loading