|
|
@ -24,7 +24,7 @@ import ( |
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/common/math" |
|
|
|
"github.com/ethereum/go-ethereum/common/math" |
|
|
|
"github.com/ethereum/go-ethereum/core/types" |
|
|
|
"github.com/ethereum/go-ethereum/core/types" |
|
|
|
"github.com/ethereum/go-ethereum/crypto" |
|
|
|
"github.com/ethereum/go-ethereum/crypto/sha3" |
|
|
|
"github.com/ethereum/go-ethereum/params" |
|
|
|
"github.com/ethereum/go-ethereum/params" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -373,13 +373,20 @@ func opSAR(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory * |
|
|
|
func opSha3(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { |
|
|
|
func opSha3(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { |
|
|
|
offset, size := stack.pop(), stack.pop() |
|
|
|
offset, size := stack.pop(), stack.pop() |
|
|
|
data := memory.Get(offset.Int64(), size.Int64()) |
|
|
|
data := memory.Get(offset.Int64(), size.Int64()) |
|
|
|
hash := crypto.Keccak256(data) |
|
|
|
|
|
|
|
evm := interpreter.evm |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if interpreter.hasher == nil { |
|
|
|
|
|
|
|
interpreter.hasher = sha3.NewKeccak256().(keccakState) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
interpreter.hasher.Reset() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
interpreter.hasher.Write(data) |
|
|
|
|
|
|
|
interpreter.hasher.Read(interpreter.hasherBuf[:]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
evm := interpreter.evm |
|
|
|
if evm.vmConfig.EnablePreimageRecording { |
|
|
|
if evm.vmConfig.EnablePreimageRecording { |
|
|
|
evm.StateDB.AddPreimage(common.BytesToHash(hash), data) |
|
|
|
evm.StateDB.AddPreimage(interpreter.hasherBuf, data) |
|
|
|
} |
|
|
|
} |
|
|
|
stack.push(interpreter.intPool.get().SetBytes(hash)) |
|
|
|
stack.push(interpreter.intPool.get().SetBytes(interpreter.hasherBuf[:])) |
|
|
|
|
|
|
|
|
|
|
|
interpreter.intPool.put(offset, size) |
|
|
|
interpreter.intPool.put(offset, size) |
|
|
|
return nil, nil |
|
|
|
return nil, nil |
|
|
|