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

Commit

Permalink
Handle UnknownBlock error
Browse files Browse the repository at this point in the history
  • Loading branch information
tdimitrov committed Nov 15, 2022
1 parent 1ac840a commit b47211f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
20 changes: 14 additions & 6 deletions node/core/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use polkadot_node_subsystem::{
messages::{RuntimeApiMessage, RuntimeApiRequest as Request},
overseer, FromOrchestra, OverseerSignal, SpawnedSubsystem, SubsystemError, SubsystemResult,
};
use polkadot_node_subsystem_types::RuntimeApiSubsystemClient;
use polkadot_node_subsystem_types::{ApiError, RuntimeApiSubsystemClient};
use polkadot_primitives::v2::Hash;

use cache::{RequestResult, RequestResultCache};
Expand Down Expand Up @@ -356,11 +356,19 @@ where
let version: u32 = $version; // enforce type for the version expression
let runtime_version = client.api_version_parachain_host(relay_parent).await
.unwrap_or_else(|e| {
gum::warn!(
target: LOG_TARGET,
"cannot query the runtime API version: {}",
e,
);
if let ApiError::UnknownBlock(s) = e {
gum::warn!(
target: LOG_TARGET,
"cannot query the runtime API version. UnknownBlock error: {}",
s,
);
} else {
gum::warn!(
target: LOG_TARGET,
"cannot query the runtime API version: {}",
e,
);
}
Some(0)
})
.unwrap_or_else(|| {
Expand Down
2 changes: 1 addition & 1 deletion node/subsystem-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub mod errors;
pub mod messages;

mod runtime_client;
pub use runtime_client::RuntimeApiSubsystemClient;
pub use runtime_client::{ApiError, RuntimeApiSubsystemClient};

pub use jaeger::*;
pub use polkadot_node_jaeger as jaeger;
Expand Down
3 changes: 2 additions & 1 deletion node/subsystem-types/src/runtime_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ use polkadot_primitives::{
ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature,
},
};
use sp_api::{ApiError, ApiExt, ProvideRuntimeApi};
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_authority_discovery::AuthorityDiscoveryApi;
use sp_consensus_babe::{BabeApi, Epoch};
use std::collections::BTreeMap;

pub use sp_api::ApiError;
/// Exposes all runtime calls that are used by the runtime API subsystem.
#[async_trait]
pub trait RuntimeApiSubsystemClient {
Expand Down

0 comments on commit b47211f

Please sign in to comment.