Skip to content

Commit

Permalink
Move EVM EVMDomainExecutorDispatch from subspace-node to `evm-dom…
Browse files Browse the repository at this point in the history
…ain-runtime` for better reuse
  • Loading branch information
nazar-pc committed Dec 18, 2023
1 parent 87b7a05 commit b0115ba
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 26 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use domain_eth_service::provider::EthProvider;
use domain_eth_service::DefaultEthConfig;
use domain_runtime_primitives::opaque::Block as DomainBlock;
use domain_service::{FullBackend, FullClient};
use evm_domain_runtime::ExecutorDispatch as EVMDomainExecutorDispatch;
use futures::StreamExt;
use sc_cli::CliConfiguration;
use sc_consensus_subspace::block_import::BlockImportingNotification;
Expand All @@ -18,9 +19,7 @@ use sp_core::traits::SpawnEssentialNamed;
use sp_domains::{DomainInstanceData, RuntimeType};
use sp_keystore::KeystorePtr;
use std::sync::Arc;
use subspace_node::domain::{
create_configuration, evm_chain_spec, AccountId20, DomainCli, EVMDomainExecutorDispatch,
};
use subspace_node::domain::{create_configuration, evm_chain_spec, AccountId20, DomainCli};
use subspace_runtime::{ExecutorDispatch as CExecutorDispatch, RuntimeApi as CRuntimeApi};
use subspace_runtime_primitives::opaque::Block as CBlock;
use subspace_service::FullClient as CFullClient;
Expand Down
5 changes: 2 additions & 3 deletions crates/subspace-node/src/bin/subspace-node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
use cross_domain_message_gossip::GossipWorkerBuilder;
use domain_client_operator::Bootstrapper;
use domain_runtime_primitives::opaque::Block as DomainBlock;
use evm_domain_runtime::ExecutorDispatch as EVMDomainExecutorDispatch;
use frame_benchmarking_cli::BenchmarkCmd;
use futures::future::TryFutureExt;
use log::warn;
Expand All @@ -37,9 +38,7 @@ use sp_core::traits::SpawnEssentialNamed;
use sp_io::SubstrateHostFunctions;
use sp_messenger::messages::ChainId;
use sp_wasm_interface::ExtendedHostFunctions;
use subspace_node::domain::{
DomainCli, DomainInstanceStarter, DomainSubcommand, EVMDomainExecutorDispatch,
};
use subspace_node::domain::{DomainCli, DomainInstanceStarter, DomainSubcommand};
use subspace_node::{Cli, Subcommand};
use subspace_proof_of_space::chia::ChiaTable;
use subspace_runtime::{Block, ExecutorDispatch, RuntimeApi};
Expand Down
19 changes: 0 additions & 19 deletions crates/subspace-node/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,3 @@ pub mod evm_chain_spec;
pub use self::cli::{DomainCli, Subcommand as DomainSubcommand};
pub use self::domain_instance_starter::{create_configuration, DomainInstanceStarter};
pub use evm_domain_runtime::AccountId as AccountId20;
use sc_executor::NativeExecutionDispatch;

/// EVM domain executor instance.
pub struct EVMDomainExecutorDispatch;

impl NativeExecutionDispatch for EVMDomainExecutorDispatch {
#[cfg(feature = "runtime-benchmarks")]
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
#[cfg(not(feature = "runtime-benchmarks"))]
type ExtendHostFunctions = ();

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

fn native_version() -> sc_executor::NativeVersion {
evm_domain_runtime::native_version()
}
}
3 changes: 2 additions & 1 deletion crates/subspace-node/src/domain/domain_instance_starter.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use super::{evm_chain_spec, DomainCli};
use crate::domain::{AccountId20, EVMDomainExecutorDispatch};
use crate::domain::AccountId20;
use cross_domain_message_gossip::{ChainTxPoolMsg, Message};
use domain_client_operator::{BootstrapResult, OperatorStreams};
use domain_eth_service::provider::EthProvider;
use domain_eth_service::DefaultEthConfig;
use domain_runtime_primitives::opaque::Block as DomainBlock;
use domain_service::{FullBackend, FullClient};
use evm_domain_runtime::ExecutorDispatch as EVMDomainExecutorDispatch;
use futures::StreamExt;
use sc_chain_spec::ChainSpec;
use sc_cli::{CliConfiguration, Database, DefaultConfigurationValues, SubstrateCli};
Expand Down
2 changes: 2 additions & 0 deletions domains/runtime/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pallet-transaction-payment = { version = "4.0.0-dev", default-features = false,
pallet-transaction-payment-rpc-runtime-api = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" }
pallet-transporter = { version = "0.1.0", path = "../../pallets/transporter", default-features = false }
scale-info = { version = "2.7.0", default-features = false, features = ["derive"] }
sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5", optional = true }
sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" }
sp-block-builder = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" }
sp-core = { version = "21.0.0", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "0831dfc3c54b10ab46e82acf98603b4af1a47bd5" }
Expand Down Expand Up @@ -98,6 +99,7 @@ std = [
"pallet-transaction-payment/std",
"pallet-transporter/std",
"scale-info/std",
"sc-executor",
"sp-api/std",
"sp-block-builder/std",
"sp-core/std",
Expand Down
20 changes: 20 additions & 0 deletions domains/runtime/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,26 @@ pub fn native_version() -> NativeVersion {
}
}

/// EVM domain executor instance.
#[cfg(feature = "std")]
pub struct ExecutorDispatch;

#[cfg(feature = "std")]
impl sc_executor::NativeExecutionDispatch for ExecutorDispatch {
#[cfg(feature = "runtime-benchmarks")]
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
#[cfg(not(feature = "runtime-benchmarks"))]
type ExtendHostFunctions = ();

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

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

parameter_types! {
pub const Version: RuntimeVersion = VERSION;
pub const BlockHashCount: BlockNumber = 2400;
Expand Down

0 comments on commit b0115ba

Please sign in to comment.