diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-02-26 06:58:01 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-02-26 06:58:01 +0800 |
commit | b155b9d80b1cb921c52c20e296f27039de3b069b (patch) | |
tree | 37ae6a87a80422bab986748ba302a08ac53569ae | |
parent | fe730239400e73babf829857272c42af7563efce (diff) | |
parent | 260ab739694b554c3cdec8531b98e0334753fbe1 (diff) | |
download | dexon-b155b9d80b1cb921c52c20e296f27039de3b069b.tar.gz dexon-b155b9d80b1cb921c52c20e296f27039de3b069b.tar.zst dexon-b155b9d80b1cb921c52c20e296f27039de3b069b.zip |
Merge pull request #388 from Gustav-Simonsson/validate_block_header_gas_limit
Validate block header gas limit
-rw-r--r-- | core/block_processor.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/block_processor.go b/core/block_processor.go index fd591a29d..f66d158b2 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -62,7 +62,7 @@ func NewBlockProcessor(db ethutil.Database, txpool *TxPool, chainManager *ChainM func (sm *BlockProcessor) TransitionState(statedb *state.StateDB, parent, block *types.Block, transientProcess bool) (receipts types.Receipts, err error) { coinbase := statedb.GetOrNewStateObject(block.Header().Coinbase) - coinbase.SetGasPool(CalcGasLimit(parent, block)) + coinbase.SetGasPool(block.Header().GasLimit) // Process the transactions on to parent state receipts, _, _, _, err = sm.ApplyTransactions(coinbase, statedb, block, block.Transactions(), transientProcess) @@ -247,6 +247,11 @@ func (sm *BlockProcessor) ValidateBlock(block, parent *types.Block) error { return fmt.Errorf("Difficulty check failed for block %v, %v", block.Header().Difficulty, expd) } + expl := CalcGasLimit(parent, block) + if expl.Cmp(block.Header().GasLimit) != 0 { + return fmt.Errorf("GasLimit check failed for block %v, %v", block.Header().GasLimit, expl) + } + if block.Time() < parent.Time() { return ValidationError("Block timestamp not after prev block (%v - %v)", block.Header().Time, parent.Header().Time) } |