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

deprecate at least in container-chain nodes, native executor #544

Merged
merged 5 commits into from
May 2, 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
25 changes: 1 addition & 24 deletions container-chains/nodes/frontier/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,12 @@
// along with Tanssi. If not, see <http://www.gnu.org/licenses/>.

// Substrate
use {
sc_executor::{NativeExecutionDispatch, NativeVersion},
sp_consensus_aura::sr25519::AuthorityId as AuraId,
};
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
// Local
use container_chain_template_frontier_runtime::{opaque::Block, AccountId, Index};

use crate::eth::EthCompatRuntimeApiCollection;

/// Only enable the benchmarking host functions when we actually want to benchmark.
#[cfg(feature = "runtime-benchmarks")]
pub type HostFunctions = frame_benchmarking::benchmarking::HostFunctions;
/// Otherwise we use empty host functions for ext host functions.
#[cfg(not(feature = "runtime-benchmarks"))]
pub type HostFunctions = ();

pub struct TemplateRuntimeExecutor;
impl NativeExecutionDispatch for TemplateRuntimeExecutor {
type ExtendHostFunctions = HostFunctions;

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

fn native_version() -> NativeVersion {
container_chain_template_frontier_runtime::native_version()
}
}

/// A set of APIs that every runtimes must implement.
pub trait BaseRuntimeApiCollection:
sp_api::ApiExt<Block>
Expand Down
5 changes: 2 additions & 3 deletions container-chains/nodes/frontier/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#[allow(deprecated)]
use {
crate::client::TemplateRuntimeExecutor,
girazoki marked this conversation as resolved.
Show resolved Hide resolved
container_chain_template_frontier_runtime::{opaque::Block, RuntimeApi},
cumulus_client_cli::CollatorOptions,
cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport,
Expand All @@ -33,7 +32,7 @@ use {
parity_scale_codec::Encode,
polkadot_parachain_primitives::primitives::HeadData,
sc_consensus::BasicQueue,
sc_executor::NativeElseWasmExecutor,
sc_executor::WasmExecutor,
sc_service::{Configuration, TFullBackend, TFullClient, TaskManager},
sp_blockchain::HeaderBackend,
sp_consensus_slots::{Slot, SlotDuration},
Expand All @@ -45,7 +44,7 @@ use {
},
};

type ParachainExecutor = NativeElseWasmExecutor<TemplateRuntimeExecutor>;
type ParachainExecutor = WasmExecutor<sp_io::SubstrateHostFunctions>;
type ParachainClient = TFullClient<Block, RuntimeApi, ParachainExecutor>;
type ParachainBackend = TFullBackend<Block>;
type ParachainBlockImport = TParachainBlockImport<
Expand Down
19 changes: 2 additions & 17 deletions container-chains/nodes/simple/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use {
parity_scale_codec::Encode,
polkadot_parachain_primitives::primitives::HeadData,
sc_consensus::BasicQueue,
sc_executor::NativeElseWasmExecutor,
sc_executor::WasmExecutor,
sc_service::{Configuration, TFullBackend, TFullClient, TaskManager},
sp_blockchain::HeaderBackend,
sp_consensus_slots::{Slot, SlotDuration},
Expand All @@ -40,22 +40,7 @@ use {
std::{sync::Arc, time::Duration},
};

/// 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>> {
container_chain_template_simple_runtime::api::dispatch(method, data)
}

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

type ParachainExecutor = NativeElseWasmExecutor<ParachainNativeExecutor>;
type ParachainExecutor = WasmExecutor<sp_io::SubstrateHostFunctions>;
type ParachainClient = TFullClient<Block, RuntimeApi, ParachainExecutor>;
type ParachainBackend = TFullBackend<Block>;
type ParachainBlockImport = TParachainBlockImport<Block, Arc<ParachainClient>, ParachainBackend>;
Expand Down
Loading