core/types/bal: check correct rlp encoding size

This commit is contained in:
Marius van der Wijden 2026-03-10 18:37:02 +01:00
parent 19c51b5098
commit 24b6d44201
2 changed files with 14 additions and 1 deletions

View file

@ -49,7 +49,7 @@ func NewBlockValidator(config *params.ChainConfig, blockchain *BlockChain) *Bloc
// validated at this point.
func (v *BlockValidator) ValidateBody(block *types.Block) error {
// check EIP 7934 RLP-encoded block size cap
if v.config.IsOsaka(block.Number(), block.Time()) && block.Size() > params.MaxBlockSize {
if v.config.IsOsaka(block.Number(), block.Time()) && block.ConsensusSize() > params.MaxBlockSize {
return ErrBlockOversized
}
// Check whether the block is already imported.

View file

@ -462,6 +462,19 @@ func (b *Block) Size() uint64 {
return uint64(c)
}
// ConsensusSize returns the RLP encoded size of the block without the BAL
// (block access list), which is not part of the consensus encoding.
func (b *Block) ConsensusSize() uint64 {
c := writeCounter(0)
rlp.Encode(&c, &extblock{
Header: b.header,
Txs: b.transactions,
Uncles: b.uncles,
Withdrawals: b.withdrawals,
})
return uint64(c)
}
// SanityCheck can be used to prevent that unbounded fields are
// stuffed with junk data to add processing overhead
func (b *Block) SanityCheck() error {