From dde6292b4454f239f8d143b7424ceacd2b5fbd94 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Fri, 31 Jan 2025 16:33:10 +0100 Subject: [PATCH] miner: move blob gas checks --- miner/worker.go | 22 +++++++++++----------- params/config.go | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index b39b3a53c0..4f20b315d2 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -365,6 +365,17 @@ func (miner *Miner) commitTransactions(env *environment, plainTxs, blobTxs *tran continue } + // Most of the blob gas logic here is agnostic as to if the chain supports + // blobs or not, however the max check panics when called on a chain without + // a defined schedule, so we need to verify it's safe to call. + if miner.chainConfig.IsCancun(env.header.Number, env.header.Time) { + if left := miner.chainConfig.MaxBlobsPerBlock(env.header.Time) - uint64(env.blobs); left < (ltx.BlobGas / params.BlobTxBlobGasPerBlob) { + log.Trace("Not enough blob space left for transaction", "hash", ltx.Hash, "left", left, "needed", ltx.BlobGas/params.BlobTxBlobGasPerBlob) + txs.Pop() + continue + } + } + // Transaction seems to fit, pull it up from the pool tx := ltx.Resolve() if tx == nil { @@ -373,17 +384,6 @@ func (miner *Miner) commitTransactions(env *environment, plainTxs, blobTxs *tran continue } - // Most of the blob gas logic here is agnostic as to if the chain supports - // blobs or not, however the max check panics when called on a chain without - // a defined schedule, so we need to verify it's safe to call. - if miner.chainConfig.IsCancun(env.header.Number, env.header.Time) { - if left := miner.chainConfig.MaxBlobsPerBlock(env.header.Time) - uint64(env.blobs); left < (ltx.BlobGas / params.BlobTxBlobGasPerBlob) { - log.Trace("Not enough blob space left for transaction", "hash", tx.Hash(), "left", left, "needed", ltx.BlobGas/params.BlobTxBlobGasPerBlob) - txs.Pop() - continue - } - } - // Error may be ignored here. The error has already been checked // during transaction acceptance in the transaction pool. from, _ := types.Sender(env.signer, tx) diff --git a/params/config.go b/params/config.go index a6595be527..1ff5928e23 100644 --- a/params/config.go +++ b/params/config.go @@ -301,7 +301,7 @@ var ( Max: 6, UpdateFraction: 3338477, } - // DefaultPragueBlobConfig is the default blob configuration for the Cancun fork. + // DefaultPragueBlobConfig is the default blob configuration for the Prague fork. DefaultPragueBlobConfig = &BlobConfig{ Target: 6, Max: 9,