consensus/misc: hardening header verification (#33860)

Defensively check parent's base fee before using it for calculations.
This commit is contained in:
Sina M 2026-02-17 15:42:48 +01:00 committed by GitHub
parent a4b3898f90
commit 550ca91b17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -43,6 +43,10 @@ func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Heade
if header.BaseFee == nil { if header.BaseFee == nil {
return errors.New("header is missing baseFee") return errors.New("header is missing baseFee")
} }
// Verify the parent header is not malformed
if config.IsLondon(parent.Number) && parent.BaseFee == nil {
return errors.New("parent header is missing baseFee")
}
// Verify the baseFee is correct based on the parent header. // Verify the baseFee is correct based on the parent header.
expectedBaseFee := CalcBaseFee(config, parent) expectedBaseFee := CalcBaseFee(config, parent)
if header.BaseFee.Cmp(expectedBaseFee) != 0 { if header.BaseFee.Cmp(expectedBaseFee) != 0 {