From 24b6d442015b6408331fd432c752f2210c60e3f3 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Tue, 10 Mar 2026 18:37:02 +0100 Subject: [PATCH] core/types/bal: check correct rlp encoding size --- core/block_validator.go | 2 +- core/types/block.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core/block_validator.go b/core/block_validator.go index 3a5379d1a9..63047d0941 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -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. diff --git a/core/types/block.go b/core/types/block.go index 1bf003d1ea..ed988ddaab 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -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 {