From 391ee5791c458266580a89aed13a0497e5a44f37 Mon Sep 17 00:00:00 2001 From: protolambda Date: Thu, 21 Sep 2023 21:56:38 +0200 Subject: [PATCH 1/2] implement op-v1.12.2 review suggestions --- core/txpool/legacypool/legacypool.go | 3 +-- miner/payload_building.go | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/txpool/legacypool/legacypool.go b/core/txpool/legacypool/legacypool.go index c45e137bd896..784256d07a01 100644 --- a/core/txpool/legacypool/legacypool.go +++ b/core/txpool/legacypool/legacypool.go @@ -1673,8 +1673,7 @@ func (pool *LegacyPool) truncateQueue() { // to trigger a re-heap is this function func (pool *LegacyPool) demoteUnexecutables() { // Iterate over all accounts and demote any non-executable transactions - gasLimit := pool.currentHead.Load().GasLimit - // TODO + gasLimit := txpool.EffectiveGasLimit(pool.chainconfig, pool.currentHead.Load().GasLimit) for addr, list := range pool.pending { nonce := pool.currentState.GetNonce(addr) diff --git a/miner/payload_building.go b/miner/payload_building.go index a93b0d3d0a9a..d05893c68e72 100644 --- a/miner/payload_building.go +++ b/miner/payload_building.go @@ -182,6 +182,7 @@ func (w *worker) buildPayload(args *BuildPayloadArgs) (*Payload, error) { // Build the initial version with no transaction included. It should be fast // enough to run. The empty payload can at least make sure there is something // to deliver for not missing slot. + // In OP-Stack, the "empty" block is constructed from provided txs only, i.e. no tx-pool usage. empty, emptyFees, err := w.getSealingBlock(args.Parent, args.Timestamp, args.FeeRecipient, args.Random, args.Withdrawals, true, args.Transactions, args.GasLimit) if err != nil { return nil, err From 786f291a18e6df492658897abff4974b121edbf7 Mon Sep 17 00:00:00 2001 From: Joshua Gutow Date: Fri, 22 Sep 2023 08:14:08 -0700 Subject: [PATCH 2/2] 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 4ac647d17081..e8230920185c 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 77435f7e7359..92f1260ed8a4 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 8d8524d90b0b..42586a8ceca0 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 0df7a63b65a6..7781a24218ee 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 7c8df0d7862b..f05bd86110a9 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 6f64e875576c..70c4ee37c22d 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 c07e0d154358..e6ce5f6aaf34 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), } }