Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b509314
feat: implement gap recovery mechanism for L1 watcher and use in Chai…
jonastheis Oct 30, 2025
0ea4ef7
make sure that there's no deadlock with command receiver as L1Watcher…
jonastheis Oct 30, 2025
5670af8
feat: add skipping logic for duplicate L1 messages and batch commits …
jonastheis Oct 30, 2025
ba20206
remove todo
jonastheis Oct 31, 2025
476d906
use select in watcher main loop
jonastheis Oct 31, 2025
f6eaf09
add test to test reset functionality
jonastheis Oct 31, 2025
21588bc
add test for preventing deadlock if send channel is full
jonastheis Oct 31, 2025
c907bd4
fmt
jonastheis Oct 31, 2025
10bc36c
add initial test setup
jonastheis Nov 4, 2025
51100a5
add L1WatcherHandleTrait for easier testability
jonastheis Nov 4, 2025
46c09f9
fix deadlock in test
jonastheis Nov 4, 2025
b96bda5
add testing of gap recovery for batch
jonastheis Nov 4, 2025
abcc90b
fix lint
jonastheis Nov 5, 2025
937b0e0
fix watcher tests
jonastheis Nov 5, 2025
f15ffb9
add possibility to filter by processed to get_batch_by_index
jonastheis Nov 5, 2025
02fb909
make test easier to debug by failing instead of hanging
jonastheis Nov 5, 2025
49d38e5
Revert "add possibility to filter by processed to get_batch_by_index"
jonastheis Nov 5, 2025
6a23c25
address review comments
jonastheis Nov 5, 2025
dce07df
embed L1Notification channel receiver inside of the L1WatcherHandle
jonastheis Nov 6, 2025
47d35e7
Merge remote-tracking branch 'origin/feat/l1-reorg' into feat/self-he…
jonastheis Nov 12, 2025
f4a999e
fixes after merge
jonastheis Nov 12, 2025
41b3ead
add l1_watcher_command_rx to addons for testing like l1_watcher_tx
jonastheis Nov 12, 2025
90fc085
Merge remote-tracking branch 'origin/feat/l1-reorg' into feat/self-he…
jonastheis Nov 12, 2025
9865e89
move checks into respective functions
jonastheis Nov 12, 2025
2f2960c
implement test for gap detection for batch and L1 messages. fix issue…
jonastheis Nov 13, 2025
d35eba1
implement gap and skip detection for revert events
jonastheis Nov 13, 2025
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
2 changes: 2 additions & 0 deletions crates/chain-orchestrator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ alloy-transport.workspace = true
# rollup-node
scroll-db = { workspace = true, features = ["test-utils"] }
rollup-node-primitives = { workspace = true, features = ["arbitrary"] }
rollup-node-watcher = { workspace = true, features = ["test-utils"] }

# scroll
reth-scroll-chainspec.workspace = true
reth-scroll-forks.workspace = true
reth-scroll-node = { workspace = true, features = ["test-utils"] }

# reth
reth-eth-wire-types.workspace = true
Expand Down
10 changes: 3 additions & 7 deletions crates/chain-orchestrator/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ pub enum ChainOrchestratorError {
/// An L1 message was not found in the database.
#[error("L1 message not found at {0}")]
L1MessageNotFound(L1MessageKey),
/// A gap was detected in the L1 message queue: the previous message before index {0} is
/// missing.
#[error("L1 message queue gap detected at index {0}, previous L1 message not found")]
L1MessageQueueGap(u64),
/// An inconsistency was detected when trying to consolidate the chain.
#[error("Chain inconsistency detected")]
ChainInconsistency,
Expand All @@ -57,9 +53,6 @@ pub enum ChainOrchestratorError {
/// The actual number of blocks.
actual: usize,
},
/// A gap was detected in batch commit events: the previous batch before index {0} is missing.
#[error("Batch commit gap detected at index {0}, previous batch commit not found")]
BatchCommitGap(u64),
/// An error occurred while making a network request.
#[error("Network request error: {0}")]
NetworkRequestError(#[from] reth_network_p2p::error::RequestError),
Expand Down Expand Up @@ -92,6 +85,9 @@ pub enum ChainOrchestratorError {
/// An error occurred while handling rollup node primitives.
#[error("An error occurred while handling rollup node primitives: {0}")]
RollupNodePrimitiveError(rollup_node_primitives::RollupNodePrimitiveError),
/// An error occurred during gap reset.
#[error("Gap reset error: {0}")]
GapResetError(String),
}

impl CanRetry for ChainOrchestratorError {
Expand Down
27 changes: 27 additions & 0 deletions crates/chain-orchestrator/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ pub enum ChainOrchestratorEvent {
/// The L1 block number in which the batch was committed.
l1_block_number: u64,
},
/// A gap has been detected in the committed batches.
BatchCommitGap {
/// The missing batch index.
missing_index: u64,
/// The latest known L1 block number to reset to before the gap.
l1_block_number_reset: u64,
},
/// A duplicate batch commit has been detected.
BatchCommitDuplicate(u64),
/// A batch has been finalized returning a list of finalized batches.
BatchFinalized {
/// The L1 block info at which the batch finalization event was received.
Expand All @@ -57,13 +66,31 @@ pub enum ChainOrchestratorEvent {
/// The new safe head after the revert.
safe_head: BlockInfo,
},
/// A gap has been detected in the reverted batches.
BatchRevertGap {
/// The missing batch index.
missing_index: u64,
/// The latest known L1 block number to reset to before the gap.
l1_block_number_reset: u64,
},
/// A duplicate batch revert has been detected.
BatchRevertDuplicate(u64),
/// A new L1 block has been received returning the L1 block number.
NewL1Block(u64),
/// An L1 block has been finalized returning the L1 block number and the list of finalized
/// batches.
L1BlockFinalized(u64, Vec<BatchInfo>),
/// A `L1Message` event has been committed returning the message queue index.
L1MessageCommitted(u64),
/// A gap has been detected in the L1 message queue.
L1MessageGap {
/// The missing L1 message queue index.
missing_index: u64,
/// The latest known L1 block number to reset to before the gap.
l1_block_number_reset: u64,
},
/// A duplicate L1 message has been detected.
L1MessageDuplicate(u64),
/// A reorg has occurred on L1, returning the L1 block number of the new L1 head,
/// the L1 message queue index of the new L1 head, and optionally the L2 head and safe block
/// info if the reorg resulted in a new L2 head or safe block.
Expand Down
Loading
Loading