Display warning on try-runtime spec_name mismatch (#9593)

* Display warning on try-runtime version mismatch

* detect spec-name mismatch in try-runtime

* Update utils/frame/try-runtime/cli/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update utils/frame/try-runtime/cli/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* Update utils/frame/remote-externalities/src/rpc_api.rs

Co-authored-by: Chevdor <chevdor@users.noreply.github.com>

* remove unused import

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Chevdor <chevdor@users.noreply.github.com>
This commit is contained in:
Kian Paimani
2021-08-20 19:41:21 +01:00
committed by GitHub
parent 12bf41d24d
commit 7f53a7f9df
4 changed files with 60 additions and 2 deletions
@@ -88,3 +88,24 @@ async fn build_client<S: AsRef<str>>(from: S) -> Result<WsClient, String> {
.await
.map_err(|e| format!("`WsClientBuilder` failed to build: {:?}", e))
}
/// Get the runtime version of a given chain.
pub async fn get_runtime_version<Block, S>(
from: S,
at: Option<Block::Hash>,
) -> Result<sp_version::RuntimeVersion, String>
where
S: AsRef<str>,
Block: BlockT + serde::de::DeserializeOwned,
Block::Header: HeaderT,
{
let params = if let Some(at) = at { vec![hash_to_json::<Block>(at)?] } else { vec![] };
let client = build_client(from).await?;
client
.request::<sp_version::RuntimeVersion>(
"state_getRuntimeVersion",
JsonRpcParams::Array(params),
)
.await
.map_err(|e| format!("state_getRuntimeVersion request failed: {:?}", e))
}