mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 03:31:10 +00:00
Refactor sc_executor::RuntimeInfo trait into 2 parts (#9498)
* Split native executor stuff from wasm executor stuff * Remove `native_runtime_version` in places * Fix warning * Fix test warning * Remove redundant NativeRuntimeInfo trait * Add a warning for use_native * Run cargo fmt * Revert "Add a warning for use_native" This reverts commit 9494f765a06037e991dd60524f2ed1b14649bfd6.
This commit is contained in:
@@ -37,7 +37,7 @@ use sc_client_api::{
|
||||
};
|
||||
use sc_client_db::{Backend, DatabaseSettings};
|
||||
use sc_consensus::import_queue::ImportQueue;
|
||||
use sc_executor::{NativeExecutionDispatch, NativeExecutor, RuntimeInfo};
|
||||
use sc_executor::{NativeExecutionDispatch, NativeExecutor, RuntimeVersionOf};
|
||||
use sc_keystore::LocalKeystore;
|
||||
use sc_network::{
|
||||
block_request_handler::{self, BlockRequestHandler},
|
||||
@@ -454,7 +454,7 @@ pub fn new_client<E, Block, RA>(
|
||||
>
|
||||
where
|
||||
Block: BlockT,
|
||||
E: CodeExecutor + RuntimeInfo,
|
||||
E: CodeExecutor + RuntimeVersionOf,
|
||||
{
|
||||
let executor = crate::client::LocalCallExecutor::new(
|
||||
backend.clone(),
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use super::{client::ClientConfig, wasm_override::WasmOverride, wasm_substitutes::WasmSubstitutes};
|
||||
use codec::{Decode, Encode};
|
||||
use sc_client_api::{backend, call_executor::CallExecutor, HeaderBackend};
|
||||
use sc_executor::{NativeVersion, RuntimeInfo, RuntimeVersion};
|
||||
use sc_executor::{RuntimeVersion, RuntimeVersionOf};
|
||||
use sp_api::{ProofRecorder, StorageTransactionCache};
|
||||
use sp_core::{
|
||||
traits::{CodeExecutor, RuntimeCode, SpawnNamed},
|
||||
@@ -49,7 +49,7 @@ pub struct LocalCallExecutor<Block: BlockT, B, E> {
|
||||
|
||||
impl<Block: BlockT, B, E> LocalCallExecutor<Block, B, E>
|
||||
where
|
||||
E: CodeExecutor + RuntimeInfo + Clone + 'static,
|
||||
E: CodeExecutor + RuntimeVersionOf + Clone + 'static,
|
||||
B: backend::Backend<Block>,
|
||||
{
|
||||
/// Creates new instance of local call executor.
|
||||
@@ -137,7 +137,7 @@ where
|
||||
impl<B, E, Block> CallExecutor<Block> for LocalCallExecutor<Block, B, E>
|
||||
where
|
||||
B: backend::Backend<Block>,
|
||||
E: CodeExecutor + RuntimeInfo + Clone + 'static,
|
||||
E: CodeExecutor + RuntimeVersionOf + Clone + 'static,
|
||||
Block: BlockT,
|
||||
{
|
||||
type Error = E::Error;
|
||||
@@ -333,25 +333,28 @@ where
|
||||
)
|
||||
.map_err(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
fn native_runtime_version(&self) -> Option<&NativeVersion> {
|
||||
Some(self.executor.native_version())
|
||||
impl<Block, B, E> sp_version::GetRuntimeVersionAt<Block> for LocalCallExecutor<Block, B, E>
|
||||
where
|
||||
B: backend::Backend<Block>,
|
||||
E: CodeExecutor + RuntimeVersionOf + Clone + 'static,
|
||||
Block: BlockT,
|
||||
{
|
||||
fn runtime_version(&self, at: &BlockId<Block>) -> Result<sp_version::RuntimeVersion, String> {
|
||||
CallExecutor::runtime_version(self, at).map_err(|e| format!("{:?}", e))
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block, B, E> sp_version::GetRuntimeVersion<Block> for LocalCallExecutor<Block, B, E>
|
||||
impl<Block, B, E> sp_version::GetNativeVersion for LocalCallExecutor<Block, B, E>
|
||||
where
|
||||
B: backend::Backend<Block>,
|
||||
E: CodeExecutor + RuntimeInfo + Clone + 'static,
|
||||
E: CodeExecutor + sp_version::GetNativeVersion + Clone + 'static,
|
||||
Block: BlockT,
|
||||
{
|
||||
fn native_version(&self) -> &sp_version::NativeVersion {
|
||||
self.executor.native_version()
|
||||
}
|
||||
|
||||
fn runtime_version(&self, at: &BlockId<Block>) -> Result<sp_version::RuntimeVersion, String> {
|
||||
CallExecutor::runtime_version(self, at).map_err(|e| format!("{:?}", e))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -96,7 +96,7 @@ use std::{
|
||||
use {
|
||||
super::call_executor::LocalCallExecutor,
|
||||
sc_client_api::in_mem,
|
||||
sc_executor::RuntimeInfo,
|
||||
sc_executor::RuntimeVersionOf,
|
||||
sp_core::traits::{CodeExecutor, SpawnNamed},
|
||||
};
|
||||
|
||||
@@ -169,7 +169,7 @@ pub fn new_in_mem<E, Block, S, RA>(
|
||||
Client<in_mem::Backend<Block>, LocalCallExecutor<Block, in_mem::Backend<Block>, E>, Block, RA>,
|
||||
>
|
||||
where
|
||||
E: CodeExecutor + RuntimeInfo,
|
||||
E: CodeExecutor + RuntimeVersionOf,
|
||||
S: BuildStorage,
|
||||
Block: BlockT,
|
||||
{
|
||||
@@ -227,7 +227,7 @@ pub fn new_with_backend<B, E, Block, S, RA>(
|
||||
config: ClientConfig<Block>,
|
||||
) -> sp_blockchain::Result<Client<B, LocalCallExecutor<Block, B, E>, Block, RA>>
|
||||
where
|
||||
E: CodeExecutor + RuntimeInfo,
|
||||
E: CodeExecutor + RuntimeVersionOf,
|
||||
S: BuildStorage,
|
||||
Block: BlockT,
|
||||
B: backend::LocalBackend<Block> + 'static,
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use prometheus_endpoint::Registry;
|
||||
use sc_executor::RuntimeInfo;
|
||||
use sc_executor::RuntimeVersionOf;
|
||||
use sc_telemetry::TelemetryHandle;
|
||||
use sp_blockchain::Result as ClientResult;
|
||||
use sp_core::traits::{CodeExecutor, SpawnNamed};
|
||||
@@ -59,7 +59,7 @@ pub fn new_light<B, S, RA, E>(
|
||||
where
|
||||
B: BlockT,
|
||||
S: BlockchainStorage<B> + 'static,
|
||||
E: CodeExecutor + RuntimeInfo + Clone + 'static,
|
||||
E: CodeExecutor + RuntimeVersionOf + Clone + 'static,
|
||||
{
|
||||
let local_executor = LocalCallExecutor::new(
|
||||
backend.clone(),
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
//! A custom WASM blob will override on-chain WASM if the spec version matches. If it is
|
||||
//! required to overrides multiple runtimes, multiple WASM blobs matching each of the spec versions
|
||||
//! needed must be provided in the given directory.
|
||||
use sc_executor::RuntimeInfo;
|
||||
use sc_executor::RuntimeVersionOf;
|
||||
use sp_blockchain::Result;
|
||||
use sp_core::traits::{FetchRuntimeCode, RuntimeCode};
|
||||
use sp_state_machine::BasicExternalities;
|
||||
@@ -112,7 +112,7 @@ pub struct WasmOverride<E> {
|
||||
|
||||
impl<E> WasmOverride<E>
|
||||
where
|
||||
E: RuntimeInfo + Clone + 'static,
|
||||
E: RuntimeVersionOf + Clone + 'static,
|
||||
{
|
||||
pub fn new<P>(path: P, executor: E) -> Result<Self>
|
||||
where
|
||||
@@ -192,7 +192,7 @@ where
|
||||
#[cfg(test)]
|
||||
pub fn dummy_overrides<E>(executor: &E) -> WasmOverride<E>
|
||||
where
|
||||
E: RuntimeInfo + Clone + 'static,
|
||||
E: RuntimeVersionOf + Clone + 'static,
|
||||
{
|
||||
let mut overrides = HashMap::new();
|
||||
overrides.insert(0, WasmBlob::new(vec![0, 0, 0, 0, 0, 0, 0, 0]));
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
use parking_lot::RwLock;
|
||||
use sc_client_api::backend;
|
||||
use sc_executor::RuntimeInfo;
|
||||
use sc_executor::RuntimeVersionOf;
|
||||
use sp_blockchain::{HeaderBackend, Result};
|
||||
use sp_core::traits::{FetchRuntimeCode, RuntimeCode};
|
||||
use sp_runtime::{
|
||||
@@ -139,7 +139,7 @@ impl<Block: BlockT, Executor: Clone, Backend> Clone for WasmSubstitutes<Block, E
|
||||
|
||||
impl<Executor, Backend, Block> WasmSubstitutes<Block, Executor, Backend>
|
||||
where
|
||||
Executor: RuntimeInfo + Clone + 'static,
|
||||
Executor: RuntimeVersionOf + Clone + 'static,
|
||||
Backend: backend::Backend<Block>,
|
||||
Block: BlockT,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user