diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index 9d4587977d..5ea3fa7277 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -63,6 +63,7 @@ var ( utils.CachePreimagesFlag, utils.OverridePassedForkTime, utils.OverrideLorentz, + utils.OverrideMaxwell, utils.OverrideVerkle, utils.MultiDataBaseFlag, }, utils.DatabaseFlags), @@ -263,6 +264,10 @@ func initGenesis(ctx *cli.Context) error { v := ctx.Uint64(utils.OverrideLorentz.Name) overrides.OverrideLorentz = &v } + if ctx.IsSet(utils.OverrideMaxwell.Name) { + v := ctx.Uint64(utils.OverrideMaxwell.Name) + overrides.OverrideMaxwell = &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 eba6c7aeba..26e28d43db 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -209,6 +209,10 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) { v := ctx.Uint64(utils.OverrideLorentz.Name) cfg.Eth.OverrideLorentz = &v } + if ctx.IsSet(utils.OverrideMaxwell.Name) { + v := ctx.Uint64(utils.OverrideMaxwell.Name) + cfg.Eth.OverrideMaxwell = &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 8ac0498f89..421b536df2 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -75,6 +75,7 @@ var ( utils.RialtoHash, utils.OverridePassedForkTime, utils.OverrideLorentz, + utils.OverrideMaxwell, utils.OverrideVerkle, utils.OverrideFullImmutabilityThreshold, utils.OverrideMinBlocksForBlobRequests, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 15f281507a..ec38bd8516 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -306,6 +306,11 @@ var ( Usage: "Manually specify the Lorentz fork timestamp, overriding the bundled setting", Category: flags.EthCategory, } + OverrideMaxwell = &cli.Uint64Flag{ + Name: "override.maxwell", + Usage: "Manually specify the Maxwell 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/consensus/misc/eip4844/eip4844.go b/consensus/misc/eip4844/eip4844.go index c077090287..382ce67a1e 100644 --- a/consensus/misc/eip4844/eip4844.go +++ b/consensus/misc/eip4844/eip4844.go @@ -83,7 +83,7 @@ func CalcExcessBlobGas(config *params.ChainConfig, parent *types.Header, headTim func CalcBlobFee(config *params.ChainConfig, header *types.Header) *big.Int { var frac uint64 switch config.LatestFork(header.Time) { - case forks.Lorentz, forks.Prague: + case forks.Maxwell, forks.Lorentz, forks.Prague: frac = config.BlobScheduleConfig.Prague.UpdateFraction case forks.Cancun: frac = config.BlobScheduleConfig.Cancun.UpdateFraction diff --git a/core/genesis.go b/core/genesis.go index e52bd1fb95..190c83bb3b 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -265,6 +265,7 @@ func (e *GenesisMismatchError) Error() string { type ChainOverrides struct { OverridePassedForkTime *uint64 OverrideLorentz *uint64 + OverrideMaxwell *uint64 OverrideVerkle *uint64 } @@ -288,6 +289,9 @@ func (o *ChainOverrides) apply(cfg *params.ChainConfig) error { if o.OverrideLorentz != nil { cfg.LorentzTime = o.OverrideLorentz } + if o.OverrideMaxwell != nil { + cfg.MaxwellTime = o.OverrideMaxwell + } if o.OverrideVerkle != nil { cfg.VerkleTime = o.OverrideVerkle } diff --git a/eth/backend.go b/eth/backend.go index 5f81b60701..9c84faeee9 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -213,6 +213,10 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { chainConfig.LorentzTime = config.OverrideLorentz overrides.OverrideLorentz = config.OverrideLorentz } + if config.OverrideMaxwell != nil { + chainConfig.MaxwellTime = config.OverrideMaxwell + overrides.OverrideMaxwell = config.OverrideMaxwell + } if config.OverrideVerkle != nil { chainConfig.VerkleTime = config.OverrideVerkle overrides.OverrideVerkle = config.OverrideVerkle diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index a241a9c03f..40d118748e 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -188,6 +188,9 @@ type Config struct { // OverrideLorentz (TODO: remove after the fork) OverrideLorentz *uint64 `toml:",omitempty"` + // OverrideMaxwell (TODO: remove after the fork) + OverrideMaxwell *uint64 `toml:",omitempty"` + // OverrideVerkle (TODO: remove after the fork) OverrideVerkle *uint64 `toml:",omitempty"` diff --git a/eth/ethconfig/gen_config.go b/eth/ethconfig/gen_config.go index 535244ca43..b834241706 100644 --- a/eth/ethconfig/gen_config.go +++ b/eth/ethconfig/gen_config.go @@ -65,6 +65,7 @@ func (c Config) MarshalTOML() (interface{}, error) { RPCTxFeeCap float64 OverridePassedForkTime *uint64 `toml:",omitempty"` OverrideLorentz *uint64 `toml:",omitempty"` + OverrideMaxwell *uint64 `toml:",omitempty"` OverrideVerkle *uint64 `toml:",omitempty"` BlobExtraReserve uint64 } @@ -118,6 +119,7 @@ func (c Config) MarshalTOML() (interface{}, error) { enc.RPCTxFeeCap = c.RPCTxFeeCap enc.OverridePassedForkTime = c.OverridePassedForkTime enc.OverrideLorentz = c.OverrideLorentz + enc.OverrideMaxwell = c.OverrideMaxwell enc.OverrideVerkle = c.OverrideVerkle enc.BlobExtraReserve = c.BlobExtraReserve return &enc, nil @@ -175,6 +177,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { RPCTxFeeCap *float64 OverridePassedForkTime *uint64 `toml:",omitempty"` OverrideLorentz *uint64 `toml:",omitempty"` + OverrideMaxwell *uint64 `toml:",omitempty"` OverrideVerkle *uint64 `toml:",omitempty"` BlobExtraReserve *uint64 } @@ -329,6 +332,9 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { if dec.OverrideLorentz != nil { c.OverrideLorentz = dec.OverrideLorentz } + if dec.OverrideMaxwell != nil { + c.OverrideMaxwell = dec.OverrideMaxwell + } if dec.OverrideVerkle != nil { c.OverrideVerkle = dec.OverrideVerkle } diff --git a/params/config.go b/params/config.go index e1d2f00ec7..2524ae77c8 100644 --- a/params/config.go +++ b/params/config.go @@ -190,6 +190,7 @@ var ( PascalTime: newUint64(1742436600), // 2025-03-20 02:10:00 AM UTC PragueTime: newUint64(1742436600), // 2025-03-20 02:10:00 AM UTC LorentzTime: newUint64(1745903100), // 2025-04-29 05:05:00 AM UTC + MaxwellTime: nil, Parlia: &ParliaConfig{}, BlobScheduleConfig: &BlobScheduleConfig{ @@ -235,6 +236,7 @@ var ( PascalTime: newUint64(1740452880), // 2025-02-25 03:08:00 AM UTC PragueTime: newUint64(1740452880), // 2025-02-25 03:08:00 AM UTC LorentzTime: newUint64(1744097580), // 2025-04-08 07:33:00 AM UTC + MaxwellTime: nil, Parlia: &ParliaConfig{}, BlobScheduleConfig: &BlobScheduleConfig{ @@ -282,6 +284,7 @@ var ( PragueTime: newUint64(0), // TODO: set them to `0` when passed on the mainnet LorentzTime: nil, + MaxwellTime: nil, Parlia: &ParliaConfig{}, BlobScheduleConfig: &BlobScheduleConfig{ @@ -599,6 +602,7 @@ type ChainConfig struct { 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) VerkleTime *uint64 `json:"verkleTime,omitempty"` // Verkle switch time (nil = no fork, 0 = already on verkle) // TerminalTotalDifficulty is the amount of total difficulty reached by @@ -765,7 +769,12 @@ func (c *ChainConfig) String() string { LorentzTime = big.NewInt(0).SetUint64(*c.LorentzTime) } - return fmt.Sprintf("{ChainID: %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, Engine: %v}", + var MaxwellTime *big.Int + if c.MaxwellTime != nil { + MaxwellTime = big.NewInt(0).SetUint64(*c.MaxwellTime) + } + + return fmt.Sprintf("{ChainID: %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, Engine: %v}", c.ChainID, c.HomesteadBlock, c.DAOForkBlock, @@ -808,6 +817,7 @@ func (c *ChainConfig) String() string { PascalTime, PragueTime, LorentzTime, + MaxwellTime, engine, ) } @@ -1164,6 +1174,20 @@ func (c *ChainConfig) IsOnLorentz(currentBlockNumber *big.Int, lastBlockTime uin return !c.IsLorentz(lastBlockNumber, lastBlockTime) && c.IsLorentz(currentBlockNumber, currentBlockTime) } +// IsMaxwell returns whether time is either equal to the Maxwell fork time or greater. +func (c *ChainConfig) IsMaxwell(num *big.Int, time uint64) bool { + return c.IsLondon(num) && isTimestampForked(c.MaxwellTime, time) +} + +// IsOnMaxwell returns whether currentBlockTime is either equal to the Maxwell fork time or greater firstly. +func (c *ChainConfig) IsOnMaxwell(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.IsMaxwell(lastBlockNumber, lastBlockTime) && c.IsMaxwell(currentBlockNumber, currentBlockTime) +} + // IsOsaka returns whether time is either equal to the Osaka fork time or greater. func (c *ChainConfig) IsOsaka(num *big.Int, time uint64) bool { return c.IsLondon(num) && isTimestampForked(c.OsakaTime, time) @@ -1253,6 +1277,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error { {name: "pragueTime", timestamp: c.PragueTime}, {name: "osakaTime", timestamp: c.OsakaTime, optional: true}, {name: "lorentzTime", timestamp: c.LorentzTime}, + {name: "maxwellTime", timestamp: c.MaxwellTime}, {name: "verkleTime", timestamp: c.VerkleTime, optional: true}, } { if lastFork.name != "" { @@ -1459,6 +1484,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int, if isForkTimestampIncompatible(c.LorentzTime, newcfg.LorentzTime, headTimestamp) { return newTimestampCompatError("Lorentz fork timestamp", c.LorentzTime, newcfg.LorentzTime) } + if isForkTimestampIncompatible(c.MaxwellTime, newcfg.MaxwellTime, headTimestamp) { + return newTimestampCompatError("Lorentz fork timestamp", c.MaxwellTime, newcfg.MaxwellTime) + } if isForkTimestampIncompatible(c.VerkleTime, newcfg.VerkleTime, headTimestamp) { return newTimestampCompatError("Verkle fork timestamp", c.VerkleTime, newcfg.VerkleTime) } @@ -1484,6 +1512,8 @@ func (c *ChainConfig) LatestFork(time uint64) forks.Fork { switch { case c.IsOsaka(london, time): return forks.Osaka + case c.IsMaxwell(london, time): + return forks.Maxwell case c.IsLorentz(london, time): return forks.Lorentz case c.IsPrague(london, time): @@ -1646,8 +1676,8 @@ type Rules struct { IsHertz bool IsHertzfix bool IsShanghai, IsKepler, IsFeynman, IsCancun, IsHaber bool - IsBohr, IsPascal, IsPrague, IsLorentz, IsOsaka bool - IsVerkle bool + IsBohr, IsPascal, IsPrague, IsLorentz, IsMaxwell bool + IsOsaka, IsVerkle bool } // Rules ensures c's ChainID is not nil. @@ -1690,6 +1720,7 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules IsPrague: c.IsPrague(num, timestamp), IsOsaka: c.IsOsaka(num, timestamp), IsLorentz: c.IsLorentz(num, timestamp), + IsMaxwell: c.IsMaxwell(num, timestamp), IsVerkle: c.IsVerkle(num, timestamp), IsEIP4762: isVerkle, } diff --git a/params/forks/forks.go b/params/forks/forks.go index de6ffa4d26..77accf942e 100644 --- a/params/forks/forks.go +++ b/params/forks/forks.go @@ -40,5 +40,6 @@ const ( Cancun Prague Lorentz + Maxwell Osaka )