core/vm: implement RETURNDATA metropolis opcodes
This commit is contained in:
committed by
Péter Szilágyi
parent
76069eef38
commit
9bd6068fef
@ -60,6 +60,8 @@ type Interpreter struct {
|
||||
intPool *intPool
|
||||
|
||||
readonly bool
|
||||
// returnData contains the last call's return data
|
||||
returnData []byte
|
||||
}
|
||||
|
||||
// NewInterpreter returns a new instance of the Interpreter.
|
||||
@ -113,6 +115,10 @@ func (in *Interpreter) Run(snapshot int, contract *Contract, input []byte) (ret
|
||||
in.evm.depth++
|
||||
defer func() { in.evm.depth-- }()
|
||||
|
||||
// Reset the previous call's return data. It's unimportant to preserve the old buffer
|
||||
// as every returning call will return new data anyway.
|
||||
in.returnData = nil
|
||||
|
||||
// Don't bother with the execution if there's no code.
|
||||
if len(contract.Code) == 0 {
|
||||
return nil, nil
|
||||
@ -213,10 +219,10 @@ func (in *Interpreter) Run(snapshot int, contract *Contract, input []byte) (ret
|
||||
case !operation.jumps:
|
||||
pc++
|
||||
}
|
||||
// if the operation returned a value make sure that is also set
|
||||
// the last return data.
|
||||
if res != nil {
|
||||
mem.lastReturn = ret
|
||||
// if the operation clears the return data (e.g. it has returning data)
|
||||
// set the last return to the result of the operation.
|
||||
if operation.clearsReturndata {
|
||||
in.returnData = res
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
|
Reference in New Issue
Block a user