Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup overrides & add the canyon network upgrade #133

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 3 additions & 13 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 3 additions & 16 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 = &params.OptimismConfig{
EIP1559Elasticity: 10,
EIP1559Denominator: 50,
}
}
if overrides != nil && overrides.OverrideOptimismCanyon != nil {
config.CanyonTime = overrides.OverrideOptimismCanyon
}
}
}
Expand Down
10 changes: 2 additions & 8 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 2 additions & 6 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package ethconfig

import (
"errors"
"math/big"
"time"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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),
}
}