Skip to content

Commit

Permalink
Merge branch 'optimism' into op_v1_13_1
Browse files Browse the repository at this point in the history
  • Loading branch information
protolambda committed Sep 22, 2023
2 parents 0b153c4 + 7997a6f commit 8737298
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 74 deletions.
13 changes: 3 additions & 10 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,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
}

if ctx.IsSet(utils.OverrideVerkle.Name) {
Expand Down
4 changes: 1 addition & 3 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ var (
utils.SmartCardDaemonPathFlag,
utils.OverrideCancun,
utils.OverrideVerkle,
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 @@ -264,19 +264,9 @@ var (
Usage: "Manually specify the Verkle 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,
}
SyncModeFlag = &flags.TextMarshalerFlag{
Expand Down
19 changes: 3 additions & 16 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,7 @@ type ChainOverrides struct {
OverrideCancun *uint64
OverrideVerkle *uint64
// optimism
OverrideOptimismBedrock *big.Int
OverrideOptimismRegolith *uint64
OverrideOptimism *bool
OverrideOptimismCanyon *uint64
}

// SetupGenesisBlock writes or updates the genesis block in db.
Expand Down Expand Up @@ -330,19 +328,8 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *trie.Database, gen
if overrides != nil && overrides.OverrideVerkle != nil {
config.VerkleTime = overrides.OverrideVerkle
}
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
3 changes: 1 addition & 2 deletions core/txpool/legacypool/legacypool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1664,8 +1664,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)

Expand Down
10 changes: 2 additions & 8 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,8 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
if config.OverrideVerkle != nil {
overrides.OverrideVerkle = config.OverrideVerkle
}
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.TransactionHistory)
if err != nil {
Expand Down
5 changes: 1 addition & 4 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 @@ -169,9 +168,7 @@ type Config struct {
// OverrideVerkle (TODO: remove after the fork)
OverrideVerkle *uint64 `toml:",omitempty"`

OverrideOptimismBedrock *big.Int
OverrideOptimismRegolith *uint64 `toml:",omitempty"`
OverrideOptimism *bool
OverrideOptimismCanyon *uint64 `toml:",omitempty"`

RollupSequencerHTTP string
RollupHistoricalRPC string
Expand Down
23 changes: 5 additions & 18 deletions eth/ethconfig/gen_config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions miner/payload_building.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,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.
emptyParams := &generateParams{
timestamp: args.Timestamp,
forceTime: true,
Expand Down
10 changes: 10 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,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 @@ -601,6 +602,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 @@ -614,6 +619,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 @@ -934,6 +942,7 @@ type Rules struct {
IsMerge, IsShanghai, IsCancun, IsPrague bool
IsVerkle bool
IsOptimismBedrock, IsOptimismRegolith bool
IsOptimismCanyon bool
}

// Rules ensures c's ChainID is not nil.
Expand Down Expand Up @@ -962,5 +971,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),
}
}

0 comments on commit 8737298

Please sign in to comment.