From 11f1b1f1da121b3d7eae40d39f829598a74c3f81 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 8 Jul 2025 11:21:38 +0200 Subject: [PATCH] params, miner: rename constants --- core/block_validator.go | 2 +- miner/worker.go | 14 +++++++------- params/protocol_params.go | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/block_validator.go b/core/block_validator.go index d4b76e02f8..008444fbbc 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -50,7 +50,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.BlockRLPSizeCap { + if v.config.IsOsaka(block.Number(), block.Time()) && block.Size() > params.MaxBlockSize { return ErrBlockOversized } // Check whether the block is already imported. diff --git a/miner/worker.go b/miner/worker.go index 88081d81ae..45a4b55f55 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -66,7 +66,7 @@ type environment struct { // txFits reports whether the transaction fits into the block size limit. func (env *environment) txFitsSize(tx *types.Transaction) bool { - return env.size+tx.Size() < params.BlockRLPSizeCap-blockRLPSizeCapBuffer + return env.size+tx.Size() < params.MaxBlockSize-maxBlockSizeBufferZone } const ( @@ -74,13 +74,13 @@ const ( commitInterruptNewHead commitInterruptResubmit commitInterruptTimeout - - // cap the size of blocks we will produce below the max allowed by - // EIP-7934. This gives us buffer room if the estimated size of the - // block we are building is off from the actual encoded size. - blockRLPSizeCapBuffer = 1_000_000 ) +// Block size is capped by the protocol at params.MaxBlockSize. When producing blocks, we +// try to say below the size including a buffer zone, this is to avoid going over the +// maximum size with auxilary data added into the block. +const maxBlockSizeBufferZone = 1_000_000 + // newPayloadResult is the result of payload generation. type newPayloadResult struct { err error @@ -115,7 +115,7 @@ func (miner *Miner) generateWork(genParam *generateParams, witness bool) *newPay // Check withdrawals fit max block size. // Due to the cap on withdrawal count, this can actually never happen, but we still need to // check to ensure the CL notices there's a problem if the withdrawal cap is ever lifted. - maxBlockSize := params.BlockRLPSizeCap - blockRLPSizeCapBuffer + maxBlockSize := params.MaxBlockSize - maxBlockSizeBufferZone if genParam.withdrawals.Size() > maxBlockSize { return &newPayloadResult{err: errors.New("withdrawals exceed max block size")} } diff --git a/params/protocol_params.go b/params/protocol_params.go index 75e6f192c7..af3d4018d6 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -179,7 +179,7 @@ const ( HistoryServeWindow = 8192 // Number of blocks to serve historical block hashes for, EIP-2935. - BlockRLPSizeCap = 8_388_608 // maximum size of an RLP-encoded block + MaxBlockSize = 8_388_608 // maximum size of an RLP-encoded block ) // Bls12381G1MultiExpDiscountTable is the gas discount table for BLS12-381 G1 multi exponentiation operation