Skip to content

Commit

Permalink
deprecate at least in container-chain nodes, native executor (#544)
Browse files Browse the repository at this point in the history
* deprecate at least in container-chain nodes, native executor

* make it compile

* remove leftovers

* leftovers agin
  • Loading branch information
girazoki committed May 2, 2024
1 parent 2d7453d commit bdf44e6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 44 deletions.
25 changes: 1 addition & 24 deletions container-chains/templates/frontier/node/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/templates/frontier/node/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,
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/templates/simple/node/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

0 comments on commit bdf44e6

Please sign in to comment.