Skip to content

Commit

Permalink
fix: propagate error instead of panicking in manual sealing (#2983)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomarQ authored Sep 28, 2024
1 parent 7fb1b17 commit a8fece3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1808,23 +1808,28 @@ where
.client
.header(hash)
.map_err(|e| sp_inherents::Error::Application(Box::new(e)))?
.expect("Best block header should be present")
.ok_or(sp_inherents::Error::Application(
"Best block header should be present".into(),
))?
.digest;
// Get the nimbus id from the digest.
let nimbus_id = digest
.logs
.iter()
.find_map(|x| {
if let DigestItem::PreRuntime(nimbus_primitives::NIMBUS_ENGINE_ID, nimbus_id) = x {
Some(
NimbusId::from_slice(nimbus_id.as_slice())
.expect("Nimbus pre-runtime digest should be valid"),
)
Some(NimbusId::from_slice(nimbus_id.as_slice()).map_err(|_| {
sp_inherents::Error::Application(
"Nimbus pre-runtime digest should be valid".into(),
)
}))
} else {
None
}
})
.expect("Nimbus pre-runtime digest should be present");
.ok_or(sp_inherents::Error::Application(
"Nimbus pre-runtime digest should be present".into(),
))??;
// Remove the old VRF digest.
let pos = digest.logs.iter().position(|x| {
matches!(
Expand Down

0 comments on commit a8fece3

Please sign in to comment.