Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚑️ Use only the WasmExecutor #251

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions nodes/parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ version.workspace = true
[dependencies]
clap = { workspace = true, features = ["derive"] }
log.workspace = true
parity-scale-codec = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
jsonrpsee = { workspace = true, features = ["server"] }
Expand Down Expand Up @@ -49,14 +48,14 @@ sc-transaction-pool.workspace = true
sc-transaction-pool-api.workspace = true
sc-network-sync.workspace = true
sp-api.workspace = true
sp-io.workspace = true
sp-block-builder.workspace = true
sp-blockchain.workspace = true
sp-consensus-aura.workspace = true
sp-core.workspace = true
sp-keystore.workspace = true
sp-runtime.workspace = true
sp-timestamp.workspace = true
sp-transaction-pool.workspace = true
substrate-frame-rpc-system.workspace = true
substrate-prometheus-endpoint.workspace = true

Expand Down Expand Up @@ -89,6 +88,7 @@ runtime-benchmarks = [
"cumulus-primitives-core/runtime-benchmarks",
"frame-benchmarking-cli/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"pallet-funding/runtime-benchmarks",
"polimec-runtime/runtime-benchmarks",
"politest-runtime/runtime-benchmarks",
Expand All @@ -98,6 +98,7 @@ runtime-benchmarks = [
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"pallet-funding/try-runtime",
"polimec-runtime/try-runtime",
"politest-runtime/try-runtime",
Expand All @@ -107,19 +108,19 @@ try-runtime = [
std = [
"cumulus-primitives-core/std",
"frame-benchmarking/std",
"frame-support/std",
"log/std",
"pallet-funding/std",
"parity-scale-codec/std",
"polkadot-primitives/std",
"serde/std",
"sp-api/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
"sp-core/std",
"sp-io/std",
"sp-keystore/std",
"sp-runtime/std",
"sp-timestamp/std",
"sp-transaction-pool/std",
"xcm/std",
]
on-chain-release-build = [
Expand Down
23 changes: 3 additions & 20 deletions nodes/parachain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
use sc_client_api::Backend;
use sc_consensus::ImportQueue;
use sc_executor::{HeapAllocStrategy, NativeElseWasmExecutor, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
use sc_network::NetworkBlock;
use sc_network_sync::SyncingService;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
Expand All @@ -59,22 +59,7 @@ use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_keystore::KeystorePtr;
use substrate_prometheus_endpoint::Registry;

/// Native executor type.
pub struct ParachainNativeExecutor;

impl sc_executor::NativeExecutionDispatch for ParachainNativeExecutor {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;

fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
polimec_runtime::api::dispatch(method, data)
}

fn native_version() -> sc_executor::NativeVersion {
polimec_runtime::native_version()
}
}

type ParachainExecutor = NativeElseWasmExecutor<ParachainNativeExecutor>;
type ParachainExecutor = WasmExecutor<(sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions)>;

type ParachainClient = TFullClient<Block, RuntimeApi, ParachainExecutor>;

Expand Down Expand Up @@ -111,16 +96,14 @@ pub fn new_partial(config: &Configuration) -> Result<Service, sc_service::Error>
.default_heap_pages
.map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ });

let wasm = WasmExecutor::builder()
let executor = WasmExecutor::builder()
.with_execution_method(config.wasm_method)
.with_onchain_heap_alloc_strategy(heap_pages)
.with_offchain_heap_alloc_strategy(heap_pages)
.with_max_runtime_instances(config.max_runtime_instances)
.with_runtime_cache_size(config.runtime_cache_size)
.build();

let executor = ParachainExecutor::new_with_wasm_executor(wasm);

let (client, backend, keystore_container, task_manager) = sc_service::new_full_parts::<Block, RuntimeApi, _>(
config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
Expand Down