From 786f291a18e6df492658897abff4974b121edbf7 Mon Sep 17 00:00:00 2001 From: Joshua Gutow Date: Fri, 22 Sep 2023 08:14:08 -0700 Subject: [PATCH] Cleanup overrides & add the Canyon network upgrade (#133) This removes the overrides for Optimism, Bedrock, and Regolith. All of these forks have already been activated. This creates an override for the next network upgrade called Canyon. --- cmd/geth/config.go | 13 +++---------- cmd/geth/main.go | 4 +--- cmd/utils/flags.go | 16 +++------------- core/genesis.go | 19 +++---------------- eth/backend.go | 10 ++-------- eth/ethconfig/config.go | 8 ++------ params/config.go | 10 ++++++++++ 7 files changed, 24 insertions(+), 56 deletions(-) diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 4ac647d170..e823092018 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -171,16 +171,9 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) { cfg.Eth.OverrideCancun = &v } - if ctx.IsSet(utils.OverrideOptimismBedrock.Name) { - cfg.Eth.OverrideOptimismBedrock = flags.GlobalBig(ctx, utils.OverrideOptimismBedrock.Name) - } - if ctx.IsSet(utils.OverrideOptimismRegolith.Name) { - v := ctx.Uint64(utils.OverrideOptimismRegolith.Name) - cfg.Eth.OverrideOptimismRegolith = &v - } - if ctx.IsSet(utils.OverrideOptimism.Name) { - override := ctx.Bool(utils.OverrideOptimism.Name) - cfg.Eth.OverrideOptimism = &override + if ctx.IsSet(utils.OverrideOptimismCanyon.Name) { + v := ctx.Uint64(utils.OverrideOptimismCanyon.Name) + cfg.Eth.OverrideOptimismCanyon = &v } backend, eth := utils.RegisterEthService(stack, &cfg.Eth) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 77435f7e73..92f1260ed8 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -65,10 +65,8 @@ var ( utils.USBFlag, utils.SmartCardDaemonPathFlag, utils.OverrideCancun, + utils.OverrideOptimismCanyon, utils.EnablePersonal, - utils.OverrideOptimismBedrock, - utils.OverrideOptimismRegolith, - utils.OverrideOptimism, utils.TxPoolLocalsFlag, utils.TxPoolNoLocalsFlag, utils.TxPoolJournalFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 8d8524d90b..42586a8cec 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -279,19 +279,9 @@ var ( Usage: "Manually specify the Cancun fork timestamp, overriding the bundled setting", Category: flags.EthCategory, } - OverrideOptimismBedrock = &flags.BigFlag{ - Name: "override.bedrock", - Usage: "Manually specify OptimismBedrock, overriding the bundled setting", - Category: flags.EthCategory, - } - OverrideOptimismRegolith = &flags.BigFlag{ - Name: "override.regolith", - Usage: "Manually specify the OptimismRegolith fork timestamp, overriding the bundled setting", - Category: flags.EthCategory, - } - OverrideOptimism = &cli.BoolFlag{ - Name: "override.optimism", - Usage: "Manually specify optimism", + OverrideOptimismCanyon = &flags.BigFlag{ + Name: "override.canyon", + Usage: "Manually specify the Optimsim Canyon fork timestamp, overriding the bundled setting", Category: flags.EthCategory, } // Light server and client settings diff --git a/core/genesis.go b/core/genesis.go index 0df7a63b65..7781a24218 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -274,9 +274,7 @@ func (e *GenesisMismatchError) Error() string { type ChainOverrides struct { OverrideCancun *uint64 // optimism - OverrideOptimismBedrock *big.Int - OverrideOptimismRegolith *uint64 - OverrideOptimism *bool + OverrideOptimismCanyon *uint64 } // SetupGenesisBlock writes or updates the genesis block in db. @@ -313,19 +311,8 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *trie.Database, gen if overrides != nil && overrides.OverrideCancun != nil { config.CancunTime = overrides.OverrideCancun } - if overrides != nil && overrides.OverrideOptimismBedrock != nil { - config.BedrockBlock = overrides.OverrideOptimismBedrock - } - if overrides != nil && overrides.OverrideOptimismRegolith != nil { - config.RegolithTime = overrides.OverrideOptimismRegolith - } - if overrides != nil && overrides.OverrideOptimism != nil { - if *overrides.OverrideOptimism { - config.Optimism = ¶ms.OptimismConfig{ - EIP1559Elasticity: 10, - EIP1559Denominator: 50, - } - } + if overrides != nil && overrides.OverrideOptimismCanyon != nil { + config.CanyonTime = overrides.OverrideOptimismCanyon } } } diff --git a/eth/backend.go b/eth/backend.go index 7c8df0d786..f05bd86110 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -204,14 +204,8 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { if config.OverrideCancun != nil { overrides.OverrideCancun = config.OverrideCancun } - if config.OverrideOptimismBedrock != nil { - overrides.OverrideOptimismBedrock = config.OverrideOptimismBedrock - } - if config.OverrideOptimismRegolith != nil { - overrides.OverrideOptimismRegolith = config.OverrideOptimismRegolith - } - if config.OverrideOptimism != nil { - overrides.OverrideOptimism = config.OverrideOptimism + if config.OverrideOptimismCanyon != nil { + overrides.OverrideOptimismCanyon = config.OverrideOptimismCanyon } eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit) if err != nil { diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 6f64e87557..70c4ee37c2 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -19,7 +19,6 @@ package ethconfig import ( "errors" - "math/big" "time" "github.com/ethereum/go-ethereum/common" @@ -163,11 +162,8 @@ type Config struct { RPCTxFeeCap float64 // OverrideCancun (TODO: remove after the fork) - OverrideCancun *uint64 `toml:",omitempty"` - - OverrideOptimismBedrock *big.Int - OverrideOptimismRegolith *uint64 `toml:",omitempty"` - OverrideOptimism *bool + OverrideCancun *uint64 `toml:",omitempty"` + OverrideOptimismCanyon *uint64 `toml:",omitempty"` RollupSequencerHTTP string RollupHistoricalRPC string diff --git a/params/config.go b/params/config.go index c07e0d1543..e6ce5f6aaf 100644 --- a/params/config.go +++ b/params/config.go @@ -315,6 +315,7 @@ type ChainConfig struct { BedrockBlock *big.Int `json:"bedrockBlock,omitempty"` // Bedrock switch block (nil = no fork, 0 = already on optimism bedrock) 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) // TerminalTotalDifficulty is the amount of total difficulty reached by // the network that triggers the consensus upgrade. @@ -561,6 +562,10 @@ func (c *ChainConfig) IsRegolith(time uint64) bool { return isTimestampForked(c.RegolithTime, time) } +func (c *ChainConfig) IsCanyon(time uint64) bool { + return isTimestampForked(c.CanyonTime, time) +} + // IsOptimism returns whether the node is an optimism node or not. func (c *ChainConfig) IsOptimism() bool { return c.Optimism != nil @@ -574,6 +579,9 @@ func (c *ChainConfig) IsOptimismBedrock(num *big.Int) bool { func (c *ChainConfig) IsOptimismRegolith(time uint64) bool { return c.IsOptimism() && c.IsRegolith(time) } +func (c *ChainConfig) IsOptimismCanyon(time uint64) bool { + return c.IsOptimism() && c.IsCanyon(time) +} // IsOptimismPreBedrock returns true iff this is an optimism node & bedrock is not yet active func (c *ChainConfig) IsOptimismPreBedrock(num *big.Int) bool { @@ -889,6 +897,7 @@ type Rules struct { IsBerlin, IsLondon bool IsMerge, IsShanghai, IsCancun, IsPrague bool IsOptimismBedrock, IsOptimismRegolith bool + IsOptimismCanyon bool } // Rules ensures c's ChainID is not nil. @@ -916,5 +925,6 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules // Optimism IsOptimismBedrock: c.IsOptimismBedrock(num), IsOptimismRegolith: c.IsOptimismRegolith(timestamp), + IsOptimismCanyon: c.IsOptimismCanyon(timestamp), } }