diff --git a/consensus/XDPoS/engines/engine_v2/verifyHeader.go b/consensus/XDPoS/engines/engine_v2/verifyHeader.go index f4a94164bb..f78cddb5e9 100644 --- a/consensus/XDPoS/engines/engine_v2/verifyHeader.go +++ b/consensus/XDPoS/engines/engine_v2/verifyHeader.go @@ -9,6 +9,7 @@ import ( "github.com/XinFinOrg/XDPoSChain/common/hexutil" "github.com/XinFinOrg/XDPoSChain/consensus" "github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/utils" + "github.com/XinFinOrg/XDPoSChain/consensus/misc" "github.com/XinFinOrg/XDPoSChain/consensus/misc/eip1559" "github.com/XinFinOrg/XDPoSChain/core/types" "github.com/XinFinOrg/XDPoSChain/log" @@ -95,6 +96,10 @@ func (x *XDPoS_v2) verifyHeader(chain consensus.ChainReader, header *types.Heade if header.UncleHash != utils.UncleHash { return utils.ErrInvalidUncleHash } + // Verify that the gas limit remains within allowed bounds + if err := misc.VerifyGaslimit(parent.GasLimit, header.GasLimit); err != nil { + return err + } // Verify the header's EIP-1559 attributes. if err := eip1559.VerifyEip1559Header(chain.Config(), header); err != nil { return err diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 0f7cfce248..c70f52b88a 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -198,6 +198,10 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent * if header.GasUsed > header.GasLimit { return fmt.Errorf("invalid gasUsed: have %d, gasLimit %d", header.GasUsed, header.GasLimit) } + // Verify that the gas limit remains within allowed bounds + if err := misc.VerifyGaslimit(parent.GasLimit, header.GasLimit); err != nil { + return err + } // Verify the header's EIP-1559 attributes. if err := eip1559.VerifyEip1559Header(chain.Config(), header); err != nil { return err