consensus: define MaxGasLimit as a const in params (#24092)

* consensus: use the maxGasLimit constant to check the header.GasLimit to avoid creating new variables repeatedly

* consensus: check the header.GasLimit by the public constant MaxGasLimit

* consensus: check the header.GasLimit by the constant MaxGasLimit
This commit is contained in:
jovijovi
2021-12-14 17:17:25 +08:00
committed by GitHub
parent 72c2c0ae7e
commit b3b8b268eb
4 changed files with 11 additions and 12 deletions

View File

@ -281,9 +281,8 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainHeaderReader, header, pa
return fmt.Errorf("invalid difficulty: have %v, want %v", header.Difficulty, expected)
}
// Verify that the gas limit is <= 2^63-1
cap := uint64(0x7fffffffffffffff)
if header.GasLimit > cap {
return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, cap)
if header.GasLimit > params.MaxGasLimit {
return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, params.MaxGasLimit)
}
// Verify that the gasUsed is <= gasLimit
if header.GasUsed > header.GasLimit {