diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index fe53b074b0..ccedad0731 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -71,6 +71,7 @@ var ( utils.OverrideLorentz, utils.OverrideMaxwell, utils.OverrideFermi, + utils.OverrideOsaka, utils.OverrideVerkle, utils.MultiDataBaseFlag, }, utils.DatabaseFlags), @@ -344,6 +345,10 @@ func initGenesis(ctx *cli.Context) error { v := ctx.Uint64(utils.OverrideFermi.Name) overrides.OverrideFermi = &v } + if ctx.IsSet(utils.OverrideOsaka.Name) { + v := ctx.Uint64(utils.OverrideOsaka.Name) + overrides.OverrideOsaka = &v + } if ctx.IsSet(utils.OverrideVerkle.Name) { v := ctx.Uint64(utils.OverrideVerkle.Name) overrides.OverrideVerkle = &v diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 55c7d5d008..16786ae249 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -270,6 +270,10 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) { v := ctx.Uint64(utils.OverrideFermi.Name) cfg.Eth.OverrideFermi = &v } + if ctx.IsSet(utils.OverrideOsaka.Name) { + v := ctx.Uint64(utils.OverrideOsaka.Name) + cfg.Eth.OverrideOsaka = &v + } if ctx.IsSet(utils.OverrideVerkle.Name) { v := ctx.Uint64(utils.OverrideVerkle.Name) cfg.Eth.OverrideVerkle = &v diff --git a/cmd/geth/main.go b/cmd/geth/main.go index a2f470945e..700758a1e1 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -76,6 +76,7 @@ var ( utils.OverrideLorentz, utils.OverrideMaxwell, utils.OverrideFermi, + utils.OverrideOsaka, utils.OverrideVerkle, utils.OverrideFullImmutabilityThreshold, utils.OverrideMinBlocksForBlobRequests, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index aa7bef1a97..51a17de863 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -315,6 +315,11 @@ var ( Usage: "Manually specify the Fermi fork timestamp, overriding the bundled setting", Category: flags.EthCategory, } + OverrideOsaka = &cli.Uint64Flag{ + Name: "override.osaka", + Usage: "Manually specify the Osaka fork timestamp, overriding the bundled setting", + Category: flags.EthCategory, + } OverrideVerkle = &cli.Uint64Flag{ Name: "override.verkle", Usage: "Manually specify the Verkle fork timestamp, overriding the bundled setting", diff --git a/core/genesis.go b/core/genesis.go index 7ab5c7156c..2437089b2a 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -271,6 +271,7 @@ type ChainOverrides struct { OverrideLorentz *uint64 OverrideMaxwell *uint64 OverrideFermi *uint64 + OverrideOsaka *uint64 OverrideVerkle *uint64 } @@ -300,6 +301,9 @@ func (o *ChainOverrides) apply(cfg *params.ChainConfig) error { if o.OverrideFermi != nil { cfg.FermiTime = o.OverrideFermi } + if o.OverrideOsaka != nil { + cfg.OsakaTime = o.OverrideOsaka + } if o.OverrideVerkle != nil { cfg.VerkleTime = o.OverrideVerkle } diff --git a/eth/backend.go b/eth/backend.go index 63f1fa9121..a4f6f08586 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -252,6 +252,10 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { chainConfig.FermiTime = config.OverrideFermi overrides.OverrideFermi = config.OverrideFermi } + if config.OverrideOsaka != nil { + chainConfig.OsakaTime = config.OverrideOsaka + overrides.OverrideOsaka = config.OverrideOsaka + } if config.OverrideVerkle != nil { chainConfig.VerkleTime = config.OverrideVerkle overrides.OverrideVerkle = config.OverrideVerkle diff --git a/eth/ethconfig/gen_config.go b/eth/ethconfig/gen_config.go index 5a2c8315e3..cce5e6b576 100644 --- a/eth/ethconfig/gen_config.go +++ b/eth/ethconfig/gen_config.go @@ -77,6 +77,7 @@ func (c Config) MarshalTOML() (interface{}, error) { OverrideOsaka *uint64 `toml:",omitempty"` OverrideVerkle *uint64 `toml:",omitempty"` BlobExtraReserve uint64 + EnableOpcodeOptimizing bool EnableIncrSnapshots bool IncrSnapshotPath string IncrSnapshotBlockInterval uint64 @@ -84,7 +85,6 @@ func (c Config) MarshalTOML() (interface{}, error) { IncrSnapshotKeptBlocks uint64 UseRemoteIncrSnapshot bool RemoteIncrSnapshotURL string - EnableOpcodeOptimizing bool } var enc Config enc.Genesis = c.Genesis @@ -219,6 +219,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { OverrideOsaka *uint64 `toml:",omitempty"` OverrideVerkle *uint64 `toml:",omitempty"` BlobExtraReserve *uint64 + EnableOpcodeOptimizing *bool EnableIncrSnapshots *bool IncrSnapshotPath *string IncrSnapshotBlockInterval *uint64 @@ -226,7 +227,6 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { IncrSnapshotKeptBlocks *uint64 UseRemoteIncrSnapshot *bool RemoteIncrSnapshotURL *string - EnableOpcodeOptimizing *bool } var dec Config if err := unmarshal(&dec); err != nil { diff --git a/params/config.go b/params/config.go index 6c107231a2..7c96e8a68e 100644 --- a/params/config.go +++ b/params/config.go @@ -226,11 +226,13 @@ var ( LorentzTime: newUint64(1745903100), // 2025-04-29 05:05:00 AM UTC MaxwellTime: newUint64(1751250600), // 2025-06-30 02:30:00 AM UTC FermiTime: nil, + OsakaTime: nil, Parlia: &ParliaConfig{}, BlobScheduleConfig: &BlobScheduleConfig{ Cancun: DefaultCancunBlobConfig, Prague: DefaultPragueBlobConfigBSC, + Osaka: DefaultOsakaBlobConfigBSC, }, } @@ -273,11 +275,13 @@ var ( LorentzTime: newUint64(1744097580), // 2025-04-08 07:33:00 AM UTC MaxwellTime: newUint64(1748243100), // 2025-05-26 07:05:00 AM UTC FermiTime: newUint64(1762741500), // 2025-11-10 02:25:00 AM UTC + OsakaTime: nil, Parlia: &ParliaConfig{}, BlobScheduleConfig: &BlobScheduleConfig{ Cancun: DefaultCancunBlobConfig, Prague: DefaultPragueBlobConfigBSC, + Osaka: DefaultOsakaBlobConfigBSC, }, } @@ -322,11 +326,13 @@ var ( MaxwellTime: newUint64(0), // TODO: set them to `0` when passed on the mainnet FermiTime: nil, + OsakaTime: nil, Parlia: &ParliaConfig{}, BlobScheduleConfig: &BlobScheduleConfig{ Cancun: DefaultCancunBlobConfig, Prague: DefaultPragueBlobConfigBSC, + Osaka: DefaultOsakaBlobConfigBSC, }, } @@ -592,6 +598,7 @@ var ( } DefaultPragueBlobConfigBSC = DefaultCancunBlobConfig + DefaultOsakaBlobConfigBSC = DefaultCancunBlobConfig ) // NetworkNames are user friendly names to use in the chain spec banner. @@ -645,10 +652,10 @@ type ChainConfig struct { BohrTime *uint64 `json:"bohrTime,omitempty"` // Bohr switch time (nil = no fork, 0 = already on bohr) PascalTime *uint64 `json:"pascalTime,omitempty"` // Pascal switch time (nil = no fork, 0 = already on pascal) PragueTime *uint64 `json:"pragueTime,omitempty"` // Prague switch time (nil = no fork, 0 = already on prague) - OsakaTime *uint64 `json:"osakaTime,omitempty"` // Osaka switch time (nil = no fork, 0 = already on osaka) LorentzTime *uint64 `json:"lorentzTime,omitempty"` // Lorentz switch time (nil = no fork, 0 = already on lorentz) MaxwellTime *uint64 `json:"maxwellTime,omitempty"` // Maxwell switch time (nil = no fork, 0 = already on maxwell) FermiTime *uint64 `json:"fermiTime,omitempty"` // Fermi switch time (nil = no fork, 0 = already on fermi) + OsakaTime *uint64 `json:"osakaTime,omitempty"` // Osaka switch time (nil = no fork, 0 = already on osaka) VerkleTime *uint64 `json:"verkleTime,omitempty"` // Verkle switch time (nil = no fork, 0 = already on verkle) // TerminalTotalDifficulty is the amount of total difficulty reached by @@ -825,9 +832,14 @@ func (c *ChainConfig) String() string { FermiTime = big.NewInt(0).SetUint64(*c.FermiTime) } + var OsakaTime *big.Int + if c.OsakaTime != nil { + OsakaTime = big.NewInt(0).SetUint64(*c.OsakaTime) + } + return fmt.Sprintf("{ChainID: %v, Engine: %v, Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Ramanujan: %v, Niels: %v, "+ "MirrorSync: %v, Bruno: %v, Berlin: %v, YOLO v3: %v, CatalystBlock: %v, London: %v, ArrowGlacier: %v, MergeFork:%v, Euler: %v, Gibbs: %v, Nano: %v, Moran: %v, Planck: %v,Luban: %v, Plato: %v, Hertz: %v, Hertzfix: %v, "+ - "ShanghaiTime: %v, KeplerTime: %v, FeynmanTime: %v, FeynmanFixTime: %v, CancunTime: %v, HaberTime: %v, HaberFixTime: %v, BohrTime: %v, PascalTime: %v, PragueTime: %v, LorentzTime: %v, MaxwellTime: %v, FermiTime: %v}", + "ShanghaiTime: %v, KeplerTime: %v, FeynmanTime: %v, FeynmanFixTime: %v, CancunTime: %v, HaberTime: %v, HaberFixTime: %v, BohrTime: %v, PascalTime: %v, PragueTime: %v, LorentzTime: %v, MaxwellTime: %v, FermiTime: %v, OsakaTime: %v}", c.ChainID, engine, c.HomesteadBlock, @@ -873,6 +885,7 @@ func (c *ChainConfig) String() string { LorentzTime, MaxwellTime, FermiTime, + OsakaTime, ) } @@ -1278,6 +1291,15 @@ func (c *ChainConfig) IsOsaka(num *big.Int, time uint64) bool { return c.IsLondon(num) && isTimestampForked(c.OsakaTime, time) } +// IsOnOsaka eturns whether currentBlockTime is either equal to the Osaka fork time or greater firstly. +func (c *ChainConfig) IsOnOsaka(currentBlockNumber *big.Int, lastBlockTime uint64, currentBlockTime uint64) bool { + lastBlockNumber := new(big.Int) + if currentBlockNumber.Cmp(big.NewInt(1)) >= 0 { + lastBlockNumber.Sub(currentBlockNumber, big.NewInt(1)) + } + return !c.IsOsaka(lastBlockNumber, lastBlockTime) && c.IsOsaka(currentBlockNumber, currentBlockTime) +} + // IsVerkle returns whether time is either equal to the Verkle fork time or greater. func (c *ChainConfig) IsVerkle(num *big.Int, time uint64) bool { return c.IsLondon(num) && isTimestampForked(c.VerkleTime, time) @@ -1360,10 +1382,10 @@ func (c *ChainConfig) CheckConfigForkOrder() error { {name: "bohrTime", timestamp: c.BohrTime}, {name: "pascalTime", timestamp: c.PascalTime}, {name: "pragueTime", timestamp: c.PragueTime}, - {name: "osakaTime", timestamp: c.OsakaTime, optional: true}, {name: "lorentzTime", timestamp: c.LorentzTime}, {name: "maxwellTime", timestamp: c.MaxwellTime}, {name: "fermiTime", timestamp: c.FermiTime}, + {name: "osakaTime", timestamp: c.OsakaTime}, {name: "verkleTime", timestamp: c.VerkleTime, optional: true}, } { if lastFork.name != "" { @@ -1565,9 +1587,6 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int, if isForkTimestampIncompatible(c.PragueTime, newcfg.PragueTime, headTimestamp) { return newTimestampCompatError("Prague fork timestamp", c.PragueTime, newcfg.PragueTime) } - if isForkTimestampIncompatible(c.OsakaTime, newcfg.OsakaTime, headTimestamp) { - return newTimestampCompatError("Osaka fork timestamp", c.OsakaTime, newcfg.OsakaTime) - } if isForkTimestampIncompatible(c.LorentzTime, newcfg.LorentzTime, headTimestamp) { return newTimestampCompatError("Lorentz fork timestamp", c.LorentzTime, newcfg.LorentzTime) } @@ -1577,6 +1596,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int, if isForkTimestampIncompatible(c.FermiTime, newcfg.FermiTime, headTimestamp) { return newTimestampCompatError("FermiTime fork timestamp", c.FermiTime, newcfg.FermiTime) } + if isForkTimestampIncompatible(c.OsakaTime, newcfg.OsakaTime, headTimestamp) { + return newTimestampCompatError("Osaka fork timestamp", c.OsakaTime, newcfg.OsakaTime) + } if isForkTimestampIncompatible(c.VerkleTime, newcfg.VerkleTime, headTimestamp) { return newTimestampCompatError("Verkle fork timestamp", c.VerkleTime, newcfg.VerkleTime) }