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

Add Holocene fork references #357

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add Holocene fork references
  • Loading branch information
sebastianst committed Aug 12, 2024
commit 9732c6b107fa2031021d7814935146b6da771ab4
5 changes: 5 additions & 0 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
cfg.Eth.OverrideOptimismGranite = &v
}

if ctx.IsSet(utils.OverrideOptimismHolocene.Name) {
v := ctx.Uint64(utils.OverrideOptimismHolocene.Name)
cfg.Eth.OverrideOptimismHolocene = &v
}

if ctx.IsSet(utils.OverrideOptimismInterop.Name) {
v := ctx.Uint64(utils.OverrideOptimismInterop.Name)
cfg.Eth.OverrideOptimismInterop = &v
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ var (
utils.OverrideOptimismEcotone,
utils.OverrideOptimismFjord,
utils.OverrideOptimismGranite,
utils.OverrideOptimismHolocene,
utils.OverrideOptimismInterop,
utils.EnablePersonal,
utils.TxPoolLocalsFlag,
Expand Down
7 changes: 6 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ var (
Usage: "Manually specify the Optimism Granite fork timestamp, overriding the bundled setting",
Category: flags.EthCategory,
}
OverrideOptimismHolocene = &cli.Uint64Flag{
Name: "override.holocene",
Usage: "Manually specify the Optimism Holocene 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",
Expand Down Expand Up @@ -1952,7 +1957,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
if rawdb.ReadCanonicalHash(chaindb, 0) != (common.Hash{}) {
cfg.Genesis = nil // fallback to db content

//validate genesis has PoS enabled in block 0
// validate genesis has PoS enabled in block 0
sebastianst marked this conversation as resolved.
Show resolved Hide resolved
genesis, err := core.ReadGenesis(chaindb)
if err != nil {
Fatalf("Could not read genesis from database: %v", err)
Expand Down
16 changes: 10 additions & 6 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,13 @@ type ChainOverrides struct {
OverrideCancun *uint64
OverrideVerkle *uint64
// optimism
OverrideOptimismCanyon *uint64
OverrideOptimismEcotone *uint64
OverrideOptimismFjord *uint64
OverrideOptimismGranite *uint64
ApplySuperchainUpgrades bool
OverrideOptimismInterop *uint64
OverrideOptimismCanyon *uint64
OverrideOptimismEcotone *uint64
OverrideOptimismFjord *uint64
OverrideOptimismGranite *uint64
OverrideOptimismHolocene *uint64
OverrideOptimismInterop *uint64
ApplySuperchainUpgrades bool
}

// SetupGenesisBlock writes or updates the genesis block in db.
Expand Down Expand Up @@ -298,6 +299,9 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *triedb.Database, g
if overrides != nil && overrides.OverrideOptimismGranite != nil {
config.GraniteTime = overrides.OverrideOptimismGranite
}
if overrides != nil && overrides.OverrideOptimismHolocene != nil {
config.HoloceneTime = overrides.OverrideOptimismHolocene
}
if overrides != nil && overrides.OverrideOptimismInterop != nil {
config.InteropTime = overrides.OverrideOptimismInterop
}
Expand Down
3 changes: 3 additions & 0 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
if config.OverrideOptimismGranite != nil {
overrides.OverrideOptimismGranite = config.OverrideOptimismGranite
}
if config.OverrideOptimismHolocene != nil {
overrides.OverrideOptimismHolocene = config.OverrideOptimismHolocene
}
if config.OverrideOptimismInterop != nil {
overrides.OverrideOptimismInterop = config.OverrideOptimismInterop
}
Expand Down
2 changes: 2 additions & 0 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ type Config struct {

OverrideOptimismGranite *uint64 `toml:",omitempty"`

OverrideOptimismHolocene *uint64 `toml:",omitempty"`

OverrideOptimismInterop *uint64 `toml:",omitempty"`

// ApplySuperchainUpgrades requests the node to load chain-configuration from the superchain-registry.
Expand Down
6 changes: 6 additions & 0 deletions eth/ethconfig/gen_config.go

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

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/deckarep/golang-set/v2 v2.1.0
github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240803025447-c92ef420eec2
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240812010938-34a43d577f74
github.com/ethereum/c-kzg-4844 v0.4.0
github.com/fatih/color v1.13.0
github.com/ferranbt/fastssz v0.1.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240803025447-c92ef420eec2 h1:ySJykDUyb8RbcfLL3pz0Cs5Ji6NMVT7kmAY634DOCoE=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240803025447-c92ef420eec2/go.mod h1:zy9f3TNPS7pwW4msMitF83fp0Wf452tZ6+Fg6d4JyXM=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240812010938-34a43d577f74 h1:HQZQalpPUXs9qnJgDmEDzpPO70Z1p8Le2l0bZ9eJjCk=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240812010938-34a43d577f74/go.mod h1:zy9f3TNPS7pwW4msMitF83fp0Wf452tZ6+Fg6d4JyXM=
github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY=
github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8=
Expand Down
24 changes: 20 additions & 4 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,10 @@ 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)
// Delta: the Delta upgrade does not affect the execution-layer, and is thus not configurable in the chain config.
EcotoneTime *uint64 `json:"ecotoneTime,omitempty"` // Ecotone switch time (nil = no fork, 0 = already on optimism ecotone)
FjordTime *uint64 `json:"fjordTime,omitempty"` // Fjord switch time (nil = no fork, 0 = already on Optimism Fjord)
GraniteTime *uint64 `json:"graniteTime,omitempty"` // Granite switch time (nil = no fork, 0 = already on Optimism Granite)
EcotoneTime *uint64 `json:"ecotoneTime,omitempty"` // Ecotone switch time (nil = no fork, 0 = already on optimism ecotone)
FjordTime *uint64 `json:"fjordTime,omitempty"` // Fjord switch time (nil = no fork, 0 = already on Optimism Fjord)
GraniteTime *uint64 `json:"graniteTime,omitempty"` // Granite switch time (nil = no fork, 0 = already on Optimism Granite)
HoloceneTime *uint64 `json:"holoceneTime,omitempty"` // Holocene switch time (nil = no fork, 0 = already on Optimism Holocene)

InteropTime *uint64 `json:"interopTime,omitempty"` // Interop switch time (nil = no fork, 0 = already on optimism interop)

Expand Down Expand Up @@ -553,6 +554,9 @@ func (c *ChainConfig) Description() string {
if c.GraniteTime != nil {
banner += fmt.Sprintf(" - Granite: @%-10v\n", *c.GraniteTime)
}
if c.HoloceneTime != nil {
banner += fmt.Sprintf(" - Holocene: @%-10v\n", *c.HoloceneTime)
}
if c.InteropTime != nil {
banner += fmt.Sprintf(" - Interop: @%-10v\n", *c.InteropTime)
}
Expand Down Expand Up @@ -684,6 +688,10 @@ func (c *ChainConfig) IsGranite(time uint64) bool {
return isTimestampForked(c.GraniteTime, time)
}

func (c *ChainConfig) IsHolocene(time uint64) bool {
return isTimestampForked(c.HoloceneTime, time)
}

func (c *ChainConfig) IsInterop(time uint64) bool {
return isTimestampForked(c.InteropTime, time)
}
Expand Down Expand Up @@ -718,6 +726,10 @@ func (c *ChainConfig) IsOptimismGranite(time uint64) bool {
return c.IsOptimism() && c.IsGranite(time)
}

func (c *ChainConfig) IsOptimismHolocene(time uint64) bool {
return c.IsOptimism() && c.IsHolocene(time)
}

// IsOptimismPreBedrock returns true iff this is an optimism node & bedrock is not yet active
func (c *ChainConfig) IsOptimismPreBedrock(num *big.Int) bool {
return c.IsOptimism() && !c.IsBedrock(num)
Expand Down Expand Up @@ -902,6 +914,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int,
if isForkTimestampIncompatible(c.GraniteTime, newcfg.GraniteTime, headTimestamp, genesisTimestamp) {
return newTimestampCompatError("Granite fork timestamp", c.GraniteTime, newcfg.GraniteTime)
}
if isForkTimestampIncompatible(c.HoloceneTime, newcfg.HoloceneTime, headTimestamp, genesisTimestamp) {
return newTimestampCompatError("Holocene fork timestamp", c.HoloceneTime, newcfg.HoloceneTime)
}
if isForkTimestampIncompatible(c.InteropTime, newcfg.InteropTime, headTimestamp, genesisTimestamp) {
return newTimestampCompatError("Interop fork timestamp", c.InteropTime, newcfg.InteropTime)
}
Expand Down Expand Up @@ -1090,7 +1105,7 @@ type Rules struct {
IsVerkle bool
IsOptimismBedrock, IsOptimismRegolith bool
IsOptimismCanyon, IsOptimismFjord bool
IsOptimismGranite bool
IsOptimismGranite, IsOptimismHolocene bool
sebastianst marked this conversation as resolved.
Show resolved Hide resolved
}

// Rules ensures c's ChainID is not nil.
Expand Down Expand Up @@ -1124,5 +1139,6 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
IsOptimismCanyon: isMerge && c.IsOptimismCanyon(timestamp),
IsOptimismFjord: isMerge && c.IsOptimismFjord(timestamp),
IsOptimismGranite: isMerge && c.IsOptimismGranite(timestamp),
IsOptimismHolocene: isMerge && c.IsOptimismHolocene(timestamp),
}
}
1 change: 1 addition & 0 deletions params/superchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func LoadOPStackChainConfig(chainID uint64) (*ChainConfig, error) {
EcotoneTime: chConfig.EcotoneTime,
FjordTime: chConfig.FjordTime,
GraniteTime: chConfig.GraniteTime,
HoloceneTime: chConfig.HoloceneTime,
TerminalTotalDifficulty: common.Big0,
TerminalTotalDifficultyPassed: true,
Ethash: nil,
Expand Down