Skip to content

Commit b7ec194

Browse files
authored
Update Interop Activation Timestamp to Use Pointer (#19244)
The commit modifies the configuration handling for interop activation timestamp to use a pointer, allowing explicit nil state and more flexible configuration across several files in the op-supernode and op-devstack packages.
1 parent 01a0dd2 commit b7ec194

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

op-devstack/sysgo/l2_cl_supernode.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ type L2CLs struct {
219219
// SupernodeConfig holds configuration options for the shared supernode.
220220
type SupernodeConfig struct {
221221
// InteropActivationTimestamp enables the interop activity at the given timestamp.
222-
// Set to 0 to disable interop (default).
223-
InteropActivationTimestamp uint64
222+
// Set to nil to disable interop (default). Non-nil (including 0) enables interop.
223+
InteropActivationTimestamp *uint64
224224
}
225225

226226
// SupernodeOption is a functional option for configuring the supernode.
@@ -229,7 +229,8 @@ type SupernodeOption func(*SupernodeConfig)
229229
// WithSupernodeInterop enables the interop activity with the given activation timestamp.
230230
func WithSupernodeInterop(activationTimestamp uint64) SupernodeOption {
231231
return func(cfg *SupernodeConfig) {
232-
cfg.InteropActivationTimestamp = activationTimestamp
232+
ts := activationTimestamp
233+
cfg.InteropActivationTimestamp = &ts
233234
}
234235
}
235236

@@ -384,8 +385,8 @@ func withSharedSupernodeCLsImpl(orch *Orchestrator, supernodeID stack.SupernodeI
384385
RPCConfig: oprpc.CLIConfig{ListenAddr: "127.0.0.1", ListenPort: 0, EnableAdmin: true},
385386
InteropActivationTimestamp: snOpts.InteropActivationTimestamp,
386387
}
387-
if snOpts.InteropActivationTimestamp > 0 {
388-
logger.Info("supernode interop enabled", "activation_timestamp", snOpts.InteropActivationTimestamp)
388+
if snOpts.InteropActivationTimestamp != nil {
389+
logger.Info("supernode interop enabled", "activation_timestamp", *snOpts.InteropActivationTimestamp)
389390
}
390391
ctx, cancel := context.WithCancel(p.Ctx())
391392
exitFn := func(err error) { p.Require().NoError(err, "supernode critical error") }

op-supernode/cmd/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,12 @@ func main() {
8080
}
8181

8282
// Populate config with interop activation timestamp from CLI context if set
83+
// Only set the pointer if the flag is explicitly provided by the user
84+
// If not set, leave as nil to disable interop
8385
if cliCtx != nil && cliCtx.IsSet(interop.InteropActivationTimestampFlag.Name) {
84-
cfg.InteropActivationTimestamp = cliCtx.Uint64(interop.InteropActivationTimestampFlag.Name)
86+
ts := cliCtx.Uint64(interop.InteropActivationTimestampFlag.Name)
87+
cfg.InteropActivationTimestamp = &ts
88+
l.Info("interop activation timestamp set from CLI", "timestamp", ts)
8589
}
8690

8791
// Create the supernode, supplying the logger, version, and close function

op-supernode/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type CLIConfig struct {
2222
MetricsConfig opmetrics.CLIConfig
2323
PprofConfig oppprof.CLIConfig
2424
RawCtx *cli.Context
25-
InteropActivationTimestamp uint64
25+
InteropActivationTimestamp *uint64
2626
}
2727

2828
func (c *CLIConfig) Check() error {

op-supernode/supernode/supernode.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ func New(ctx context.Context, log gethlog.Logger, version string, requestStop co
9292
}
9393

9494
log.Info("initializing interop activity? %v", cfg.RawCtx.IsSet(interop.InteropActivationTimestampFlag.Name))
95-
// Initialize interop activity if the activation timestamp is set
96-
if cfg.InteropActivationTimestamp > 0 {
97-
interopActivity := interop.New(log.New("activity", "interop"), cfg.InteropActivationTimestamp, s.chains, cfg.DataDir)
95+
// Initialize interop activity if the activation timestamp is set (non-nil)
96+
// If it's nil, don't start interop. If it's non-nil (including 0), do start it.
97+
if cfg.InteropActivationTimestamp != nil {
98+
interopActivity := interop.New(log.New("activity", "interop"), *cfg.InteropActivationTimestamp, s.chains, cfg.DataDir)
9899
s.activities = append(s.activities, interopActivity)
99100
for _, chain := range s.chains {
100101
chain.RegisterVerifier(interopActivity)

0 commit comments

Comments
 (0)