forked from cerc-io/plugeth
cmd/geth, core: add support for recording SHA3 preimages (#3543)
This commit is contained in:
committed by
Felix Lange
parent
26d385c18b
commit
17d92233d9
@@ -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
|
||||
|
||||
@@ -60,6 +60,7 @@ type StateDB interface {
|
||||
Snapshot() int
|
||||
|
||||
AddLog(*types.Log)
|
||||
AddPreimage(common.Hash, []byte)
|
||||
}
|
||||
|
||||
// Account represents a contract or basic ethereum account.
|
||||
|
||||
@@ -67,3 +67,4 @@ func (NoopStateDB) Empty(common.Address) bool { return f
|
||||
func (NoopStateDB) RevertToSnapshot(int) {}
|
||||
func (NoopStateDB) Snapshot() int { return 0 }
|
||||
func (NoopStateDB) AddLog(*types.Log) {}
|
||||
func (NoopStateDB) AddPreimage(common.Hash, []byte) {}
|
||||
|
||||
@@ -44,6 +44,8 @@ type Config struct {
|
||||
NoRecursion bool
|
||||
// Disable gas metering
|
||||
DisableGasMetering bool
|
||||
// Enable recording of SHA3/keccak preimages
|
||||
EnablePreimageRecording bool
|
||||
// JumpTable contains the EVM instruction table. This
|
||||
// may me left uninitialised and will be set the default
|
||||
// table.
|
||||
|
||||
Reference in New Issue
Block a user