core/vm: polish RETURNDATA, add missing returns to CALL*

This commit is contained in:
Péter Szilágyi
2017-08-16 13:36:48 +03:00
parent 9bd6068fef
commit 4e0fea4d30
7 changed files with 75 additions and 72 deletions

View File

@@ -53,8 +53,8 @@ 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
// returns determines whether the opertions sets the return data
returns bool
}
var (
@@ -74,6 +74,7 @@ func NewMetropolisInstructionSet() [256]operation {
validateStack: makeStackFunc(6, 1),
memorySize: memoryStaticCall,
valid: true,
returns: true,
}
instructionSet[RETURNDATASIZE] = operation{
execute: opReturnDataSize,
@@ -101,6 +102,7 @@ func NewHomesteadInstructionSet() [256]operation {
validateStack: makeStackFunc(6, 1),
memorySize: memoryDelegateCall,
valid: true,
returns: true,
}
return instructionSet
}
@@ -286,22 +288,22 @@ func NewFrontierInstructionSet() [256]operation {
valid: true,
},
CALLDATALOAD: {
execute: opCalldataLoad,
execute: opCallDataLoad,
gasCost: constGasFunc(GasFastestStep),
validateStack: makeStackFunc(1, 1),
valid: true,
},
CALLDATASIZE: {
execute: opCalldataSize,
execute: opCallDataSize,
gasCost: constGasFunc(GasQuickStep),
validateStack: makeStackFunc(0, 1),
valid: true,
},
CALLDATACOPY: {
execute: opCalldataCopy,
gasCost: gasCalldataCopy,
execute: opCallDataCopy,
gasCost: gasCallDataCopy,
validateStack: makeStackFunc(3, 0),
memorySize: memoryCalldataCopy,
memorySize: memoryCallDataCopy,
valid: true,
},
CODESIZE: {
@@ -876,29 +878,29 @@ func NewFrontierInstructionSet() [256]operation {
writes: true,
},
CREATE: {
execute: opCreate,
gasCost: gasCreate,
validateStack: makeStackFunc(3, 1),
memorySize: memoryCreate,
valid: true,
writes: true,
clearsReturndata: true,
execute: opCreate,
gasCost: gasCreate,
validateStack: makeStackFunc(3, 1),
memorySize: memoryCreate,
valid: true,
writes: true,
returns: true,
},
CALL: {
execute: opCall,
gasCost: gasCall,
validateStack: makeStackFunc(7, 1),
memorySize: memoryCall,
valid: true,
clearsReturndata: true,
execute: opCall,
gasCost: gasCall,
validateStack: makeStackFunc(7, 1),
memorySize: memoryCall,
valid: true,
returns: true,
},
CALLCODE: {
execute: opCallCode,
gasCost: gasCallCode,
validateStack: makeStackFunc(7, 1),
memorySize: memoryCall,
valid: true,
clearsReturndata: true,
execute: opCallCode,
gasCost: gasCallCode,
validateStack: makeStackFunc(7, 1),
memorySize: memoryCall,
valid: true,
returns: true,
},
RETURN: {
execute: opReturn,