diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-03 18:28:55 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-03 18:28:55 +0800 |
commit | f49e398ebe32e243688a591e0752407016acb770 (patch) | |
tree | bee588e02548ee8193d07a9c8980c630b8ce7a9a | |
parent | 29a9c6bedd39f3432f8031475646ec151ca5caa5 (diff) | |
download | dexon-f49e398ebe32e243688a591e0752407016acb770.tar dexon-f49e398ebe32e243688a591e0752407016acb770.tar.gz dexon-f49e398ebe32e243688a591e0752407016acb770.tar.bz2 dexon-f49e398ebe32e243688a591e0752407016acb770.tar.lz dexon-f49e398ebe32e243688a591e0752407016acb770.tar.xz dexon-f49e398ebe32e243688a591e0752407016acb770.tar.zst dexon-f49e398ebe32e243688a591e0752407016acb770.zip |
bool => int
-rw-r--r-- | core/vm/gas.go | 126 |
1 files changed, 63 insertions, 63 deletions
diff --git a/core/vm/gas.go b/core/vm/gas.go index 33fc3a002..32f5fec04 100644 --- a/core/vm/gas.go +++ b/core/vm/gas.go @@ -38,7 +38,7 @@ func baseCheck(op OpCode, stack *stack, gas *big.Int) error { 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()) } @@ -57,70 +57,70 @@ func toWordSize(size *big.Int) *big.Int { type req struct { stackPop int gas *big.Int - stackPush bool + stackPush int } var _baseCheck = map[OpCode]req{ // opcode | stack pop | gas price | stack push - ADD: {2, GasFastestStep, true}, - LT: {2, GasFastestStep, true}, - GT: {2, GasFastestStep, true}, - SLT: {2, GasFastestStep, true}, - SGT: {2, GasFastestStep, true}, - EQ: {2, GasFastestStep, true}, - ISZERO: {1, GasFastestStep, true}, - SUB: {2, GasFastestStep, true}, - AND: {2, GasFastestStep, true}, - OR: {2, GasFastestStep, true}, - XOR: {2, GasFastestStep, true}, - NOT: {1, GasFastestStep, true}, - BYTE: {2, GasFastestStep, true}, - CALLDATALOAD: {1, GasFastestStep, true}, - CALLDATACOPY: {3, GasFastestStep, true}, - MLOAD: {1, GasFastestStep, true}, - MSTORE: {2, GasFastestStep, false}, - MSTORE8: {2, GasFastestStep, false}, - CODECOPY: {3, GasFastestStep, false}, - MUL: {2, GasFastStep, true}, - DIV: {2, GasFastStep, true}, - SDIV: {2, GasFastStep, true}, - MOD: {2, GasFastStep, true}, - SMOD: {2, GasFastStep, true}, - SIGNEXTEND: {2, GasFastStep, true}, - ADDMOD: {3, GasMidStep, true}, - MULMOD: {3, GasMidStep, true}, - JUMP: {1, GasMidStep, false}, - JUMPI: {2, GasSlowStep, false}, - EXP: {2, GasSlowStep, true}, - ADDRESS: {0, GasQuickStep, true}, - ORIGIN: {0, GasQuickStep, true}, - CALLER: {0, GasQuickStep, true}, - CALLVALUE: {0, GasQuickStep, true}, - CODESIZE: {0, GasQuickStep, true}, - GASPRICE: {0, GasQuickStep, true}, - COINBASE: {0, GasQuickStep, true}, - TIMESTAMP: {0, GasQuickStep, true}, - NUMBER: {0, GasQuickStep, true}, - CALLDATASIZE: {0, GasQuickStep, true}, - DIFFICULTY: {0, GasQuickStep, true}, - GASLIMIT: {0, GasQuickStep, true}, - POP: {1, GasQuickStep, false}, - PC: {0, GasQuickStep, true}, - MSIZE: {0, GasQuickStep, true}, - GAS: {0, GasQuickStep, true}, - BLOCKHASH: {1, GasExtStep, true}, - BALANCE: {1, GasExtStep, true}, - EXTCODESIZE: {1, GasExtStep, true}, - EXTCODECOPY: {4, GasExtStep, false}, - SLOAD: {1, params.SloadGas, true}, - SSTORE: {2, Zero, false}, - SHA3: {2, params.Sha3Gas, true}, - CREATE: {3, params.CreateGas, true}, - CALL: {7, params.CallGas, true}, - CALLCODE: {7, params.CallGas, true}, - JUMPDEST: {0, params.JumpdestGas, false}, - SUICIDE: {1, Zero, false}, - RETURN: {2, Zero, false}, - PUSH1: {0, GasFastestStep, true}, - DUP1: {0, Zero, true}, + ADD: {2, GasFastestStep, 1}, + LT: {2, GasFastestStep, 1}, + GT: {2, GasFastestStep, 1}, + SLT: {2, GasFastestStep, 1}, + SGT: {2, GasFastestStep, 1}, + EQ: {2, GasFastestStep, 1}, + ISZERO: {1, GasFastestStep, 1}, + SUB: {2, GasFastestStep, 1}, + AND: {2, GasFastestStep, 1}, + OR: {2, GasFastestStep, 1}, + XOR: {2, GasFastestStep, 1}, + NOT: {1, GasFastestStep, 1}, + BYTE: {2, GasFastestStep, 1}, + CALLDATALOAD: {1, GasFastestStep, 1}, + CALLDATACOPY: {3, GasFastestStep, 1}, + MLOAD: {1, GasFastestStep, 1}, + MSTORE: {2, GasFastestStep, 0}, + MSTORE8: {2, GasFastestStep, 0}, + CODECOPY: {3, GasFastestStep, 0}, + MUL: {2, GasFastStep, 1}, + DIV: {2, GasFastStep, 1}, + SDIV: {2, GasFastStep, 1}, + MOD: {2, GasFastStep, 1}, + SMOD: {2, GasFastStep, 1}, + SIGNEXTEND: {2, GasFastStep, 1}, + ADDMOD: {3, GasMidStep, 1}, + MULMOD: {3, GasMidStep, 1}, + JUMP: {1, GasMidStep, 0}, + JUMPI: {2, GasSlowStep, 0}, + EXP: {2, GasSlowStep, 1}, + ADDRESS: {0, GasQuickStep, 1}, + ORIGIN: {0, GasQuickStep, 1}, + CALLER: {0, GasQuickStep, 1}, + CALLVALUE: {0, GasQuickStep, 1}, + CODESIZE: {0, GasQuickStep, 1}, + GASPRICE: {0, GasQuickStep, 1}, + COINBASE: {0, GasQuickStep, 1}, + TIMESTAMP: {0, GasQuickStep, 1}, + NUMBER: {0, GasQuickStep, 1}, + CALLDATASIZE: {0, GasQuickStep, 1}, + DIFFICULTY: {0, GasQuickStep, 1}, + GASLIMIT: {0, GasQuickStep, 1}, + POP: {1, GasQuickStep, 0}, + PC: {0, GasQuickStep, 1}, + MSIZE: {0, GasQuickStep, 1}, + GAS: {0, GasQuickStep, 1}, + BLOCKHASH: {1, GasExtStep, 1}, + BALANCE: {1, GasExtStep, 1}, + EXTCODESIZE: {1, GasExtStep, 1}, + EXTCODECOPY: {4, GasExtStep, 0}, + SLOAD: {1, params.SloadGas, 1}, + SSTORE: {2, Zero, 0}, + SHA3: {2, params.Sha3Gas, 1}, + CREATE: {3, params.CreateGas, 1}, + CALL: {7, params.CallGas, 1}, + CALLCODE: {7, params.CallGas, 1}, + JUMPDEST: {0, params.JumpdestGas, 0}, + SUICIDE: {1, Zero, 0}, + RETURN: {2, Zero, 0}, + PUSH1: {0, GasFastestStep, 1}, + DUP1: {0, Zero, 1}, } |