-
Notifications
You must be signed in to change notification settings - Fork 5
feat: implement self-healing recovery mechanism for gaps in L1 data #403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jonastheis
wants to merge
18
commits into
main
Choose a base branch
from
feat/self-healing-l1-events
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+721
−83
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
b509314
feat: implement gap recovery mechanism for L1 watcher and use in Chai…
jonastheis 0ea4ef7
make sure that there's no deadlock with command receiver as L1Watcher…
jonastheis 5670af8
feat: add skipping logic for duplicate L1 messages and batch commits …
jonastheis ba20206
remove todo
jonastheis 476d906
use select in watcher main loop
jonastheis f6eaf09
add test to test reset functionality
jonastheis 21588bc
add test for preventing deadlock if send channel is full
jonastheis c907bd4
fmt
jonastheis 10bc36c
add initial test setup
jonastheis 51100a5
add L1WatcherHandleTrait for easier testability
jonastheis 46c09f9
fix deadlock in test
jonastheis b96bda5
add testing of gap recovery for batch
jonastheis abcc90b
fix lint
jonastheis 937b0e0
fix watcher tests
jonastheis f15ffb9
add possibility to filter by processed to get_batch_by_index
jonastheis 02fb909
make test easier to debug by failing instead of hanging
jonastheis 49d38e5
Revert "add possibility to filter by processed to get_batch_by_index"
jonastheis 6a23c25
address review comments
jonastheis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| use crate::L1Notification; | ||
| use std::sync::Arc; | ||
| use tokio::sync::mpsc; | ||
|
|
||
| /// Commands that can be sent to the L1 Watcher. | ||
| #[derive(Debug)] | ||
| pub enum L1WatcherCommand { | ||
| /// Reset the watcher to a specific L1 block number. | ||
| /// | ||
| /// This is used for gap recovery when the chain orchestrator detects missing L1 events. | ||
| ResetToBlock { | ||
| /// The L1 block number to reset to (last known good state) | ||
| block: u64, | ||
| /// New sender to replace the current notification channel | ||
| new_sender: mpsc::Sender<Arc<L1Notification>>, | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| //! Command handle for the L1 Watcher. | ||
|
|
||
| mod command; | ||
|
|
||
| pub use command::L1WatcherCommand; | ||
|
|
||
| use crate::L1Notification; | ||
| use std::sync::Arc; | ||
| use tokio::sync::{mpsc, mpsc::UnboundedSender, oneshot}; | ||
|
|
||
| /// Handle to interact with the L1 Watcher. | ||
| #[derive(Debug)] | ||
| pub struct L1WatcherHandle { | ||
| to_watcher_tx: UnboundedSender<L1WatcherCommand>, | ||
| } | ||
|
|
||
| impl L1WatcherHandle { | ||
| /// Create a new handle with the given command sender. | ||
| pub const fn new(to_watcher_tx: UnboundedSender<L1WatcherCommand>) -> Self { | ||
| Self { to_watcher_tx } | ||
| } | ||
|
|
||
| /// Send a command to the watcher without waiting for a response. | ||
| fn send_command(&self, command: L1WatcherCommand) { | ||
| if let Err(err) = self.to_watcher_tx.send(command) { | ||
| tracing::error!(target: "scroll::watcher", ?err, "Failed to send command to L1 watcher"); | ||
| } | ||
| } | ||
|
|
||
| /// Reset the L1 Watcher to a specific block number with a fresh notification channel. | ||
| /// | ||
| /// Returns an error if the command could not be delivered or the watcher | ||
| /// dropped the response channel. | ||
| pub async fn reset_to_block( | ||
| &self, | ||
| block: u64, | ||
| new_sender: mpsc::Sender<Arc<L1Notification>>, | ||
| ) -> Result<(), oneshot::error::RecvError> { | ||
| self.send_command(L1WatcherCommand::ResetToBlock { block, new_sender }); | ||
|
|
||
| Ok(()) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we create a L1 watcher handle and receiver channel here that can be used for testing?