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

Commit b47211f

Browse files
committed
Handle UnknownBlock error
1 parent 1ac840a commit b47211f

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

node/core/runtime-api/src/lib.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use polkadot_node_subsystem::{
2727
messages::{RuntimeApiMessage, RuntimeApiRequest as Request},
2828
overseer, FromOrchestra, OverseerSignal, SpawnedSubsystem, SubsystemError, SubsystemResult,
2929
};
30-
use polkadot_node_subsystem_types::RuntimeApiSubsystemClient;
30+
use polkadot_node_subsystem_types::{ApiError, RuntimeApiSubsystemClient};
3131
use polkadot_primitives::v2::Hash;
3232

3333
use cache::{RequestResult, RequestResultCache};
@@ -356,11 +356,19 @@ where
356356
let version: u32 = $version; // enforce type for the version expression
357357
let runtime_version = client.api_version_parachain_host(relay_parent).await
358358
.unwrap_or_else(|e| {
359-
gum::warn!(
360-
target: LOG_TARGET,
361-
"cannot query the runtime API version: {}",
362-
e,
363-
);
359+
if let ApiError::UnknownBlock(s) = e {
360+
gum::warn!(
361+
target: LOG_TARGET,
362+
"cannot query the runtime API version. UnknownBlock error: {}",
363+
s,
364+
);
365+
} else {
366+
gum::warn!(
367+
target: LOG_TARGET,
368+
"cannot query the runtime API version: {}",
369+
e,
370+
);
371+
}
364372
Some(0)
365373
})
366374
.unwrap_or_else(|| {

node/subsystem-types/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub mod errors;
3131
pub mod messages;
3232

3333
mod runtime_client;
34-
pub use runtime_client::RuntimeApiSubsystemClient;
34+
pub use runtime_client::{ApiError, RuntimeApiSubsystemClient};
3535

3636
pub use jaeger::*;
3737
pub use polkadot_node_jaeger as jaeger;

node/subsystem-types/src/runtime_client.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ use polkadot_primitives::{
2525
ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex, ValidatorSignature,
2626
},
2727
};
28-
use sp_api::{ApiError, ApiExt, ProvideRuntimeApi};
28+
use sp_api::{ApiExt, ProvideRuntimeApi};
2929
use sp_authority_discovery::AuthorityDiscoveryApi;
3030
use sp_consensus_babe::{BabeApi, Epoch};
3131
use std::collections::BTreeMap;
3232

33+
pub use sp_api::ApiError;
3334
/// Exposes all runtime calls that are used by the runtime API subsystem.
3435
#[async_trait]
3536
pub trait RuntimeApiSubsystemClient {

0 commit comments

Comments
 (0)