From f561467ae1ce01a283ff883e32ca2028e19db33b Mon Sep 17 00:00:00 2001 From: Sebastian Stammler Date: Mon, 12 Aug 2024 22:52:58 +0200 Subject: [PATCH] Add Holocene fork references (#357) --- cmd/geth/config.go | 5 +++++ cmd/geth/main.go | 1 + cmd/utils/flags.go | 7 ++++++- core/genesis.go | 16 ++++++++++------ eth/backend.go | 3 +++ eth/ethconfig/config.go | 2 ++ eth/ethconfig/gen_config.go | 6 ++++++ go.mod | 2 +- go.sum | 4 ++-- params/config.go | 24 ++++++++++++++++++++---- params/superchain.go | 1 + 11 files changed, 57 insertions(+), 14 deletions(-) diff --git a/cmd/geth/config.go b/cmd/geth/config.go index c6d14f3693..c76db472bb 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -195,6 +195,11 @@ func makeFullNode(ctx *cli.Context) *node.Node { cfg.Eth.OverrideOptimismGranite = &v } + if ctx.IsSet(utils.OverrideOptimismHolocene.Name) { + v := ctx.Uint64(utils.OverrideOptimismHolocene.Name) + cfg.Eth.OverrideOptimismHolocene = &v + } + if ctx.IsSet(utils.OverrideOptimismInterop.Name) { v := ctx.Uint64(utils.OverrideOptimismInterop.Name) cfg.Eth.OverrideOptimismInterop = &v diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 314748fc1e..fbb6210c35 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -70,6 +70,7 @@ var ( utils.OverrideOptimismEcotone, utils.OverrideOptimismFjord, utils.OverrideOptimismGranite, + utils.OverrideOptimismHolocene, utils.OverrideOptimismInterop, utils.EnablePersonal, utils.TxPoolLocalsFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index a82aad387f..201a4944a1 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -283,6 +283,11 @@ var ( Usage: "Manually specify the Optimism Granite fork timestamp, overriding the bundled setting", Category: flags.EthCategory, } + OverrideOptimismHolocene = &cli.Uint64Flag{ + Name: "override.holocene", + Usage: "Manually specify the Optimism Holocene fork timestamp, overriding the bundled setting", + Category: flags.EthCategory, + } OverrideOptimismInterop = &cli.Uint64Flag{ Name: "override.interop", Usage: "Manually specify the Optimsim Interop feature-set fork timestamp, overriding the bundled setting", @@ -2017,7 +2022,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { if rawdb.ReadCanonicalHash(chaindb, 0) != (common.Hash{}) { cfg.Genesis = nil // fallback to db content - //validate genesis has PoS enabled in block 0 + // validate genesis has PoS enabled in block 0 genesis, err := core.ReadGenesis(chaindb) if err != nil { Fatalf("Could not read genesis from database: %v", err) diff --git a/core/genesis.go b/core/genesis.go index a85df0f3fa..a7dfef07f5 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -258,12 +258,13 @@ type ChainOverrides struct { OverrideCancun *uint64 OverrideVerkle *uint64 // optimism - OverrideOptimismCanyon *uint64 - OverrideOptimismEcotone *uint64 - OverrideOptimismFjord *uint64 - OverrideOptimismGranite *uint64 - ApplySuperchainUpgrades bool - OverrideOptimismInterop *uint64 + OverrideOptimismCanyon *uint64 + OverrideOptimismEcotone *uint64 + OverrideOptimismFjord *uint64 + OverrideOptimismGranite *uint64 + OverrideOptimismHolocene *uint64 + OverrideOptimismInterop *uint64 + ApplySuperchainUpgrades bool } // SetupGenesisBlock writes or updates the genesis block in db. @@ -334,6 +335,9 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g if overrides != nil && overrides.OverrideOptimismGranite != nil { config.GraniteTime = overrides.OverrideOptimismGranite } + if overrides != nil && overrides.OverrideOptimismHolocene != nil { + config.HoloceneTime = overrides.OverrideOptimismHolocene + } if overrides != nil && overrides.OverrideOptimismInterop != nil { config.InteropTime = overrides.OverrideOptimismInterop } diff --git a/eth/backend.go b/eth/backend.go index feeb006785..ace4a00c24 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -236,6 +236,9 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { if config.OverrideOptimismGranite != nil { overrides.OverrideOptimismGranite = config.OverrideOptimismGranite } + if config.OverrideOptimismHolocene != nil { + overrides.OverrideOptimismHolocene = config.OverrideOptimismHolocene + } if config.OverrideOptimismInterop != nil { overrides.OverrideOptimismInterop = config.OverrideOptimismInterop } diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 088b19d34b..2dc03013d5 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -176,6 +176,8 @@ type Config struct { OverrideOptimismGranite *uint64 `toml:",omitempty"` + OverrideOptimismHolocene *uint64 `toml:",omitempty"` + OverrideOptimismInterop *uint64 `toml:",omitempty"` // ApplySuperchainUpgrades requests the node to load chain-configuration from the superchain-registry. diff --git a/eth/ethconfig/gen_config.go b/eth/ethconfig/gen_config.go index 1448c75488..a8ffe914a4 100644 --- a/eth/ethconfig/gen_config.go +++ b/eth/ethconfig/gen_config.go @@ -63,6 +63,7 @@ func (c Config) MarshalTOML() (interface{}, error) { OverrideOptimismEcotone *uint64 `toml:",omitempty"` OverrideOptimismFjord *uint64 `toml:",omitempty"` OverrideOptimismGranite *uint64 `toml:",omitempty"` + OverrideOptimismHolocene *uint64 `toml:",omitempty"` OverrideOptimismInterop *uint64 `toml:",omitempty"` ApplySuperchainUpgrades bool `toml:",omitempty"` RollupSequencerHTTP string @@ -119,6 +120,7 @@ func (c Config) MarshalTOML() (interface{}, error) { enc.OverrideOptimismEcotone = c.OverrideOptimismEcotone enc.OverrideOptimismFjord = c.OverrideOptimismFjord enc.OverrideOptimismGranite = c.OverrideOptimismGranite + enc.OverrideOptimismHolocene = c.OverrideOptimismHolocene enc.OverrideOptimismInterop = c.OverrideOptimismInterop enc.ApplySuperchainUpgrades = c.ApplySuperchainUpgrades enc.RollupSequencerHTTP = c.RollupSequencerHTTP @@ -179,6 +181,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { OverrideOptimismEcotone *uint64 `toml:",omitempty"` OverrideOptimismFjord *uint64 `toml:",omitempty"` OverrideOptimismGranite *uint64 `toml:",omitempty"` + OverrideOptimismHolocene *uint64 `toml:",omitempty"` OverrideOptimismInterop *uint64 `toml:",omitempty"` ApplySuperchainUpgrades *bool `toml:",omitempty"` RollupSequencerHTTP *string @@ -330,6 +333,9 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { if dec.OverrideOptimismGranite != nil { c.OverrideOptimismGranite = dec.OverrideOptimismGranite } + if dec.OverrideOptimismHolocene != nil { + c.OverrideOptimismHolocene = dec.OverrideOptimismHolocene + } if dec.OverrideOptimismInterop != nil { c.OverrideOptimismInterop = dec.OverrideOptimismInterop } diff --git a/go.mod b/go.mod index 71b188c65d..0e7ab41f6d 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/deckarep/golang-set/v2 v2.6.0 github.com/donovanhide/eventsource v0.0.0-20210830082556-c59027999da0 github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 - github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240803025447-c92ef420eec2 + github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240812010938-34a43d577f74 github.com/ethereum/c-kzg-4844 v1.0.0 github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 github.com/fatih/color v1.16.0 diff --git a/go.sum b/go.sum index 162e336785..095dfd6210 100644 --- a/go.sum +++ b/go.sum @@ -169,8 +169,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240803025447-c92ef420eec2 h1:ySJykDUyb8RbcfLL3pz0Cs5Ji6NMVT7kmAY634DOCoE= -github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240803025447-c92ef420eec2/go.mod h1:zy9f3TNPS7pwW4msMitF83fp0Wf452tZ6+Fg6d4JyXM= +github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240812010938-34a43d577f74 h1:HQZQalpPUXs9qnJgDmEDzpPO70Z1p8Le2l0bZ9eJjCk= +github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240812010938-34a43d577f74/go.mod h1:zy9f3TNPS7pwW4msMitF83fp0Wf452tZ6+Fg6d4JyXM= github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 h1:KrE8I4reeVvf7C1tm8elRjj4BdscTYzz/WAbYyf/JI4= diff --git a/params/config.go b/params/config.go index dfa18b953a..e5ec0272f3 100644 --- a/params/config.go +++ b/params/config.go @@ -394,9 +394,10 @@ type ChainConfig struct { RegolithTime *uint64 `json:"regolithTime,omitempty"` // Regolith switch time (nil = no fork, 0 = already on optimism regolith) CanyonTime *uint64 `json:"canyonTime,omitempty"` // Canyon switch time (nil = no fork, 0 = already on optimism canyon) // Delta: the Delta upgrade does not affect the execution-layer, and is thus not configurable in the chain config. - EcotoneTime *uint64 `json:"ecotoneTime,omitempty"` // Ecotone switch time (nil = no fork, 0 = already on optimism ecotone) - FjordTime *uint64 `json:"fjordTime,omitempty"` // Fjord switch time (nil = no fork, 0 = already on Optimism Fjord) - GraniteTime *uint64 `json:"graniteTime,omitempty"` // Granite switch time (nil = no fork, 0 = already on Optimism Granite) + EcotoneTime *uint64 `json:"ecotoneTime,omitempty"` // Ecotone switch time (nil = no fork, 0 = already on optimism ecotone) + FjordTime *uint64 `json:"fjordTime,omitempty"` // Fjord switch time (nil = no fork, 0 = already on Optimism Fjord) + GraniteTime *uint64 `json:"graniteTime,omitempty"` // Granite switch time (nil = no fork, 0 = already on Optimism Granite) + HoloceneTime *uint64 `json:"holoceneTime,omitempty"` // Holocene switch time (nil = no fork, 0 = already on Optimism Holocene) InteropTime *uint64 `json:"interopTime,omitempty"` // Interop switch time (nil = no fork, 0 = already on optimism interop) @@ -556,6 +557,9 @@ func (c *ChainConfig) Description() string { if c.GraniteTime != nil { banner += fmt.Sprintf(" - Granite: @%-10v\n", *c.GraniteTime) } + if c.HoloceneTime != nil { + banner += fmt.Sprintf(" - Holocene: @%-10v\n", *c.HoloceneTime) + } if c.InteropTime != nil { banner += fmt.Sprintf(" - Interop: @%-10v\n", *c.InteropTime) } @@ -692,6 +696,10 @@ func (c *ChainConfig) IsGranite(time uint64) bool { return isTimestampForked(c.GraniteTime, time) } +func (c *ChainConfig) IsHolocene(time uint64) bool { + return isTimestampForked(c.HoloceneTime, time) +} + func (c *ChainConfig) IsInterop(time uint64) bool { return isTimestampForked(c.InteropTime, time) } @@ -726,6 +734,10 @@ func (c *ChainConfig) IsOptimismGranite(time uint64) bool { return c.IsOptimism() && c.IsGranite(time) } +func (c *ChainConfig) IsOptimismHolocene(time uint64) bool { + return c.IsOptimism() && c.IsHolocene(time) +} + // IsOptimismPreBedrock returns true iff this is an optimism node & bedrock is not yet active func (c *ChainConfig) IsOptimismPreBedrock(num *big.Int) bool { return c.IsOptimism() && !c.IsBedrock(num) @@ -910,6 +922,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int, if isForkTimestampIncompatible(c.GraniteTime, newcfg.GraniteTime, headTimestamp, genesisTimestamp) { return newTimestampCompatError("Granite fork timestamp", c.GraniteTime, newcfg.GraniteTime) } + if isForkTimestampIncompatible(c.HoloceneTime, newcfg.HoloceneTime, headTimestamp, genesisTimestamp) { + return newTimestampCompatError("Holocene fork timestamp", c.HoloceneTime, newcfg.HoloceneTime) + } if isForkTimestampIncompatible(c.InteropTime, newcfg.InteropTime, headTimestamp, genesisTimestamp) { return newTimestampCompatError("Interop fork timestamp", c.InteropTime, newcfg.InteropTime) } @@ -1107,7 +1122,7 @@ type Rules struct { IsVerkle bool IsOptimismBedrock, IsOptimismRegolith bool IsOptimismCanyon, IsOptimismFjord bool - IsOptimismGranite bool + IsOptimismGranite, IsOptimismHolocene bool } // Rules ensures c's ChainID is not nil. @@ -1144,5 +1159,6 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules IsOptimismCanyon: isMerge && c.IsOptimismCanyon(timestamp), IsOptimismFjord: isMerge && c.IsOptimismFjord(timestamp), IsOptimismGranite: isMerge && c.IsOptimismGranite(timestamp), + IsOptimismHolocene: isMerge && c.IsOptimismHolocene(timestamp), } } diff --git a/params/superchain.go b/params/superchain.go index 648216e01f..bb54483c18 100644 --- a/params/superchain.go +++ b/params/superchain.go @@ -70,6 +70,7 @@ func LoadOPStackChainConfig(chainID uint64) (*ChainConfig, error) { EcotoneTime: chConfig.EcotoneTime, FjordTime: chConfig.FjordTime, GraniteTime: chConfig.GraniteTime, + HoloceneTime: chConfig.HoloceneTime, TerminalTotalDifficulty: common.Big0, TerminalTotalDifficultyPassed: true, Ethash: nil,