aboutsummaryrefslogtreecommitdiffstats
path: root/core/block_processor.go
diff options
context:
space:
mode:
authorGustav Simonsson <gustav.simonsson@gmail.com>2015-04-02 11:17:15 +0800
committerGustav Simonsson <gustav.simonsson@gmail.com>2015-04-02 12:22:32 +0800
commitc26c8d3a44cdd45994b6d99777d620565bab8f9c (patch)
tree6ab5a74981e9fb9f869f1ef884a375163b898113 /core/block_processor.go
parent516ec28544e0f9c76e18d82742d3ae58cfb59cc1 (diff)
downloadgo-tangerine-c26c8d3a44cdd45994b6d99777d620565bab8f9c.tar.gz
go-tangerine-c26c8d3a44cdd45994b6d99777d620565bab8f9c.tar.zst
go-tangerine-c26c8d3a44cdd45994b6d99777d620565bab8f9c.zip
Read most protocol params from common/params.json
* Add params package with exported variables generated from github.com/ethereum/common/blob/master/params.json * Use params package variables in applicable places * Add check for minimum gas limit in validation of block's gas limit * Remove common/params.json from go-ethereum to avoid outdated version of it
Diffstat (limited to 'core/block_processor.go')
-rw-r--r--core/block_processor.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/core/block_processor.go b/core/block_processor.go
index f7f0cd188..18667c449 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
+ "github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/pow"
"github.com/ethereum/go-ethereum/rlp"
"gopkg.in/fatih/set.v0"
@@ -252,7 +253,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (td *big
// an uncle or anything that isn't on the current block chain.
// Validation validates easy over difficult (dagger takes longer time = difficult)
func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error {
- if len(block.Extra) > 1024 {
+ if big.NewInt(int64(len(block.Extra))).Cmp(params.MaximumExtraDataSize) == 1 {
return fmt.Errorf("Block extra data too long (%d)", len(block.Extra))
}
@@ -261,13 +262,11 @@ func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error {
return fmt.Errorf("Difficulty check failed for block %v, %v", block.Difficulty, expd)
}
- // TODO: use use minGasLimit and gasLimitBoundDivisor from
- // https://github.com/ethereum/common/blob/master/params.json
- // block.gasLimit - parent.gasLimit <= parent.gasLimit / 1024
+ // block.gasLimit - parent.gasLimit <= parent.gasLimit / GasLimitBoundDivisor
a := new(big.Int).Sub(block.GasLimit, parent.GasLimit)
a.Abs(a)
- b := new(big.Int).Div(parent.GasLimit, big.NewInt(1024))
- if !(a.Cmp(b) < 0) {
+ b := new(big.Int).Div(parent.GasLimit, params.GasLimitBoundDivisor)
+ if !(a.Cmp(b) < 0) || (block.GasLimit.Cmp(params.MinGasLimit) == -1) {
return fmt.Errorf("GasLimit check failed for block %v (%v > %v)", block.GasLimit, a, b)
}