aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/interpreter.go
diff options
context:
space:
mode:
Diffstat (limited to 'core/vm/interpreter.go')
-rw-r--r--core/vm/interpreter.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go
index 661ada691..954839f2e 100644
--- a/core/vm/interpreter.go
+++ b/core/vm/interpreter.go
@@ -59,7 +59,8 @@ type Interpreter struct {
gasTable params.GasTable
intPool *intPool
- readonly bool
+ readOnly bool // Whether to throw on stateful modifications
+ returnData []byte // Last CALL's return data for subsequent reuse
}
// NewInterpreter returns a new instance of the Interpreter.
@@ -88,7 +89,7 @@ func NewInterpreter(evm *EVM, cfg Config) *Interpreter {
func (in *Interpreter) enforceRestrictions(op OpCode, operation operation, stack *Stack) error {
if in.evm.chainRules.IsMetropolis {
- if in.readonly {
+ if in.readOnly {
// If the interpreter is operating in readonly mode, make sure no
// state-modifying operation is performed. The 3rd stack item
// for a call operation is the value. Transfering value from one
@@ -113,6 +114,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 +218,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.returns {
+ in.returnData = res
}
}
return nil, nil