Skip to content

Commit 2db1486

Browse files
authored
fix: remove NativeElseWasmExecutor and use wasm executor exclusively (#978)
1 parent c4d846b commit 2db1486

File tree

6 files changed

+61
-146
lines changed

6 files changed

+61
-146
lines changed

Cargo.lock

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace.package]
2-
version = "1.3.0"
2+
version = "1.3.1"
33
authors = ["Tangle Foundation."]
44
edition = "2021"
55
license = "Unlicense"

node/src/command.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,7 @@ pub fn run() -> sc_cli::Result<()> {
235235
);
236236
}
237237

238-
cmd.run_with_spec::<sp_runtime::traits::HashingFor<Block>,
239-
<crate::service::tangle::ExecutorDispatch as sc_executor::NativeExecutionDispatch>::ExtendHostFunctions>(Some(
238+
cmd.run_with_spec::<sp_runtime::traits::HashingFor<Block>, sp_io::SubstrateHostFunctions>(Some(
240239
config.chain_spec,
241240
))
242241
},

node/src/eth.rs

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::{
1919
time::Duration,
2020
};
2121

22-
use futures::{future, prelude::*};
22+
use futures::StreamExt;
2323
// Substrate
2424
pub use fc_storage::{StorageOverride, StorageOverrideHandler};
2525
use sc_client_api::BlockchainEvents;
@@ -215,34 +215,41 @@ pub async fn spawn_frontier_tasks(
215215
// Spawn main mapping sync worker background task.
216216
match &*frontier_backend {
217217
fc_db::Backend::KeyValue(b) => {
218+
// Create a MappingSyncWorker and spawn it using StreamExt::for_each
219+
let import_notifications = client.import_notification_stream();
220+
221+
let worker = fc_mapping_sync::kv::MappingSyncWorker::new(
222+
import_notifications,
223+
Duration::new(6, 0),
224+
client.clone(),
225+
backend,
226+
storage_override.clone(),
227+
b.clone(),
228+
3,
229+
0,
230+
fc_mapping_sync::SyncStrategy::Normal,
231+
sync,
232+
pubsub_notification_sinks,
233+
);
234+
218235
task_manager.spawn_essential_handle().spawn(
219236
"frontier-mapping-sync-worker",
220237
Some("frontier"),
221-
fc_mapping_sync::kv::MappingSyncWorker::new(
222-
client.import_notification_stream(),
223-
Duration::new(6, 0),
224-
client.clone(),
225-
backend,
226-
storage_override.clone(),
227-
b.clone(),
228-
3,
229-
0,
230-
fc_mapping_sync::SyncStrategy::Normal,
231-
sync,
232-
pubsub_notification_sinks,
233-
)
234-
.for_each(|()| future::ready(())),
238+
worker.for_each(|_| futures::future::ready(())),
235239
);
236240
},
237241
fc_db::Backend::Sql(b) => {
242+
// Create a SyncWorker with blockchain notifications
243+
let import_notifications = client.import_notification_stream();
244+
238245
task_manager.spawn_essential_handle().spawn_blocking(
239246
"frontier-mapping-sync-worker",
240247
Some("frontier"),
241248
fc_mapping_sync::sql::SyncWorker::run(
242249
client.clone(),
243250
backend,
244251
b.clone(),
245-
client.import_notification_stream(),
252+
import_notifications,
246253
fc_mapping_sync::sql::SyncWorkerConfig {
247254
read_notification_timeout: Duration::from_secs(10),
248255
check_indexed_blocks_interval: Duration::from_secs(60),

node/src/manual_seal.rs

Lines changed: 10 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ use crate::{
2323
StorageOverrideHandler,
2424
},
2525
};
26-
use futures::{future, prelude::*, FutureExt};
26+
use futures::{future, FutureExt};
2727
use sc_client_api::{Backend, BlockBackend};
2828
use sc_consensus::BasicQueue;
2929
use sc_consensus_babe::BabeWorkerHandle;
3030
use sc_consensus_grandpa::SharedVoterState;
3131
#[allow(deprecated)]
32-
pub use sc_executor::NativeElseWasmExecutor;
32+
pub use sc_executor::WasmExecutor;
3333
use sc_service::{error::Error as ServiceError, Configuration, TaskManager};
3434
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker};
3535
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
@@ -48,63 +48,13 @@ use tangle_testnet_runtime::{self, RuntimeApi, TransactionConverter};
4848
/// imported and generated.
4949
const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512;
5050

51-
#[cfg(not(feature = "testnet"))]
52-
pub mod tangle {
53-
// Our native executor instance.
54-
pub struct ExecutorDispatch;
55-
56-
impl sc_executor::NativeExecutionDispatch for ExecutorDispatch {
57-
/// Only enable the benchmarking host functions when we actually want to benchmark.
58-
#[cfg(feature = "runtime-benchmarks")]
59-
type ExtendHostFunctions =
60-
(frame_benchmarking::benchmarking::HostFunctions, primitives_ext::ext::HostFunctions);
61-
/// Otherwise we only use the default Substrate host functions.
62-
#[cfg(not(feature = "runtime-benchmarks"))]
63-
type ExtendHostFunctions = primitives_ext::ext::HostFunctions;
64-
65-
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
66-
tangle_runtime::api::dispatch(method, data)
67-
}
68-
69-
fn native_version() -> sc_executor::NativeVersion {
70-
tangle_runtime::native_version()
71-
}
72-
}
73-
}
74-
75-
#[cfg(feature = "testnet")]
76-
pub mod testnet {
77-
// Our native executor instance.
78-
pub struct ExecutorDispatch;
79-
80-
impl sc_executor::NativeExecutionDispatch for ExecutorDispatch {
81-
/// Only enable the benchmarking host functions when we actually want to benchmark.
82-
#[cfg(feature = "runtime-benchmarks")]
83-
type ExtendHostFunctions =
84-
(frame_benchmarking::benchmarking::HostFunctions, primitives_ext::ext::HostFunctions);
85-
/// Otherwise we only use the default Substrate host functions.
86-
#[cfg(not(feature = "runtime-benchmarks"))]
87-
type ExtendHostFunctions = primitives_ext::ext::HostFunctions;
88-
89-
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
90-
tangle_testnet_runtime::api::dispatch(method, data)
91-
}
92-
93-
fn native_version() -> sc_executor::NativeVersion {
94-
tangle_testnet_runtime::native_version()
95-
}
96-
}
97-
}
98-
9951
#[cfg(not(feature = "testnet"))]
10052
#[allow(deprecated)]
101-
pub(crate) type FullClient =
102-
sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<tangle::ExecutorDispatch>>;
53+
pub(crate) type FullClient = sc_service::TFullClient<Block, RuntimeApi, WasmExecutor>;
10354

10455
#[cfg(feature = "testnet")]
10556
#[allow(deprecated)]
106-
pub(crate) type FullClient =
107-
sc_service::TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<testnet::ExecutorDispatch>>;
57+
pub(crate) type FullClient = sc_service::TFullClient<Block, RuntimeApi, WasmExecutor>;
10858

10959
pub(crate) type FullBackend = sc_service::TFullBackend<Block>;
11060
type FullSelectChain = sc_consensus::LongestChain<FullBackend, Block>;
@@ -174,8 +124,12 @@ where
174124
})
175125
.transpose()?;
176126

177-
#[allow(deprecated)]
178-
let executor = sc_service::new_native_or_wasm_executor(config);
127+
// Create the WasmExecutor with allow_missing_host_functions flag set to true
128+
let executor = WasmExecutor::builder()
129+
.with_max_runtime_instances(config.max_runtime_instances)
130+
.with_runtime_cache_size(config.runtime_cache_size)
131+
.with_allow_missing_host_functions(true)
132+
.build();
179133

180134
let (client, backend, keystore_container, task_manager) =
181135
sc_service::new_full_parts::<Block, RuntimeApi, _>(

0 commit comments

Comments
 (0)