diff --git a/core/vm/instructions.go b/core/vm/instructions.go index bdd8ac3f9bda0..5462e7e5d5919 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -596,8 +596,11 @@ func opCreate(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]b scope.Contract.Gas += returnGas if suberr == ErrExecutionReverted { + // set the return data + interpreter.returnData = res return res, nil } + interpreter.returnData = nil return nil, nil } @@ -632,8 +635,11 @@ func opCreate2(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([] scope.Contract.Gas += returnGas if suberr == ErrExecutionReverted { + // set the return data + interpreter.returnData = res return res, nil } + interpreter.returnData = nil return nil, nil } @@ -672,6 +678,8 @@ func opCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byt } scope.Contract.Gas += returnGas + // set the return data + interpreter.returnData = ret return ret, nil } @@ -707,6 +715,8 @@ func opCallCode(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([ } scope.Contract.Gas += returnGas + // set the return data + interpreter.returnData = ret return ret, nil } @@ -735,6 +745,8 @@ func opDelegateCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext } scope.Contract.Gas += returnGas + // set the return data + interpreter.returnData = ret return ret, nil } @@ -763,6 +775,8 @@ func opStaticCall(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) } scope.Contract.Gas += returnGas + // set the return data + interpreter.returnData = ret return ret, nil } @@ -777,6 +791,8 @@ func opRevert(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]b offset, size := scope.Stack.pop(), scope.Stack.pop() ret := scope.Memory.GetPtr(int64(offset.Uint64()), int64(size.Uint64())) + // set the return data + interpreter.returnData = ret return ret, ErrExecutionReverted } diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 7a30d60b3f3f5..65c042a88cd55 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -259,11 +259,6 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) ( // execute the operation res, err = operation.execute(&pc, in, callContext) - // 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 - } if err != nil { break diff --git a/core/vm/jump_table.go b/core/vm/jump_table.go index f6023b6170736..82429e82f1214 100644 --- a/core/vm/jump_table.go +++ b/core/vm/jump_table.go @@ -128,7 +128,6 @@ func newConstantinopleInstructionSet() JumpTable { maxStack: maxStack(4, 1), memorySize: memoryCreate2, writes: true, - returns: true, } return instructionSet } @@ -144,7 +143,6 @@ func newByzantiumInstructionSet() JumpTable { minStack: minStack(6, 1), maxStack: maxStack(6, 1), memorySize: memoryStaticCall, - returns: true, } instructionSet[RETURNDATASIZE] = &operation{ execute: opReturnDataSize, @@ -166,7 +164,6 @@ func newByzantiumInstructionSet() JumpTable { minStack: minStack(2, 0), maxStack: maxStack(2, 0), memorySize: memoryRevert, - returns: true, } return instructionSet } @@ -203,7 +200,6 @@ func newHomesteadInstructionSet() JumpTable { minStack: minStack(6, 1), maxStack: maxStack(6, 1), memorySize: memoryDelegateCall, - returns: true, } return instructionSet } @@ -989,7 +985,6 @@ func newFrontierInstructionSet() JumpTable { maxStack: maxStack(3, 1), memorySize: memoryCreate, writes: true, - returns: true, }, CALL: { execute: opCall, @@ -998,7 +993,6 @@ func newFrontierInstructionSet() JumpTable { minStack: minStack(7, 1), maxStack: maxStack(7, 1), memorySize: memoryCall, - returns: true, }, CALLCODE: { execute: opCallCode, @@ -1007,7 +1001,6 @@ func newFrontierInstructionSet() JumpTable { minStack: minStack(7, 1), maxStack: maxStack(7, 1), memorySize: memoryCall, - returns: true, }, RETURN: { execute: opReturn,