diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 256f2ad61f..eaca43c767 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -231,9 +231,9 @@ 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 { + // 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 } } diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index e1f69433f0..cdc82e05c3 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -53,11 +53,13 @@ type operation struct { valid bool // reverts determined whether the operation reverts state reverts bool + // clearsReturndata determines whether the opertions clears the return data + clearsReturndata bool } var ( - frontierInstructionSet = NewFrontierInstructionSet() - homesteadInstructionSet = NewHomesteadInstructionSet() + frontierInstructionSet = NewFrontierInstructionSet() + homesteadInstructionSet = NewHomesteadInstructionSet() metropolisInstructionSet = NewMetropolisInstructionSet() ) @@ -881,26 +883,29 @@ func NewFrontierInstructionSet() [256]operation { writes: true, }, CREATE: { - execute: opCreate, - gasCost: gasCreate, - validateStack: makeStackFunc(3, 1), - memorySize: memoryCreate, - valid: true, - writes: true, + execute: opCreate, + gasCost: gasCreate, + validateStack: makeStackFunc(3, 1), + memorySize: memoryCreate, + valid: true, + writes: true, + clearsReturndata: true, }, CALL: { - execute: opCall, - gasCost: gasCall, - validateStack: makeStackFunc(7, 1), - memorySize: memoryCall, - valid: true, + execute: opCall, + gasCost: gasCall, + validateStack: makeStackFunc(7, 1), + memorySize: memoryCall, + valid: true, + clearsReturndata: true, }, CALLCODE: { - execute: opCallCode, - gasCost: gasCallCode, - validateStack: makeStackFunc(7, 1), - memorySize: memoryCall, - valid: true, + execute: opCallCode, + gasCost: gasCallCode, + validateStack: makeStackFunc(7, 1), + memorySize: memoryCall, + valid: true, + clearsReturndata: true, }, RETURN: { execute: opReturn,