aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/block_processor.go2
-rw-r--r--core/chain_manager.go3
-rw-r--r--core/vm/gas.go131
3 files changed, 69 insertions, 67 deletions
diff --git a/core/block_processor.go b/core/block_processor.go
index 97c885536..0a98f3e32 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -342,7 +342,7 @@ func (sm *BlockProcessor) VerifyUncles(statedb *state.StateDB, block, parent *ty
return UncleError(fmt.Sprintf("Uncle's parent unknown (%x)", uncle.ParentHash[0:4]))
}
- if err := sm.ValidateHeader(uncle, ancestorHeaders[uncle.ParentHash]); err != nil && err != BlockEqualTSErr {
+ if err := sm.ValidateHeader(uncle, ancestorHeaders[uncle.ParentHash]); err != nil {
return ValidationError(fmt.Sprintf("%v", err))
}
diff --git a/core/chain_manager.go b/core/chain_manager.go
index d97a94b06..bf5ba9b40 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -448,7 +448,8 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error {
}
if err == BlockEqualTSErr {
- queue[i] = ChainSideEvent{block, logs}
+ //queue[i] = ChainSideEvent{block, logs}
+ // XXX silently discard it?
continue
}
diff --git a/core/vm/gas.go b/core/vm/gas.go
index f7abe63f8..32f5fec04 100644
--- a/core/vm/gas.go
+++ b/core/vm/gas.go
@@ -2,8 +2,9 @@ package vm
import (
"fmt"
- "github.com/ethereum/go-ethereum/params"
"math/big"
+
+ "github.com/ethereum/go-ethereum/params"
)
var (
@@ -37,8 +38,8 @@ func baseCheck(op OpCode, stack *stack, gas *big.Int) error {
return err
}
- if r.stackPush && len(stack.data)-r.stackPop+1 > int(params.StackLimit.Int64()) {
- return fmt.Errorf("stack limit reached (%d)", 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())
}
gas.Add(gas, r.gas)
@@ -56,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},
}