aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/interpreter.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2017-08-16 18:07:33 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-08-16 18:43:08 +0800
commit9bd6068fefe5687735bed342f3545f515fa717c8 (patch)
treed68767398eedd0a07c055fc8e880c4b4ab565a70 /core/vm/interpreter.go
parent76069eef38082089d2eaf99661a80e1a953bf271 (diff)
downloadgo-tangerine-9bd6068fefe5687735bed342f3545f515fa717c8.tar
go-tangerine-9bd6068fefe5687735bed342f3545f515fa717c8.tar.gz
go-tangerine-9bd6068fefe5687735bed342f3545f515fa717c8.tar.bz2
go-tangerine-9bd6068fefe5687735bed342f3545f515fa717c8.tar.lz
go-tangerine-9bd6068fefe5687735bed342f3545f515fa717c8.tar.xz
go-tangerine-9bd6068fefe5687735bed342f3545f515fa717c8.tar.zst
go-tangerine-9bd6068fefe5687735bed342f3545f515fa717c8.zip
core/vm: implement RETURNDATA metropolis opcodes
Diffstat (limited to 'core/vm/interpreter.go')
-rw-r--r--core/vm/interpreter.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go
index 661ada691..1c7481bc5 100644
--- a/core/vm/interpreter.go
+++ b/core/vm/interpreter.go
@@ -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