Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.

Commit 1e17ef1

Browse files
committed
Switch to wasm only, port paritytech/cumulus#1054
1 parent bdc99e4 commit 1e17ef1

File tree

9 files changed

+133
-120
lines changed

9 files changed

+133
-120
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate", bra
6868
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" }
6969

7070
# Substrate Primitive Dependencies
71+
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" }
7172
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" }
7273
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" }
7374
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18" }
@@ -84,7 +85,6 @@ sp-transaction-pool = { git = "https://github.com/paritytech/substrate", branch
8485

8586
# Cumulus dependencies
8687
cumulus-client-cli = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
87-
cumulus-client-collator = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
8888
cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
8989
cumulus-client-consensus-relay-chain = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }
9090
cumulus-client-consensus-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.18" }

node/src/command.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ macro_rules! construct_async_run {
354354
#[cfg(feature = "phala-native")]
355355
if runner.config().chain_spec.is_phala() {
356356
return runner.async_run(|$config| {
357-
let $components = new_partial::<phala_parachain_runtime::RuntimeApi, PhalaParachainRuntimeExecutor, _>(
357+
let $components = new_partial::<phala_parachain_runtime::RuntimeApi, _>(
358358
&$config,
359359
crate::service::phala::parachain_build_import_queue,
360360
)?;
@@ -366,7 +366,7 @@ macro_rules! construct_async_run {
366366
#[cfg(feature = "khala-native")]
367367
if runner.config().chain_spec.is_khala() {
368368
return runner.async_run(|$config| {
369-
let $components = new_partial::<khala_parachain_runtime::RuntimeApi, KhalaParachainRuntimeExecutor, _>(
369+
let $components = new_partial::<khala_parachain_runtime::RuntimeApi, _>(
370370
&$config,
371371
crate::service::khala::parachain_build_import_queue,
372372
)?;
@@ -378,7 +378,7 @@ macro_rules! construct_async_run {
378378
#[cfg(feature = "rhala-native")]
379379
if runner.config().chain_spec.is_rhala() {
380380
return runner.async_run(|$config| {
381-
let $components = new_partial::<rhala_parachain_runtime::RuntimeApi, RhalaParachainRuntimeExecutor, _>(
381+
let $components = new_partial::<rhala_parachain_runtime::RuntimeApi, _>(
382382
&$config,
383383
crate::service::rhala::parachain_build_import_queue,
384384
)?;
@@ -390,7 +390,7 @@ macro_rules! construct_async_run {
390390
#[cfg(feature = "thala-native")]
391391
if runner.config().chain_spec.is_thala() {
392392
return runner.async_run(|$config| {
393-
let $components = new_partial::<thala_parachain_runtime::RuntimeApi, ThalaParachainRuntimeExecutor, _>(
393+
let $components = new_partial::<thala_parachain_runtime::RuntimeApi, _>(
394394
&$config,
395395
crate::service::thala::parachain_build_import_queue,
396396
)?;
@@ -402,7 +402,7 @@ macro_rules! construct_async_run {
402402
#[cfg(feature = "shell-native")]
403403
if runner.config().chain_spec.is_shell() {
404404
return runner.async_run(|$config| {
405-
let $components = new_partial::<shell_parachain_runtime::RuntimeApi, ShellParachainRuntimeExecutor, _>(
405+
let $components = new_partial::<shell_parachain_runtime::RuntimeApi, _>(
406406
&$config,
407407
crate::service::shell::parachain_build_import_queue,
408408
)?;

node/src/service/khala.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ use cumulus_client_consensus_aura::{
77
use cumulus_primitives_core::ParaId;
88

99
pub use parachains_common::{AccountId, Balance, Block, Hash, Header, Index as Nonce};
10-
use sc_executor::NativeElseWasmExecutor;
10+
use sc_executor::WasmExecutor;
1111

12-
use sc_client_api::ExecutorProvider;
1312
use sc_service::{
1413
Configuration, TFullClient, TaskManager,
1514
};
@@ -34,14 +33,14 @@ impl sc_executor::NativeExecutionDispatch for RuntimeExecutor {
3433
/// Build the import queue for the parachain runtime.
3534
#[allow(clippy::type_complexity)]
3635
pub fn parachain_build_import_queue(
37-
client: Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<RuntimeExecutor>>>,
36+
client: Arc<TFullClient<Block, RuntimeApi, WasmExecutor<crate::service::HostFunctions>>>,
3837
config: &Configuration,
3938
telemetry: Option<TelemetryHandle>,
4039
task_manager: &TaskManager,
4140
) -> Result<
4241
sc_consensus::DefaultImportQueue<
4342
Block,
44-
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<RuntimeExecutor>>,
43+
TFullClient<Block, RuntimeApi, WasmExecutor<crate::service::HostFunctions>>,
4544
>,
4645
sc_service::Error,
4746
> {
@@ -70,7 +69,7 @@ pub fn parachain_build_import_queue(
7069
Ok((time, slot))
7170
},
7271
registry: config.prometheus_registry(),
73-
can_author_with: sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone()),
72+
can_author_with: sp_consensus::AlwaysCanAuthor,
7473
spawner: &task_manager.spawn_essential_handle(),
7574
telemetry,
7675
})
@@ -85,9 +84,9 @@ pub async fn start_parachain_node(
8584
id: ParaId,
8685
) -> sc_service::error::Result<(
8786
TaskManager,
88-
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<RuntimeExecutor>>>,
87+
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<crate::service::HostFunctions>>>,
8988
)> {
90-
crate::service::start_node_impl::<RuntimeApi, RuntimeExecutor, _, _, _>(
89+
crate::service::start_node_impl::<RuntimeApi, _, _, _>(
9190
parachain_config,
9291
polkadot_config,
9392
collator_options,
@@ -118,6 +117,7 @@ pub async fn start_parachain_node(
118117
proposer_factory,
119118
create_inherent_data_providers: move |_, (relay_parent, validation_data)| {
120119
let relay_chain_interface = relay_chain_interface.clone();
120+
121121
async move {
122122
let parachain_inherent =
123123
cumulus_primitives_parachain_inherent::ParachainInherentData::create_at(
@@ -126,11 +126,12 @@ pub async fn start_parachain_node(
126126
&validation_data,
127127
id,
128128
).await;
129-
let time = sp_timestamp::InherentDataProvider::from_system_time();
129+
130+
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
130131

131132
let slot =
132133
sp_consensus_aura::inherents::InherentDataProvider::from_timestamp_and_slot_duration(
133-
*time,
134+
*timestamp,
134135
slot_duration,
135136
);
136137

@@ -139,11 +140,12 @@ pub async fn start_parachain_node(
139140
"Failed to create parachain inherent",
140141
)
141142
})?;
142-
Ok((time, slot, parachain_inherent))
143+
144+
Ok((timestamp, slot, parachain_inherent))
143145
}
144146
},
145147
block_import: client.clone(),
146-
para_client: client,
148+
para_client: client.clone(),
147149
backoff_authoring_blocks: Option::<()>::None,
148150
sync_oracle,
149151
keystore,

node/src/service/mod.rs

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use cumulus_relay_chain_rpc_interface::RelayChainRPCInterface;
2828
use polkadot_service::CollatorPair;
2929

3030
pub use parachains_common::{AccountId, Balance, Block, Hash, Header, Index as Nonce};
31-
use sc_executor::NativeElseWasmExecutor;
31+
use sc_executor::WasmExecutor;
3232

3333
use sc_network::NetworkService;
3434
use sc_service::{
@@ -51,6 +51,13 @@ pub mod thala;
5151
#[cfg(feature = "shell-native")]
5252
pub mod shell;
5353

54+
#[cfg(not(feature = "runtime-benchmarks"))]
55+
type HostFunctions = sp_io::SubstrateHostFunctions;
56+
57+
#[cfg(feature = "runtime-benchmarks")]
58+
type HostFunctions =
59+
(sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions);
60+
5461
async fn build_relay_chain_interface(
5562
polkadot_config: Configuration,
5663
parachain_config: &Configuration,
@@ -75,28 +82,28 @@ async fn build_relay_chain_interface(
7582
/// Use this macro if you don't actually need the full service, but just the builder in order to
7683
/// be able to perform chain operations.
7784
#[allow(clippy::type_complexity)]
78-
pub fn new_partial<RuntimeApi, Executor, BIQ>(
85+
pub fn new_partial<RuntimeApi, BIQ>(
7986
config: &Configuration,
8087
build_import_queue: BIQ,
8188
) -> Result<
8289
PartialComponents<
83-
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
90+
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
8491
TFullBackend<Block>,
8592
(),
8693
sc_consensus::DefaultImportQueue<
8794
Block,
88-
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
95+
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
8996
>,
9097
sc_transaction_pool::FullPool<
9198
Block,
92-
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
99+
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
93100
>,
94101
(Option<Telemetry>, Option<TelemetryWorkerHandle>),
95102
>,
96103
sc_service::Error,
97104
>
98105
where
99-
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>
106+
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>
100107
+ Send
101108
+ Sync
102109
+ 'static,
@@ -109,16 +116,15 @@ pub fn new_partial<RuntimeApi, Executor, BIQ>(
109116
> + sp_offchain::OffchainWorkerApi<Block>
110117
+ sp_block_builder::BlockBuilder<Block>,
111118
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
112-
Executor: sc_executor::NativeExecutionDispatch + 'static,
113119
BIQ: FnOnce(
114-
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
120+
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
115121
&Configuration,
116122
Option<TelemetryHandle>,
117123
&TaskManager,
118124
) -> Result<
119125
sc_consensus::DefaultImportQueue<
120126
Block,
121-
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
127+
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
122128
>,
123129
sc_service::Error,
124130
>,
@@ -134,16 +140,17 @@ pub fn new_partial<RuntimeApi, Executor, BIQ>(
134140
})
135141
.transpose()?;
136142

137-
let executor = sc_executor::NativeElseWasmExecutor::<Executor>::new(
143+
let executor = sc_executor::WasmExecutor::<HostFunctions>::new(
138144
config.wasm_method,
139145
config.default_heap_pages,
140146
config.max_runtime_instances,
147+
None,
141148
config.runtime_cache_size,
142149
);
143150

144151
let (client, backend, keystore_container, task_manager) =
145152
sc_service::new_full_parts::<Block, RuntimeApi, _>(
146-
config,
153+
&config,
147154
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
148155
executor,
149156
)?;
@@ -189,7 +196,7 @@ pub fn new_partial<RuntimeApi, Executor, BIQ>(
189196
///
190197
/// This is the actual implementation that is abstract over the executor and the runtime api.
191198
#[sc_tracing::logging::prefix_logs_with("Parachain")]
192-
async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
199+
async fn start_node_impl<RuntimeApi, RB, BIQ, BIC>(
193200
parachain_config: Configuration,
194201
polkadot_config: Configuration,
195202
collator_options: CollatorOptions,
@@ -199,10 +206,10 @@ async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
199206
build_consensus: BIC,
200207
) -> sc_service::error::Result<(
201208
TaskManager,
202-
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
209+
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
203210
)>
204211
where
205-
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>
212+
RuntimeApi: ConstructRuntimeApi<Block, TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>
206213
+ Send
207214
+ Sync
208215
+ 'static,
@@ -219,34 +226,33 @@ async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
219226
+ substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>
220227
+ pallet_mq_runtime_api::MqApi<Block>,
221228
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
222-
Executor: sc_executor::NativeExecutionDispatch + 'static,
223229
RB: Fn(
224-
Arc<TFullClient<Block, RuntimeApi, Executor>>,
230+
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
225231
) -> Result<jsonrpc_core::IoHandler<sc_rpc::Metadata>, sc_service::Error>
226232
+ Send
227233
+ 'static,
228234
BIQ: FnOnce(
229-
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
235+
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
230236
&Configuration,
231237
Option<TelemetryHandle>,
232238
&TaskManager,
233239
) -> Result<
234240
sc_consensus::DefaultImportQueue<
235241
Block,
236-
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
242+
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
237243
>,
238244
sc_service::Error,
239245
> + 'static,
240246
BIC: FnOnce(
241-
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
247+
Arc<TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>>,
242248
Option<&Registry>,
243249
Option<TelemetryHandle>,
244250
&TaskManager,
245251
Arc<dyn RelayChainInterface>,
246252
Arc<
247253
sc_transaction_pool::FullPool<
248254
Block,
249-
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
255+
TFullClient<Block, RuntimeApi, WasmExecutor<HostFunctions>>,
250256
>,
251257
>,
252258
Arc<NetworkService<Block, Hash>>,
@@ -260,7 +266,7 @@ async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
260266

261267
let parachain_config = prepare_node_config(parachain_config);
262268

263-
let params = new_partial::<RuntimeApi, Executor, BIQ>(&parachain_config, build_import_queue)?;
269+
let params = new_partial::<RuntimeApi, BIQ>(&parachain_config, build_import_queue)?;
264270
let (mut telemetry, telemetry_worker_handle) = params.other;
265271

266272
let client = params.client.clone();
@@ -274,11 +280,11 @@ async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
274280
&mut task_manager,
275281
collator_options.clone(),
276282
)
277-
.await
278-
.map_err(|e| match e {
279-
RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,
280-
s => s.to_string().into(),
281-
})?;
283+
.await
284+
.map_err(|e| match e {
285+
RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x,
286+
s => s.to_string().into(),
287+
})?;
282288

283289
let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id);
284290

@@ -363,7 +369,7 @@ async fn start_node_impl<RuntimeApi, Executor, RB, BIQ, BIC>(
363369
announce_block,
364370
client: client.clone(),
365371
task_manager: &mut task_manager,
366-
relay_chain_interface,
372+
relay_chain_interface: relay_chain_interface.clone(),
367373
spawner,
368374
parachain_consensus,
369375
import_queue,

0 commit comments

Comments
 (0)