mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
consensus/misc/eip4844: unexport TargetBlobsPerBlock
This commit is contained in:
parent
fa73a5e424
commit
886d6edc2b
2 changed files with 21 additions and 22 deletions
|
|
@ -61,7 +61,7 @@ func VerifyEIP4844Header(config *params.ChainConfig, parent, header *types.Heade
|
||||||
// blobs on top of the excess blob gas.
|
// blobs on top of the excess blob gas.
|
||||||
func CalcExcessBlobGas(config *params.ChainConfig, parent *types.Header) uint64 {
|
func CalcExcessBlobGas(config *params.ChainConfig, parent *types.Header) uint64 {
|
||||||
var (
|
var (
|
||||||
targetGas = uint64(TargetBlobsPerBlock(config, parent.Time)) * params.BlobTxBlobGasPerBlob
|
targetGas = uint64(targetBlobsPerBlock(config, parent.Time)) * params.BlobTxBlobGasPerBlob
|
||||||
parentExcessBlobGas uint64
|
parentExcessBlobGas uint64
|
||||||
parentBlobGasUsed uint64
|
parentBlobGasUsed uint64
|
||||||
)
|
)
|
||||||
|
|
@ -88,26 +88,6 @@ func CalcBlobFee(config *params.ChainConfig, header *types.Header) *big.Int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TargetBlobsPerBlock returns the target blobs per block associated with
|
|
||||||
// requested time.
|
|
||||||
func TargetBlobsPerBlock(cfg *params.ChainConfig, time uint64) int {
|
|
||||||
if cfg.BlobScheduleConfig == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
var (
|
|
||||||
london = cfg.LondonBlock
|
|
||||||
s = cfg.BlobScheduleConfig
|
|
||||||
)
|
|
||||||
switch {
|
|
||||||
case cfg.IsPrague(london, time) && s.Prague != nil:
|
|
||||||
return s.Prague.Target
|
|
||||||
case cfg.IsCancun(london, time) && s.Cancun != nil:
|
|
||||||
return s.Cancun.Target
|
|
||||||
default:
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MaxBlobsPerBlock returns the max blobs per block for a block at the given timestamp.
|
// MaxBlobsPerBlock returns the max blobs per block for a block at the given timestamp.
|
||||||
func MaxBlobsPerBlock(cfg *params.ChainConfig, time uint64) int {
|
func MaxBlobsPerBlock(cfg *params.ChainConfig, time uint64) int {
|
||||||
if cfg.BlobScheduleConfig == nil {
|
if cfg.BlobScheduleConfig == nil {
|
||||||
|
|
@ -149,6 +129,25 @@ func LatestMaxBlobsPerBlock(cfg *params.ChainConfig) int {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// targetBlobsPerBlock returns the target number of blobs in a block at the given timestamp.
|
||||||
|
func targetBlobsPerBlock(cfg *params.ChainConfig, time uint64) int {
|
||||||
|
if cfg.BlobScheduleConfig == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var (
|
||||||
|
london = cfg.LondonBlock
|
||||||
|
s = cfg.BlobScheduleConfig
|
||||||
|
)
|
||||||
|
switch {
|
||||||
|
case cfg.IsPrague(london, time) && s.Prague != nil:
|
||||||
|
return s.Prague.Target
|
||||||
|
case cfg.IsCancun(london, time) && s.Cancun != nil:
|
||||||
|
return s.Cancun.Target
|
||||||
|
default:
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// fakeExponential approximates factor * e ** (numerator / denominator) using
|
// fakeExponential approximates factor * e ** (numerator / denominator) using
|
||||||
// Taylor expansion.
|
// Taylor expansion.
|
||||||
func fakeExponential(factor, numerator, denominator *big.Int) *big.Int {
|
func fakeExponential(factor, numerator, denominator *big.Int) *big.Int {
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import (
|
||||||
func TestCalcExcessBlobGas(t *testing.T) {
|
func TestCalcExcessBlobGas(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
config = params.MainnetChainConfig
|
config = params.MainnetChainConfig
|
||||||
targetBlobs = TargetBlobsPerBlock(config, *config.CancunTime)
|
targetBlobs = targetBlobsPerBlock(config, *config.CancunTime)
|
||||||
targetBlobGas = uint64(targetBlobs) * params.BlobTxBlobGasPerBlob
|
targetBlobGas = uint64(targetBlobs) * params.BlobTxBlobGasPerBlob
|
||||||
)
|
)
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue