From 2f957067778483be0028f30023ba3c972e3d81d7 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Tue, 21 Oct 2025 16:48:17 +0200 Subject: [PATCH 1/2] Add helpers to expose TargetBlobs chain config Rollups may want to use these to dynamically adjust blobs posted after BPO forks. --- consensus/misc/eip4844/eip4844.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/consensus/misc/eip4844/eip4844.go b/consensus/misc/eip4844/eip4844.go index e14d1295613..5de3150b194 100644 --- a/consensus/misc/eip4844/eip4844.go +++ b/consensus/misc/eip4844/eip4844.go @@ -200,6 +200,30 @@ func LatestMaxBlobsPerBlock(cfg *params.ChainConfig) int { return bcfg.Max } +// TargetBlobsPerBlock returns the target blobs per block for a block at the given timestamp. +func TargetBlobsPerBlock(cfg *params.ChainConfig, time uint64) int { + blobConfig := latestBlobConfig(cfg, time) + if blobConfig == nil { + return 0 + } + return blobConfig.Target +} + +// TargetBlobGasPerBlock returns the target blob gas that can be spent in a block at the given timestamp. +func TargetBlobGasPerBlock(cfg *params.ChainConfig, time uint64) uint64 { + return uint64(TargetBlobsPerBlock(cfg, time)) * params.BlobTxBlobGasPerBlob +} + +// LatestTargetBlobsPerBlock returns the latest target blobs per block defined by the +// configuration, regardless of the currently active fork. +func LatestTargetBlobsPerBlock(cfg *params.ChainConfig) int { + bcfg := latestBlobConfig(cfg, math.MaxUint64) + if bcfg == nil { + return 0 + } + return bcfg.Target +} + // fakeExponential approximates factor * e ** (numerator / denominator) using // Taylor expansion. func fakeExponential(factor, numerator, denominator *big.Int) *big.Int { From 5a2fa75da74afd69d186b0345df9aef463ef0554 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Thu, 30 Oct 2025 15:20:55 +0100 Subject: [PATCH 2/2] Only expose TargetBlobsPerBlock --- consensus/misc/eip4844/eip4844.go | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/consensus/misc/eip4844/eip4844.go b/consensus/misc/eip4844/eip4844.go index 5de3150b194..c1a21195e32 100644 --- a/consensus/misc/eip4844/eip4844.go +++ b/consensus/misc/eip4844/eip4844.go @@ -209,21 +209,6 @@ func TargetBlobsPerBlock(cfg *params.ChainConfig, time uint64) int { return blobConfig.Target } -// TargetBlobGasPerBlock returns the target blob gas that can be spent in a block at the given timestamp. -func TargetBlobGasPerBlock(cfg *params.ChainConfig, time uint64) uint64 { - return uint64(TargetBlobsPerBlock(cfg, time)) * params.BlobTxBlobGasPerBlob -} - -// LatestTargetBlobsPerBlock returns the latest target blobs per block defined by the -// configuration, regardless of the currently active fork. -func LatestTargetBlobsPerBlock(cfg *params.ChainConfig) int { - bcfg := latestBlobConfig(cfg, math.MaxUint64) - if bcfg == nil { - return 0 - } - return bcfg.Target -} - // fakeExponential approximates factor * e ** (numerator / denominator) using // Taylor expansion. func fakeExponential(factor, numerator, denominator *big.Int) *big.Int {