Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions op-acceptance-tests/tests/sdm/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
70 changes: 30 additions & 40 deletions op-acceptance-tests/tests/sync/follow_l2/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -17,28 +16,15 @@ 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()

// Takes about 2 minutes for L1 finalization
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,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -126,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)
Expand Down Expand Up @@ -159,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),
Expand All @@ -170,18 +164,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
Expand Down Expand Up @@ -255,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)
Expand Down
2 changes: 1 addition & 1 deletion op-devstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment thread
joshklop marked this conversation as resolved.
Resolved
- `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)

Expand Down
9 changes: 9 additions & 0 deletions op-devstack/presets/option_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion op-devstack/presets/singlechain_twoverifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 12 additions & 6 deletions op-devstack/sysgo/mixed_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (see startL2CLForKey).
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 (
Expand Down
28 changes: 28 additions & 0 deletions op-devstack/sysgo/mixed_runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Comment thread
joshklop marked this conversation as resolved.
Resolved
{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) })
Comment thread
joshklop marked this conversation as resolved.
Resolved
require.Contains(t, dt.failure, "DEVSTACK_L2CL_KIND")
})
}
}
38 changes: 14 additions & 24 deletions op-devstack/sysgo/singlechain_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -105,28 +101,32 @@ 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 {
Comment thread
einar-oplabs marked this conversation as resolved.
Resolved
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,
NoDiscovery: true,
L2FollowSource: followSource,
L2CLOptions: l2CLOpts,
})
default:
t.Require().FailNowf("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,
Expand All @@ -137,25 +137,29 @@ 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{
L2CLConfig: resolveKonaL2CLConfig(t, key, l2Net.ChainID(), true, "", l2CLOpts),
SequencerStopped: true,
},
)
default: // op-node
case MixedL2CLOpNode:
return startL2CLNode(t, keys, l1Net, l2Net, l1EL, l1CL, l2EL, jwtSecret, l2CLNodeStartConfig{
Key: key,
IsSequencer: true,
NoDiscovery: true,
L2CLOptions: l2CLOpts,
SequencerStopped: true,
})
default:
t.Require().FailNowf("unsupported L2 CL kind", "unknown L2 CL kind %q", clKind)
return nil // unreachable
}
}

Expand Down Expand Up @@ -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
Expand Down
28 changes: 25 additions & 3 deletions op-devstack/sysgo/singlechain_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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")
})
}
}
}
Loading
Loading