Skip to content

Commit

Permalink
create sc-domains to hold domain specific host functions and extensio…
Browse files Browse the repository at this point in the history
…n factory
  • Loading branch information
vedhavyas committed Feb 23, 2024
1 parent e4d9d28 commit 5cdebfd
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 15 deletions.
24 changes: 23 additions & 1 deletion Cargo.lock

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

33 changes: 33 additions & 0 deletions crates/sc-domains/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "sc-domains"
version = "0.1.0"
authors = ["Subspace Labs <https://subspace.network>"]
description = "Subspace service."
edition = "2021"
license = "GPL-3.0-or-later"
homepage = "https://subspace.network"
repository = "https://github.com/subspace/subspace"
include = [
"/src",
"/Cargo.toml",
]

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
frame-benchmarking = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", optional = true }
sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sp-domains = { version = "0.1.0", path = "../sp-domains" }
sp-externalities = { version = "0.19.0", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sp-messenger-host-functions = { version = "0.1.0", path = "../../domains/primitives/messenger-host-functions" }
sp-runtime = { version = "24.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sp-subspace-mmr = { version = "0.1.0", path = "../sp-subspace-mmr" }

[features]
runtime-benchmarks = ["dep:frame-benchmarking"]
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
// Copyright (C) 2021 Subspace Labs, Inc.
// SPDX-License-Identifier: GPL-3.0-or-later

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Domain specific Host functions and Extension factory
use sc_client_api::execution_extensions::ExtensionsFactory as ExtensionsFactoryT;
use sc_executor::RuntimeVersionOf;
use sp_api::ProvideRuntimeApi;
Expand Down
1 change: 1 addition & 0 deletions crates/subspace-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ sc-cli = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-s
sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-consensus-subspace = { version = "0.1.0", path = "../sc-consensus-subspace" }
sc-domains = { version = "0.1.0", path = "../sc-domains" }
sc-informant = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-keystore = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
Expand Down
6 changes: 3 additions & 3 deletions crates/subspace-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ use domain_runtime_primitives::opaque::Block as DomainBlock;
use frame_benchmarking_cli::BenchmarkCmd;
use futures::future::TryFutureExt;
use sc_cli::{ChainSpec, SubstrateCli};
use sc_domains::HostFunctions as DomainsHostFunctions;
use sc_service::{Configuration, PartialComponents};
use serde_json::Value;
use sp_core::crypto::Ss58AddressFormat;
use subspace_proof_of_space::chia::ChiaTable;
use subspace_runtime::{Block, RuntimeApi};
use subspace_service::domains::HostFunctions as DomainHostFunctions;
use subspace_service::HostFunctions;
use tracing::warn;

Expand Down Expand Up @@ -349,7 +349,7 @@ fn main() -> Result<(), Error> {
.into(),
);
}
cmd.run::<DomainBlock, DomainHostFunctions>(domain_config)
cmd.run::<DomainBlock, DomainsHostFunctions>(domain_config)
}
_ => todo!("Not implemented"),
}
Expand All @@ -372,7 +372,7 @@ fn main() -> Result<(), Error> {
})?;

let executor =
sc_service::new_wasm_executor::<DomainHostFunctions>(&domain_config);
sc_service::new_wasm_executor::<DomainsHostFunctions>(&domain_config);

let (client, _, _, _) = sc_service::new_full_parts::<
DomainBlock,
Expand Down
6 changes: 5 additions & 1 deletion crates/subspace-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polk
sc-consensus-subspace = { version = "0.1.0", path = "../sc-consensus-subspace" }
sc-consensus-subspace-rpc = { version = "0.1.0", path = "../sc-consensus-subspace-rpc" }
sc-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-domains = { version = "0.1.0", path = "../sc-domains" }
sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-informant = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
Expand Down Expand Up @@ -89,4 +90,7 @@ frame-system-rpc-runtime-api = { version = "4.0.0-dev", git = "https://github.co
pallet-transaction-payment-rpc-runtime-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }

[features]
runtime-benchmarks = ["dep:frame-benchmarking"]
runtime-benchmarks = [
"dep:frame-benchmarking",
"sc-domains/runtime-benchmarks",
]
5 changes: 2 additions & 3 deletions crates/subspace-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
)]

pub mod config;
pub mod domains;
pub mod dsn;
mod metrics;
pub mod rpc;
Expand All @@ -40,7 +39,6 @@ use crate::transaction_pool::FullPool;
use core::sync::atomic::{AtomicU32, Ordering};
use cross_domain_message_gossip::xdm_gossip_peers_set_config;
use domain_runtime_primitives::opaque::{Block as DomainBlock, Header as DomainHeader};
use domains::ExtensionsFactory as DomainsExtensionFactory;
use frame_system_rpc_runtime_api::AccountNonceApi;
use futures::channel::oneshot;
use futures::FutureExt;
Expand Down Expand Up @@ -69,6 +67,7 @@ use sc_consensus_subspace::slot_worker::{
};
use sc_consensus_subspace::verifier::{SubspaceVerifier, SubspaceVerifierOptions};
use sc_consensus_subspace::SubspaceLink;
use sc_domains::ExtensionsFactory as DomainsExtensionFactory;
use sc_network::{NetworkService, NotificationService};
use sc_proof_of_time::source::gossip::pot_gossip_peers_set_config;
use sc_proof_of_time::source::PotSourceWorker;
Expand Down Expand Up @@ -230,7 +229,7 @@ struct SubspaceExtensionsFactory<PosTable, Client, DomainBlock> {
client: Arc<Client>,
pot_verifier: PotVerifier,
executor: Arc<RuntimeExecutor>,
domains_executor: Arc<domains::RuntimeExecutor>,
domains_executor: Arc<sc_domains::RuntimeExecutor>,
_pos_table: PhantomData<(PosTable, DomainBlock)>,
}

Expand Down
7 changes: 5 additions & 2 deletions domains/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ sp-io = { version = "23.0.0", git = "https://github.com/subspace/polkadot-sdk",
sc-chain-spec = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-domains = { version = "0.1.0", path = "../../crates/sc-domains" }
sc-executor = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-informant = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
Expand Down Expand Up @@ -63,7 +64,6 @@ sp-subspace-mmr = { version = "0.1.0", path = "../../crates/sp-subspace-mmr" }
sp-transaction-pool = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
subspace-core-primitives = { version = "0.1.0", path = "../../crates/subspace-core-primitives" }
subspace-runtime-primitives = { version = "0.1.0", path = "../../crates/subspace-runtime-primitives" }
subspace-service = { version = "0.1.0", path = "../../crates/subspace-service" }
substrate-frame-rpc-system = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
substrate-prometheus-endpoint = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
tokio = "1.35.1"
Expand All @@ -73,4 +73,7 @@ tracing = "0.1.40"
substrate-build-script-utils = { version = "3.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }

[features]
runtime-benchmarks = ["dep:frame-benchmarking"]
runtime-benchmarks = [
"dep:frame-benchmarking",
"sc-domains/runtime-benchmarks",
]
2 changes: 1 addition & 1 deletion domains/service/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use sc_client_api::{
BlockBackend, BlockImportNotification, BlockchainEvents, ExecutorProvider, ProofProvider,
};
use sc_consensus::SharedBlockImport;
use sc_domains::{ExtensionsFactory, RuntimeExecutor};
use sc_network::NetworkPeers;
use sc_rpc_api::DenyUnsafe;
use sc_service::{
Expand Down Expand Up @@ -47,7 +48,6 @@ use std::str::FromStr;
use std::sync::Arc;
use subspace_core_primitives::PotOutput;
use subspace_runtime_primitives::Nonce;
use subspace_service::domains::{ExtensionsFactory, RuntimeExecutor};
use substrate_frame_rpc_system::AccountNonceApi;

pub type DomainOperator<Block, CBlock, CClient, RuntimeApi> = Operator<
Expand Down
2 changes: 1 addition & 1 deletion domains/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use futures::channel::oneshot;
use futures::{FutureExt, StreamExt};
use sc_client_api::{BlockBackend, BlockchainEvents, HeaderBackend, ProofProvider};
use sc_consensus::ImportQueue;
use sc_domains::RuntimeExecutor;
use sc_network::config::Roles;
use sc_network::peer_store::PeerStore;
use sc_network::NetworkService;
Expand All @@ -31,7 +32,6 @@ use sp_blockchain::HeaderMetadata;
use sp_consensus::block_validation::{Chain, DefaultBlockAnnounceValidator};
use sp_runtime::traits::{Block as BlockT, BlockIdTo, Zero};
use std::sync::Arc;
pub use subspace_service::domains::RuntimeExecutor;

/// Domain full client.
pub type FullClient<Block, RuntimeApi> = TFullClient<Block, RuntimeApi, RuntimeExecutor>;
Expand Down
1 change: 1 addition & 0 deletions domains/test/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ rand = "0.8.5"
pallet-transaction-payment = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
pallet-transaction-payment-rpc = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-client-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-domains = { version = "0.1.0", path = "../../../crates/sc-domains" }
sc-network = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-service = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion domains/test/service/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use domain_client_operator::{fetch_domain_bootstrap_info, BootstrapResult, Opera
use domain_runtime_primitives::opaque::Block;
use domain_runtime_primitives::Balance;
use domain_service::providers::DefaultProvider;
use domain_service::{FullClient, RuntimeExecutor};
use domain_service::FullClient;
use domain_test_primitives::OnchainStateApi;
use evm_domain_test_runtime;
use evm_domain_test_runtime::AccountId as AccountId20;
Expand All @@ -19,6 +19,7 @@ use frame_support::dispatch::{DispatchInfo, PostDispatchInfo};
use frame_system::pallet_prelude::BlockNumberFor;
use pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi;
use sc_client_api::HeaderBackend;
use sc_domains::RuntimeExecutor;
use sc_network::{NetworkService, NetworkStateInfo};
use sc_network_sync::SyncingService;
use sc_service::config::MultiaddrWithPeerId;
Expand Down
1 change: 1 addition & 0 deletions test/subspace-test-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ parking_lot = "0.12.1"
sc-block-builder = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-client-api = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-domains = { version = "0.1.0", path = "../../crates/sc-domains" }
sc-executor = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-network = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
sc-network-sync = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" }
Expand Down
4 changes: 2 additions & 2 deletions test/subspace-test-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use sc_consensus::block_import::{
use sc_consensus::{
BasicQueue, BlockImport, SharedBlockImport, StateAction, Verifier as VerifierT,
};
use sc_domains::ExtensionsFactory as DomainsExtensionFactory;
use sc_network::config::{NetworkConfiguration, TransportConfig};
use sc_network::{multiaddr, NotificationService};
use sc_service::config::{
Expand Down Expand Up @@ -82,7 +83,6 @@ use std::time;
use subspace_core_primitives::{PotOutput, Solution};
use subspace_runtime_primitives::opaque::Block;
use subspace_runtime_primitives::{AccountId, Balance, Hash};
use subspace_service::domains::ExtensionsFactory as DomainsExtensionFactory;
use subspace_service::transaction_pool::FullPool;
use subspace_service::{FullSelectChain, RuntimeExecutor};
use subspace_test_client::{chain_spec, Backend, Client};
Expand Down Expand Up @@ -362,7 +362,7 @@ impl MockConsensusNode {
.set_extensions_factory(MockExtensionsFactory::<
_,
DomainBlock,
subspace_service::domains::RuntimeExecutor,
sc_domains::RuntimeExecutor,
>::new(
client.clone(),
Arc::new(domain_executor),
Expand Down

0 comments on commit 5cdebfd

Please sign in to comment.