wip: decouple BPO forks from named forks

This commit is contained in:
Jared Wasinger 2025-10-14 16:39:17 +08:00 committed by MariusVanDerWijden
parent 79b6a56d3a
commit 07ddc5869d
8 changed files with 27 additions and 79 deletions

View file

@ -73,8 +73,6 @@ func latestBlobConfig(cfg *params.ChainConfig, time uint64) *BlobConfig {
bc = s.BPO2 bc = s.BPO2
case cfg.IsBPO1(london, time) && s.BPO1 != nil: case cfg.IsBPO1(london, time) && s.BPO1 != nil:
bc = s.BPO1 bc = s.BPO1
case cfg.IsOsaka(london, time) && s.Osaka != nil:
bc = s.Osaka
case cfg.IsPrague(london, time) && s.Prague != nil: case cfg.IsPrague(london, time) && s.Prague != nil:
bc = s.Prague bc = s.Prague
case cfg.IsCancun(london, time) && s.Cancun != nil: case cfg.IsCancun(london, time) && s.Cancun != nil:

View file

@ -120,7 +120,6 @@ func TestCalcBlobFeePostOsaka(t *testing.T) {
BlobScheduleConfig: &params.BlobScheduleConfig{ BlobScheduleConfig: &params.BlobScheduleConfig{
Cancun: params.DefaultCancunBlobConfig, Cancun: params.DefaultCancunBlobConfig,
Prague: params.DefaultPragueBlobConfig, Prague: params.DefaultPragueBlobConfig,
Osaka: params.DefaultOsakaBlobConfig,
BPO1: &params.BlobConfig{ BPO1: &params.BlobConfig{
Target: 9, Target: 9,
Max: 14, Max: 14,
@ -191,7 +190,7 @@ func TestFakeExponential(t *testing.T) {
func TestCalcExcessBlobGasEIP7918(t *testing.T) { func TestCalcExcessBlobGasEIP7918(t *testing.T) {
var ( var (
cfg = params.MergedTestChainConfig cfg = params.MergedTestChainConfig
targetBlobs = cfg.BlobScheduleConfig.Osaka.Target targetBlobs = cfg.BlobScheduleConfig.Prague.Target
blobGasTarget = uint64(targetBlobs) * params.BlobTxBlobGasPerBlob blobGasTarget = uint64(targetBlobs) * params.BlobTxBlobGasPerBlob
) )

View file

@ -293,8 +293,6 @@ func TestVerkleGenesisCommit(t *testing.T) {
BlobScheduleConfig: &params.BlobScheduleConfig{ BlobScheduleConfig: &params.BlobScheduleConfig{
Cancun: params.DefaultCancunBlobConfig, Cancun: params.DefaultCancunBlobConfig,
Prague: params.DefaultPragueBlobConfig, Prague: params.DefaultPragueBlobConfig,
Osaka: params.DefaultOsakaBlobConfig,
Verkle: params.DefaultPragueBlobConfig,
}, },
} }

View file

@ -1234,11 +1234,6 @@ func TestBillyMigration(t *testing.T) {
Max: maxBlobs, Max: maxBlobs,
UpdateFraction: params.DefaultCancunBlobConfig.UpdateFraction, UpdateFraction: params.DefaultCancunBlobConfig.UpdateFraction,
}, },
Osaka: &params.BlobConfig{
Target: maxBlobs / 2,
Max: maxBlobs,
UpdateFraction: params.DefaultCancunBlobConfig.UpdateFraction,
},
}, },
} }
chain := &testBlockChain{ chain := &testBlockChain{

View file

@ -61,7 +61,7 @@ var (
TerminalTotalDifficulty: common.Big0, TerminalTotalDifficulty: common.Big0,
EnableVerkleAtGenesis: true, EnableVerkleAtGenesis: true,
BlobScheduleConfig: &params.BlobScheduleConfig{ BlobScheduleConfig: &params.BlobScheduleConfig{
Verkle: params.DefaultPragueBlobConfig, Prague: params.DefaultPragueBlobConfig,
}, },
// TODO uncomment when proof generation is merged // TODO uncomment when proof generation is merged
// ProofInBlocks: true, // ProofInBlocks: true,
@ -85,7 +85,7 @@ var (
TerminalTotalDifficulty: common.Big0, TerminalTotalDifficulty: common.Big0,
EnableVerkleAtGenesis: true, EnableVerkleAtGenesis: true,
BlobScheduleConfig: &params.BlobScheduleConfig{ BlobScheduleConfig: &params.BlobScheduleConfig{
Verkle: params.DefaultPragueBlobConfig, Prague: params.DefaultPragueBlobConfig,
}, },
} }
) )

View file

@ -1213,7 +1213,7 @@ func (api *BlockChainAPI) Config(ctx context.Context) (*configResponse, error) {
forkid := forkid.NewID(c, types.NewBlockWithHeader(genesis), ^uint64(0), t).Hash forkid := forkid.NewID(c, types.NewBlockWithHeader(genesis), ^uint64(0), t).Hash
return &config{ return &config{
ActivationTime: activationTime, ActivationTime: activationTime,
BlobSchedule: c.BlobConfig(c.LatestFork(t)), BlobSchedule: c.BlobConfig(t),
ChainId: (*hexutil.Big)(c.ChainID), ChainId: (*hexutil.Big)(c.ChainID),
ForkId: forkid[:], ForkId: forkid[:],
Precompiles: precompiles, Precompiles: precompiles,

View file

@ -99,7 +99,6 @@ var (
BlobScheduleConfig: &BlobScheduleConfig{ BlobScheduleConfig: &BlobScheduleConfig{
Cancun: DefaultCancunBlobConfig, Cancun: DefaultCancunBlobConfig,
Prague: DefaultPragueBlobConfig, Prague: DefaultPragueBlobConfig,
Osaka: DefaultOsakaBlobConfig,
BPO1: DefaultBPO1BlobConfig, BPO1: DefaultBPO1BlobConfig,
BPO2: DefaultBPO2BlobConfig, BPO2: DefaultBPO2BlobConfig,
}, },
@ -135,7 +134,6 @@ var (
BlobScheduleConfig: &BlobScheduleConfig{ BlobScheduleConfig: &BlobScheduleConfig{
Cancun: DefaultCancunBlobConfig, Cancun: DefaultCancunBlobConfig,
Prague: DefaultPragueBlobConfig, Prague: DefaultPragueBlobConfig,
Osaka: DefaultOsakaBlobConfig,
BPO1: DefaultBPO1BlobConfig, BPO1: DefaultBPO1BlobConfig,
BPO2: DefaultBPO2BlobConfig, BPO2: DefaultBPO2BlobConfig,
}, },
@ -171,7 +169,6 @@ var (
BlobScheduleConfig: &BlobScheduleConfig{ BlobScheduleConfig: &BlobScheduleConfig{
Cancun: DefaultCancunBlobConfig, Cancun: DefaultCancunBlobConfig,
Prague: DefaultPragueBlobConfig, Prague: DefaultPragueBlobConfig,
Osaka: DefaultOsakaBlobConfig,
BPO1: DefaultBPO1BlobConfig, BPO1: DefaultBPO1BlobConfig,
BPO2: DefaultBPO2BlobConfig, BPO2: DefaultBPO2BlobConfig,
}, },
@ -324,7 +321,6 @@ var (
BlobScheduleConfig: &BlobScheduleConfig{ BlobScheduleConfig: &BlobScheduleConfig{
Cancun: DefaultCancunBlobConfig, Cancun: DefaultCancunBlobConfig,
Prague: DefaultPragueBlobConfig, Prague: DefaultPragueBlobConfig,
Osaka: DefaultOsakaBlobConfig,
}, },
} }
@ -373,12 +369,6 @@ var (
Max: 9, Max: 9,
UpdateFraction: 5007716, UpdateFraction: 5007716,
} }
// DefaultOsakaBlobConfig is the default blob configuration for the Osaka fork.
DefaultOsakaBlobConfig = &BlobConfig{
Target: 6,
Max: 9,
UpdateFraction: 5007716,
}
// DefaultBPO1BlobConfig is the default blob configuration for the BPO1 fork. // DefaultBPO1BlobConfig is the default blob configuration for the BPO1 fork.
DefaultBPO1BlobConfig = &BlobConfig{ DefaultBPO1BlobConfig = &BlobConfig{
Target: 10, Target: 10,
@ -407,7 +397,6 @@ var (
DefaultBlobSchedule = &BlobScheduleConfig{ DefaultBlobSchedule = &BlobScheduleConfig{
Cancun: DefaultCancunBlobConfig, Cancun: DefaultCancunBlobConfig,
Prague: DefaultPragueBlobConfig, Prague: DefaultPragueBlobConfig,
Osaka: DefaultOsakaBlobConfig,
} }
) )
@ -664,7 +653,7 @@ func (c *ChainConfig) Description() string {
banner += fmt.Sprintf(" - Prague: @%-10v blob: (%s)\n", *c.PragueTime, c.BlobScheduleConfig.Prague) banner += fmt.Sprintf(" - Prague: @%-10v blob: (%s)\n", *c.PragueTime, c.BlobScheduleConfig.Prague)
} }
if c.OsakaTime != nil { if c.OsakaTime != nil {
banner += fmt.Sprintf(" - Osaka: @%-10v blob: (%s)\n", *c.OsakaTime, c.BlobScheduleConfig.Osaka) banner += fmt.Sprintf(" - Osaka: @%-10v\n", *c.OsakaTime)
} }
if c.BPO1Time != nil { if c.BPO1Time != nil {
banner += fmt.Sprintf(" - BPO1: @%-10v blob: (%s)\n", *c.BPO1Time, c.BlobScheduleConfig.BPO1) banner += fmt.Sprintf(" - BPO1: @%-10v blob: (%s)\n", *c.BPO1Time, c.BlobScheduleConfig.BPO1)
@ -682,10 +671,10 @@ func (c *ChainConfig) Description() string {
banner += fmt.Sprintf(" - BPO5: @%-10v blob: (%s)\n", *c.BPO5Time, c.BlobScheduleConfig.BPO5) banner += fmt.Sprintf(" - BPO5: @%-10v blob: (%s)\n", *c.BPO5Time, c.BlobScheduleConfig.BPO5)
} }
if c.AmsterdamTime != nil { if c.AmsterdamTime != nil {
banner += fmt.Sprintf(" - Amsterdam: @%-10v blob: (%s)\n", *c.AmsterdamTime, c.BlobScheduleConfig.Amsterdam) banner += fmt.Sprintf(" - Amsterdam: @%-10v\n", *c.AmsterdamTime)
} }
if c.VerkleTime != nil { if c.VerkleTime != nil {
banner += fmt.Sprintf(" - Verkle: @%-10v blob: (%s)\n", *c.VerkleTime, c.BlobScheduleConfig.Verkle) banner += fmt.Sprintf(" - Verkle: @%-10v\n", *c.VerkleTime)
} }
banner += fmt.Sprintf("\nAll fork specifications can be found at https://ethereum.github.io/execution-specs/src/ethereum/forks/\n") banner += fmt.Sprintf("\nAll fork specifications can be found at https://ethereum.github.io/execution-specs/src/ethereum/forks/\n")
return banner return banner
@ -710,14 +699,11 @@ func (bc *BlobConfig) String() string {
type BlobScheduleConfig struct { type BlobScheduleConfig struct {
Cancun *BlobConfig `json:"cancun,omitempty"` Cancun *BlobConfig `json:"cancun,omitempty"`
Prague *BlobConfig `json:"prague,omitempty"` Prague *BlobConfig `json:"prague,omitempty"`
Osaka *BlobConfig `json:"osaka,omitempty"`
Verkle *BlobConfig `json:"verkle,omitempty"`
BPO1 *BlobConfig `json:"bpo1,omitempty"` BPO1 *BlobConfig `json:"bpo1,omitempty"`
BPO2 *BlobConfig `json:"bpo2,omitempty"` BPO2 *BlobConfig `json:"bpo2,omitempty"`
BPO3 *BlobConfig `json:"bpo3,omitempty"` BPO3 *BlobConfig `json:"bpo3,omitempty"`
BPO4 *BlobConfig `json:"bpo4,omitempty"` BPO4 *BlobConfig `json:"bpo4,omitempty"`
BPO5 *BlobConfig `json:"bpo5,omitempty"` BPO5 *BlobConfig `json:"bpo5,omitempty"`
Amsterdam *BlobConfig `json:"amsterdam,omitempty"`
} }
// IsHomestead returns whether num is either equal to the homestead block or greater. // IsHomestead returns whether num is either equal to the homestead block or greater.
@ -982,7 +968,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
} }
} }
// Check that all forks with blobs explicitly define the blob schedule configuration. // Check that all defined BPOs have valid configurations
bsc := c.BlobScheduleConfig bsc := c.BlobScheduleConfig
if bsc == nil { if bsc == nil {
bsc = new(BlobScheduleConfig) bsc = new(BlobScheduleConfig)
@ -994,25 +980,17 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
}{ }{
{name: "cancun", timestamp: c.CancunTime, config: bsc.Cancun}, {name: "cancun", timestamp: c.CancunTime, config: bsc.Cancun},
{name: "prague", timestamp: c.PragueTime, config: bsc.Prague}, {name: "prague", timestamp: c.PragueTime, config: bsc.Prague},
{name: "osaka", timestamp: c.OsakaTime, config: bsc.Osaka},
{name: "bpo1", timestamp: c.BPO1Time, config: bsc.BPO1}, {name: "bpo1", timestamp: c.BPO1Time, config: bsc.BPO1},
{name: "bpo2", timestamp: c.BPO2Time, config: bsc.BPO2}, {name: "bpo2", timestamp: c.BPO2Time, config: bsc.BPO2},
{name: "bpo3", timestamp: c.BPO3Time, config: bsc.BPO3}, {name: "bpo3", timestamp: c.BPO3Time, config: bsc.BPO3},
{name: "bpo4", timestamp: c.BPO4Time, config: bsc.BPO4}, {name: "bpo4", timestamp: c.BPO4Time, config: bsc.BPO4},
{name: "bpo5", timestamp: c.BPO5Time, config: bsc.BPO5}, {name: "bpo5", timestamp: c.BPO5Time, config: bsc.BPO5},
{name: "amsterdam", timestamp: c.AmsterdamTime, config: bsc.Amsterdam},
} { } {
if cur.config != nil { if cur.config != nil {
if err := cur.config.validate(); err != nil { if err := cur.config.validate(); err != nil {
return fmt.Errorf("invalid chain configuration in blobSchedule for fork %q: %v", cur.name, err) return fmt.Errorf("invalid chain configuration in blobSchedule for fork %q: %v", cur.name, err)
} }
} }
if cur.timestamp != nil {
// If the fork is configured, a blob schedule must be defined for it.
if cur.config == nil {
return fmt.Errorf("invalid chain configuration: missing entry for fork %q in blobSchedule", cur.name)
}
}
} }
return nil return nil
} }
@ -1140,16 +1118,6 @@ func (c *ChainConfig) LatestFork(time uint64) forks.Fork {
switch { switch {
case c.IsAmsterdam(london, time): case c.IsAmsterdam(london, time):
return forks.Amsterdam return forks.Amsterdam
case c.IsBPO5(london, time):
return forks.BPO5
case c.IsBPO4(london, time):
return forks.BPO4
case c.IsBPO3(london, time):
return forks.BPO3
case c.IsBPO2(london, time):
return forks.BPO2
case c.IsBPO1(london, time):
return forks.BPO1
case c.IsOsaka(london, time): case c.IsOsaka(london, time):
return forks.Osaka return forks.Osaka
case c.IsPrague(london, time): case c.IsPrague(london, time):
@ -1163,24 +1131,22 @@ func (c *ChainConfig) LatestFork(time uint64) forks.Fork {
} }
} }
// BlobConfig returns the blob config associated with the provided fork. // BlobConfig returns the blob config associated with the provided timestamp.
func (c *ChainConfig) BlobConfig(fork forks.Fork) *BlobConfig { func (c *ChainConfig) BlobConfig(ts uint64) *BlobConfig {
switch fork { switch {
case forks.BPO5: case isTimestampForked(c.BPO5Time, ts):
return c.BlobScheduleConfig.BPO5 return c.BlobScheduleConfig.BPO5
case forks.BPO4: case isTimestampForked(c.BPO4Time, ts):
return c.BlobScheduleConfig.BPO4 return c.BlobScheduleConfig.BPO4
case forks.BPO3: case isTimestampForked(c.BPO3Time, ts):
return c.BlobScheduleConfig.BPO3 return c.BlobScheduleConfig.BPO3
case forks.BPO2: case isTimestampForked(c.BPO2Time, ts):
return c.BlobScheduleConfig.BPO2 return c.BlobScheduleConfig.BPO2
case forks.BPO1: case isTimestampForked(c.BPO1Time, ts):
return c.BlobScheduleConfig.BPO1 return c.BlobScheduleConfig.BPO1
case forks.Osaka: case isTimestampForked(c.PragueTime, ts):
return c.BlobScheduleConfig.Osaka
case forks.Prague:
return c.BlobScheduleConfig.Prague return c.BlobScheduleConfig.Prague
case forks.Cancun: case isTimestampForked(c.CancunTime, ts):
return c.BlobScheduleConfig.Cancun return c.BlobScheduleConfig.Cancun
default: default:
return nil return nil
@ -1211,6 +1177,8 @@ func (c *ChainConfig) ActiveSystemContracts(time uint64) map[string]common.Addre
// the fork isn't defined or isn't a time-based fork. // the fork isn't defined or isn't a time-based fork.
func (c *ChainConfig) Timestamp(fork forks.Fork) *uint64 { func (c *ChainConfig) Timestamp(fork forks.Fork) *uint64 {
switch { switch {
case fork == forks.Amsterdam:
return c.AmsterdamTime
case fork == forks.BPO5: case fork == forks.BPO5:
return c.BPO5Time return c.BPO5Time
case fork == forks.BPO4: case fork == forks.BPO4:

View file

@ -434,7 +434,6 @@ var Forks = map[string]*params.ChainConfig{
BlobScheduleConfig: &params.BlobScheduleConfig{ BlobScheduleConfig: &params.BlobScheduleConfig{
Cancun: params.DefaultCancunBlobConfig, Cancun: params.DefaultCancunBlobConfig,
Prague: params.DefaultPragueBlobConfig, Prague: params.DefaultPragueBlobConfig,
Osaka: params.DefaultOsakaBlobConfig,
}, },
}, },
"PragueToOsakaAtTime15k": { "PragueToOsakaAtTime15k": {
@ -461,7 +460,6 @@ var Forks = map[string]*params.ChainConfig{
BlobScheduleConfig: &params.BlobScheduleConfig{ BlobScheduleConfig: &params.BlobScheduleConfig{
Cancun: params.DefaultCancunBlobConfig, Cancun: params.DefaultCancunBlobConfig,
Prague: params.DefaultPragueBlobConfig, Prague: params.DefaultPragueBlobConfig,
Osaka: params.DefaultOsakaBlobConfig,
}, },
}, },
"BPO1": { "BPO1": {
@ -489,7 +487,6 @@ var Forks = map[string]*params.ChainConfig{
BlobScheduleConfig: &params.BlobScheduleConfig{ BlobScheduleConfig: &params.BlobScheduleConfig{
Cancun: params.DefaultCancunBlobConfig, Cancun: params.DefaultCancunBlobConfig,
Prague: params.DefaultPragueBlobConfig, Prague: params.DefaultPragueBlobConfig,
Osaka: params.DefaultOsakaBlobConfig,
BPO1: bpo1BlobConfig, BPO1: bpo1BlobConfig,
}, },
}, },
@ -518,7 +515,6 @@ var Forks = map[string]*params.ChainConfig{
BlobScheduleConfig: &params.BlobScheduleConfig{ BlobScheduleConfig: &params.BlobScheduleConfig{
Cancun: params.DefaultCancunBlobConfig, Cancun: params.DefaultCancunBlobConfig,
Prague: params.DefaultPragueBlobConfig, Prague: params.DefaultPragueBlobConfig,
Osaka: params.DefaultOsakaBlobConfig,
BPO1: bpo1BlobConfig, BPO1: bpo1BlobConfig,
}, },
}, },
@ -548,7 +544,6 @@ var Forks = map[string]*params.ChainConfig{
BlobScheduleConfig: &params.BlobScheduleConfig{ BlobScheduleConfig: &params.BlobScheduleConfig{
Cancun: params.DefaultCancunBlobConfig, Cancun: params.DefaultCancunBlobConfig,
Prague: params.DefaultPragueBlobConfig, Prague: params.DefaultPragueBlobConfig,
Osaka: params.DefaultOsakaBlobConfig,
BPO1: bpo1BlobConfig, BPO1: bpo1BlobConfig,
BPO2: bpo2BlobConfig, BPO2: bpo2BlobConfig,
}, },
@ -579,7 +574,6 @@ var Forks = map[string]*params.ChainConfig{
BlobScheduleConfig: &params.BlobScheduleConfig{ BlobScheduleConfig: &params.BlobScheduleConfig{
Cancun: params.DefaultCancunBlobConfig, Cancun: params.DefaultCancunBlobConfig,
Prague: params.DefaultPragueBlobConfig, Prague: params.DefaultPragueBlobConfig,
Osaka: params.DefaultOsakaBlobConfig,
BPO1: bpo1BlobConfig, BPO1: bpo1BlobConfig,
BPO2: bpo2BlobConfig, BPO2: bpo2BlobConfig,
}, },
@ -611,7 +605,6 @@ var Forks = map[string]*params.ChainConfig{
BlobScheduleConfig: &params.BlobScheduleConfig{ BlobScheduleConfig: &params.BlobScheduleConfig{
Cancun: params.DefaultCancunBlobConfig, Cancun: params.DefaultCancunBlobConfig,
Prague: params.DefaultPragueBlobConfig, Prague: params.DefaultPragueBlobConfig,
Osaka: params.DefaultOsakaBlobConfig,
BPO1: bpo1BlobConfig, BPO1: bpo1BlobConfig,
BPO2: bpo2BlobConfig, BPO2: bpo2BlobConfig,
BPO3: params.DefaultBPO3BlobConfig, BPO3: params.DefaultBPO3BlobConfig,
@ -644,7 +637,6 @@ var Forks = map[string]*params.ChainConfig{
BlobScheduleConfig: &params.BlobScheduleConfig{ BlobScheduleConfig: &params.BlobScheduleConfig{
Cancun: params.DefaultCancunBlobConfig, Cancun: params.DefaultCancunBlobConfig,
Prague: params.DefaultPragueBlobConfig, Prague: params.DefaultPragueBlobConfig,
Osaka: params.DefaultOsakaBlobConfig,
BPO1: bpo1BlobConfig, BPO1: bpo1BlobConfig,
BPO2: bpo2BlobConfig, BPO2: bpo2BlobConfig,
BPO3: params.DefaultBPO3BlobConfig, BPO3: params.DefaultBPO3BlobConfig,
@ -678,7 +670,6 @@ var Forks = map[string]*params.ChainConfig{
BlobScheduleConfig: &params.BlobScheduleConfig{ BlobScheduleConfig: &params.BlobScheduleConfig{
Cancun: params.DefaultCancunBlobConfig, Cancun: params.DefaultCancunBlobConfig,
Prague: params.DefaultPragueBlobConfig, Prague: params.DefaultPragueBlobConfig,
Osaka: params.DefaultOsakaBlobConfig,
BPO1: bpo1BlobConfig, BPO1: bpo1BlobConfig,
BPO2: bpo2BlobConfig, BPO2: bpo2BlobConfig,
BPO3: params.DefaultBPO3BlobConfig, BPO3: params.DefaultBPO3BlobConfig,
@ -713,7 +704,6 @@ var Forks = map[string]*params.ChainConfig{
BlobScheduleConfig: &params.BlobScheduleConfig{ BlobScheduleConfig: &params.BlobScheduleConfig{
Cancun: params.DefaultCancunBlobConfig, Cancun: params.DefaultCancunBlobConfig,
Prague: params.DefaultPragueBlobConfig, Prague: params.DefaultPragueBlobConfig,
Osaka: params.DefaultOsakaBlobConfig,
BPO1: bpo1BlobConfig, BPO1: bpo1BlobConfig,
BPO2: bpo2BlobConfig, BPO2: bpo2BlobConfig,
BPO3: params.DefaultBPO3BlobConfig, BPO3: params.DefaultBPO3BlobConfig,