Skip to content

Commit

Permalink
chore: Box StageError variant in PipelineError
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected committed Dec 6, 2024
1 parent 552c623 commit d3d6be4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
6 changes: 3 additions & 3 deletions crates/consensus/beacon/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,7 @@ mod tests {
.await;
assert_matches!(
res.await,
Ok(Err(BeaconConsensusEngineError::Pipeline(n))) if matches!(*n.as_ref(),PipelineError::Stage(StageError::ChannelClosed))
Ok(Err(BeaconConsensusEngineError::Pipeline(n))) if matches!(*n.as_ref(),PipelineError::Stage( .. ))
);
}

Expand Down Expand Up @@ -2089,7 +2089,7 @@ mod tests {
Ok(result) => {
assert_matches!(
result,
Err(BeaconConsensusEngineError::Pipeline(n)) if matches!(*n.as_ref(), PipelineError::Stage(StageError::ChannelClosed))
Err(BeaconConsensusEngineError::Pipeline(n)) if matches!(*n.as_ref(), PipelineError::Stage( .. ))
);
break
}
Expand Down Expand Up @@ -2141,7 +2141,7 @@ mod tests {

assert_matches!(
rx.await,
Ok(Err(BeaconConsensusEngineError::Pipeline(n))) if matches!(*n.as_ref(),PipelineError::Stage(StageError::ChannelClosed))
Ok(Err(BeaconConsensusEngineError::Pipeline(n))) if matches!(*n.as_ref(),PipelineError::Stage( .. ))
);
}

Expand Down
1 change: 1 addition & 0 deletions crates/stages/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ reth-errors.workspace = true
reth-stages-types.workspace = true
reth-static-file-types.workspace = true

# alloy
alloy-primitives.workspace = true

# metrics
Expand Down
8 changes: 7 additions & 1 deletion crates/stages/api/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl From<std::io::Error> for StageError {
pub enum PipelineError {
/// The pipeline encountered an irrecoverable error in one of the stages.
#[error(transparent)]
Stage(#[from] StageError),
Stage(Box<dyn core::error::Error + Send + Sync>),
/// The pipeline encountered a database error.
#[error(transparent)]
Database(#[from] DatabaseError),
Expand All @@ -167,3 +167,9 @@ pub enum PipelineError {
#[error("unexpected unwind")]
UnexpectedUnwind,
}

impl From<StageError> for PipelineError {
fn from(value: StageError) -> Self {
Self::Stage(Box::new(value))
}
}
9 changes: 2 additions & 7 deletions crates/stages/api/src/pipeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ impl<N: ProviderNodeTypes> Pipeline<N> {
Err(err) => {
self.event_sender.notify(PipelineEvent::Error { stage_id });

return Err(PipelineError::Stage(StageError::Fatal(Box::new(err))))
return Err(PipelineError::Stage(Box::new(StageError::Fatal(Box::new(err)))))
}
}
}
Expand Down Expand Up @@ -1111,11 +1111,6 @@ mod tests {
StaticFileProducer::new(provider_factory.clone(), PruneModes::default()),
);
let result = pipeline.run().await;
assert_matches!(
result,
Err(PipelineError::Stage(StageError::DatabaseIntegrity(
ProviderError::BlockBodyIndicesNotFound(5)
)))
);
assert_matches!(result, Err(PipelineError::Stage(..)));
}
}

0 comments on commit d3d6be4

Please sign in to comment.