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

substrate-node: NativeElseWasmExecutor is no longer used #2521

Merged
merged 13 commits into from
Nov 29, 2023
Merged
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ members = [
"substrate/bin/node-template/runtime",
"substrate/bin/node/bench",
"substrate/bin/node/cli",
"substrate/bin/node/executor",
"substrate/bin/node/inspect",
"substrate/bin/node/primitives",
"substrate/bin/node/rpc",
Expand Down
40 changes: 38 additions & 2 deletions substrate/bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ sc-storage-monitor = { path = "../../../client/storage-monitor" }
sc-offchain = { path = "../../../client/offchain" }

# frame dependencies
frame-benchmarking = { path = "../../../frame/benchmarking" }
frame-system = { path = "../../../frame/system" }
frame-system-rpc-runtime-api = { path = "../../../frame/system/rpc/runtime-api" }
pallet-assets = { path = "../../../frame/assets" }
Expand All @@ -102,7 +103,6 @@ pallet-skip-feeless-payment = { path = "../../../frame/transaction-payment/skip-
kitchensink-runtime = { path = "../runtime" }
node-rpc = { path = "../rpc" }
node-primitives = { path = "../primitives" }
node-executor = { package = "staging-node-executor", path = "../executor" }

# CLI-specific dependencies
sc-cli = { path = "../../../client/cli", optional = true}
Expand Down Expand Up @@ -136,6 +136,26 @@ substrate-rpc-client = { path = "../../../utils/frame/rpc/client" }
pallet-timestamp = { path = "../../../frame/timestamp" }
substrate-cli-test-utils = { path = "../../../test-utils/cli" }

wat = "1.0"
frame-support = { path = "../../../frame/support" }
node-testing = { path = "../testing" }
pallet-balances = { path = "../../../frame/balances" }
pallet-contracts = { path = "../../../frame/contracts" }
pallet-glutton = { path = "../../../frame/glutton" }
pallet-sudo = { path = "../../../frame/sudo" }
pallet-treasury = { path = "../../../frame/treasury" }
pallet-transaction-payment = { path = "../../../frame/transaction-payment" }
sp-application-crypto = { path = "../../../primitives/application-crypto" }
pallet-root-testing = { path = "../../../frame/root-testing" }
sp-consensus-babe = { path = "../../../primitives/consensus/babe" }
sp-externalities = { path = "../../../primitives/externalities" }
sp-keyring = { path = "../../../primitives/keyring" }
sp-runtime = { path = "../../../primitives/runtime" }
serde_json = "1.0.108"
scale-info = { version = "2.10.0", features = ["derive", "serde"] }
sp-trie = { path = "../../../primitives/trie" }
sp-state-machine = { path = "../../../primitives/state-machine" }

[build-dependencies]
clap = { version = "4.4.6", optional = true }
clap_complete = { version = "4.0.2", optional = true }
Expand Down Expand Up @@ -163,32 +183,44 @@ cli = [
]
runtime-benchmarks = [
"frame-benchmarking-cli/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"kitchensink-runtime/runtime-benchmarks",
"node-executor/runtime-benchmarks",
"node-inspect?/runtime-benchmarks",
"pallet-asset-tx-payment/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-contracts/runtime-benchmarks",
"pallet-glutton/runtime-benchmarks",
"pallet-im-online/runtime-benchmarks",
"pallet-skip-feeless-payment/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-treasury/runtime-benchmarks",
"sc-client-db/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
# Enable features that allow the runtime to be tried and debugged. Name might be subject to change
# in the near future.
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"kitchensink-runtime/try-runtime",
"pallet-asset-conversion-tx-payment/try-runtime",
"pallet-asset-tx-payment/try-runtime",
"pallet-assets/try-runtime",
"pallet-balances/try-runtime",
"pallet-contracts/try-runtime",
"pallet-glutton/try-runtime",
"pallet-im-online/try-runtime",
"pallet-root-testing/try-runtime",
"pallet-skip-feeless-payment/try-runtime",
"pallet-sudo/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-treasury/try-runtime",
"sp-runtime/try-runtime",
"substrate-cli-test-utils/try-runtime",
"try-runtime-cli/try-runtime",
Expand All @@ -201,3 +233,7 @@ harness = false
[[bench]]
name = "block_production"
harness = false

[[bench]]
name = "executor"
harness = false
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use kitchensink_runtime::{
constants::currency::*, Block, BuildStorage, CheckedExtrinsic, Header, RuntimeCall,
RuntimeGenesisConfig, UncheckedExtrinsic,
};
use node_executor::RuntimeExecutor;
use node_primitives::{BlockNumber, Hash};
use node_testing::keyring::*;
use sc_executor::{Externalities, RuntimeVersionOf};
Expand All @@ -32,7 +31,7 @@ use sp_core::{
};
use sp_runtime::traits::BlakeTwo256;
use sp_state_machine::TestExternalities as CoreTestExternalities;
use staging_node_executor as node_executor;
use staging_node_cli::service::RuntimeExecutor;

criterion_group!(benches, bench_execute_block);
criterion_main!(benches);
Expand Down
18 changes: 17 additions & 1 deletion substrate/bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
use frame_system_rpc_runtime_api::AccountNonceApi;
use futures::prelude::*;
use kitchensink_runtime::RuntimeApi;
use node_executor::RuntimeExecutor;
use node_primitives::Block;
use sc_client_api::{Backend, BlockBackend};
use sc_consensus_babe::{self, SlotProportion};
Expand All @@ -41,6 +40,23 @@ use sp_core::crypto::Pair;
use sp_runtime::{generic, traits::Block as BlockT, SaturatedConversion};
use std::sync::Arc;

/// Host functions required for kitchensink runtime and Substrate node.
#[cfg(not(feature = "runtime-benchmarks"))]
pub type HostFunctions =
(sp_io::SubstrateHostFunctions, sp_statement_store::runtime_api::HostFunctions);

/// Host functions required for kitchensink runtime and Substrate node.
#[cfg(feature = "runtime-benchmarks")]
pub type HostFunctions = (
sp_io::SubstrateHostFunctions,
sp_statement_store::runtime_api::HostFunctions,
frame_benchmarking::benchmarking::HostFunctions,
);

/// A specialized `WasmExecutor` intended to use accross substrate node. It provides all required
/// HostFunctions.
pub type RuntimeExecutor = sc_executor::WasmExecutor<HostFunctions>;

/// The full client type definition.
pub type FullClient = sc_service::TFullClient<Block, RuntimeApi, RuntimeExecutor>;
type FullBackend = sc_service::TFullBackend<Block>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use kitchensink_runtime::{
use node_primitives::{BlockNumber, Hash};
use node_testing::keyring::*;
use sp_externalities::Externalities;
use staging_node_executor::RuntimeExecutor;
use staging_node_cli::service::RuntimeExecutor;

pub const TEST_KEY_TYPE_ID: KeyTypeId = KeyTypeId(*b"test");

Expand Down
72 changes: 0 additions & 72 deletions substrate/bin/node/executor/Cargo.toml

This file was deleted.

34 changes: 0 additions & 34 deletions substrate/bin/node/executor/src/lib.rs

This file was deleted.

4 changes: 2 additions & 2 deletions substrate/bin/node/inspect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ targets = ["x86_64-unknown-linux-gnu"]
clap = { version = "4.4.6", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.6.1" }
thiserror = "1.0"
node-executor = { package = "staging-node-executor", path = "../executor" }
sc-cli = { path = "../../../client/cli" }
sc-client-api = { path = "../../../client/api" }
sc-service = { path = "../../../client/service", default-features = false}
sp-blockchain = { path = "../../../primitives/blockchain" }
sp-core = { path = "../../../primitives/core" }
sp-io = { path = "../../../primitives/io" }
sp-runtime = { path = "../../../primitives/runtime" }
sp-statement-store = { path = "../../../primitives/statement-store" }

[features]
runtime-benchmarks = [
"node-executor/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
5 changes: 4 additions & 1 deletion substrate/bin/node/inspect/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ use sc_cli::{CliConfiguration, ImportParams, Result, SharedParams};
use sc_service::Configuration;
use sp_runtime::traits::Block;

type HostFunctions =
(sp_io::SubstrateHostFunctions, sp_statement_store::runtime_api::HostFunctions);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we need to support benchmarking::HostFunctions here.
We cannot add dep on node-cli as there would be cycle.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand, why can you not add the HF here? Should be a dependency on frame-benchmarking, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I could. But it is probably not needed.

impl InspectCmd {
/// Run the inspect command, passing the inspector.
pub fn run<B, RA>(&self, config: Configuration) -> Result<()>
where
B: Block,
RA: Send + Sync + 'static,
{
let executor = sc_service::new_wasm_executor::<node_executor::HostFunctions>(&config);
let executor = sc_service::new_wasm_executor::<HostFunctions>(&config);
let client = sc_service::new_full_client::<B, RA, _>(&config, None, executor)?;
let inspect = Inspector::<B>::new(client);

Expand Down
2 changes: 1 addition & 1 deletion substrate/bin/node/testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ futures = "0.3.21"
log = "0.4.17"
tempfile = "3.1.0"
frame-system = { path = "../../../frame/system" }
node-executor = { package = "staging-node-executor", path = "../executor" }
node-cli = { package = "staging-node-cli", path = "../cli" }
node-primitives = { path = "../primitives" }
kitchensink-runtime = { path = "../runtime" }
pallet-asset-conversion = { path = "../../../frame/asset-conversion" }
Expand Down
2 changes: 1 addition & 1 deletion substrate/bin/node/testing/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use sp_runtime::BuildStorage;
pub use substrate_test_client::*;

/// Call executor for `kitchensink-runtime` `TestClient`.
use node_executor::RuntimeExecutor;
use node_cli::service::RuntimeExecutor;

/// Default backend type.
pub type Backend = sc_client_db::Backend<node_primitives::Block>;
Expand Down