diff options
author | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-03-30 21:59:14 +0800 |
---|---|---|
committer | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-03-30 22:07:24 +0800 |
commit | 9feed3f61ebd3875fef8355fab9f1027989c03d6 (patch) | |
tree | e5a4cdeedb5149d914d955ecefe554ff8276c33f /core/block_processor.go | |
parent | f23529c5cde47f713ada745629a7bdc8e1506fa7 (diff) | |
download | go-tangerine-9feed3f61ebd3875fef8355fab9f1027989c03d6.tar go-tangerine-9feed3f61ebd3875fef8355fab9f1027989c03d6.tar.gz go-tangerine-9feed3f61ebd3875fef8355fab9f1027989c03d6.tar.bz2 go-tangerine-9feed3f61ebd3875fef8355fab9f1027989c03d6.tar.lz go-tangerine-9feed3f61ebd3875fef8355fab9f1027989c03d6.tar.xz go-tangerine-9feed3f61ebd3875fef8355fab9f1027989c03d6.tar.zst go-tangerine-9feed3f61ebd3875fef8355fab9f1027989c03d6.zip |
Correct gas limit validation according to new algorithm
* Use absolute value of (block's gas limit) - (parent's gas limit)
in comparison with diff limit.
* Ensure the diff is strictly smaller than the allowed size.
Diffstat (limited to 'core/block_processor.go')
-rw-r--r-- | core/block_processor.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/core/block_processor.go b/core/block_processor.go index bc3274eb5..e970ad06e 100644 --- a/core/block_processor.go +++ b/core/block_processor.go @@ -260,10 +260,13 @@ 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 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 { + if !(a.Cmp(b) < 0) { return fmt.Errorf("GasLimit check failed for block %v (%v > %v)", block.GasLimit, a, b) } |