Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Return splittable error from executor params request fn
Browse files Browse the repository at this point in the history
  • Loading branch information
s0me0ne-unkn0wn committed Nov 25, 2022
1 parent 0d06cd3 commit a85038d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
11 changes: 6 additions & 5 deletions node/core/pvf-checker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//! as well as submitting statements regarding them passing or not the PVF pre-checking.

use futures::{channel::oneshot, future::BoxFuture, prelude::*, stream::FuturesUnordered};
use polkadot_node_subsystem_util::{executor_params_at_relay_parent, Error};
use polkadot_node_subsystem_util::{executor_params_at_relay_parent, runtime::Error};

use polkadot_node_subsystem::{
messages::{CandidateValidationMessage, PreCheckOutcome, PvfCheckerMessage, RuntimeApiMessage},
Expand Down Expand Up @@ -540,14 +540,15 @@ async fn initiate_precheck(
let executor_params = match executor_params_at_relay_parent(relay_parent, sender).await {
Ok(executor_params) => executor_params,
Err(err) => {
// Error::Oneshot indicates a failure to communicate with the runtime (probably
// being shut down). Error::RuntimeApi is a failure to acquire either session
// Error::RuntimeRequestCanceled indicates a failure to communicate with the runtime
// (probably being shut down). Error::RuntimeApi is a failure to acquire either session
// index or executor params for the session which indicates a permanent failure to
// run pre-checking on the code provided.
state.currently_checking.push(Box::pin(async move {
match err {
Error::RuntimeApi(_) => Some((PreCheckOutcome::Failed, validation_code_hash)),
Error::Oneshot(_) => None,
Error::RuntimeRequest(_) =>
Some((PreCheckOutcome::Failed, validation_code_hash)),
Error::RuntimeRequestCanceled(_) => None,
_ => unreachable!(), // The callee never generates other error types
}
}));
Expand Down
11 changes: 6 additions & 5 deletions node/subsystem-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#![warn(missing_docs)]

use crate::runtime::Error as SubsysUtilError;
use polkadot_node_subsystem::{
errors::{RuntimeApiError, SubsystemError},
messages::{RuntimeApiMessage, RuntimeApiRequest, RuntimeApiSender},
Expand Down Expand Up @@ -219,21 +220,21 @@ specialize_requests! {
pub async fn executor_params_at_relay_parent(
relay_parent: Hash,
sender: &mut impl overseer::SubsystemSender<RuntimeApiMessage>,
) -> Result<ExecutorParams, Error> {
) -> Result<ExecutorParams, SubsysUtilError> {
match request_session_index_for_child(relay_parent, sender).await.await {
Err(err) => {
// Failed to communicate with the runtime
Err(Error::Oneshot(err))
Err(SubsysUtilError::RuntimeRequestCanceled(err))
},
Ok(Err(err)) => {
// Runtime has failed to obtain a session index at the relay-parent; should never happen
Err(Error::RuntimeApi(err))
Err(SubsysUtilError::RuntimeRequest(err))
},
Ok(Ok(session_index)) => {
match request_session_executor_params(relay_parent, session_index, sender).await.await {
Err(err) => {
// Failed to communicate with the runtime
Err(Error::Oneshot(err))
Err(SubsysUtilError::RuntimeRequestCanceled(err))
},
Ok(Err(_)) => {
// Runtime doesn't yet support the api requested, should execute anyway
Expand All @@ -243,7 +244,7 @@ pub async fn executor_params_at_relay_parent(
Ok(Ok(None)) => {
// Storage doesn't contain a parameter set for the given session; should
// never happen
Err(Error::RuntimeApi(RuntimeApiError::NotSupported {
Err(SubsysUtilError::RuntimeRequest(RuntimeApiError::NotSupported {
runtime_api_name: "SessionExecutorParams",
}))
},
Expand Down

0 comments on commit a85038d

Please sign in to comment.