diff --git a/core/state/statedb.go b/core/state/statedb.go index 374b47769b16..b4e1e7bef755 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -357,13 +357,8 @@ func (s *StateDB) GetState(addr common.Address, hash common.Hash) common.Hash { // GetProof returns the Merkle proof for a given account. func (s *StateDB) GetProof(addr common.Address) ([][]byte, error) { - return s.GetProofByHash(common.BytesToHash(addr.Bytes())) -} - -// GetProofByHash returns the Merkle proof for a given account. -func (s *StateDB) GetProofByHash(addrHash common.Hash) ([][]byte, error) { var proof zkproof.ProofList - err := s.trie.Prove(addrHash[:] /*, 0*/, &proof) + err := s.trie.Prove(addr.Bytes(), &proof) return proof, err } diff --git a/trie/zk_trie.go b/trie/zk_trie.go index 1472d74c992f..d2fc5ec761ab 100644 --- a/trie/zk_trie.go +++ b/trie/zk_trie.go @@ -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 @@ -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 {