Upgrade Substrate & Polkadot (#583)

This commit is contained in:
Bastian Köcher
2021-08-22 21:22:36 +02:00
committed by GitHub
parent 102a1d5428
commit 52bc169b52
8 changed files with 1051 additions and 1416 deletions
Generated
+832 -1319
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -63,7 +63,7 @@ sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch =
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" } substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" }
# RPC related dependencies # RPC related dependencies
jsonrpc-core = "15.1.0" jsonrpc-core = "18.0.0"
sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "master" } frame-rpc-system = { package = "substrate-frame-rpc-system", git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" } pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
+1 -1
View File
@@ -370,7 +370,7 @@ impl pallet_xcm::Config for Runtime {
type XcmExecuteFilter = Everything; type XcmExecuteFilter = Everything;
type XcmExecutor = XcmExecutor<XcmConfig>; type XcmExecutor = XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything; type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = (); type XcmReserveTransferFilter = frame_support::traits::Nothing;
type Weigher = FixedWeightBounds<UnitWeightCost, Call>; type Weigher = FixedWeightBounds<UnitWeightCost, Call>;
type LocationInverter = LocationInverter<Ancestry>; type LocationInverter = LocationInverter<Ancestry>;
} }
-4
View File
@@ -583,10 +583,6 @@ impl CliConfiguration<Self> for RelayChainCli {
self.base.base.rpc_cors(is_dev) self.base.base.rpc_cors(is_dev)
} }
fn telemetry_external_transport(&self) -> Result<Option<sc_service::config::ExtTransport>> {
self.base.base.telemetry_external_transport()
}
fn default_heap_pages(&self) -> Result<Option<u64>> { fn default_heap_pages(&self) -> Result<Option<u64>> {
self.base.base.default_heap_pages() self.base.base.default_heap_pages()
} }
+172 -67
View File
@@ -27,6 +27,7 @@ use cumulus_primitives_core::{
relay_chain::v1::{Hash as PHash, PersistedValidationData}, relay_chain::v1::{Hash as PHash, PersistedValidationData},
ParaId, ParaId,
}; };
use polkadot_service::NativeExecutionDispatch;
use crate::rpc; use crate::rpc;
pub use parachains_common::{AccountId, Balance, Block, Hash, Header, Index as Nonce}; pub use parachains_common::{AccountId, Balance, Block, Hash, Header, Index as Nonce};
@@ -38,8 +39,7 @@ use sc_consensus::{
import_queue::{BasicQueue, Verifier as VerifierT}, import_queue::{BasicQueue, Verifier as VerifierT},
BlockImportParams, BlockImportParams,
}; };
use sc_executor::native_executor_instance; use sc_executor::NativeElseWasmExecutor;
pub use sc_executor::NativeExecutor;
use sc_network::NetworkService; use sc_network::NetworkService;
use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager}; use sc_service::{Configuration, PartialComponents, Role, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
@@ -54,43 +54,80 @@ use sp_runtime::{
use std::sync::Arc; use std::sync::Arc;
use substrate_prometheus_endpoint::Registry; use substrate_prometheus_endpoint::Registry;
// Native executor instance. /// Native executor instance.
native_executor_instance!( pub struct RococoParachainRuntimeExecutor;
pub RococoParachainRuntimeExecutor,
rococo_parachain_runtime::api::dispatch,
rococo_parachain_runtime::native_version,
);
// Native executor instance. impl sc_executor::NativeExecutionDispatch for RococoParachainRuntimeExecutor {
native_executor_instance!( type ExtendHostFunctions = ();
pub ShellRuntimeExecutor,
shell_runtime::api::dispatch, fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
shell_runtime::native_version, rococo_parachain_runtime::api::dispatch(method, data)
); }
fn native_version() -> sc_executor::NativeVersion {
rococo_parachain_runtime::native_version()
}
}
/// Native executor instance.
pub struct ShellRuntimeExecutor;
impl sc_executor::NativeExecutionDispatch for ShellRuntimeExecutor {
type ExtendHostFunctions = ();
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
shell_runtime::api::dispatch(method, data)
}
fn native_version() -> sc_executor::NativeVersion {
shell_runtime::native_version()
}
}
// Native Statemint executor instance. // Native Statemint executor instance.
native_executor_instance!( pub struct StatemintRuntimeExecutor;
pub StatemintRuntimeExecutor,
statemint_runtime::api::dispatch,
statemint_runtime::native_version,
frame_benchmarking::benchmarking::HostFunctions,
);
// Native Statemine executor instance. impl sc_executor::NativeExecutionDispatch for StatemintRuntimeExecutor {
native_executor_instance!( type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
pub StatemineRuntimeExecutor,
statemine_runtime::api::dispatch,
statemine_runtime::native_version,
frame_benchmarking::benchmarking::HostFunctions,
);
// Native Westmint executor instance. fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
native_executor_instance!( statemint_runtime::api::dispatch(method, data)
pub WestmintRuntimeExecutor, }
westmint_runtime::api::dispatch,
westmint_runtime::native_version, fn native_version() -> sc_executor::NativeVersion {
frame_benchmarking::benchmarking::HostFunctions, statemint_runtime::native_version()
); }
}
/// Native Statemine executor instance.
pub struct StatemineRuntimeExecutor;
impl sc_executor::NativeExecutionDispatch for StatemineRuntimeExecutor {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
statemine_runtime::api::dispatch(method, data)
}
fn native_version() -> sc_executor::NativeVersion {
statemine_runtime::native_version()
}
}
/// Native Westmint executor instance.
pub struct WestmintRuntimeExecutor;
impl sc_executor::NativeExecutionDispatch for WestmintRuntimeExecutor {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
westmint_runtime::api::dispatch(method, data)
}
fn native_version() -> sc_executor::NativeVersion {
westmint_runtime::native_version()
}
}
/// Starts a `ServiceBuilder` for a full service. /// Starts a `ServiceBuilder` for a full service.
/// ///
@@ -101,17 +138,23 @@ pub fn new_partial<RuntimeApi, Executor, BIQ>(
build_import_queue: BIQ, build_import_queue: BIQ,
) -> Result< ) -> Result<
PartialComponents< PartialComponents<
TFullClient<Block, RuntimeApi, Executor>, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
TFullBackend<Block>, TFullBackend<Block>,
(), (),
sc_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>, sc_consensus::DefaultImportQueue<
sc_transaction_pool::FullPool<Block, TFullClient<Block, RuntimeApi, Executor>>, Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
>,
sc_transaction_pool::FullPool<
Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
>,
(Option<Telemetry>, Option<TelemetryWorkerHandle>), (Option<Telemetry>, Option<TelemetryWorkerHandle>),
>, >,
sc_service::Error, sc_service::Error,
> >
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, Executor>> RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>
+ Send + Send
+ Sync + Sync
+ 'static, + 'static,
@@ -124,14 +167,17 @@ where
> + sp_offchain::OffchainWorkerApi<Block> > + sp_offchain::OffchainWorkerApi<Block>
+ sp_block_builder::BlockBuilder<Block>, + sp_block_builder::BlockBuilder<Block>,
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static, Executor: NativeExecutionDispatch + 'static,
BIQ: FnOnce( BIQ: FnOnce(
Arc<TFullClient<Block, RuntimeApi, Executor>>, Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
&Configuration, &Configuration,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>, sc_consensus::DefaultImportQueue<
Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
>,
sc_service::Error, sc_service::Error,
>, >,
{ {
@@ -146,10 +192,17 @@ where
}) })
.transpose()?; .transpose()?;
let executor = sc_executor::NativeElseWasmExecutor::<Executor>::new(
config.wasm_method,
config.default_heap_pages,
config.max_runtime_instances,
);
let (client, backend, keystore_container, task_manager) = let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, Executor>( sc_service::new_full_parts::<Block, RuntimeApi, _>(
&config, &config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
executor,
)?; )?;
let client = Arc::new(client); let client = Arc::new(client);
@@ -200,9 +253,12 @@ async fn start_shell_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
rpc_ext_builder: RB, rpc_ext_builder: RB,
build_import_queue: BIQ, build_import_queue: BIQ,
build_consensus: BIC, build_consensus: BIC,
) -> sc_service::error::Result<(TaskManager, Arc<TFullClient<Block, RuntimeApi, Executor>>)> ) -> sc_service::error::Result<(
TaskManager,
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
)>
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, Executor>> RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>
+ Send + Send
+ Sync + Sync
+ 'static, + 'static,
@@ -218,26 +274,34 @@ where
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>, sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static, Executor: sc_executor::NativeExecutionDispatch + 'static,
RB: Fn( RB: Fn(
Arc<TFullClient<Block, RuntimeApi, Executor>>, Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
) -> Result<jsonrpc_core::IoHandler<sc_rpc::Metadata>, sc_service::Error> ) -> Result<jsonrpc_core::IoHandler<sc_rpc::Metadata>, sc_service::Error>
+ Send + Send
+ 'static, + 'static,
BIQ: FnOnce( BIQ: FnOnce(
Arc<TFullClient<Block, RuntimeApi, Executor>>, Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
&Configuration, &Configuration,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>, sc_consensus::DefaultImportQueue<
Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
>,
sc_service::Error, sc_service::Error,
>, >,
BIC: FnOnce( BIC: FnOnce(
Arc<TFullClient<Block, RuntimeApi, Executor>>, Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
Option<&Registry>, Option<&Registry>,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
&polkadot_service::NewFull<polkadot_service::Client>, &polkadot_service::NewFull<polkadot_service::Client>,
Arc<sc_transaction_pool::FullPool<Block, TFullClient<Block, RuntimeApi, Executor>>>, Arc<
sc_transaction_pool::FullPool<
Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
>,
>,
Arc<NetworkService<Block, Hash>>, Arc<NetworkService<Block, Hash>>,
SyncCryptoStorePtr, SyncCryptoStorePtr,
bool, bool,
@@ -365,9 +429,12 @@ async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
_rpc_ext_builder: RB, _rpc_ext_builder: RB,
build_import_queue: BIQ, build_import_queue: BIQ,
build_consensus: BIC, build_consensus: BIC,
) -> sc_service::error::Result<(TaskManager, Arc<TFullClient<Block, RuntimeApi, Executor>>)> ) -> sc_service::error::Result<(
TaskManager,
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
)>
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, Executor>> RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>
+ Send + Send
+ Sync + Sync
+ 'static, + 'static,
@@ -390,21 +457,29 @@ where
+ Send + Send
+ 'static, + 'static,
BIQ: FnOnce( BIQ: FnOnce(
Arc<TFullClient<Block, RuntimeApi, Executor>>, Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
&Configuration, &Configuration,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>, sc_consensus::DefaultImportQueue<
Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
>,
sc_service::Error, sc_service::Error,
> + 'static, > + 'static,
BIC: FnOnce( BIC: FnOnce(
Arc<TFullClient<Block, RuntimeApi, Executor>>, Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
Option<&Registry>, Option<&Registry>,
Option<TelemetryHandle>, Option<TelemetryHandle>,
&TaskManager, &TaskManager,
&polkadot_service::NewFull<polkadot_service::Client>, &polkadot_service::NewFull<polkadot_service::Client>,
Arc<sc_transaction_pool::FullPool<Block, TFullClient<Block, RuntimeApi, Executor>>>, Arc<
sc_transaction_pool::FullPool<
Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
>,
>,
Arc<NetworkService<Block, Hash>>, Arc<NetworkService<Block, Hash>>,
SyncCryptoStorePtr, SyncCryptoStorePtr,
bool, bool,
@@ -536,7 +611,11 @@ where
/// Build the import queue for the rococo parachain runtime. /// Build the import queue for the rococo parachain runtime.
pub fn rococo_parachain_build_import_queue( pub fn rococo_parachain_build_import_queue(
client: Arc< client: Arc<
TFullClient<Block, rococo_parachain_runtime::RuntimeApi, RococoParachainRuntimeExecutor>, TFullClient<
Block,
rococo_parachain_runtime::RuntimeApi,
NativeElseWasmExecutor<RococoParachainRuntimeExecutor>,
>,
>, >,
config: &Configuration, config: &Configuration,
telemetry: Option<TelemetryHandle>, telemetry: Option<TelemetryHandle>,
@@ -544,7 +623,11 @@ pub fn rococo_parachain_build_import_queue(
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<
Block, Block,
TFullClient<Block, rococo_parachain_runtime::RuntimeApi, RococoParachainRuntimeExecutor>, TFullClient<
Block,
rococo_parachain_runtime::RuntimeApi,
NativeElseWasmExecutor<RococoParachainRuntimeExecutor>,
>,
>, >,
sc_service::Error, sc_service::Error,
> { > {
@@ -587,7 +670,13 @@ pub async fn start_rococo_parachain_node(
id: ParaId, id: ParaId,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(
TaskManager, TaskManager,
Arc<TFullClient<Block, rococo_parachain_runtime::RuntimeApi, RococoParachainRuntimeExecutor>>, Arc<
TFullClient<
Block,
rococo_parachain_runtime::RuntimeApi,
NativeElseWasmExecutor<RococoParachainRuntimeExecutor>,
>,
>,
)> { )> {
start_node_impl::<rococo_parachain_runtime::RuntimeApi, RococoParachainRuntimeExecutor, _, _, _>( start_node_impl::<rococo_parachain_runtime::RuntimeApi, RococoParachainRuntimeExecutor, _, _, _>(
parachain_config, parachain_config,
@@ -677,14 +766,16 @@ pub async fn start_rococo_parachain_node(
/// Build the import queue for the shell runtime. /// Build the import queue for the shell runtime.
pub fn shell_build_import_queue( pub fn shell_build_import_queue(
client: Arc<TFullClient<Block, shell_runtime::RuntimeApi, ShellRuntimeExecutor>>, client: Arc<
TFullClient<Block, shell_runtime::RuntimeApi, NativeElseWasmExecutor<ShellRuntimeExecutor>>,
>,
config: &Configuration, config: &Configuration,
_: Option<TelemetryHandle>, _: Option<TelemetryHandle>,
task_manager: &TaskManager, task_manager: &TaskManager,
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue< sc_consensus::DefaultImportQueue<
Block, Block,
TFullClient<Block, shell_runtime::RuntimeApi, ShellRuntimeExecutor>, TFullClient<Block, shell_runtime::RuntimeApi, NativeElseWasmExecutor<ShellRuntimeExecutor>>,
>, >,
sc_service::Error, sc_service::Error,
> { > {
@@ -705,9 +796,17 @@ pub async fn start_shell_node(
id: ParaId, id: ParaId,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(
TaskManager, TaskManager,
Arc<TFullClient<Block, shell_runtime::RuntimeApi, ShellRuntimeExecutor>>, Arc<
TFullClient<Block, shell_runtime::RuntimeApi, NativeElseWasmExecutor<ShellRuntimeExecutor>>,
>,
)> { )> {
start_shell_node_impl::<shell_runtime::RuntimeApi, ShellRuntimeExecutor, _, _, _>( start_shell_node_impl::<
shell_runtime::RuntimeApi,
ShellRuntimeExecutor,
_,
_,
_,
>(
parachain_config, parachain_config,
polkadot_config, polkadot_config,
id, id,
@@ -879,16 +978,19 @@ where
/// Build the import queue for the statemint/statemine/westmine runtime. /// Build the import queue for the statemint/statemine/westmine runtime.
pub fn statemint_build_import_queue<RuntimeApi, Executor>( pub fn statemint_build_import_queue<RuntimeApi, Executor>(
client: Arc<TFullClient<Block, RuntimeApi, Executor>>, client: Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
config: &Configuration, config: &Configuration,
telemetry_handle: Option<TelemetryHandle>, telemetry_handle: Option<TelemetryHandle>,
task_manager: &TaskManager, task_manager: &TaskManager,
) -> Result< ) -> Result<
sc_consensus::DefaultImportQueue<Block, TFullClient<Block, RuntimeApi, Executor>>, sc_consensus::DefaultImportQueue<
Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
>,
sc_service::Error, sc_service::Error,
> >
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, Executor>> RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>
+ Send + Send
+ Sync + Sync
+ 'static, + 'static,
@@ -961,9 +1063,12 @@ pub async fn start_statemint_node<RuntimeApi, Executor>(
parachain_config: Configuration, parachain_config: Configuration,
polkadot_config: Configuration, polkadot_config: Configuration,
id: ParaId, id: ParaId,
) -> sc_service::error::Result<(TaskManager, Arc<TFullClient<Block, RuntimeApi, Executor>>)> ) -> sc_service::error::Result<(
TaskManager,
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
)>
where where
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, Executor>> RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>
+ Send + Send
+ Sync + Sync
+ 'static, + 'static,
+16 -8
View File
@@ -17,7 +17,7 @@
//! A Cumulus test client. //! A Cumulus test client.
mod block_builder; mod block_builder;
use codec::{Encode, Decode}; use codec::{Decode, Encode};
use runtime::{ use runtime::{
Balance, Block, BlockHashCount, Call, GenesisConfig, Runtime, Signature, SignedExtra, Balance, Block, BlockHashCount, Call, GenesisConfig, Runtime, Signature, SignedExtra,
SignedPayload, UncheckedExtrinsic, VERSION, SignedPayload, UncheckedExtrinsic, VERSION,
@@ -39,12 +39,20 @@ pub use substrate_test_client::*;
pub type ParachainBlockData = cumulus_primitives_core::ParachainBlockData<Block>; pub type ParachainBlockData = cumulus_primitives_core::ParachainBlockData<Block>;
mod local_executor { mod local_executor {
use substrate_test_client::sc_executor::native_executor_instance; /// Native executor instance.
native_executor_instance!( pub struct LocalExecutor;
pub LocalExecutor,
cumulus_test_runtime::api::dispatch, impl sc_executor::NativeExecutionDispatch for LocalExecutor {
cumulus_test_runtime::native_version, type ExtendHostFunctions = ();
);
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
cumulus_test_runtime::api::dispatch(method, data)
}
fn native_version() -> sc_executor::NativeVersion {
cumulus_test_runtime::native_version()
}
}
} }
/// Native executor used for tests. /// Native executor used for tests.
@@ -55,7 +63,7 @@ pub type Backend = substrate_test_client::Backend<Block>;
/// Test client executor. /// Test client executor.
pub type Executor = pub type Executor =
client::LocalCallExecutor<Block, Backend, sc_executor::NativeExecutor<LocalExecutor>>; client::LocalCallExecutor<Block, Backend, sc_executor::NativeElseWasmExecutor<LocalExecutor>>;
/// Test client builder for Cumulus /// Test client builder for Cumulus
pub type TestClientBuilder = pub type TestClientBuilder =
+1 -1
View File
@@ -57,7 +57,7 @@ cumulus-test-runtime = { path = "../runtime" }
cumulus-test-relay-validation-worker-provider = { path = "../relay-validation-worker-provider" } cumulus-test-relay-validation-worker-provider = { path = "../relay-validation-worker-provider" }
# RPC related dependencies # RPC related dependencies
jsonrpc-core = "15.1.0" jsonrpc-core = "18.0.0"
[dev-dependencies] [dev-dependencies]
futures = "0.3.5" futures = "0.3.5"
+28 -15
View File
@@ -31,8 +31,6 @@ use cumulus_primitives_core::ParaId;
use cumulus_test_runtime::{Hash, Header, NodeBlock as Block, RuntimeApi}; use cumulus_test_runtime::{Hash, Header, NodeBlock as Block, RuntimeApi};
use polkadot_primitives::v1::{CollatorPair, Hash as PHash, PersistedValidationData}; use polkadot_primitives::v1::{CollatorPair, Hash as PHash, PersistedValidationData};
use sc_client_api::execution_extensions::ExecutionStrategies; use sc_client_api::execution_extensions::ExecutionStrategies;
use sc_executor::native_executor_instance;
pub use sc_executor::NativeExecutor;
use sc_network::{config::TransportConfig, multiaddr, NetworkService}; use sc_network::{config::TransportConfig, multiaddr, NetworkService};
use sc_service::{ use sc_service::{
config::{ config::{
@@ -78,15 +76,27 @@ impl ParachainConsensus<Block> for NullConsensus {
/// The signature of the announce block fn. /// The signature of the announce block fn.
pub type AnnounceBlockFn = Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>; pub type AnnounceBlockFn = Arc<dyn Fn(Hash, Option<Vec<u8>>) + Send + Sync>;
// Native executor instance. /// Native executor instance.
native_executor_instance!( pub struct RuntimeExecutor;
pub RuntimeExecutor,
cumulus_test_runtime::api::dispatch, impl sc_executor::NativeExecutionDispatch for RuntimeExecutor {
cumulus_test_runtime::native_version, type ExtendHostFunctions = ();
);
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
cumulus_test_runtime::api::dispatch(method, data)
}
fn native_version() -> sc_executor::NativeVersion {
cumulus_test_runtime::native_version()
}
}
/// The client type being used by the test service. /// The client type being used by the test service.
pub type Client = TFullClient<runtime::NodeBlock, runtime::RuntimeApi, RuntimeExecutor>; pub type Client = TFullClient<
runtime::NodeBlock,
runtime::RuntimeApi,
sc_executor::NativeElseWasmExecutor<RuntimeExecutor>,
>;
/// Starts a `ServiceBuilder` for a full service. /// Starts a `ServiceBuilder` for a full service.
/// ///
@@ -105,8 +115,14 @@ pub fn new_partial(
>, >,
sc_service::Error, sc_service::Error,
> { > {
let executor = sc_executor::NativeElseWasmExecutor::<RuntimeExecutor>::new(
config.wasm_method,
config.default_heap_pages,
config.max_runtime_instances,
);
let (client, backend, keystore_container, task_manager) = let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, RuntimeExecutor>(&config, None)?; sc_service::new_full_parts::<Block, RuntimeApi, _>(&config, None, executor)?;
let client = Arc::new(client); let client = Arc::new(client);
let registry = config.prometheus_registry(); let registry = config.prometheus_registry();
@@ -155,14 +171,12 @@ async fn start_node_impl<RB>(
consensus: Consensus, consensus: Consensus,
) -> sc_service::error::Result<( ) -> sc_service::error::Result<(
TaskManager, TaskManager,
Arc<TFullClient<Block, RuntimeApi, RuntimeExecutor>>, Arc<Client>,
Arc<NetworkService<Block, H256>>, Arc<NetworkService<Block, H256>>,
RpcHandlers, RpcHandlers,
)> )>
where where
RB: Fn( RB: Fn(Arc<Client>) -> Result<jsonrpc_core::IoHandler<sc_rpc::Metadata>, sc_service::Error>
Arc<TFullClient<Block, RuntimeApi, RuntimeExecutor>>,
) -> Result<jsonrpc_core::IoHandler<sc_rpc::Metadata>, sc_service::Error>
+ Send + Send
+ 'static, + 'static,
{ {
@@ -629,7 +643,6 @@ pub fn node_config(
rpc_max_payload: None, rpc_max_payload: None,
prometheus_config: None, prometheus_config: None,
telemetry_endpoints: None, telemetry_endpoints: None,
telemetry_external_transport: None,
default_heap_pages: None, default_heap_pages: None,
offchain_worker: OffchainWorkerConfig { offchain_worker: OffchainWorkerConfig {
enabled: true, enabled: true,