Skip to content

Commit

Permalink
Add Holocene fork references (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianst authored Aug 12, 2024
1 parent ee83530 commit f561467
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 14 deletions.
5 changes: 5 additions & 0 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ func makeFullNode(ctx *cli.Context) *node.Node {
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 @@ -70,6 +70,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 @@ -283,6 +283,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 @@ -2017,7 +2022,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
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 @@ -258,12 +258,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 @@ -334,6 +335,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 @@ -236,6 +236,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 @@ -176,6 +176,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 @@ -23,7 +23,7 @@ require (
github.com/deckarep/golang-set/v2 v2.6.0
github.com/donovanhide/eventsource v0.0.0-20210830082556-c59027999da0
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 v1.0.0
github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0
github.com/fatih/color v1.16.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
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/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 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA=
github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 h1:KrE8I4reeVvf7C1tm8elRjj4BdscTYzz/WAbYyf/JI4=
Expand Down
24 changes: 20 additions & 4 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,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 @@ -556,6 +557,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 @@ -692,6 +696,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 @@ -726,6 +734,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 @@ -910,6 +922,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 @@ -1107,7 +1122,7 @@ type Rules struct {
IsVerkle bool
IsOptimismBedrock, IsOptimismRegolith bool
IsOptimismCanyon, IsOptimismFjord bool
IsOptimismGranite bool
IsOptimismGranite, IsOptimismHolocene bool
}

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

0 comments on commit f561467

Please sign in to comment.