diff options
author | Maran <maran.hidskes@gmail.com> | 2014-06-10 23:23:32 +0800 |
---|---|---|
committer | Maran <maran.hidskes@gmail.com> | 2014-06-10 23:23:32 +0800 |
commit | bdc206885a1d9c730464f60ec65557403720be1e (patch) | |
tree | 2686f3c960f6f2966f44d014e4143fa41eb84edd /ethchain/state_manager.go | |
parent | 69044fe5774840a49de3f881a490db52e907affb (diff) | |
download | dexon-bdc206885a1d9c730464f60ec65557403720be1e.tar dexon-bdc206885a1d9c730464f60ec65557403720be1e.tar.gz dexon-bdc206885a1d9c730464f60ec65557403720be1e.tar.bz2 dexon-bdc206885a1d9c730464f60ec65557403720be1e.tar.lz dexon-bdc206885a1d9c730464f60ec65557403720be1e.tar.xz dexon-bdc206885a1d9c730464f60ec65557403720be1e.tar.zst dexon-bdc206885a1d9c730464f60ec65557403720be1e.zip |
Don't mine transactions if they would go over the GasLimit implements ethereum/go-ethereum#77 further.
Diffstat (limited to 'ethchain/state_manager.go')
-rw-r--r-- | ethchain/state_manager.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ethchain/state_manager.go b/ethchain/state_manager.go index f1c09b819..aea5433ff 100644 --- a/ethchain/state_manager.go +++ b/ethchain/state_manager.go @@ -114,6 +114,8 @@ func (sm *StateManager) ApplyTransactions(state *State, block *Block, txs []*Tra // Process each transaction/contract var receipts []*Receipt var validTxs []*Transaction + var ignoredTxs []*Transaction // Transactions which go over the gasLimit + totalUsedGas := big.NewInt(0) for _, tx := range txs { usedGas, err := sm.ApplyTransaction(state, block, tx) @@ -121,6 +123,12 @@ func (sm *StateManager) ApplyTransactions(state *State, block *Block, txs []*Tra if IsNonceErr(err) { continue } + if IsGasLimitErr(err) { + ignoredTxs = append(ignoredTxs, tx) + // We need to figure out if we want to do something with thse txes + ethutil.Config.Log.Debugln("Gastlimit:", err) + continue + } ethutil.Config.Log.Infoln(err) } @@ -151,6 +159,7 @@ func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transac script []byte ) totalGasUsed = big.NewInt(0) + snapshot := state.Snapshot() // Apply the transaction to the current state gas, err = sm.Ethereum.TxPool().ProcessTransaction(tx, state, false) @@ -190,6 +199,14 @@ func (sm *StateManager) ApplyTransaction(state *State, block *Block, tx *Transac } } + parent := sm.bc.GetBlock(block.PrevHash) + total := new(big.Int).Add(block.GasUsed, totalGasUsed) + limit := block.CalcGasLimit(parent) + if total.Cmp(limit) > 0 { + state.Revert(snapshot) + err = GasLimitError(total, limit) + } + return } |