Skip to content
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

fix(client): Channel reader error handling #539

Merged
merged 2 commits into from
Sep 19, 2024
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
2 changes: 1 addition & 1 deletion bin/client/src/l1/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ where
// Break the loop unless the error signifies that there is not enough data to
// complete the current step. In this case, we retry the step to see if other
// stages can make progress.
if !matches!(e, StageError::NotEnoughData) {
if !matches!(e, StageError::NotEnoughData | StageError::Temporary(_)) {
break;
}
}
Expand Down
6 changes: 4 additions & 2 deletions crates/derive/src/stages/channel_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
stages::{decompress_brotli, BatchQueueProvider},
traits::{OriginAdvancer, OriginProvider, ResettableStage},
};
use anyhow::anyhow;
use op_alloy_genesis::{RollupConfig, SystemConfig};
use op_alloy_protocol::BlockInfo;

Expand Down Expand Up @@ -63,7 +64,8 @@ where
/// Creates the batch reader from available channel data.
async fn set_batch_reader(&mut self) -> StageResult<()> {
if self.next_batch.is_none() {
let channel = self.prev.next_data().await?.ok_or(StageError::NoChannel)?;
let channel =
self.prev.next_data().await?.ok_or(StageError::Temporary(anyhow!("No channel")))?;
self.next_batch = Some(BatchReader::from(&channel[..]));
}
Ok(())
Expand Down Expand Up @@ -244,7 +246,7 @@ mod test {
async fn test_next_batch_batch_reader_no_data() {
let mock = MockChannelReaderProvider::new(vec![Ok(None)]);
let mut reader = ChannelReader::new(mock, Arc::new(RollupConfig::default()));
assert_eq!(reader.next_batch().await, Err(StageError::NoChannel));
assert!(matches!(reader.next_batch().await.unwrap_err(), StageError::Temporary(_)));
assert!(reader.next_batch.is_none());
}

Expand Down