aboutsummaryrefslogtreecommitdiffstats
path: root/consensus
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2017-05-04 18:53:42 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-05-04 18:53:42 +0800
commit14cc40a31a3f3aa229e6770911324daa2928ef57 (patch)
treeef0795701a68240e685437f7a6ccc371e2a4e358 /consensus
parent881df0e6296520c2a230c5aaad96f2e1ba721d87 (diff)
downloaddexon-14cc40a31a3f3aa229e6770911324daa2928ef57.tar
dexon-14cc40a31a3f3aa229e6770911324daa2928ef57.tar.gz
dexon-14cc40a31a3f3aa229e6770911324daa2928ef57.tar.bz2
dexon-14cc40a31a3f3aa229e6770911324daa2928ef57.tar.lz
dexon-14cc40a31a3f3aa229e6770911324daa2928ef57.tar.xz
dexon-14cc40a31a3f3aa229e6770911324daa2928ef57.tar.zst
dexon-14cc40a31a3f3aa229e6770911324daa2928ef57.zip
Hive-test fixes (#14419)
* core: Fix for consensus test gasLimit > 2^63-1 https://github.com/ethereum/tests/blob/develop/BlockchainTests/bcInvalidHeaderTest.json#L238 * core: fix testcase for uncle gasUsage > gasLimit : https://github.com/ethereum/tests/blob/develop/BlockchainTests/EIP150/bcUncleHeaderValiditiy.json#L986 * math/big: rename TTM63m1 -> MaxBig63, + go fmt * core: documentation
Diffstat (limited to 'consensus')
-rw-r--r--consensus/ethash/consensus.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go
index 4f1ab8702..2930032e5 100644
--- a/consensus/ethash/consensus.go
+++ b/consensus/ethash/consensus.go
@@ -243,6 +243,15 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent *
if expected.Cmp(header.Difficulty) != 0 {
return fmt.Errorf("invalid difficulty: have %v, want %v", header.Difficulty, expected)
}
+ // Verify that the gas limit is <= 2^63-1
+ if header.GasLimit.Cmp(math.MaxBig63) > 0 {
+ return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, math.MaxBig63)
+ }
+ // Verify that the gasUsed is <= gasLimit
+ if header.GasUsed.Cmp(header.GasLimit) > 0 {
+ return fmt.Errorf("invalid gasUsed: have %v, gasLimit %v", header.GasUsed, header.GasLimit)
+ }
+
// Verify that the gas limit remains within allowed bounds
diff := new(big.Int).Set(parent.GasLimit)
diff = diff.Sub(diff, header.GasLimit)