From 8ba567f82b9bb7dfb97a22d33a08815e00106717 Mon Sep 17 00:00:00 2001 From: protolambda Date: Tue, 17 Jan 2023 18:00:55 +0100 Subject: [PATCH] optimism: minor goerli fixes - banner, clique config, networkid (#36) --- core/rawdb/accessors_metadata.go | 3 +++ eth/backend.go | 7 ++++++- params/config.go | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/rawdb/accessors_metadata.go b/core/rawdb/accessors_metadata.go index 2ff29d1ad..45ced36a4 100644 --- a/core/rawdb/accessors_metadata.go +++ b/core/rawdb/accessors_metadata.go @@ -64,6 +64,9 @@ func ReadChainConfig(db ethdb.KeyValueReader, hash common.Hash) *params.ChainCon log.Error("Invalid chain config JSON", "hash", hash, "err", err) return nil } + if config.Optimism != nil { + config.Clique = nil // get rid of legacy clique data in chain config (optimism goerli issue) + } return &config } diff --git a/eth/backend.go b/eth/backend.go index 35274e390..e4c5e1838 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -170,7 +170,6 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { if bcVersion != nil { dbVer = fmt.Sprintf("%d", *bcVersion) } - log.Info("Initialising Ethereum protocol", "network", config.NetworkId, "dbversion", dbVer) if !config.SkipBcVersionCheck { if bcVersion != nil && *bcVersion > core.BlockChainVersion { @@ -213,6 +212,12 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { if err != nil { return nil, err } + if chainConfig := eth.blockchain.Config(); chainConfig.Optimism != nil { // config.Genesis.Config.ChainID cannot be used because it's based on CLI flags only, thus default to mainnet L1 + config.NetworkId = chainConfig.ChainID.Uint64() // optimism defaults eth network ID to chain ID + eth.networkID = config.NetworkId + } + log.Info("Initialising Ethereum protocol", "network", config.NetworkId, "dbversion", dbVer) + eth.bloomIndexer.Start(eth.blockchain) if config.TxPool.Journal != "" { diff --git a/params/config.go b/params/config.go index 00dfd32fc..071c7eb6e 100644 --- a/params/config.go +++ b/params/config.go @@ -506,6 +506,8 @@ func (c *ChainConfig) Description() string { } banner += fmt.Sprintf("Chain ID: %v (%s)\n", c.ChainID, network) switch { + case c.Optimism != nil: + banner += "Consensus: Optimism\n" case c.Ethash != nil: if c.TerminalTotalDifficulty == nil { banner += "Consensus: Ethash (proof-of-work)\n" @@ -522,8 +524,6 @@ func (c *ChainConfig) Description() string { } else { banner += "Consensus: Beacon (proof-of-stake), merged from Clique (proof-of-authority)\n" } - case c.Optimism != nil: - banner += "Consensus: Optimism\n" default: banner += "Consensus: unknown\n" }