cmd/geth, core: add support for recording SHA3 preimages (#3543)

This commit is contained in:
Nick Johnson
2017-01-17 11:19:50 +00:00
committed by Felix Lange
parent 26d385c18b
commit 17d92233d9
29 changed files with 156 additions and 46 deletions

View File

@ -247,7 +247,12 @@ func opMulmod(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *S
func opSha3(pc *uint64, env *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
offset, size := stack.pop(), stack.pop()
hash := crypto.Keccak256(memory.Get(offset.Int64(), size.Int64()))
data := memory.Get(offset.Int64(), size.Int64())
hash := crypto.Keccak256(data)
if env.vmConfig.EnablePreimageRecording {
env.StateDB.AddPreimage(common.BytesToHash(hash), data)
}
stack.push(common.BytesToBig(hash))
return nil, nil