Skip to content

Commit

Permalink
fix: proper preimage storage
Browse files Browse the repository at this point in the history
  • Loading branch information
omerfirmak committed Nov 21, 2024
1 parent 2d8e65c commit ef22c82
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions trie/zk_trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (mt *ZkTrie) TryUpdate(key []byte, vFlag uint32, vPreimage []Byte32) error
mt.lock.Lock()
defer mt.lock.Unlock()

mt.secKeyCache[string(nodeKey.Bytes())] = key
mt.secKeyCache[string(nodeKey.Bytes())] = append([]byte{}, key...)

newRootKey, _, err := mt.addLeaf(newLeafNode, mt.rootKey, 0, path)
// sanity check
Expand Down Expand Up @@ -293,8 +293,9 @@ func (mt *ZkTrie) commit(nodeHash *Hash, path []byte, nodeSet *trienode.NodeSet,

if node.Type == NodeTypeLeaf_New {
if mt.preimages != nil {
nodeKeyBytes := node.NodeKey.Bytes()
mt.preimages.insertPreimage(map[common.Hash][]byte{
common.BytesToHash(nodeHash.Bytes()): node.NodeKey.Bytes(),
common.BytesToHash(nodeKeyBytes): mt.secKeyCache[string(nodeKeyBytes)],
})
}
if collectLeaf {
Expand Down

0 comments on commit ef22c82

Please sign in to comment.