Commit e632b531 authored by Joshua Gutow's avatar Joshua Gutow

op-node: Add Canyon hard fork override

parent c5732fc5
...@@ -256,6 +256,11 @@ var ( ...@@ -256,6 +256,11 @@ var (
EnvVars: prefixEnvVars("BETA_ROLLUP_LOAD_PROTOCOL_VERSIONS"), EnvVars: prefixEnvVars("BETA_ROLLUP_LOAD_PROTOCOL_VERSIONS"),
Hidden: true, Hidden: true,
} }
CanyonOverrideFlag = &cli.Uint64Flag{
Name: "override.canyon",
Usage: "Manually specify the Canyon fork timestamp, overriding the bundled setting",
Hidden: true,
}
) )
var requiredFlags = []cli.Flag{ var requiredFlags = []cli.Flag{
...@@ -300,6 +305,7 @@ var optionalFlags = []cli.Flag{ ...@@ -300,6 +305,7 @@ var optionalFlags = []cli.Flag{
BetaExtraNetworks, BetaExtraNetworks,
BetaRollupHalt, BetaRollupHalt,
BetaRollupLoadProtocolVersions, BetaRollupLoadProtocolVersions,
CanyonOverrideFlag,
} }
// Flags contains the list of configuration options available to the binary. // Flags contains the list of configuration options available to the binary.
......
...@@ -75,6 +75,10 @@ type Config struct { ...@@ -75,6 +75,10 @@ type Config struct {
// Active if RegolithTime != nil && L2 block timestamp >= *RegolithTime, inactive otherwise. // Active if RegolithTime != nil && L2 block timestamp >= *RegolithTime, inactive otherwise.
RegolithTime *uint64 `json:"regolith_time,omitempty"` RegolithTime *uint64 `json:"regolith_time,omitempty"`
// CanyonTime sets the activation time of the next network upgrade.
// Active if CanyonTime != nil && L2 block timestamp >= *CanyonTime, inactive otherwise.
CanyonTime *uint64 `json:"canyon_time,omitempty"`
// Note: below addresses are part of the block-derivation process, // Note: below addresses are part of the block-derivation process,
// and required to be the same network-wide to stay in consensus. // and required to be the same network-wide to stay in consensus.
...@@ -259,6 +263,11 @@ func (c *Config) IsRegolith(timestamp uint64) bool { ...@@ -259,6 +263,11 @@ func (c *Config) IsRegolith(timestamp uint64) bool {
return c.RegolithTime != nil && timestamp >= *c.RegolithTime return c.RegolithTime != nil && timestamp >= *c.RegolithTime
} }
// IsCanyon returns true if the Canyon hardfork is active at or past the given timestamp.
func (c *Config) IsCanyon(timestamp uint64) bool {
return c.CanyonTime != nil && timestamp >= *c.CanyonTime
}
// Description outputs a banner describing the important parts of rollup configuration in a human-readable form. // Description outputs a banner describing the important parts of rollup configuration in a human-readable form.
// Optionally provide a mapping of L2 chain IDs to network names to label the L2 chain with if not unknown. // Optionally provide a mapping of L2 chain IDs to network names to label the L2 chain with if not unknown.
// The config should be config.Check()-ed before creating a description. // The config should be config.Check()-ed before creating a description.
...@@ -286,6 +295,7 @@ func (c *Config) Description(l2Chains map[string]string) string { ...@@ -286,6 +295,7 @@ func (c *Config) Description(l2Chains map[string]string) string {
// Report the upgrade configuration // Report the upgrade configuration
banner += "Post-Bedrock Network Upgrades (timestamp based):\n" banner += "Post-Bedrock Network Upgrades (timestamp based):\n"
banner += fmt.Sprintf(" - Regolith: %s\n", fmtForkTimeOrUnset(c.RegolithTime)) banner += fmt.Sprintf(" - Regolith: %s\n", fmtForkTimeOrUnset(c.RegolithTime))
banner += fmt.Sprintf(" - Canyon: %s\n", fmtForkTimeOrUnset(c.CanyonTime))
// Report the protocol version // Report the protocol version
banner += fmt.Sprintf("Node supports up to OP-Stack Protocol Version: %s\n", OPStackSupport) banner += fmt.Sprintf("Node supports up to OP-Stack Protocol Version: %s\n", OPStackSupport)
return banner return banner
...@@ -310,7 +320,8 @@ func (c *Config) LogDescription(log log.Logger, l2Chains map[string]string) { ...@@ -310,7 +320,8 @@ func (c *Config) LogDescription(log log.Logger, l2Chains map[string]string) {
log.Info("Rollup Config", "l2_chain_id", c.L2ChainID, "l2_network", networkL2, "l1_chain_id", c.L1ChainID, log.Info("Rollup Config", "l2_chain_id", c.L2ChainID, "l2_network", networkL2, "l1_chain_id", c.L1ChainID,
"l1_network", networkL1, "l2_start_time", c.Genesis.L2Time, "l2_block_hash", c.Genesis.L2.Hash.String(), "l1_network", networkL1, "l2_start_time", c.Genesis.L2Time, "l2_block_hash", c.Genesis.L2.Hash.String(),
"l2_block_number", c.Genesis.L2.Number, "l1_block_hash", c.Genesis.L1.Hash.String(), "l2_block_number", c.Genesis.L2.Number, "l1_block_hash", c.Genesis.L1.Hash.String(),
"l1_block_number", c.Genesis.L1.Number, "regolith_time", fmtForkTimeOrUnset(c.RegolithTime)) "l1_block_number", c.Genesis.L1.Number, "regolith_time", fmtForkTimeOrUnset(c.RegolithTime),
"canyon_time", fmtForkTimeOrUnset(c.CanyonTime))
} }
func fmtForkTimeOrUnset(v *uint64) string { func fmtForkTimeOrUnset(v *uint64) string {
......
...@@ -202,6 +202,10 @@ Conflicting configuration is deprecated, and will stop the op-node from starting ...@@ -202,6 +202,10 @@ Conflicting configuration is deprecated, and will stop the op-node from starting
if err != nil { if err != nil {
return nil, err return nil, err
} }
if ctx.IsSet(flags.CanyonOverrideFlag.Name) {
canyon := ctx.Uint64(flags.CanyonOverrideFlag.Name)
config.CanyonTime = &canyon
}
return config, nil return config, nil
} }
...@@ -216,6 +220,10 @@ Conflicting configuration is deprecated, and will stop the op-node from starting ...@@ -216,6 +220,10 @@ Conflicting configuration is deprecated, and will stop the op-node from starting
if err := json.NewDecoder(file).Decode(&rollupConfig); err != nil { if err := json.NewDecoder(file).Decode(&rollupConfig); err != nil {
return nil, fmt.Errorf("failed to decode rollup config: %w", err) return nil, fmt.Errorf("failed to decode rollup config: %w", err)
} }
if ctx.IsSet(flags.CanyonOverrideFlag.Name) {
canyon := ctx.Uint64(flags.CanyonOverrideFlag.Name)
rollupConfig.CanyonTime = &canyon
}
return &rollupConfig, nil return &rollupConfig, nil
} }
......
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