bool => int

pull/632/merge
obscuren 10 years ago
parent 29a9c6bedd
commit f49e398ebe
  1. 126
      core/vm/gas.go

@ -38,7 +38,7 @@ func baseCheck(op OpCode, stack *stack, gas *big.Int) error {
return err return err
} }
if r.stackPush && len(stack.data)-r.stackPop > int(params.StackLimit.Int64()) { if r.stackPush > 0 && len(stack.data)-r.stackPop+r.stackPush > int(params.StackLimit.Int64())+1 {
return fmt.Errorf("stack limit reached %d (%d)", len(stack.data), params.StackLimit.Int64()) return fmt.Errorf("stack limit reached %d (%d)", len(stack.data), params.StackLimit.Int64())
} }
@ -57,70 +57,70 @@ func toWordSize(size *big.Int) *big.Int {
type req struct { type req struct {
stackPop int stackPop int
gas *big.Int gas *big.Int
stackPush bool stackPush int
} }
var _baseCheck = map[OpCode]req{ var _baseCheck = map[OpCode]req{
// opcode | stack pop | gas price | stack push // opcode | stack pop | gas price | stack push
ADD: {2, GasFastestStep, true}, ADD: {2, GasFastestStep, 1},
LT: {2, GasFastestStep, true}, LT: {2, GasFastestStep, 1},
GT: {2, GasFastestStep, true}, GT: {2, GasFastestStep, 1},
SLT: {2, GasFastestStep, true}, SLT: {2, GasFastestStep, 1},
SGT: {2, GasFastestStep, true}, SGT: {2, GasFastestStep, 1},
EQ: {2, GasFastestStep, true}, EQ: {2, GasFastestStep, 1},
ISZERO: {1, GasFastestStep, true}, ISZERO: {1, GasFastestStep, 1},
SUB: {2, GasFastestStep, true}, SUB: {2, GasFastestStep, 1},
AND: {2, GasFastestStep, true}, AND: {2, GasFastestStep, 1},
OR: {2, GasFastestStep, true}, OR: {2, GasFastestStep, 1},
XOR: {2, GasFastestStep, true}, XOR: {2, GasFastestStep, 1},
NOT: {1, GasFastestStep, true}, NOT: {1, GasFastestStep, 1},
BYTE: {2, GasFastestStep, true}, BYTE: {2, GasFastestStep, 1},
CALLDATALOAD: {1, GasFastestStep, true}, CALLDATALOAD: {1, GasFastestStep, 1},
CALLDATACOPY: {3, GasFastestStep, true}, CALLDATACOPY: {3, GasFastestStep, 1},
MLOAD: {1, GasFastestStep, true}, MLOAD: {1, GasFastestStep, 1},
MSTORE: {2, GasFastestStep, false}, MSTORE: {2, GasFastestStep, 0},
MSTORE8: {2, GasFastestStep, false}, MSTORE8: {2, GasFastestStep, 0},
CODECOPY: {3, GasFastestStep, false}, CODECOPY: {3, GasFastestStep, 0},
MUL: {2, GasFastStep, true}, MUL: {2, GasFastStep, 1},
DIV: {2, GasFastStep, true}, DIV: {2, GasFastStep, 1},
SDIV: {2, GasFastStep, true}, SDIV: {2, GasFastStep, 1},
MOD: {2, GasFastStep, true}, MOD: {2, GasFastStep, 1},
SMOD: {2, GasFastStep, true}, SMOD: {2, GasFastStep, 1},
SIGNEXTEND: {2, GasFastStep, true}, SIGNEXTEND: {2, GasFastStep, 1},
ADDMOD: {3, GasMidStep, true}, ADDMOD: {3, GasMidStep, 1},
MULMOD: {3, GasMidStep, true}, MULMOD: {3, GasMidStep, 1},
JUMP: {1, GasMidStep, false}, JUMP: {1, GasMidStep, 0},
JUMPI: {2, GasSlowStep, false}, JUMPI: {2, GasSlowStep, 0},
EXP: {2, GasSlowStep, true}, EXP: {2, GasSlowStep, 1},
ADDRESS: {0, GasQuickStep, true}, ADDRESS: {0, GasQuickStep, 1},
ORIGIN: {0, GasQuickStep, true}, ORIGIN: {0, GasQuickStep, 1},
CALLER: {0, GasQuickStep, true}, CALLER: {0, GasQuickStep, 1},
CALLVALUE: {0, GasQuickStep, true}, CALLVALUE: {0, GasQuickStep, 1},
CODESIZE: {0, GasQuickStep, true}, CODESIZE: {0, GasQuickStep, 1},
GASPRICE: {0, GasQuickStep, true}, GASPRICE: {0, GasQuickStep, 1},
COINBASE: {0, GasQuickStep, true}, COINBASE: {0, GasQuickStep, 1},
TIMESTAMP: {0, GasQuickStep, true}, TIMESTAMP: {0, GasQuickStep, 1},
NUMBER: {0, GasQuickStep, true}, NUMBER: {0, GasQuickStep, 1},
CALLDATASIZE: {0, GasQuickStep, true}, CALLDATASIZE: {0, GasQuickStep, 1},
DIFFICULTY: {0, GasQuickStep, true}, DIFFICULTY: {0, GasQuickStep, 1},
GASLIMIT: {0, GasQuickStep, true}, GASLIMIT: {0, GasQuickStep, 1},
POP: {1, GasQuickStep, false}, POP: {1, GasQuickStep, 0},
PC: {0, GasQuickStep, true}, PC: {0, GasQuickStep, 1},
MSIZE: {0, GasQuickStep, true}, MSIZE: {0, GasQuickStep, 1},
GAS: {0, GasQuickStep, true}, GAS: {0, GasQuickStep, 1},
BLOCKHASH: {1, GasExtStep, true}, BLOCKHASH: {1, GasExtStep, 1},
BALANCE: {1, GasExtStep, true}, BALANCE: {1, GasExtStep, 1},
EXTCODESIZE: {1, GasExtStep, true}, EXTCODESIZE: {1, GasExtStep, 1},
EXTCODECOPY: {4, GasExtStep, false}, EXTCODECOPY: {4, GasExtStep, 0},
SLOAD: {1, params.SloadGas, true}, SLOAD: {1, params.SloadGas, 1},
SSTORE: {2, Zero, false}, SSTORE: {2, Zero, 0},
SHA3: {2, params.Sha3Gas, true}, SHA3: {2, params.Sha3Gas, 1},
CREATE: {3, params.CreateGas, true}, CREATE: {3, params.CreateGas, 1},
CALL: {7, params.CallGas, true}, CALL: {7, params.CallGas, 1},
CALLCODE: {7, params.CallGas, true}, CALLCODE: {7, params.CallGas, 1},
JUMPDEST: {0, params.JumpdestGas, false}, JUMPDEST: {0, params.JumpdestGas, 0},
SUICIDE: {1, Zero, false}, SUICIDE: {1, Zero, 0},
RETURN: {2, Zero, false}, RETURN: {2, Zero, 0},
PUSH1: {0, GasFastestStep, true}, PUSH1: {0, GasFastestStep, 1},
DUP1: {0, Zero, true}, DUP1: {0, Zero, 1},
} }

Loading…
Cancel
Save