From 6ad221afab85925227b9c5c3eab5b1a54e627e37 Mon Sep 17 00:00:00 2001 From: protolambda Date: Thu, 23 Nov 2023 16:38:32 +0100 Subject: [PATCH] params: interopTime configuration and override option --- cmd/geth/config.go | 5 +++++ cmd/geth/main.go | 1 + cmd/utils/flags.go | 5 +++++ core/genesis.go | 4 ++++ eth/backend.go | 3 +++ eth/ethconfig/config.go | 2 ++ params/config.go | 9 +++++++++ 7 files changed, 29 insertions(+) diff --git a/cmd/geth/config.go b/cmd/geth/config.go index 81128ab00705..194f779842f4 100644 --- a/cmd/geth/config.go +++ b/cmd/geth/config.go @@ -180,6 +180,11 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) { cfg.Eth.OverrideOptimismCanyon = &v } + if ctx.IsSet(utils.OverrideOptimismInterop.Name) { + v := ctx.Uint64(utils.OverrideOptimismInterop.Name) + cfg.Eth.OverrideOptimismInterop = &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 d4942aabf98c..17b9d3216dbd 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -68,6 +68,7 @@ var ( utils.OverrideCancun, utils.OverrideVerkle, utils.OverrideOptimismCanyon, + utils.OverrideOptimismInterop, utils.EnablePersonal, utils.TxPoolLocalsFlag, utils.TxPoolNoLocalsFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 7b4316d054b4..c5c81dc16b67 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -267,6 +267,11 @@ var ( Usage: "Manually specify the Optimsim Canyon 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", + Category: flags.EthCategory, + } SyncModeFlag = &flags.TextMarshalerFlag{ Name: "syncmode", Usage: `Blockchain sync mode ("snap", "full" or "light")`, diff --git a/core/genesis.go b/core/genesis.go index bc346d5acea7..47cc0c2cb279 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -259,6 +259,7 @@ type ChainOverrides struct { // optimism OverrideOptimismCanyon *uint64 ApplySuperchainUpgrades bool + OverrideOptimismInterop *uint64 } // SetupGenesisBlock writes or updates the genesis block in db. @@ -318,6 +319,9 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *trie.Database, gen config.Optimism.EIP1559DenominatorCanyon = 250 } } + if overrides != nil && overrides.OverrideOptimismInterop != nil { + config.InteropTime = overrides.OverrideOptimismInterop + } } } // Just commit the new block if there is no stored genesis block. diff --git a/eth/backend.go b/eth/backend.go index 97224ecbfc7b..a1b4c4ba0951 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -219,6 +219,9 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { if config.OverrideOptimismCanyon != nil { overrides.OverrideOptimismCanyon = config.OverrideOptimismCanyon } + if config.OverrideOptimismInterop != nil { + overrides.OverrideOptimismInterop = config.OverrideOptimismInterop + } overrides.ApplySuperchainUpgrades = config.ApplySuperchainUpgrades eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TransactionHistory) if err != nil { diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index f31d31aab84a..0422bef15519 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -172,6 +172,8 @@ type Config struct { OverrideOptimismCanyon *uint64 `toml:",omitempty"` + OverrideOptimismInterop *uint64 `toml:",omitempty"` + // ApplySuperchainUpgrades requests the node to load chain-configuration from the superchain-registry. ApplySuperchainUpgrades bool `toml:",omitempty"` diff --git a/params/config.go b/params/config.go index 22041b76e6d4..3f9cabc159ac 100644 --- a/params/config.go +++ b/params/config.go @@ -359,6 +359,8 @@ 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) + InteropTime *uint64 `json:"interopTime,omitempty"` // Interop switch time (nil = no fork, 0 = already on optimism interop) + // TerminalTotalDifficulty is the amount of total difficulty reached by // the network that triggers the consensus upgrade. TerminalTotalDifficulty *big.Int `json:"terminalTotalDifficulty,omitempty"` @@ -505,6 +507,9 @@ func (c *ChainConfig) Description() string { if c.CanyonTime != nil { banner += fmt.Sprintf(" - Canyon: @%-10v\n", *c.CanyonTime) } + if c.InteropTime != nil { + banner += fmt.Sprintf(" - Interop: @%-10v\n", *c.InteropTime) + } return banner } @@ -621,6 +626,10 @@ func (c *ChainConfig) IsCanyon(time uint64) bool { return isTimestampForked(c.CanyonTime, time) } +func (c *ChainConfig) IsInterop(time uint64) bool { + return isTimestampForked(c.InteropTime, time) +} + // IsOptimism returns whether the node is an optimism node or not. func (c *ChainConfig) IsOptimism() bool { return c.Optimism != nil