Skip to content
Closed
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
18 changes: 0 additions & 18 deletions op-acceptance-tests/tests/sync/elsync/reorg/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,6 @@ func TestUnsafeGapFillAfterSafeReorg(gt *testing.T) {
// 4. Verifier then backfills and closes the unsafe gap once reconnected via CLP2P.
func TestUnsafeGapFillAfterUnsafeReorg_RestartL2CL(gt *testing.T) {
t := devtest.ParallelT(gt)
// Example error with kona-node:
//
// assertions.go:387: ERROR[03-30|22:17:07.231]
// assertions.go:387: Error Trace: /optimism/op-devstack/dsl/l2_el.go:204
// assertions.go:387: /optimism/op-acceptance-tests/tests/sync/elsync/reorg/sync_test.go:211
// assertions.go:387: Error: Received unexpected error:
// assertions.go:387: operation failed permanently after 30 attempts: expected head to reorg 0x893d77533b0ff9b37a92090679bf256d987b4535f06186ec71f29e68ddccd9a5:14, but got 0x893d77533b0ff9b37a92090679bf256d987b4535f06186ec71f29e68ddccd9a5:14
// assertions.go:387: Test: TestUnsafeGapFillAfterUnsafeReorg_RestartL2CL
sysgo.SkipOnKonaNode(t, "not supported (timeout)")
sys := newReorgSystem(t)
require := t.Require()
logger := t.Logger()
Expand Down Expand Up @@ -259,15 +250,6 @@ func TestUnsafeGapFillAfterUnsafeReorg_RestartL2CL(gt *testing.T) {
// 4. CLP2P is restored Verifier, the verifier backfills and the unsafe gap is closed.
func TestUnsafeGapFillAfterUnsafeReorg_RestartCLP2P(gt *testing.T) {
t := devtest.ParallelT(gt)
// Example error with kona-node:
//
// assertions.go:387: ERROR[03-31|11:15:39.398]
// assertions.go:387: Error Trace: /optimism/op-devstack/dsl/l2_el.go:204
// assertions.go:387: /optimism/op-acceptance-tests/tests/sync/elsync/reorg/sync_test.go:356
// assertions.go:387: Error: Received unexpected error:
// assertions.go:387: operation failed permanently after 30 attempts: expected head to reorg 0x166970054ad16ad090210e5d1045538eeccd2afd88ea991b010de026d0106870:18, but got 0x166970054ad16ad090210e5d1045538eeccd2afd88ea991b010de026d0106870:18
// assertions.go:387: Test: TestUnsafeGapFillAfterUnsafeReorg_RestartCLP2P
sysgo.SkipOnKonaNode(t, "not supported (timeout)")
sys := newReorgSystem(t)
require := t.Require()
logger := t.Logger()
Expand Down
1 change: 1 addition & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/kona/bin/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ op-alloy-network.workspace = true
# general
url.workspace = true
dirs.workspace = true
humantime.workspace = true
strum.workspace = true
discv5.workspace = true
enr.workspace = true
Expand Down
15 changes: 14 additions & 1 deletion rust/kona/bin/node/src/commands/node/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use anyhow::{Context as _, Result, bail};
use backon::{ExponentialBuilder, Retryable};
use clap::Parser;
use kona_cli::{LogConfig, MetricsArgs};
use kona_engine::EngineClient;
use kona_engine::{DEFAULT_EL_SYNC_SAFE_OFFSET, EngineClient};
use kona_genesis::{L1ChainConfig, RollupConfig};
use kona_interop::DependencySet;
use kona_node_service::{EngineConfig, L1ConfigBuilder, NodeMode, RollupNodeBuilder};
Expand All @@ -25,6 +25,7 @@ use std::{
io::{Read, Write},
path::PathBuf,
sync::Arc,
time::Duration,
};
use strum::IntoEnumIterator;
use tracing::{debug, error, info};
Expand Down Expand Up @@ -126,6 +127,16 @@ pub struct NodeCommand {
/// Reorgs are supported, but may be slow to recover from.
#[arg(long = "verifier.l1-confs", env = "KONA_NODE_VERIFIER_L1_CONFS", default_value_t = 0)]
pub verifier_l1_confs: u64,
/// After execution-layer sync, or when the execution layer's forkchoice labels are behind its
/// chain, set the safe and finalized heads this far behind the synced tip (converted to L2
/// blocks with ceiling division). Mirrors op-node's `--syncmode.offset-el-safe`.
#[arg(
long = "syncmode.offset-el-safe",
env = "KONA_NODE_SYNCMODE_OFFSET_EL_SAFE",
default_value = "12h",
value_parser = humantime::parse_duration,
)]
pub el_sync_safe_offset: Duration,
/// P2P CLI arguments.
#[command(flatten)]
pub p2p_flags: P2PArgs,
Expand All @@ -148,6 +159,7 @@ impl Default for NodeCommand {
interop_dependency_set: None,
safedb_path: None,
verifier_l1_confs: 0,
el_sync_safe_offset: DEFAULT_EL_SYNC_SAFE_OFFSET,
node_mode: NodeMode::Validator,
p2p_flags: P2PArgs::default(),
rpc_flags: RpcArgs::default(),
Expand Down Expand Up @@ -349,6 +361,7 @@ impl NodeCommand {
.with_dependency_set(dependency_set)
.with_safe_db(safe_db)
.with_verifier_l1_confs(self.verifier_l1_confs)
.with_el_sync_safe_offset(self.el_sync_safe_offset)
.build()
.start()
.await
Expand Down
27 changes: 27 additions & 0 deletions rust/kona/bin/node/src/commands/node/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,33 @@ fn verifier_confirmation_depth_has_the_expected_environment_variable() {
assert_eq!(arg.get_env().unwrap(), "KONA_NODE_VERIFIER_L1_CONFS");
}

/// Like op-node, the EL-sync safe offset defaults to 12h and takes durations such as `30m`.
#[rstest::rstest]
#[case::default(None, 12 * 60 * 60)]
#[case::minutes(Some("30m"), 30 * 60)]
#[case::disabled(Some("0s"), 0)]
fn el_sync_safe_offset_parses_durations(#[case] flag: Option<&str>, #[case] seconds: u64) {
let flag = flag.map(|value| ["--syncmode.offset-el-safe", value]);
let args = NodeCommand::parse_from(
std::iter::once("node")
.chain(default_flags().iter().copied())
.chain(flag.into_iter().flatten()),
);
assert_eq!(args.el_sync_safe_offset, std::time::Duration::from_secs(seconds));
}

#[test]
fn el_sync_safe_offset_default_matches_the_engine() {
assert_eq!(
NodeCommand::default().el_sync_safe_offset,
kona_engine::DEFAULT_EL_SYNC_SAFE_OFFSET
);
use clap::CommandFactory;
let command = NodeCommand::command();
let arg = command.get_arguments().find(|arg| arg.get_id() == "el_sync_safe_offset").unwrap();
assert_eq!(arg.get_env().unwrap(), "KONA_NODE_SYNCMODE_OFFSET_EL_SAFE");
}

#[test]
fn test_node_cli_missing_l1_eth_rpc() {
let err = NodeCommand::try_parse_from(["node"]).unwrap_err();
Expand Down
4 changes: 3 additions & 1 deletion rust/kona/crates/node/engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ mod metrics;
pub use metrics::Metrics;

mod sync;
pub use sync::{L2ForkchoiceState, SyncStartError, find_starting_forkchoice};
pub use sync::{
DEFAULT_EL_SYNC_SAFE_OFFSET, L2ForkchoiceState, SyncStartError, find_starting_forkchoice,
};

#[cfg(any(test, feature = "test-utils"))]
/// Utilities that are useful when creating unit tests using structs within this library.
Expand Down
9 changes: 9 additions & 0 deletions rust/kona/crates/node/engine/src/sync/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ use thiserror::Error;
/// An error that can occur during the sync start process.
#[derive(Error, Debug)]
pub enum SyncStartError {
/// The canonical L1 view changed during recovery; retry with a fresh view.
#[error("Canonical chain changed during sync-start recovery")]
ChainViewChanged,
/// An rpc error occurred
#[error("An RPC error occurred: {0}")]
RpcError(#[from] RpcError<TransportErrorKind>),
Expand All @@ -29,6 +32,12 @@ pub enum SyncStartError {
/// Finalized block mismatch
#[error("Finalized block mismatch. Expected {0}, Got {1}")]
MismatchedFinalizedBlock(B256, B256),
/// Recovery would rewind the unsafe origin by more than op-node's five lookback windows.
#[error("L1 reorg exceeds five sync lookback windows")]
ReorgTooDeep,
/// The finalized L2 block's L1 origin is no longer canonical, so L1 reorged below finality.
#[error("Finalized L2 block's L1 origin is no longer canonical")]
FinalizedL1OriginReplaced,
/// L1 origin mismatch.
#[error("L1 origin mismatch")]
L1OriginMismatch,
Expand Down
Loading
Loading