Skip to content

Commit 11f1b1f

Browse files
committed
params, miner: rename constants
1 parent 319fd95 commit 11f1b1f

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

core/block_validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func NewBlockValidator(config *params.ChainConfig, blockchain *BlockChain) *Bloc
5050
// validated at this point.
5151
func (v *BlockValidator) ValidateBody(block *types.Block) error {
5252
// check EIP 7934 RLP-encoded block size cap
53-
if v.config.IsOsaka(block.Number(), block.Time()) && block.Size() > params.BlockRLPSizeCap {
53+
if v.config.IsOsaka(block.Number(), block.Time()) && block.Size() > params.MaxBlockSize {
5454
return ErrBlockOversized
5555
}
5656
// Check whether the block is already imported.

miner/worker.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,21 @@ type environment struct {
6666

6767
// txFits reports whether the transaction fits into the block size limit.
6868
func (env *environment) txFitsSize(tx *types.Transaction) bool {
69-
return env.size+tx.Size() < params.BlockRLPSizeCap-blockRLPSizeCapBuffer
69+
return env.size+tx.Size() < params.MaxBlockSize-maxBlockSizeBufferZone
7070
}
7171

7272
const (
7373
commitInterruptNone int32 = iota
7474
commitInterruptNewHead
7575
commitInterruptResubmit
7676
commitInterruptTimeout
77-
78-
// cap the size of blocks we will produce below the max allowed by
79-
// EIP-7934. This gives us buffer room if the estimated size of the
80-
// block we are building is off from the actual encoded size.
81-
blockRLPSizeCapBuffer = 1_000_000
8277
)
8378

79+
// Block size is capped by the protocol at params.MaxBlockSize. When producing blocks, we
80+
// try to say below the size including a buffer zone, this is to avoid going over the
81+
// maximum size with auxilary data added into the block.
82+
const maxBlockSizeBufferZone = 1_000_000
83+
8484
// newPayloadResult is the result of payload generation.
8585
type newPayloadResult struct {
8686
err error
@@ -115,7 +115,7 @@ func (miner *Miner) generateWork(genParam *generateParams, witness bool) *newPay
115115
// Check withdrawals fit max block size.
116116
// Due to the cap on withdrawal count, this can actually never happen, but we still need to
117117
// check to ensure the CL notices there's a problem if the withdrawal cap is ever lifted.
118-
maxBlockSize := params.BlockRLPSizeCap - blockRLPSizeCapBuffer
118+
maxBlockSize := params.MaxBlockSize - maxBlockSizeBufferZone
119119
if genParam.withdrawals.Size() > maxBlockSize {
120120
return &newPayloadResult{err: errors.New("withdrawals exceed max block size")}
121121
}

params/protocol_params.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ const (
179179

180180
HistoryServeWindow = 8192 // Number of blocks to serve historical block hashes for, EIP-2935.
181181

182-
BlockRLPSizeCap = 8_388_608 // maximum size of an RLP-encoded block
182+
MaxBlockSize = 8_388_608 // maximum size of an RLP-encoded block
183183
)
184184

185185
// Bls12381G1MultiExpDiscountTable is the gas discount table for BLS12-381 G1 multi exponentiation operation

0 commit comments

Comments
 (0)