Skip to content

Commit

Permalink
superchain: implement protocol-version handling review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
protolambda committed Sep 14, 2023
1 parent 60b827b commit 5e58eb5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ var (
utils.RollupHistoricalRPCTimeoutFlag,
utils.RollupDisableTxPoolGossipFlag,
utils.RollupComputePendingBlock,
utils.RollupHaltOnIncompatibleProtocolVersionFlag,
configFileFlag,
}, utils.NetworkFlags, utils.DatabasePathFlags)

Expand Down
4 changes: 3 additions & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,8 @@ func (s *Ethereum) Stop() error {
return nil
}

// HandleRequiredProtocolVersion handles the protocol version signal. This implements opt-in halting,
// the protocol version data is already logged and metered when signaled through the Engine API.
func (s *Ethereum) HandleRequiredProtocolVersion(required params.ProtocolVersion) error {
var needLevel int
switch s.config.RollupHaltOnIncompatibleProtocolVersion {
Expand All @@ -601,7 +603,7 @@ func (s *Ethereum) HandleRequiredProtocolVersion(required params.ProtocolVersion
haveLevel = 1
}
if haveLevel >= needLevel { // halt if we opted in to do so at this granularity
log.Error("opted to halt, unprepared for protocol change", "required", required, "local", params.OPStackSupport)
log.Error("Opted to halt, unprepared for protocol change", "required", required, "local", params.OPStackSupport)
return s.nodeCloser()
}
return nil
Expand Down
24 changes: 12 additions & 12 deletions eth/catalyst/superchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type SuperchainSignal struct {

func (api *ConsensusAPI) SignalSuperchainV1(signal *SuperchainSignal) (params.ProtocolVersion, error) {
if signal == nil {
log.Info("received empty superchain version signal", "local", params.OPStackSupport)
log.Info("Received empty superchain version signal", "local", params.OPStackSupport)
return params.OPStackSupport, nil
}
// update metrics and log any warnings/info
Expand All @@ -31,7 +31,7 @@ func (api *ConsensusAPI) SignalSuperchainV1(signal *SuperchainSignal) (params.Pr
LogProtocolVersionSupport(logger, params.OPStackSupport, signal.Required, "required")

if err := api.eth.HandleRequiredProtocolVersion(signal.Required); err != nil {
log.Error("failed to handle required protocol version", "err", err, "required", signal.Required)
log.Error("Failed to handle required protocol version", "err", err, "required", signal.Required)
return params.OPStackSupport, err
}

Expand All @@ -41,24 +41,24 @@ func (api *ConsensusAPI) SignalSuperchainV1(signal *SuperchainSignal) (params.Pr
func LogProtocolVersionSupport(logger log.Logger, local, other params.ProtocolVersion, name string) {
switch local.Compare(other) {
case params.AheadMajor:
logger.Info(fmt.Sprintf("ahead with major %s protocol version change", name))
logger.Info(fmt.Sprintf("Ahead with major %s protocol version change", name))
case params.AheadMinor, params.AheadPatch, params.AheadPrerelease:
logger.Debug(fmt.Sprintf("ahead with compatible %s protocol version change", name))
logger.Debug(fmt.Sprintf("Ahead with compatible %s protocol version change", name))
case params.Matching:
logger.Debug(fmt.Sprintf("latest %s protocol version is supported", name))
logger.Debug(fmt.Sprintf("Latest %s protocol version is supported", name))
case params.OutdatedMajor:
logger.Error(fmt.Sprintf("outdated with major %s protocol change", name))
logger.Error(fmt.Sprintf("Outdated with major %s protocol change", name))
case params.OutdatedMinor:
logger.Warn(fmt.Sprintf("outdated with minor backward-compatible %s protocol change", name))
logger.Warn(fmt.Sprintf("Outdated with minor backward-compatible %s protocol change", name))
case params.OutdatedPatch:
logger.Info(fmt.Sprintf("outdated with support backward-compatible %s protocol change", name))
logger.Info(fmt.Sprintf("Outdated with support backward-compatible %s protocol change", name))
case params.OutdatedPrerelease:
logger.Debug(fmt.Sprintf("new %s protocol pre-release is available", name))
logger.Debug(fmt.Sprintf("New %s protocol pre-release is available", name))
case params.DiffBuild:
logger.Debug(fmt.Sprintf("ignoring %s protocolversion signal, local build is different", name))
logger.Debug(fmt.Sprintf("Ignoring %s protocolversion signal, local build is different", name))
case params.DiffVersionType:
logger.Warn(fmt.Sprintf("failed to recognize %s protocol version signal version-type", name))
logger.Warn(fmt.Sprintf("Failed to recognize %s protocol version signal version-type", name))
case params.EmptyVersion:
logger.Debug(fmt.Sprintf("no %s protocol version available to check", name))
logger.Debug(fmt.Sprintf("No %s protocol version available to check", name))
}
}

0 comments on commit 5e58eb5

Please sign in to comment.