Skip to content

Commit

Permalink
fix(client): Channel reader error handling (#539)
Browse files Browse the repository at this point in the history
* fix(client): Channel reader error handling

* fmt
  • Loading branch information
clabby authored Sep 19, 2024
1 parent 2a82bf7 commit a7e2aac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
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

0 comments on commit a7e2aac

Please sign in to comment.