|
43 | 43 | errBlockInterruptedByTimeout = errors.New("timeout while building block") |
44 | 44 | ) |
45 | 45 |
|
| 46 | +// maxBlobsPerBlock returns the maximum number of blobs per block. |
| 47 | +// Users can specify the maximum number of blobs per block if necessary. |
| 48 | +func (miner *Miner) maxBlobsPerBlock(time uint64) int { |
| 49 | + maxBlobs := eip4844.MaxBlobsPerBlock(miner.chainConfig, time) |
| 50 | + if miner.config.MaxBlobsPerBlock != nil { |
| 51 | + maxBlobs = *miner.config.MaxBlobsPerBlock |
| 52 | + } |
| 53 | + return maxBlobs |
| 54 | +} |
| 55 | + |
46 | 56 | // environment is the worker's current environment and holds all |
47 | 57 | // information of the sealing block generation. |
48 | 58 | type environment struct { |
@@ -309,7 +319,7 @@ func (miner *Miner) commitBlobTransaction(env *environment, tx *types.Transactio |
309 | 319 | // isn't really a better place right now. The blob gas limit is checked at block validation time |
310 | 320 | // and not during execution. This means core.ApplyTransaction will not return an error if the |
311 | 321 | // tx has too many blobs. So we have to explicitly check it here. |
312 | | - maxBlobs := eip4844.MaxBlobsPerBlock(miner.chainConfig, env.header.Time) |
| 322 | + maxBlobs := miner.maxBlobsPerBlock(env.header.Time) |
313 | 323 | if env.blobs+len(sc.Blobs) > maxBlobs { |
314 | 324 | return errors.New("max data blobs reached") |
315 | 325 | } |
@@ -364,7 +374,7 @@ func (miner *Miner) commitTransactions(env *environment, plainTxs, blobTxs *tran |
364 | 374 | } |
365 | 375 | // If we don't have enough blob space for any further blob transactions, |
366 | 376 | // skip that list altogether |
367 | | - if !blobTxs.Empty() && env.blobs >= eip4844.MaxBlobsPerBlock(miner.chainConfig, env.header.Time) { |
| 377 | + if !blobTxs.Empty() && env.blobs >= miner.maxBlobsPerBlock(env.header.Time) { |
368 | 378 | log.Trace("Not enough blob space for further blob transactions") |
369 | 379 | blobTxs.Clear() |
370 | 380 | // Fall though to pick up any plain txs |
@@ -403,7 +413,7 @@ func (miner *Miner) commitTransactions(env *environment, plainTxs, blobTxs *tran |
403 | 413 | // blobs or not, however the max check panics when called on a chain without |
404 | 414 | // a defined schedule, so we need to verify it's safe to call. |
405 | 415 | if isCancun { |
406 | | - left := eip4844.MaxBlobsPerBlock(miner.chainConfig, env.header.Time) - env.blobs |
| 416 | + left := miner.maxBlobsPerBlock(env.header.Time) - env.blobs |
407 | 417 | if left < int(ltx.BlobGas/params.BlobTxBlobGasPerBlob) { |
408 | 418 | log.Trace("Not enough blob space left for transaction", "hash", ltx.Hash, "left", left, "needed", ltx.BlobGas/params.BlobTxBlobGasPerBlob) |
409 | 419 | txs.Pop() |
|
0 commit comments