diff --git a/op-conductor/conductor/config.go b/op-conductor/conductor/config.go index ad65a0e34cc3f66972e25bc6e1bbd969b28fba1c..2d356a6553e1be44a281f4b87cc50da4464d099d 100644 --- a/op-conductor/conductor/config.go +++ b/op-conductor/conductor/config.go @@ -118,6 +118,7 @@ func NewConfig(ctx *cli.Context, log log.Logger) (*Config, error) { HealthCheck: HealthCheckConfig{ Interval: ctx.Uint64(flags.HealthCheckInterval.Name), UnsafeInterval: ctx.Uint64(flags.HealthCheckUnsafeInterval.Name), + SafeEnabled: ctx.Bool(flags.HealthCheckSafeEnabled.Name), SafeInterval: ctx.Uint64(flags.HealthCheckSafeInterval.Name), MinPeerCount: ctx.Uint64(flags.HealthCheckMinPeerCount.Name), }, @@ -138,6 +139,9 @@ type HealthCheckConfig struct { // UnsafeInterval is the interval allowed between unsafe head and now in seconds. UnsafeInterval uint64 + // SafeEnabled is whether to enable safe head progression checks. + SafeEnabled bool + // SafeInterval is the interval between safe head progression measured in seconds. SafeInterval uint64 diff --git a/op-conductor/conductor/service.go b/op-conductor/conductor/service.go index 4775d8a4883606b37c33c68292d5651da49ee6be..4308d302cd6622ca8fadc90124eeeb76666c1318 100644 --- a/op-conductor/conductor/service.go +++ b/op-conductor/conductor/service.go @@ -176,6 +176,7 @@ func (c *OpConductor) initHealthMonitor(ctx context.Context) error { c.cfg.HealthCheck.UnsafeInterval, c.cfg.HealthCheck.SafeInterval, c.cfg.HealthCheck.MinPeerCount, + c.cfg.HealthCheck.SafeEnabled, &c.cfg.RollupCfg, node, p2p, diff --git a/op-conductor/flags/flags.go b/op-conductor/flags/flags.go index c16de5c645db9fc72d7efe8d0441d45d416b5ffe..687813ae58f327774588cb6136a3601862960fae 100644 --- a/op-conductor/flags/flags.go +++ b/op-conductor/flags/flags.go @@ -64,6 +64,12 @@ var ( Usage: "Interval allowed between unsafe head and now measured in seconds", EnvVars: opservice.PrefixEnvVar(EnvVarPrefix, "HEALTHCHECK_UNSAFE_INTERVAL"), } + HealthCheckSafeEnabled = &cli.BoolFlag{ + Name: "healthcheck.safe-enabled", + Usage: "Whether to enable safe head progression checks", + EnvVars: opservice.PrefixEnvVar(EnvVarPrefix, "HEALTHCHECK_SAFE_ENABLED"), + Value: false, + } HealthCheckSafeInterval = &cli.Uint64Flag{ Name: "healthcheck.safe-interval", Usage: "Interval between safe head progression measured in seconds", @@ -105,6 +111,7 @@ var optionalFlags = []cli.Flag{ Paused, RPCEnableProxy, RaftBootstrap, + HealthCheckSafeEnabled, } func init() { diff --git a/op-conductor/health/monitor.go b/op-conductor/health/monitor.go index 7a541e7b3876f18173985f3c42e682759b519b60..62c20bad1ad4637319efa91da43120122328876f 100644 --- a/op-conductor/health/monitor.go +++ b/op-conductor/health/monitor.go @@ -34,7 +34,7 @@ type HealthMonitor interface { // interval is the interval between health checks measured in seconds. // safeInterval is the interval between safe head progress measured in seconds. // minPeerCount is the minimum number of peers required for the sequencer to be healthy. -func NewSequencerHealthMonitor(log log.Logger, interval, unsafeInterval, safeInterval, minPeerCount uint64, rollupCfg *rollup.Config, node dial.RollupClientInterface, p2p p2p.API) HealthMonitor { +func NewSequencerHealthMonitor(log log.Logger, interval, unsafeInterval, safeInterval, minPeerCount uint64, safeEnabled bool, rollupCfg *rollup.Config, node dial.RollupClientInterface, p2p p2p.API) HealthMonitor { return &SequencerHealthMonitor{ log: log, done: make(chan struct{}), @@ -42,6 +42,7 @@ func NewSequencerHealthMonitor(log log.Logger, interval, unsafeInterval, safeInt healthUpdateCh: make(chan error), rollupCfg: rollupCfg, unsafeInterval: unsafeInterval, + safeEnabled: safeEnabled, safeInterval: safeInterval, minPeerCount: minPeerCount, timeProviderFn: currentTimeProvicer, @@ -58,6 +59,7 @@ type SequencerHealthMonitor struct { rollupCfg *rollup.Config unsafeInterval uint64 + safeEnabled bool safeInterval uint64 minPeerCount uint64 interval uint64 @@ -169,7 +171,7 @@ func (hm *SequencerHealthMonitor) healthCheck() error { return ErrSequencerNotHealthy } - if now-status.SafeL2.Time > hm.safeInterval { + if hm.safeEnabled && now-status.SafeL2.Time > hm.safeInterval { hm.log.Error( "safe head is not progressing as expected", "now", now, diff --git a/op-conductor/health/monitor_test.go b/op-conductor/health/monitor_test.go index 0384e5b4b0b5ed6be45f5a35a136f11f419a1a5a..45a66267b8cadc7f9ecce7103954eaaa3ff55154 100644 --- a/op-conductor/health/monitor_test.go +++ b/op-conductor/health/monitor_test.go @@ -62,6 +62,7 @@ func (s *HealthMonitorTestSuite) SetupMonitor( rollupCfg: s.rollupCfg, unsafeInterval: unsafeInterval, safeInterval: safeInterval, + safeEnabled: true, minPeerCount: s.minPeerCount, timeProviderFn: tp.Now, node: mockRollupClient, @@ -147,6 +148,13 @@ func (s *HealthMonitorTestSuite) TestUnhealthySafeHeadNotProgressing() { } } + // test that the safeEnabled flag works + monitor.safeEnabled = false + rc.ExpectSyncStatus(mockSyncStatus(now+6, 4, now, 1), nil) + rc.ExpectSyncStatus(mockSyncStatus(now+6, 4, now, 1), nil) + healthy := <-healthUpdateCh + s.Nil(healthy) + s.NoError(monitor.Stop()) }