Commit e1c7dbe2 authored by Sebastian Stammler's avatar Sebastian Stammler Committed by GitHub

Add Granite and Holocene fork references (#11339)

parent 95a26147
......@@ -11,7 +11,7 @@ require (
github.com/crate-crypto/go-kzg-4844 v0.7.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240717194452-c01722001e88
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240801182704-4810f97b7ee9
github.com/ethereum/go-ethereum v1.13.15
github.com/fsnotify/fsnotify v1.7.0
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb
......
......@@ -173,8 +173,8 @@ github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 h1:RWHKLhCrQThMfch+QJ1Z
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3/go.mod h1:QziizLAiF0KqyLdNJYD7O5cpDlaFMNZzlxYNcWsJUxs=
github.com/ethereum-optimism/op-geth v1.101315.3-rc.1 h1:Q/B0FBdtglzsFtqurvUsiNfH8isCOFFF/pf9ss0L4eY=
github.com/ethereum-optimism/op-geth v1.101315.3-rc.1/go.mod h1:h5C5tP+7gkMrlUGENuiV5ddlwJ4RxLdmdapRuTAGlnw=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240717194452-c01722001e88 h1:pNwXkcFBM230tLKbw9mju6P568x20G6H0ka9y8pKe70=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240717194452-c01722001e88/go.mod h1:zy9f3TNPS7pwW4msMitF83fp0Wf452tZ6+Fg6d4JyXM=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240801182704-4810f97b7ee9 h1:Yqi7oOCWRN3SMl3rL5zGYSHIw2MyuTJ1nqokSi7ejfU=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240801182704-4810f97b7ee9/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/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
......
......@@ -35,6 +35,8 @@ const (
Delta ForkName = "delta"
Ecotone ForkName = "ecotone"
Fjord ForkName = "fjord"
Granite ForkName = "granite"
Holocene ForkName = "holocene"
Interop ForkName = "interop"
None ForkName = "none"
)
......@@ -46,6 +48,8 @@ var nextFork = map[ForkName]ForkName{
Delta: Ecotone,
Ecotone: Fjord,
Fjord: Interop,
Granite: Granite,
Holocene: Holocene,
Interop: None,
}
......@@ -125,6 +129,12 @@ func (s *ChainSpec) CheckForkActivation(log log.Logger, block eth.L2BlockRef) {
if s.config.IsFjord(block.Time) {
s.currentFork = Fjord
}
if s.config.IsGranite(block.Time) {
s.currentFork = Fjord
}
if s.config.IsHolocene(block.Time) {
s.currentFork = Fjord
}
if s.config.IsInterop(block.Time) {
s.currentFork = Interop
}
......@@ -145,6 +155,10 @@ func (s *ChainSpec) CheckForkActivation(log log.Logger, block eth.L2BlockRef) {
foundActivationBlock = s.config.IsEcotoneActivationBlock(block.Time)
case Fjord:
foundActivationBlock = s.config.IsFjordActivationBlock(block.Time)
case Granite:
foundActivationBlock = s.config.IsGraniteActivationBlock(block.Time)
case Holocene:
foundActivationBlock = s.config.IsHoloceneActivationBlock(block.Time)
case Interop:
foundActivationBlock = s.config.IsInteropActivationBlock(block.Time)
}
......
......@@ -86,6 +86,7 @@ func LoadOPStackRollupConfig(chainID uint64) (*Config, error) {
DeltaTime: chConfig.DeltaTime,
EcotoneTime: chConfig.EcotoneTime,
FjordTime: chConfig.FjordTime,
GraniteTime: chConfig.GraniteTime,
BatchInboxAddress: common.Address(chConfig.BatchInboxAddr),
DepositContractAddress: common.Address(addrs.OptimismPortalProxy),
L1SystemConfigAddress: common.Address(addrs.SystemConfigProxy),
......
......@@ -109,6 +109,14 @@ type Config struct {
// Active if FjordTime != nil && L2 block timestamp >= *FjordTime, inactive otherwise.
FjordTime *uint64 `json:"fjord_time,omitempty"`
// GraniteTime sets the activation time of the Granite network upgrade.
// Active if GraniteTime != nil && L2 block timestamp >= *GraniteTime, inactive otherwise.
GraniteTime *uint64 `json:"granite_time,omitempty"`
// HoloceneTime sets the activation time of the Holocene network upgrade.
// Active if HoloceneTime != nil && L2 block timestamp >= *HoloceneTime, inactive otherwise.
HoloceneTime *uint64 `json:"holocene_time,omitempty"`
// InteropTime sets the activation time for an experimental feature-set, activated like a hardfork.
// Active if InteropTime != nil && L2 block timestamp >= *InteropTime, inactive otherwise.
InteropTime *uint64 `json:"interop_time,omitempty"`
......@@ -322,6 +330,12 @@ func (cfg *Config) Check() error {
if err := checkFork(cfg.EcotoneTime, cfg.FjordTime, Ecotone, Fjord); err != nil {
return err
}
if err := checkFork(cfg.FjordTime, cfg.GraniteTime, Fjord, Granite); err != nil {
return err
}
if err := checkFork(cfg.GraniteTime, cfg.HoloceneTime, Granite, Holocene); err != nil {
return err
}
return nil
}
......@@ -410,12 +424,14 @@ func (c *Config) IsFjord(timestamp uint64) bool {
return c.FjordTime != nil && timestamp >= *c.FjordTime
}
// IsFjordActivationBlock returns whether the specified block is the first block subject to the
// Fjord upgrade.
func (c *Config) IsFjordActivationBlock(l2BlockTime uint64) bool {
return c.IsFjord(l2BlockTime) &&
l2BlockTime >= c.BlockTime &&
!c.IsFjord(l2BlockTime-c.BlockTime)
// IsGranite returns true if the Granite hardfork is active at or past the given timestamp.
func (c *Config) IsGranite(timestamp uint64) bool {
return c.GraniteTime != nil && timestamp >= *c.GraniteTime
}
// IsHolocene returns true if the Holocene hardfork is active at or past the given timestamp.
func (c *Config) IsHolocene(timestamp uint64) bool {
return c.HoloceneTime != nil && timestamp >= *c.HoloceneTime
}
// IsInterop returns true if the Interop hardfork is active at or past the given timestamp.
......@@ -449,6 +465,30 @@ func (c *Config) IsEcotoneActivationBlock(l2BlockTime uint64) bool {
!c.IsEcotone(l2BlockTime-c.BlockTime)
}
// IsFjordActivationBlock returns whether the specified block is the first block subject to the
// Fjord upgrade.
func (c *Config) IsFjordActivationBlock(l2BlockTime uint64) bool {
return c.IsFjord(l2BlockTime) &&
l2BlockTime >= c.BlockTime &&
!c.IsFjord(l2BlockTime-c.BlockTime)
}
// IsGraniteActivationBlock returns whether the specified block is the first block subject to the
// Granite upgrade.
func (c *Config) IsGraniteActivationBlock(l2BlockTime uint64) bool {
return c.IsGranite(l2BlockTime) &&
l2BlockTime >= c.BlockTime &&
!c.IsGranite(l2BlockTime-c.BlockTime)
}
// IsHoloceneActivationBlock returns whether the specified block is the first block subject to the
// Holocene upgrade.
func (c *Config) IsHoloceneActivationBlock(l2BlockTime uint64) bool {
return c.IsHolocene(l2BlockTime) &&
l2BlockTime >= c.BlockTime &&
!c.IsHolocene(l2BlockTime-c.BlockTime)
}
func (c *Config) IsInteropActivationBlock(l2BlockTime uint64) bool {
return c.IsInterop(l2BlockTime) &&
l2BlockTime >= c.BlockTime &&
......@@ -564,6 +604,8 @@ func (c *Config) Description(l2Chains map[string]string) string {
banner += fmt.Sprintf(" - Delta: %s\n", fmtForkTimeOrUnset(c.DeltaTime))
banner += fmt.Sprintf(" - Ecotone: %s\n", fmtForkTimeOrUnset(c.EcotoneTime))
banner += fmt.Sprintf(" - Fjord: %s\n", fmtForkTimeOrUnset(c.FjordTime))
banner += fmt.Sprintf(" - Granite: %s\n", fmtForkTimeOrUnset(c.GraniteTime))
banner += fmt.Sprintf(" - Holocene: %s\n", fmtForkTimeOrUnset(c.HoloceneTime))
banner += fmt.Sprintf(" - Interop: %s\n", fmtForkTimeOrUnset(c.InteropTime))
// Report the protocol version
banner += fmt.Sprintf("Node supports up to OP-Stack Protocol Version: %s\n", OPStackSupport)
......@@ -598,6 +640,8 @@ func (c *Config) LogDescription(log log.Logger, l2Chains map[string]string) {
"delta_time", fmtForkTimeOrUnset(c.DeltaTime),
"ecotone_time", fmtForkTimeOrUnset(c.EcotoneTime),
"fjord_time", fmtForkTimeOrUnset(c.FjordTime),
"granite_time", fmtForkTimeOrUnset(c.GraniteTime),
"holocene_time", fmtForkTimeOrUnset(c.HoloceneTime),
"interop_time", fmtForkTimeOrUnset(c.InteropTime),
"plasma_mode", c.PlasmaConfig != nil,
)
......
......@@ -260,6 +260,14 @@ func applyOverrides(ctx *cli.Context, rollupConfig *rollup.Config) {
fjord := ctx.Uint64(opflags.FjordOverrideFlagName)
rollupConfig.FjordTime = &fjord
}
if ctx.IsSet(opflags.GraniteOverrideFlagName) {
granite := ctx.Uint64(opflags.GraniteOverrideFlagName)
rollupConfig.GraniteTime = &granite
}
if ctx.IsSet(opflags.HoloceneOverrideFlagName) {
holocene := ctx.Uint64(opflags.HoloceneOverrideFlagName)
rollupConfig.HoloceneTime = &holocene
}
}
func NewSyncConfig(ctx *cli.Context, log log.Logger) (*sync.Config, error) {
......
......@@ -17,6 +17,8 @@ const (
DeltaOverrideFlagName = "override.delta"
EcotoneOverrideFlagName = "override.ecotone"
FjordOverrideFlagName = "override.fjord"
GraniteOverrideFlagName = "override.granite"
HoloceneOverrideFlagName = "override.holocene"
)
func CLIFlags(envPrefix string, category string) []cli.Flag {
......@@ -49,6 +51,20 @@ func CLIFlags(envPrefix string, category string) []cli.Flag {
Hidden: false,
Category: category,
},
&cli.Uint64Flag{
Name: GraniteOverrideFlagName,
Usage: "Manually specify the Granite fork timestamp, overriding the bundled setting",
EnvVars: opservice.PrefixEnvVar(envPrefix, "OVERRIDE_GRANITE"),
Hidden: false,
Category: category,
},
&cli.Uint64Flag{
Name: HoloceneOverrideFlagName,
Usage: "Manually specify the Holocene fork timestamp, overriding the bundled setting",
EnvVars: opservice.PrefixEnvVar(envPrefix, "OVERRIDE_HOLOCENE"),
Hidden: false,
Category: category,
},
CLINetworkFlag(envPrefix, category),
CLIRollupConfigFlag(envPrefix, category),
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment