From ec0255719a60f4741186cd3cd095cc166b03a87c Mon Sep 17 00:00:00 2001 From: Einar Rasmussen Date: Fri, 6 Nov 2026 20:36:50 -0800 Subject: [PATCH 1/3] op-devstack,op-acceptance-tests: run the follow-source tests against kona-node The follow_l2 tests skipped on kona-node because the single-chain test sequencer requires an op-node CL, and the two-verifiers preset applied DEVSTACK_L2CL_KIND to every node. The preset now always runs the sequencer and the deriving verifier "b" on op-node, and only the follow-source verifier "c" takes the env-selected CL. Under kona-node that checks kona's follow-source mode against an op-node upstream; under op-node every node keeps its CL. The preset also no longer starts a proposer or challenger, which no follow_l2 test uses, and accepts only the options that runtime honors. The single-chain CL starters take the CL kind as an argument instead of reading DEVSTACK_L2CL_KIND, each preset resolves it once, and an unknown kind, the empty string included, fails instead of running op-node. Presets with interop at genesis pin their sequencer to op-node, which they already required. Co-Authored-By: Claude Opus 5.5 Co-Authored-By: Claude Fable 5.1 --- .../tests/sync/follow_l2/sync_test.go | 42 +---------- op-devstack/presets/option_validation.go | 9 +++ .../presets/singlechain_twoverifiers.go | 2 +- op-devstack/sysgo/mixed_runtime.go | 2 +- op-devstack/sysgo/singlechain_build.go | 38 ++++------ op-devstack/sysgo/singlechain_build_test.go | 28 +++++++- op-devstack/sysgo/singlechain_interop.go | 14 +++- op-devstack/sysgo/singlechain_runtime.go | 61 +++++++++++++--- op-devstack/sysgo/singlechain_variants.go | 69 ++++++++++++++----- .../sysgo/singlechain_variants_test.go | 31 +++++++++ 10 files changed, 200 insertions(+), 96 deletions(-) create mode 100644 op-devstack/sysgo/singlechain_variants_test.go diff --git a/op-acceptance-tests/tests/sync/follow_l2/sync_test.go b/op-acceptance-tests/tests/sync/follow_l2/sync_test.go index 5a6babfbaad..a779a90df55 100644 --- a/op-acceptance-tests/tests/sync/follow_l2/sync_test.go +++ b/op-acceptance-tests/tests/sync/follow_l2/sync_test.go @@ -8,7 +8,6 @@ import ( "github.com/ethereum-optimism/optimism/op-devstack/devtest" "github.com/ethereum-optimism/optimism/op-devstack/dsl" "github.com/ethereum-optimism/optimism/op-devstack/presets" - "github.com/ethereum-optimism/optimism/op-devstack/sysgo" "github.com/ethereum-optimism/optimism/op-service/eth" safety "github.com/ethereum-optimism/optimism/op-service/eth/safety" @@ -17,18 +16,6 @@ import ( func TestFollowL2_Safe_Finalized_CurrentL1(gt *testing.T) { t := devtest.ParallelT(gt) - // Example error with kona-node: - // - // assertions.go:387: ERROR[03-31|11:33:11.255] - // assertions.go:387: Error Trace: /optimism/op-devstack/sysgo/singlechain_variants.go:143 - // assertions.go:387: /optimism/op-devstack/sysgo/singlechain_variants.go:53 - // assertions.go:387: /optimism/op-devstack/presets/singlechain_twoverifiers.go:24 - // assertions.go:387: /optimism/op-acceptance-tests/tests/sync/follow_l2/setup_test.go:24 - // assertions.go:387: /optimism/op-acceptance-tests/tests/sync/follow_l2/sync_test.go:18 - // assertions.go:387: Error: Should be true - // assertions.go:387: Test: TestFollowL2_Safe_Finalized_CurrentL1 - // assertions.go:387: Messages: single-chain test sequencer requires an op-node CL node - sysgo.SkipOnKonaNode(t, "not supported") sys := newSingleChainTwoVerifiersFollowL2(t) logger := t.Logger() @@ -36,9 +23,8 @@ func TestFollowL2_Safe_Finalized_CurrentL1(gt *testing.T) { attempts := 70 target := uint64(3) - // L2CL is the sequencer with CL follow source, derivation disabled - // L2CLB is the verifier without follow source, derivation enabled - // L2CLC is the verifier with CL follow source, derivation disabled + // L2CL is the sequencer and L2CLB the deriving verifier, both op-node by the preset. + // L2CLC follows L2CLB with derivation disabled and runs the CL kind DEVSTACK_L2CL_KIND selects. // All verifiers must eventually advance unsafe, safe, finalized checkMatchedAll := func(lvl safety.Level) { dsl.CheckAll(t, @@ -71,18 +57,6 @@ func TestFollowL2_Safe_Finalized_CurrentL1(gt *testing.T) { func TestFollowL2_ReorgRecovery(gt *testing.T) { t := devtest.ParallelT(gt) - // Example error with kona-node: - // - // assertions.go:387: ERROR[03-31|11:31:11.567] - // assertions.go:387: Error Trace: /optimism/op-devstack/sysgo/singlechain_variants.go:143 - // assertions.go:387: /optimism/op-devstack/sysgo/singlechain_variants.go:53 - // assertions.go:387: /optimism/op-devstack/presets/singlechain_twoverifiers.go:24 - // assertions.go:387: /optimism/op-acceptance-tests/tests/sync/follow_l2/setup_test.go:24 - // assertions.go:387: /optimism/op-acceptance-tests/tests/sync/follow_l2/sync_test.go:60 - // assertions.go:387: Error: Should be true - // assertions.go:387: Test: TestFollowL2_ReorgRecovery - // assertions.go:387: Messages: single-chain test sequencer requires an op-node CL node - sysgo.SkipOnKonaNode(t, "not supported") sys := newSingleChainTwoVerifiersFollowL2(t) require := t.Require() logger := t.Logger() @@ -170,18 +144,6 @@ func TestFollowL2_ReorgRecovery(gt *testing.T) { func TestFollowL2_WithoutCLP2P(gt *testing.T) { t := devtest.ParallelT(gt) - // Example error with kona-node: - // - // assertions.go:387: ERROR[03-31|11:27:57.797] - // assertions.go:387: Error Trace: /optimism/op-devstack/sysgo/singlechain_variants.go:143 - // assertions.go:387: /optimism/op-devstack/sysgo/singlechain_variants.go:53 - // assertions.go:387: /optimism/op-devstack/presets/singlechain_twoverifiers.go:24 - // assertions.go:387: /optimism/op-acceptance-tests/tests/sync/follow_l2/setup_test.go:24 - // assertions.go:387: /optimism/op-acceptance-tests/tests/sync/follow_l2/sync_test.go:136 - // assertions.go:387: Error: Should be true - // assertions.go:387: Test: TestFollowL2_WithoutCLP2P - // assertions.go:387: Messages: single-chain test sequencer requires an op-node CL nod - sysgo.SkipOnKonaNode(t, "not supported") // Without CL P2P, L2CLC learns of new blocks only from its follow source, polled every two // L2 blocks. When the source's local-safe head is past L2CLC's unsafe head, op-node has its // EL sync to it, gets SYNCING back and resets local-safe to the finalized head. It recovers diff --git a/op-devstack/presets/option_validation.go b/op-devstack/presets/option_validation.go index 0ba613ce813..4a0357b38c3 100644 --- a/op-devstack/presets/option_validation.go +++ b/op-devstack/presets/option_validation.go @@ -164,6 +164,15 @@ const minimalPresetSupportedOptionKinds = optionKindDeployer | optionKindProofValidation | optionKindSkipHonestProposer +// The two-verifiers preset starts no proposer or challenger, so it takes no fault-proof options. +const singleChainTwoVerifiersPresetSupportedOptionKinds = optionKindDeployer | + optionKindBatcher | + optionKindOpReth | + optionKindGlobalL2CL | + optionKindL1EL | + optionKindTimeTravel | + optionKindAfterBuild + // minimalNoFaultProofsPresetSupportedOptionKinds adds alt-DA, which only this preset supports (see WithAltDA). const minimalNoFaultProofsPresetSupportedOptionKinds = minimalPresetSupportedOptionKinds | optionKindAltDA diff --git a/op-devstack/presets/singlechain_twoverifiers.go b/op-devstack/presets/singlechain_twoverifiers.go index 4de57d3c2b9..0047044a7f8 100644 --- a/op-devstack/presets/singlechain_twoverifiers.go +++ b/op-devstack/presets/singlechain_twoverifiers.go @@ -20,7 +20,7 @@ type SingleChainTwoVerifiers struct { // // The target is created from the runtime plus any additional preset options. func NewSingleChainTwoVerifiersWithoutCheck(t devtest.T, opts ...Option) *SingleChainTwoVerifiers { - presetCfg, presetOpts := collectSupportedPresetConfig(t, "NewSingleChainTwoVerifiersWithoutCheck", opts, minimalPresetSupportedOptionKinds) + presetCfg, presetOpts := collectSupportedPresetConfig(t, "NewSingleChainTwoVerifiersWithoutCheck", opts, singleChainTwoVerifiersPresetSupportedOptionKinds) out := singleChainTwoVerifiersFromRuntime(t, sysgo.NewSingleChainTwoVerifiersRuntimeWithConfig(t, presetCfg)) presetOpts.applyPreset(out) return out diff --git a/op-devstack/sysgo/mixed_runtime.go b/op-devstack/sysgo/mixed_runtime.go index 8a792ecfb40..61b55027d91 100644 --- a/op-devstack/sysgo/mixed_runtime.go +++ b/op-devstack/sysgo/mixed_runtime.go @@ -72,7 +72,7 @@ func devstackL2CLKind() MixedL2CLKind { // ResolveMixedL2CLKind returns the L2 CL kind requested via DEVSTACK_L2CL_KIND, // defaulting to op-node when the variable is unset. Tests that build explicit // MixedSingleChainNodeSpec lists use this so they honor the same env-driven CL -// selection as the higher-level single-chain presets (see startL2CLForKey). +// selection as the higher-level single-chain presets. func ResolveMixedL2CLKind() MixedL2CLKind { if kind := devstackL2CLKind(); kind != "" { return kind diff --git a/op-devstack/sysgo/singlechain_build.go b/op-devstack/sysgo/singlechain_build.go index 616d1fed364..9e2f58c0e7b 100644 --- a/op-devstack/sysgo/singlechain_build.go +++ b/op-devstack/sysgo/singlechain_build.go @@ -91,11 +91,7 @@ func applyConfigPrefundedL2(t devtest.T, keys devkeys.Keys, l1ChainID, l2ChainID l1Config.WithPrefundedAccount(addrFor(devkeys.SystemConfigOwner), *millionEth) } -// startL2CLForKey starts an L2 CL node for the given key, respecting DEVSTACK_L2CL_KIND. -// This is the env-aware dispatch point for preset runtimes that don't build explicit node -// specs. Runtimes constructed from explicit MixedSingleChainNodeSpec.CLKind values (e.g. -// NewMixedSingleChainRuntime) don't route through here; they resolve the env up front via -// ResolveMixedL2CLKind instead. +// startL2CLForKey starts an L2 CL node of the given kind for the given key. func startL2CLForKey( t devtest.T, keys devkeys.Keys, @@ -105,17 +101,18 @@ func startL2CLForKey( l1CL *L1CLNode, l2EL L2ELNode, jwtSecret [32]byte, + clKind MixedL2CLKind, clKey, elKey string, isSequencer bool, followSource string, l2CLOpts []L2CLOption, ) L2CLNode { - switch devstackL2CLKind() { + switch clKind { case MixedL2CLKona: return startMixedKonaNode(t, keys, l1Net, l2Net, l1EL, l1CL, l2EL, clKey, elKey, konaNodeStartConfig{ L2CLConfig: resolveKonaL2CLConfig(t, clKey, l2Net.ChainID(), isSequencer, followSource, l2CLOpts), }) - default: // op-node + case MixedL2CLOpNode: return startL2CLNode(t, keys, l1Net, l2Net, l1EL, l1CL, l2EL, jwtSecret, l2CLNodeStartConfig{ Key: clKey, IsSequencer: isSequencer, @@ -123,10 +120,13 @@ func startL2CLForKey( L2FollowSource: followSource, L2CLOptions: l2CLOpts, }) + default: + t.Require().FailNow("unsupported L2 CL kind", "unknown L2 CL kind %q", clKind) + return nil // unreachable } } -// startStoppedSequencerCL starts the env-selected sequencer CL in the stopped +// startStoppedSequencerCL starts a sequencer CL of the given kind in the stopped // state required while a conductor cluster is being assembled. func startStoppedSequencerCL( t devtest.T, @@ -137,10 +137,11 @@ func startStoppedSequencerCL( l1CL *L1CLNode, l2EL L2ELNode, jwtSecret [32]byte, + clKind MixedL2CLKind, key string, l2CLOpts []L2CLOption, ) L2CLNode { - switch devstackL2CLKind() { + switch clKind { case MixedL2CLKona: return startMixedKonaNode( t, keys, l1Net, l2Net, l1EL, l1CL, l2EL, key, key, konaNodeStartConfig{ @@ -148,7 +149,7 @@ func startStoppedSequencerCL( SequencerStopped: true, }, ) - default: // op-node + case MixedL2CLOpNode: return startL2CLNode(t, keys, l1Net, l2Net, l1EL, l1CL, l2EL, jwtSecret, l2CLNodeStartConfig{ Key: key, IsSequencer: true, @@ -156,6 +157,9 @@ func startStoppedSequencerCL( L2CLOptions: l2CLOpts, SequencerStopped: true, }) + default: + t.Require().FailNow("unsupported L2 CL kind", "unknown L2 CL kind %q", clKind) + return nil // unreachable } } @@ -201,20 +205,6 @@ func connectL2CLPeers(t devtest.T, logger log.Logger, l2CL1, l2CL2 L2CLNode) { require.True(ok2, "peer register invalid (cl2 missing cl1)") } -func startSequencerCL( - t devtest.T, - keys devkeys.Keys, - l1Net *L1Network, - l2Net *L2Network, - l1EL L1ELNode, - l1CL *L1CLNode, - l2EL L2ELNode, - jwtSecret [32]byte, - l2CLOpts []L2CLOption, -) L2CLNode { - return startL2CLForKey(t, keys, l1Net, l2Net, l1EL, l1CL, l2EL, jwtSecret, "sequencer", "sequencer", true, "", l2CLOpts) -} - type l2CLNodeStartConfig struct { Key string IsSequencer bool diff --git a/op-devstack/sysgo/singlechain_build_test.go b/op-devstack/sysgo/singlechain_build_test.go index 07dada44d10..e69392ec74d 100644 --- a/op-devstack/sysgo/singlechain_build_test.go +++ b/op-devstack/sysgo/singlechain_build_test.go @@ -12,7 +12,8 @@ import ( ) func TestKonaOptionsRejectedBeforeStartup(t *testing.T) { - t.Setenv("DEVSTACK_L2CL_KIND", string(MixedL2CLKona)) + // The env asks for op-node, so a kona-node rejection shows the explicit kind picks the CL. + t.Setenv("DEVSTACK_L2CL_KIND", string(MixedL2CLOpNode)) t.Setenv("KONA_NODE_P2P_NO_DISCOVERY", "true") for _, stopped := range []bool{false, true} { t.Run(fmt.Sprintf("stopped=%t", stopped), func(t *testing.T) { @@ -24,12 +25,33 @@ func TestKonaOptionsRejectedBeforeStartup(t *testing.T) { // Nil startup dependencies ensure validation runs before starting any process or RPC. require.PanicsWithValue(t, "Kona option rejected", func() { if stopped { - startStoppedSequencerCL(dt, nil, nil, network, nil, nil, nil, [32]byte{}, "node", opts) + startStoppedSequencerCL(dt, nil, nil, network, nil, nil, nil, [32]byte{}, MixedL2CLKona, "node", opts) } else { - startL2CLForKey(dt, nil, nil, network, nil, nil, nil, [32]byte{}, "node", "node", true, "", opts) + startL2CLForKey(dt, nil, nil, network, nil, nil, nil, [32]byte{}, MixedL2CLKona, "node", "node", true, "", opts) } }) require.Contains(t, dt.failure, "unsupported L2CL option for kona-node") }) } } + +// A kind the starters do not know, including the empty string, fails before anything starts +// instead of silently running op-node. +func TestUnknownL2CLKindRejectedBeforeStartup(t *testing.T) { + for _, kind := range []MixedL2CLKind{"", "kona", "Kona-Node"} { + for _, stopped := range []bool{false, true} { + t.Run(fmt.Sprintf("kind=%q/stopped=%t", kind, stopped), func(t *testing.T) { + dt := &rejectedKonaOptionTest{T: devtest.SerialT(t)} + network := &L2Network{chainID: eth.ChainIDFromUInt64(901)} + require.PanicsWithValue(t, "Kona option rejected", func() { + if stopped { + startStoppedSequencerCL(dt, nil, nil, network, nil, nil, nil, [32]byte{}, kind, "node", nil) + } else { + startL2CLForKey(dt, nil, nil, network, nil, nil, nil, [32]byte{}, kind, "node", "node", true, "", nil) + } + }) + require.Contains(t, dt.failure, "unknown L2 CL kind") + }) + } + } +} diff --git a/op-devstack/sysgo/singlechain_interop.go b/op-devstack/sysgo/singlechain_interop.go index c3bad3d2f2b..80ba236837d 100644 --- a/op-devstack/sysgo/singlechain_interop.go +++ b/op-devstack/sysgo/singlechain_interop.go @@ -31,8 +31,10 @@ func startSingleChainInteropPrimaryNoSupernode( jwtPath string, jwtSecret [32]byte, cfg PresetConfig, + sequencerCLKind MixedL2CLKind, ) singleChainPrimaryRuntime { t.Require().NotNil(world.Interop, "single-chain interop runtime requires interop support") + requireOpNodeSequencerCLKind(t, sequencerCLKind) l2EL := startSequencerEL(t, world.L2Network, jwtPath, jwtSecret, ResolveMixedL2ELOpts(t)...) l2CL := startL2CLNode(t, keys, world.L1Network, world.L2Network, l1EL, l1CL, l2EL, jwtSecret, l2CLNodeStartConfig{ @@ -54,10 +56,12 @@ func startSingleChainInteropPrimaryNoSupernode( func NewMinimalInteropNoSupernodeRuntime(t devtest.T) *SingleChainRuntime { return newSingleChainRuntimeWithConfig(t, PresetConfig{}, singleChainRuntimeSpec{ BuildWorld: newSingleChainInteropWorldNoSupernode, + SequencerCLKind: MixedL2CLOpNode, StartPrimary: startSingleChainInteropPrimaryNoSupernode, + StartBatcher: true, - StartProposer: true, StartChallenger: false, + StartProposer: true, }) } @@ -70,10 +74,12 @@ func NewSingleChainInteropNoSupernodeSuperRootRuntimeWithConfig(t devtest.T, cfg cfg.AddedGameTypes = append(cfg.AddedGameTypes, gameTypes.SuperCannonKonaGameType) return newSingleChainRuntimeWithConfig(t, cfg, singleChainRuntimeSpec{ BuildWorld: newSingleChainInteropWorldNoSupernode, + SequencerCLKind: MixedL2CLOpNode, StartPrimary: startDefaultSingleChainPrimary, + StartBatcher: true, - StartProposer: false, StartChallenger: true, + StartProposer: false, }) } @@ -88,9 +94,11 @@ func NewSingleChainInteropNoSupernodeZKDisputeRuntimeWithConfig(t devtest.T, cfg cfg.AddedGameTypes = append(cfg.AddedGameTypes, gameTypes.ZKDisputeGameType) return newSingleChainRuntimeWithConfig(t, cfg, singleChainRuntimeSpec{ BuildWorld: newSingleChainInteropWorldNoSupernode, + SequencerCLKind: MixedL2CLOpNode, StartPrimary: startDefaultSingleChainPrimary, + StartBatcher: true, - StartProposer: false, StartChallenger: true, + StartProposer: false, }) } diff --git a/op-devstack/sysgo/singlechain_runtime.go b/op-devstack/sysgo/singlechain_runtime.go index de6501560fa..98487eeac8b 100644 --- a/op-devstack/sysgo/singlechain_runtime.go +++ b/op-devstack/sysgo/singlechain_runtime.go @@ -45,13 +45,43 @@ type singleChainPrimaryRuntime struct { CL L2CLNode } +type singleChainPrimaryStartFunc func( + t devtest.T, + keys devkeys.Keys, + world singleChainRuntimeWorld, + l1EL *L1Geth, + l1CL *L1CLNode, + jwtPath string, + jwtSecret [32]byte, + cfg PresetConfig, + sequencerCLKind MixedL2CLKind, +) singleChainPrimaryRuntime + type singleChainRuntimeSpec struct { BuildWorld func(t devtest.T, keys devkeys.Keys, cfg PresetConfig, startL1 func(*L1Network) (*L1Geth, *L1CLNode)) singleChainRuntimeWorld - StartPrimary func(t devtest.T, keys devkeys.Keys, world singleChainRuntimeWorld, l1EL *L1Geth, l1CL *L1CLNode, jwtPath string, jwtSecret [32]byte, cfg PresetConfig) singleChainPrimaryRuntime + SequencerCLKind MixedL2CLKind + StartPrimary singleChainPrimaryStartFunc + StartBatcher bool - StartProposer bool StartChallenger bool - TestSequencer string + StartProposer bool + + TestSequencer string +} + +// requireOpNodeSequencerCLKind fails unless the sequencer runs on op-node, which the single-chain +// interop sequencer requires. +func requireOpNodeSequencerCLKind(t devtest.T, sequencerCLKind MixedL2CLKind) { + t.Require().Equal(MixedL2CLOpNode, sequencerCLKind, "single-chain interop sequencer requires op-node") +} + +// resolveSequencerCLKind returns the L2 CL kind the environment requests for the sequencer, +// pinned to op-node when the chain runs interop at genesis. +func resolveSequencerCLKind(cfg PresetConfig) MixedL2CLKind { + if cfg.InteropAtGenesis { + return MixedL2CLOpNode + } + return ResolveMixedL2CLKind() } func newSingleChainNodeRuntime(name string, isSequencer bool, el L2ELNode, cl L2CLNode) *SingleChainNodeRuntime { @@ -94,6 +124,7 @@ func startDefaultSingleChainPrimary( jwtPath string, jwtSecret [32]byte, cfg PresetConfig, + sequencerCLKind MixedL2CLKind, ) singleChainPrimaryRuntime { safeDBPath := filepath.Join(t.TempDirWithPrefix("l2-safe-db-"+world.L2Network.ChainID().String()), "safe-head.db") l2CLOptions := []L2CLOption{L2CLOptionFn(func(_ devtest.T, _ ComponentTarget, cfg *L2CLConfig) { @@ -104,6 +135,7 @@ func startDefaultSingleChainPrimary( sequencerELOpts := append(append([]OpRethOption{}, ResolveMixedL2ELOpts(t)...), cfg.OpRethOptions...) l2EL := startSequencerEL(t, world.L2Network, jwtPath, jwtSecret, sequencerELOpts...) if world.Interop != nil { + requireOpNodeSequencerCLKind(t, sequencerCLKind) l2CL := startL2CLNode(t, keys, world.L1Network, world.L2Network, l1EL, l1CL, l2EL, jwtSecret, l2CLNodeStartConfig{ Key: "sequencer", IsSequencer: true, @@ -113,7 +145,7 @@ func startDefaultSingleChainPrimary( }) return singleChainPrimaryRuntime{EL: l2EL, CL: l2CL} } - l2CL := startSequencerCL(t, keys, world.L1Network, world.L2Network, l1EL, l1CL, l2EL, jwtSecret, l2CLOptions) + l2CL := startL2CLForKey(t, keys, world.L1Network, world.L2Network, l1EL, l1CL, l2EL, jwtSecret, sequencerCLKind, "sequencer", "sequencer", true, "", l2CLOptions) return singleChainPrimaryRuntime{ EL: l2EL, CL: l2CL, @@ -132,6 +164,7 @@ func startStoppedSingleChainPrimary( jwtPath string, jwtSecret [32]byte, cfg PresetConfig, + sequencerCLKind MixedL2CLKind, ) singleChainPrimaryRuntime { t.Require().Nil(world.Interop, "conductor primary does not support interop") safeDBPath := filepath.Join(t.TempDirWithPrefix("l2-safe-db-"+world.L2Network.ChainID().String()), "safe-head.db") @@ -144,7 +177,7 @@ func startStoppedSingleChainPrimary( l2EL := startSequencerEL(t, world.L2Network, jwtPath, jwtSecret, sequencerELOpts...) l2CL := startStoppedSequencerCL( t, keys, world.L1Network, world.L2Network, l1EL, l1CL, l2EL, jwtSecret, - "sequencer", l2CLOptions, + sequencerCLKind, "sequencer", l2CLOptions, ) return singleChainPrimaryRuntime{EL: l2EL, CL: l2CL} } @@ -174,7 +207,7 @@ func newSingleChainRuntimeWithConfig(t devtest.T, cfg PresetConfig, spec singleC return l1EL, l1CL }) - primary := spec.StartPrimary(t, keys, world, l1EL, l1CL, jwtPath, jwtSecret, cfg) + primary := spec.StartPrimary(t, keys, world, l1EL, l1CL, jwtPath, jwtSecret, cfg, spec.SequencerCLKind) primaryNode := newSingleChainNodeRuntime("sequencer", true, primary.EL, primary.CL) var l2Batcher *L2Batcher @@ -239,12 +272,18 @@ func NewMinimalRuntime(t devtest.T) *SingleChainRuntime { } func NewMinimalRuntimeWithConfig(t devtest.T, cfg PresetConfig) *SingleChainRuntime { + return newMinimalRuntime(t, cfg, resolveSequencerCLKind(cfg)) +} + +func newMinimalRuntime(t devtest.T, cfg PresetConfig, sequencerCLKind MixedL2CLKind) *SingleChainRuntime { return newSingleChainRuntimeWithConfig(t, cfg, singleChainRuntimeSpec{ BuildWorld: newDefaultSingleChainWorld, + SequencerCLKind: sequencerCLKind, StartPrimary: startDefaultSingleChainPrimary, + StartBatcher: true, - StartProposer: true, StartChallenger: true, + StartProposer: true, }) } @@ -254,12 +293,18 @@ func NewMinimalRuntimeWithConfig(t devtest.T, cfg PresetConfig) *SingleChainRunt // fault proofs. Skipping the challenger also avoids requiring cannon prestate // artifacts, which are expensive to build locally. func NewMinimalNoFaultProofsRuntimeWithConfig(t devtest.T, cfg PresetConfig) *SingleChainRuntime { + return newMinimalNoFaultProofsRuntime(t, cfg, resolveSequencerCLKind(cfg)) +} + +func newMinimalNoFaultProofsRuntime(t devtest.T, cfg PresetConfig, sequencerCLKind MixedL2CLKind) *SingleChainRuntime { return newSingleChainRuntimeWithConfig(t, cfg, singleChainRuntimeSpec{ BuildWorld: newDefaultSingleChainWorld, + SequencerCLKind: sequencerCLKind, StartPrimary: startDefaultSingleChainPrimary, + StartBatcher: true, - StartProposer: false, StartChallenger: false, + StartProposer: false, }) } diff --git a/op-devstack/sysgo/singlechain_variants.go b/op-devstack/sysgo/singlechain_variants.go index e6787b9c2f4..5d9819bbf1b 100644 --- a/op-devstack/sysgo/singlechain_variants.go +++ b/op-devstack/sysgo/singlechain_variants.go @@ -32,15 +32,17 @@ func NewSingleChainMultiNodeRuntime(t devtest.T, withP2P bool) *SingleChainRunti } func NewSingleChainMultiNodeRuntimeWithConfig(t devtest.T, withP2P bool, cfg PresetConfig) *SingleChainRuntime { - return addSingleChainVerifier(t, NewMinimalRuntimeWithConfig(t, cfg), withP2P, cfg) + clKind := ResolveMixedL2CLKind() + return addSingleChainVerifier(t, newMinimalRuntime(t, cfg, resolveSequencerCLKind(cfg)), clKind, withP2P, cfg) } func NewSingleChainWithIsolatedVerifierRuntimeWithConfig(t devtest.T, cfg PresetConfig) *SingleChainRuntime { - return addSingleChainVerifier(t, NewMinimalNoFaultProofsRuntimeWithConfig(t, cfg), false, cfg) + clKind := ResolveMixedL2CLKind() + return addSingleChainVerifier(t, newMinimalNoFaultProofsRuntime(t, cfg, resolveSequencerCLKind(cfg)), clKind, false, cfg) } -func addSingleChainVerifier(t devtest.T, runtime *SingleChainRuntime, withP2P bool, cfg PresetConfig) *SingleChainRuntime { - nodeB := addSingleChainOpNode(t, runtime, "b", false, "", cfg.GlobalL2CLOptions...) +func addSingleChainVerifier(t devtest.T, runtime *SingleChainRuntime, clKind MixedL2CLKind, withP2P bool, cfg PresetConfig) *SingleChainRuntime { + nodeB := addSingleChainNode(t, runtime, "b", clKind, false, "", cfg.GlobalL2CLOptions...) if withP2P { connectSingleChainNodes(t, runtime.L2EL, runtime.L2CL, nodeB) } @@ -52,11 +54,22 @@ func NewSingleChainTwoVerifiersRuntime(t devtest.T) *SingleChainRuntime { return NewSingleChainTwoVerifiersRuntimeWithConfig(t, PresetConfig{}) } +// NewSingleChainTwoVerifiersRuntimeWithConfig adds two verifiers to a minimal runtime without +// fault proofs: "b" derives from L1, and "c" follows "b" as its follow source. The CL kind of each +// node comes from newSingleChainTwoVerifiersCLKinds. func NewSingleChainTwoVerifiersRuntimeWithConfig(t devtest.T, cfg PresetConfig) *SingleChainRuntime { - runtime := NewSingleChainMultiNodeRuntimeWithConfig(t, true, cfg) + requestedCLKind := ResolveMixedL2CLKind() + clKinds := newSingleChainTwoVerifiersCLKinds(requestedCLKind) + t.Logger().Info("Pinned the L2 CL kind of the sequencer and verifier b; verifier c uses the requested kind", + "requestedKind", requestedCLKind, + "b", clKinds.DerivingVerifier, + "c", clKinds.FollowSourceVerifier, + "sequencer", clKinds.Sequencer, + ) + runtime := addSingleChainVerifier(t, newMinimalNoFaultProofsRuntime(t, cfg, clKinds.Sequencer), clKinds.DerivingVerifier, true, cfg) nodeB := runtime.Nodes["b"] t.Require().NotNil(nodeB, "missing single-chain node b") - nodeC := addSingleChainOpNode(t, runtime, "c", false, nodeB.CL.UserRPC(), cfg.GlobalL2CLOptions...) + nodeC := addSingleChainNode(t, runtime, "c", clKinds.FollowSourceVerifier, false, nodeB.CL.UserRPC(), cfg.GlobalL2CLOptions...) connectSingleChainNodes(t, runtime.L2EL, runtime.L2CL, nodeC) connectSingleChainNodes(t, nodeB.EL, nodeB.CL, nodeC) @@ -66,6 +79,24 @@ func NewSingleChainTwoVerifiersRuntimeWithConfig(t devtest.T, cfg PresetConfig) return runtime } +type singleChainTwoVerifiersCLKinds struct { + DerivingVerifier MixedL2CLKind + FollowSourceVerifier MixedL2CLKind + Sequencer MixedL2CLKind +} + +// newSingleChainTwoVerifiersCLKinds runs the sequencer and the deriving verifier on op-node +// whatever the requested kind, and only the follow-source verifier on the requested kind, so a +// kona-node run exercises kona's follow-source mode against an op-node upstream rather than kona +// sequencing or derivation. +func newSingleChainTwoVerifiersCLKinds(requested MixedL2CLKind) singleChainTwoVerifiersCLKinds { + return singleChainTwoVerifiersCLKinds{ + DerivingVerifier: MixedL2CLOpNode, + FollowSourceVerifier: requested, + Sequencer: MixedL2CLOpNode, + } +} + func NewSimpleWithSyncTesterRuntime(t devtest.T) *SingleChainRuntime { return NewSimpleWithSyncTesterRuntimeWithConfig(t, PresetConfig{}) } @@ -116,6 +147,7 @@ func NewMinimalWithConductorsRuntime(t devtest.T) *SingleChainRuntime { } func NewMinimalWithConductorsRuntimeWithConfig(t devtest.T, cfg PresetConfig) *SingleChainRuntime { + clKind := ResolveMixedL2CLKind() // The CL and conductor depend on each other's RPC endpoints. Allocate a // stable proxy for each conductor before starting its CL, then attach the // conductor once its dynamically allocated RPC port is known. @@ -140,22 +172,24 @@ func NewMinimalWithConductorsRuntimeWithConfig(t devtest.T, cfg PresetConfig) *S // challenger, and rust e2e jobs do not build cannon artifacts. runtime := newSingleChainRuntimeWithConfig(t, cfg, singleChainRuntimeSpec{ BuildWorld: newDefaultSingleChainWorld, + SequencerCLKind: clKind, StartPrimary: startStoppedSingleChainPrimary, + StartBatcher: true, - StartProposer: true, StartChallenger: false, + StartProposer: true, }) // Every conductor member sequences once leadership reaches it, so a binary override has to // apply to all of them or it would silently stop taking effect on transfer. The primary already // received these options from startStoppedSingleChainPrimary. candidateELOpts := append(append([]OpRethOption{}, ResolveMixedL2ELOpts(t)...), cfg.OpRethOptions...) - nodeB := addStoppedSingleChainSequencerNode(t, runtime, "b", candidateELOpts, cfg.GlobalL2CLOptions...) - nodeC := addStoppedSingleChainSequencerNode(t, runtime, "c", candidateELOpts, cfg.GlobalL2CLOptions...) + nodeB := addStoppedSingleChainSequencerNode(t, runtime, "b", clKind, candidateELOpts, cfg.GlobalL2CLOptions...) + nodeC := addStoppedSingleChainSequencerNode(t, runtime, "c", clKind, candidateELOpts, cfg.GlobalL2CLOptions...) // A non-candidate node, always stock: it never sequences, so it independently validates every // block the candidates build. Without it an overridden binary on all three members could accept // its own invalid blocks and the run would still pass. - nodeVerifier := addSingleChainOpNode(t, runtime, "verifier", false, "", cfg.GlobalL2CLOptions...) + nodeVerifier := addSingleChainNode(t, runtime, "verifier", clKind, false, "", cfg.GlobalL2CLOptions...) healthCheck := conductorHealthCheckConfig(cfg.ConductorFastHealthChecks) conductorA := startConductorNode(t, "sequencer", runtime.L2Network, runtime.L2CL, conductorRPCProxies["sequencer"], runtime.L2EL, true, false, healthCheck) @@ -233,24 +267,26 @@ func replaceSingleChainTestSequencer(t devtest.T, runtime *SingleChainRuntime, n runtime.TestSequencer = newTestSequencerRuntime(testSequencer, name) } -func addSingleChainOpNode( +func addSingleChainNode( t devtest.T, runtime *SingleChainRuntime, name string, + clKind MixedL2CLKind, isSequencer bool, followSource string, l2Opts ...L2CLOption, ) *SingleChainNodeRuntime { - return addSingleChainOpNodeWithELOpts(t, runtime, name, isSequencer, followSource, nil, l2Opts...) + return addSingleChainNodeWithELOpts(t, runtime, name, clKind, isSequencer, followSource, nil, l2Opts...) } -// addSingleChainOpNodeWithELOpts adds a node whose EL takes op-reth options. Passing none yields a +// addSingleChainNodeWithELOpts adds a node whose EL takes op-reth options. Passing none yields a // stock op-reth, which is what lets a preset keep an independent check on blocks built by an // overridden binary. -func addSingleChainOpNodeWithELOpts( +func addSingleChainNodeWithELOpts( t devtest.T, runtime *SingleChainRuntime, name string, + clKind MixedL2CLKind, isSequencer bool, followSource string, elOpts []OpRethOption, @@ -259,7 +295,7 @@ func addSingleChainOpNodeWithELOpts( jwtPath := runtime.L2EL.JWTPath() jwtSecret := readJWTSecretFromPath(t, jwtPath) l2EL := startMixedOpRethNode(t, runtime.L2Network, name, jwtPath, jwtSecret, nil, elOpts...) - l2CL := startL2CLForKey(t, runtime.Keys, runtime.L1Network, runtime.L2Network, runtime.L1EL, runtime.L1CL, l2EL, jwtSecret, name, name, isSequencer, followSource, l2Opts) + l2CL := startL2CLForKey(t, runtime.Keys, runtime.L1Network, runtime.L2Network, runtime.L1EL, runtime.L1CL, l2EL, jwtSecret, clKind, name, name, isSequencer, followSource, l2Opts) node := newSingleChainNodeRuntime(name, isSequencer, l2EL, l2CL) runtime.Nodes[name] = node return node @@ -271,6 +307,7 @@ func addStoppedSingleChainSequencerNode( t devtest.T, runtime *SingleChainRuntime, name string, + clKind MixedL2CLKind, elOpts []OpRethOption, l2Opts ...L2CLOption, ) *SingleChainNodeRuntime { @@ -279,7 +316,7 @@ func addStoppedSingleChainSequencerNode( l2EL := startMixedOpRethNode(t, runtime.L2Network, name, jwtPath, jwtSecret, nil, elOpts...) l2CL := startStoppedSequencerCL( t, runtime.Keys, runtime.L1Network, runtime.L2Network, runtime.L1EL, runtime.L1CL, - l2EL, jwtSecret, name, l2Opts, + l2EL, jwtSecret, clKind, name, l2Opts, ) node := newSingleChainNodeRuntime(name, true, l2EL, l2CL) runtime.Nodes[name] = node diff --git a/op-devstack/sysgo/singlechain_variants_test.go b/op-devstack/sysgo/singlechain_variants_test.go new file mode 100644 index 00000000000..cd10d25e2c3 --- /dev/null +++ b/op-devstack/sysgo/singlechain_variants_test.go @@ -0,0 +1,31 @@ +package sysgo + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestSingleChainTwoVerifiersCLKinds(t *testing.T) { + clKinds := func(sequencer, derivingVerifier, followSourceVerifier MixedL2CLKind) singleChainTwoVerifiersCLKinds { + return singleChainTwoVerifiersCLKinds{ + DerivingVerifier: derivingVerifier, + FollowSourceVerifier: followSourceVerifier, + Sequencer: sequencer, + } + } + for _, testCase := range []struct { + name string + requestedKind MixedL2CLKind + want singleChainTwoVerifiersCLKinds + }{ + {name: "empty", requestedKind: "", want: clKinds(MixedL2CLOpNode, MixedL2CLOpNode, MixedL2CLOpNode)}, + {name: "op-node", requestedKind: MixedL2CLOpNode, want: clKinds(MixedL2CLOpNode, MixedL2CLOpNode, MixedL2CLOpNode)}, + {name: "kona-node", requestedKind: MixedL2CLKona, want: clKinds(MixedL2CLOpNode, MixedL2CLOpNode, MixedL2CLKona)}, + } { + t.Run(testCase.name, func(t *testing.T) { + t.Setenv("DEVSTACK_L2CL_KIND", string(testCase.requestedKind)) + require.Equal(t, testCase.want, newSingleChainTwoVerifiersCLKinds(ResolveMixedL2CLKind())) + }) + } +} From d5994d3b4e76780bf16adfa59df04032d4d86cf9 Mon Sep 17 00:00:00 2001 From: Einar Rasmussen Date: Fri, 13 Nov 2026 00:55:02 +0100 Subject: [PATCH 2/3] op-acceptance-tests: require follow_l2 recovery past the reorged block TestFollowL2_ReorgRecovery could pass with the follow-source verifier and the deriving verifier both reset to genesis. The follow-source verifier must now hold the reorged block as local-safe before the L1 reorg, replace it in its EL with the deriving verifier's block, and move its local-safe head past that height. TestFollowL2_WithoutCLP2P also checks that the finalized head follows the deriving verifier after reconnecting. Co-Authored-By: Claude Opus 5.5 --- .../tests/sync/follow_l2/sync_test.go | 28 +++++++++++++++++ .../sysgo/singlechain_variants_test.go | 31 ------------------- 2 files changed, 28 insertions(+), 31 deletions(-) delete mode 100644 op-devstack/sysgo/singlechain_variants_test.go diff --git a/op-acceptance-tests/tests/sync/follow_l2/sync_test.go b/op-acceptance-tests/tests/sync/follow_l2/sync_test.go index a779a90df55..2da8d1ea3bd 100644 --- a/op-acceptance-tests/tests/sync/follow_l2/sync_test.go +++ b/op-acceptance-tests/tests/sync/follow_l2/sync_test.go @@ -100,6 +100,14 @@ func TestFollowL2_ReorgRecovery(gt *testing.T) { // Make sure verifier safe head is also advanced from reorgL2Block or matched sys.L2ELB.Reached(eth.Safe, l2BlockBeforeReorg.Number, 3) + // The follow-source verifier must hold the block about to be reorged as local-safe, so the + // recovery checks below start from a real safe head rather than from genesis. + require.NoError(sys.L2CLC.ReachedWithProgressFn( + safety.LocalSafe, safety.LocalUnsafe, l2BlockBeforeReorg.Number, + 2*time.Minute, 30*time.Second, + )()) + require.Equal(l2BlockBeforeReorg.Hash, sys.L2ELC.BlockRefByNumber(l2BlockBeforeReorg.Number).Hash, + "follow-source verifier must hold the deriving verifier's block before the L1 reorg") // Reorg L1 block which safe block L1 Origin points to l1BlockBeforeReorg := sys.L1EL.BlockRefByNumber(l2BlockBeforeReorg.L1Origin.Number) @@ -133,6 +141,18 @@ func TestFollowL2_ReorgRecovery(gt *testing.T) { }, 60*time.Second, 2*time.Second) logger.Info("Triggered L2 reorg", "l2", l2BlockAfterReorg) + sys.L2ELC.ReorgTriggered(l2BlockBeforeReorg, 60) + // A local-safe head past the reorged height shows the follow-source verifier recovered; the + // in-sync checks below also pass when both verifiers sit at genesis. Waiting for the EL reorg + // first means the unsafe head that bounds this wait is already climbing on the new chain. + require.NoError(sys.L2CLC.ReachedWithProgressFn( + safety.LocalSafe, safety.LocalUnsafe, l2BlockBeforeReorg.Number+1, + 5*time.Minute, time.Minute, + )()) + require.Equal(sys.L2ELB.BlockRefByNumber(l2BlockBeforeReorg.Number).Hash, + sys.L2ELC.BlockRefByNumber(l2BlockBeforeReorg.Number).Hash, + "follow-source verifier must replace the reorged block with the deriving verifier's") + attempts := 30 dsl.CheckAll(t, sys.L2CL.InSyncFn(sys.L2CLB, safety.LocalUnsafe, attempts), @@ -217,6 +237,14 @@ func TestFollowL2_WithoutCLP2P(gt *testing.T) { sys.L2CLC.InSyncFn(sys.L2CLB, safety.LocalUnsafe, attempts), ) + // The deriving verifier finalizes past genesis first, so the comparison cannot pass with both + // nodes at genesis. + require.NoError(sys.L2CLB.ReachedWithProgressFn( + safety.Finalized, safety.LocalSafe, 1, + 5*time.Minute, time.Minute, + )()) + sys.L2CLC.InSync(sys.L2CLB, safety.Finalized, attempts) + t.Cleanup(func() { sys.L2CLC.ConnectPeer(sys.L2CLB) sys.L2CLB.ConnectPeer(sys.L2CLC) diff --git a/op-devstack/sysgo/singlechain_variants_test.go b/op-devstack/sysgo/singlechain_variants_test.go deleted file mode 100644 index cd10d25e2c3..00000000000 --- a/op-devstack/sysgo/singlechain_variants_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package sysgo - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestSingleChainTwoVerifiersCLKinds(t *testing.T) { - clKinds := func(sequencer, derivingVerifier, followSourceVerifier MixedL2CLKind) singleChainTwoVerifiersCLKinds { - return singleChainTwoVerifiersCLKinds{ - DerivingVerifier: derivingVerifier, - FollowSourceVerifier: followSourceVerifier, - Sequencer: sequencer, - } - } - for _, testCase := range []struct { - name string - requestedKind MixedL2CLKind - want singleChainTwoVerifiersCLKinds - }{ - {name: "empty", requestedKind: "", want: clKinds(MixedL2CLOpNode, MixedL2CLOpNode, MixedL2CLOpNode)}, - {name: "op-node", requestedKind: MixedL2CLOpNode, want: clKinds(MixedL2CLOpNode, MixedL2CLOpNode, MixedL2CLOpNode)}, - {name: "kona-node", requestedKind: MixedL2CLKona, want: clKinds(MixedL2CLOpNode, MixedL2CLOpNode, MixedL2CLKona)}, - } { - t.Run(testCase.name, func(t *testing.T) { - t.Setenv("DEVSTACK_L2CL_KIND", string(testCase.requestedKind)) - require.Equal(t, testCase.want, newSingleChainTwoVerifiersCLKinds(ResolveMixedL2CLKind())) - }) - } -} From aafe0f0151b3d9c4c4123ea276fd5d3e9dd6a293 Mon Sep 17 00:00:00 2001 From: Einar Rasmussen Date: Fri, 13 Nov 2026 00:55:03 +0100 Subject: [PATCH 3/3] op-devstack: validate DEVSTACK_L2CL_KIND when it is resolved ResolveMixedL2CLKind takes the test handle and fails on a value other than op-node or kona-node, so an invalid kind fails before any node starts instead of when the first node of that kind starts. The two-verifiers runtime reads the follow-source verifier's kind into a local in place of singleChainTwoVerifiersCLKinds, the multi-node runtimes call the exported minimal-runtime constructors, the CL-kind starters use FailNowf, and the README says that some presets pin nodes to op-node. Co-Authored-By: Claude Opus 5.5 --- op-acceptance-tests/tests/sdm/init_test.go | 4 +- op-devstack/README.md | 2 +- op-devstack/sysgo/mixed_runtime.go | 18 +++++--- op-devstack/sysgo/mixed_runtime_test.go | 28 +++++++++++++ op-devstack/sysgo/singlechain_build.go | 4 +- op-devstack/sysgo/singlechain_runtime.go | 8 ++-- op-devstack/sysgo/singlechain_variants.go | 49 ++++++---------------- 7 files changed, 62 insertions(+), 51 deletions(-) diff --git a/op-acceptance-tests/tests/sdm/init_test.go b/op-acceptance-tests/tests/sdm/init_test.go index db96beb2240..643f7b6caec 100644 --- a/op-acceptance-tests/tests/sdm/init_test.go +++ b/op-acceptance-tests/tests/sdm/init_test.go @@ -43,7 +43,7 @@ func newSDMRethSystemWithIsolatedVerifier(t devtest.T) *sdmtest.RethSystem { // derivation actor stays in AwaitingELSyncCompletion, the EL gets no engine calls, and the // safe head never leaves genesis. kona-node has no L1-only bootstrap of the force-build path // today, so this test cannot pass under kona-node and is op-node-only for now. - if sysgo.ResolveMixedL2CLKind() == sysgo.MixedL2CLKona { + if sysgo.ResolveMixedL2CLKind(t) == sysgo.MixedL2CLKona { t.Skip("isolated-verifier force-build path is not supported by kona-node (no L1-only EL-sync bootstrap); op-node only") } return buildSDMRethSystem(t, true, true, true, "", nil) @@ -84,7 +84,7 @@ func buildSDMRethSystem( ) *sdmtest.RethSystem { // Honor DEVSTACK_L2CL_KIND so the kona acceptance suite exercises this test with // kona-node on both the sequencer and verifier (defaults to op-node when unset). - clKind := sysgo.ResolveMixedL2CLKind() + clKind := sysgo.ResolveMixedL2CLKind(t) sequencerKey := "sequencer-op-reth" // The two sequencer paths are disjoint, and neither is an extension point for a diff --git a/op-devstack/README.md b/op-devstack/README.md index d2246ed928d..5dfab54b194 100644 --- a/op-devstack/README.md +++ b/op-devstack/README.md @@ -110,7 +110,7 @@ and returns a typed output that the test then may use. - `DEVSTACK_MONOREPO_ROOT`: Absolute path to a monorepo checkout. Used by out-of-tree acceptance suites (which depend on this module by git rev) so contract-artifact resolution can find `packages/contracts-bedrock` outside the cwd-relative walk. In-tree runs don't need it. ### Rust stack env vars: -- `DEVSTACK_L2CL_KIND=kona-node` to select kona-node as default L2 CL node +- `DEVSTACK_L2CL_KIND=kona-node` to select kona-node as default L2 CL node. Any value other than `op-node` or `kona-node` fails the test before a node starts. Some presets pin nodes to op-node whatever the variable says, such as the sequencer of a chain with interop at genesis, and the sequencer and deriving verifier of the two-verifiers preset. - `RUST_BINARY_PATH_KONA_NODE=/home/USERHERE/projects/kona/target/debug/kona-node` to select the kona-node executable to run (skips the build; the path must exist) - `RUST_BINARY_PATH_OP_RETH=/home/USERHERE/projects/reth/target/release/op-reth` to select the op-reth executable to run (skips the build; the path must exist) diff --git a/op-devstack/sysgo/mixed_runtime.go b/op-devstack/sysgo/mixed_runtime.go index 61b55027d91..08bc3aba0d6 100644 --- a/op-devstack/sysgo/mixed_runtime.go +++ b/op-devstack/sysgo/mixed_runtime.go @@ -70,14 +70,20 @@ func devstackL2CLKind() MixedL2CLKind { } // ResolveMixedL2CLKind returns the L2 CL kind requested via DEVSTACK_L2CL_KIND, -// defaulting to op-node when the variable is unset. Tests that build explicit -// MixedSingleChainNodeSpec lists use this so they honor the same env-driven CL -// selection as the higher-level single-chain presets. -func ResolveMixedL2CLKind() MixedL2CLKind { - if kind := devstackL2CLKind(); kind != "" { +// defaulting to op-node when the variable is unset, and fails the test on any other +// value before a node starts. Tests that build explicit MixedSingleChainNodeSpec lists +// use this so they honor the same env-driven CL selection as the higher-level +// single-chain presets. +func ResolveMixedL2CLKind(t devtest.T) MixedL2CLKind { + switch kind := devstackL2CLKind(); kind { + case "": + return MixedL2CLOpNode + case MixedL2CLOpNode, MixedL2CLKona: return kind + default: + t.Require().FailNowf("unsupported L2 CL kind", "DEVSTACK_L2CL_KIND=%q, want %q or %q", kind, MixedL2CLOpNode, MixedL2CLKona) + return "" // unreachable } - return MixedL2CLOpNode } const ( diff --git a/op-devstack/sysgo/mixed_runtime_test.go b/op-devstack/sysgo/mixed_runtime_test.go index ae5124255dd..5c97f9ca742 100644 --- a/op-devstack/sysgo/mixed_runtime_test.go +++ b/op-devstack/sysgo/mixed_runtime_test.go @@ -66,3 +66,31 @@ func TestResolveMixedL2ELOptsReadsEnv(t *testing.T) { require.Equal(t, []string{"--extra.bind=127.0.0.1:0"}, cfg.ExtraArgs) require.True(t, cfg.DisableProofsHistory) } + +func TestResolveMixedL2CLKind(t *testing.T) { + for _, tc := range []struct { + env string + want MixedL2CLKind + }{ + {env: "", want: MixedL2CLOpNode}, + {env: "op-node", want: MixedL2CLOpNode}, + {env: "kona-node", want: MixedL2CLKona}, + } { + t.Run(tc.env, func(t *testing.T) { + t.Setenv("DEVSTACK_L2CL_KIND", tc.env) + require.Equal(t, tc.want, ResolveMixedL2CLKind(devtest.SerialT(t))) + }) + } +} + +// An unknown kind fails at resolution, before any preset starts a node of that kind. +func TestResolveMixedL2CLKindRejectsUnknownKind(t *testing.T) { + for _, kind := range []string{"kona", "Kona-Node", "op-geth"} { + t.Run(kind, func(t *testing.T) { + t.Setenv("DEVSTACK_L2CL_KIND", kind) + dt := &rejectedKonaOptionTest{T: devtest.SerialT(t)} + require.PanicsWithValue(t, "Kona option rejected", func() { ResolveMixedL2CLKind(dt) }) + require.Contains(t, dt.failure, "DEVSTACK_L2CL_KIND") + }) + } +} diff --git a/op-devstack/sysgo/singlechain_build.go b/op-devstack/sysgo/singlechain_build.go index 9e2f58c0e7b..68ba9535293 100644 --- a/op-devstack/sysgo/singlechain_build.go +++ b/op-devstack/sysgo/singlechain_build.go @@ -121,7 +121,7 @@ func startL2CLForKey( L2CLOptions: l2CLOpts, }) default: - t.Require().FailNow("unsupported L2 CL kind", "unknown L2 CL kind %q", clKind) + t.Require().FailNowf("unsupported L2 CL kind", "unknown L2 CL kind %q", clKind) return nil // unreachable } } @@ -158,7 +158,7 @@ func startStoppedSequencerCL( SequencerStopped: true, }) default: - t.Require().FailNow("unsupported L2 CL kind", "unknown L2 CL kind %q", clKind) + t.Require().FailNowf("unsupported L2 CL kind", "unknown L2 CL kind %q", clKind) return nil // unreachable } } diff --git a/op-devstack/sysgo/singlechain_runtime.go b/op-devstack/sysgo/singlechain_runtime.go index 98487eeac8b..f3c827358f2 100644 --- a/op-devstack/sysgo/singlechain_runtime.go +++ b/op-devstack/sysgo/singlechain_runtime.go @@ -77,11 +77,11 @@ func requireOpNodeSequencerCLKind(t devtest.T, sequencerCLKind MixedL2CLKind) { // resolveSequencerCLKind returns the L2 CL kind the environment requests for the sequencer, // pinned to op-node when the chain runs interop at genesis. -func resolveSequencerCLKind(cfg PresetConfig) MixedL2CLKind { +func resolveSequencerCLKind(t devtest.T, cfg PresetConfig) MixedL2CLKind { if cfg.InteropAtGenesis { return MixedL2CLOpNode } - return ResolveMixedL2CLKind() + return ResolveMixedL2CLKind(t) } func newSingleChainNodeRuntime(name string, isSequencer bool, el L2ELNode, cl L2CLNode) *SingleChainNodeRuntime { @@ -272,7 +272,7 @@ func NewMinimalRuntime(t devtest.T) *SingleChainRuntime { } func NewMinimalRuntimeWithConfig(t devtest.T, cfg PresetConfig) *SingleChainRuntime { - return newMinimalRuntime(t, cfg, resolveSequencerCLKind(cfg)) + return newMinimalRuntime(t, cfg, resolveSequencerCLKind(t, cfg)) } func newMinimalRuntime(t devtest.T, cfg PresetConfig, sequencerCLKind MixedL2CLKind) *SingleChainRuntime { @@ -293,7 +293,7 @@ func newMinimalRuntime(t devtest.T, cfg PresetConfig, sequencerCLKind MixedL2CLK // fault proofs. Skipping the challenger also avoids requiring cannon prestate // artifacts, which are expensive to build locally. func NewMinimalNoFaultProofsRuntimeWithConfig(t devtest.T, cfg PresetConfig) *SingleChainRuntime { - return newMinimalNoFaultProofsRuntime(t, cfg, resolveSequencerCLKind(cfg)) + return newMinimalNoFaultProofsRuntime(t, cfg, resolveSequencerCLKind(t, cfg)) } func newMinimalNoFaultProofsRuntime(t devtest.T, cfg PresetConfig, sequencerCLKind MixedL2CLKind) *SingleChainRuntime { diff --git a/op-devstack/sysgo/singlechain_variants.go b/op-devstack/sysgo/singlechain_variants.go index 5d9819bbf1b..b63b01a1e05 100644 --- a/op-devstack/sysgo/singlechain_variants.go +++ b/op-devstack/sysgo/singlechain_variants.go @@ -32,13 +32,13 @@ func NewSingleChainMultiNodeRuntime(t devtest.T, withP2P bool) *SingleChainRunti } func NewSingleChainMultiNodeRuntimeWithConfig(t devtest.T, withP2P bool, cfg PresetConfig) *SingleChainRuntime { - clKind := ResolveMixedL2CLKind() - return addSingleChainVerifier(t, newMinimalRuntime(t, cfg, resolveSequencerCLKind(cfg)), clKind, withP2P, cfg) + clKind := ResolveMixedL2CLKind(t) + return addSingleChainVerifier(t, NewMinimalRuntimeWithConfig(t, cfg), clKind, withP2P, cfg) } func NewSingleChainWithIsolatedVerifierRuntimeWithConfig(t devtest.T, cfg PresetConfig) *SingleChainRuntime { - clKind := ResolveMixedL2CLKind() - return addSingleChainVerifier(t, newMinimalNoFaultProofsRuntime(t, cfg, resolveSequencerCLKind(cfg)), clKind, false, cfg) + clKind := ResolveMixedL2CLKind(t) + return addSingleChainVerifier(t, NewMinimalNoFaultProofsRuntimeWithConfig(t, cfg), clKind, false, cfg) } func addSingleChainVerifier(t devtest.T, runtime *SingleChainRuntime, clKind MixedL2CLKind, withP2P bool, cfg PresetConfig) *SingleChainRuntime { @@ -55,21 +55,16 @@ func NewSingleChainTwoVerifiersRuntime(t devtest.T) *SingleChainRuntime { } // NewSingleChainTwoVerifiersRuntimeWithConfig adds two verifiers to a minimal runtime without -// fault proofs: "b" derives from L1, and "c" follows "b" as its follow source. The CL kind of each -// node comes from newSingleChainTwoVerifiersCLKinds. +// fault proofs: "b" derives from L1, and "c" follows "b" as its follow source. func NewSingleChainTwoVerifiersRuntimeWithConfig(t devtest.T, cfg PresetConfig) *SingleChainRuntime { - requestedCLKind := ResolveMixedL2CLKind() - clKinds := newSingleChainTwoVerifiersCLKinds(requestedCLKind) - t.Logger().Info("Pinned the L2 CL kind of the sequencer and verifier b; verifier c uses the requested kind", - "requestedKind", requestedCLKind, - "b", clKinds.DerivingVerifier, - "c", clKinds.FollowSourceVerifier, - "sequencer", clKinds.Sequencer, - ) - runtime := addSingleChainVerifier(t, newMinimalNoFaultProofsRuntime(t, cfg, clKinds.Sequencer), clKinds.DerivingVerifier, true, cfg) + // Only "c" takes the requested CL kind; the sequencer and "b" stay on op-node, so a kona-node + // run exercises kona's follow-source mode against an op-node upstream. + followKind := ResolveMixedL2CLKind(t) + t.Logger().Info("Starting two-verifier runtime", "b", MixedL2CLOpNode, "c", followKind, "sequencer", MixedL2CLOpNode) + runtime := addSingleChainVerifier(t, newMinimalNoFaultProofsRuntime(t, cfg, MixedL2CLOpNode), MixedL2CLOpNode, true, cfg) nodeB := runtime.Nodes["b"] t.Require().NotNil(nodeB, "missing single-chain node b") - nodeC := addSingleChainNode(t, runtime, "c", clKinds.FollowSourceVerifier, false, nodeB.CL.UserRPC(), cfg.GlobalL2CLOptions...) + nodeC := addSingleChainNode(t, runtime, "c", followKind, false, nodeB.CL.UserRPC(), cfg.GlobalL2CLOptions...) connectSingleChainNodes(t, runtime.L2EL, runtime.L2CL, nodeC) connectSingleChainNodes(t, nodeB.EL, nodeB.CL, nodeC) @@ -79,24 +74,6 @@ func NewSingleChainTwoVerifiersRuntimeWithConfig(t devtest.T, cfg PresetConfig) return runtime } -type singleChainTwoVerifiersCLKinds struct { - DerivingVerifier MixedL2CLKind - FollowSourceVerifier MixedL2CLKind - Sequencer MixedL2CLKind -} - -// newSingleChainTwoVerifiersCLKinds runs the sequencer and the deriving verifier on op-node -// whatever the requested kind, and only the follow-source verifier on the requested kind, so a -// kona-node run exercises kona's follow-source mode against an op-node upstream rather than kona -// sequencing or derivation. -func newSingleChainTwoVerifiersCLKinds(requested MixedL2CLKind) singleChainTwoVerifiersCLKinds { - return singleChainTwoVerifiersCLKinds{ - DerivingVerifier: MixedL2CLOpNode, - FollowSourceVerifier: requested, - Sequencer: MixedL2CLOpNode, - } -} - func NewSimpleWithSyncTesterRuntime(t devtest.T) *SingleChainRuntime { return NewSimpleWithSyncTesterRuntimeWithConfig(t, PresetConfig{}) } @@ -147,7 +124,7 @@ func NewMinimalWithConductorsRuntime(t devtest.T) *SingleChainRuntime { } func NewMinimalWithConductorsRuntimeWithConfig(t devtest.T, cfg PresetConfig) *SingleChainRuntime { - clKind := ResolveMixedL2CLKind() + clKind := ResolveMixedL2CLKind(t) // The CL and conductor depend on each other's RPC endpoints. Allocate a // stable proxy for each conductor before starting its CL, then attach the // conductor once its dynamically allocated RPC port is known. @@ -186,7 +163,7 @@ func NewMinimalWithConductorsRuntimeWithConfig(t devtest.T, cfg PresetConfig) *S nodeB := addStoppedSingleChainSequencerNode(t, runtime, "b", clKind, candidateELOpts, cfg.GlobalL2CLOptions...) nodeC := addStoppedSingleChainSequencerNode(t, runtime, "c", clKind, candidateELOpts, cfg.GlobalL2CLOptions...) - // A non-candidate node, always stock: it never sequences, so it independently validates every + // A non-candidate node with stock op-reth: it never sequences, so it independently validates every // block the candidates build. Without it an overridden binary on all three members could accept // its own invalid blocks and the run would still pass. nodeVerifier := addSingleChainNode(t, runtime, "verifier", clKind, false, "", cfg.GlobalL2CLOptions...)