mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
core: Fix for consensus test gasLimit > 2^63-1 https://github.com/ethereum/tests/blob/develop/BlockchainTests/bcInvalidHeaderTest.json#L238
This commit is contained in:
parent
e1dc7ece62
commit
a8aaac7e68
2 changed files with 7 additions and 0 deletions
|
|
@ -27,6 +27,8 @@ var (
|
|||
tt256 = BigPow(2, 256)
|
||||
tt256m1 = new(big.Int).Sub(tt256, big.NewInt(1))
|
||||
MaxBig256 = new(big.Int).Set(tt256m1)
|
||||
tt63 = BigPow(2,63)
|
||||
TT63m1 = new(big.Int).Sub(tt63,big.NewInt(1))
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
|||
|
|
@ -243,6 +243,11 @@ 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
|
||||
if header.GasLimit.Cmp(math.TT63m1) > 0{
|
||||
return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, math.TT63m1)
|
||||
}
|
||||
|
||||
// Verify that the gas limit remains within allowed bounds
|
||||
diff := new(big.Int).Set(parent.GasLimit)
|
||||
diff = diff.Sub(diff, header.GasLimit)
|
||||
|
|
|
|||
Loading…
Reference in a new issue