diff --git a/crates/sp-domains/src/lib.rs b/crates/sp-domains/src/lib.rs index b4013fd8b6..118612fd0f 100644 --- a/crates/sp-domains/src/lib.rs +++ b/crates/sp-domains/src/lib.rs @@ -50,6 +50,7 @@ use sp_runtime::{Digest, DigestItem, OpaqueExtrinsic, Percent}; use sp_runtime_interface::pass_by; use sp_runtime_interface::pass_by::PassBy; use sp_std::collections::btree_set::BTreeSet; +use sp_std::fmt::{Display, Formatter}; use sp_std::vec::Vec; use sp_weights::Weight; use subspace_core_primitives::crypto::blake3_hash; @@ -170,6 +171,12 @@ impl DomainId { } } +impl Display for DomainId { + fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { + self.0.fmt(f) + } +} + impl PassBy for DomainId { type PassBy = pass_by::Codec; } diff --git a/crates/subspace-node/src/bin/subspace-node.rs b/crates/subspace-node/src/bin/subspace-node.rs index 45935087bc..0625b8e1b7 100644 --- a/crates/subspace-node/src/bin/subspace-node.rs +++ b/crates/subspace-node/src/bin/subspace-node.rs @@ -433,6 +433,21 @@ fn main() -> Result<(), Error> { runner.run_node_until_exit(|consensus_chain_config| async move { let tokio_handle = consensus_chain_config.tokio_handle.clone(); let database_source = consensus_chain_config.database.clone(); + + let domains_bootstrap_nodes: serde_json::map::Map = + consensus_chain_config + .chain_spec + .properties() + .get("domainsBootstrapNodes") + .map(|d| serde_json::from_value(d.clone())) + .transpose() + .map_err(|error| { + sc_service::Error::Other(format!( + "Failed to decode Domains bootstrap nodes: {error:?}" + )) + })? + .unwrap_or_default(); + let consensus_chain_node = { let span = sc_tracing::tracing::info_span!( sc_tracing::logging::PREFIX_LOG_SPAN, @@ -556,14 +571,29 @@ fn main() -> Result<(), Error> { ); let _enter = span.enter(); - let domain_cli = DomainCli::new( + let mut domain_cli = DomainCli::new( cli.run .base_path()? .map(|base_path| base_path.path().to_path_buf()), cli.domain_args.into_iter(), ); + let domain_id = domain_cli.domain_id; + if domain_cli.run.network_params.bootnodes.is_empty() { + domain_cli.run.network_params.bootnodes = domains_bootstrap_nodes + .get(&format!("{}", domain_id)) + .map(|d| serde_json::from_value(d.clone())) + .transpose() + .map_err(|error| { + sc_service::Error::Other(format!( + "Failed to decode Domain: {} bootstrap nodes: {error:?}", + domain_id + )) + })? + .unwrap_or_default(); + } + // start relayer for consensus chain let mut xdm_gossip_worker_builder = GossipWorkerBuilder::new(); { diff --git a/crates/subspace-node/src/chain_spec_utils.rs b/crates/subspace-node/src/chain_spec_utils.rs index 6bf890da70..18d6203bcb 100644 --- a/crates/subspace-node/src/chain_spec_utils.rs +++ b/crates/subspace-node/src/chain_spec_utils.rs @@ -1,5 +1,7 @@ use frame_support::traits::Get; use sc_service::Properties; +use serde_json::map::Map; +use serde_json::Value; use sp_core::crypto::AccountId32; use sp_core::{sr25519, Pair, Public}; use sp_runtime::traits::IdentifyAccount; @@ -18,6 +20,11 @@ pub(crate) fn chain_spec_properties() -> Properties { ); properties.insert("tokenDecimals".to_string(), DECIMAL_PLACES.into()); properties.insert("tokenSymbol".to_string(), "tSSC".into()); + let domains_bootstrap_nodes = Map::::new(); + properties.insert( + "domainsBootstrapNodes".to_string(), + domains_bootstrap_nodes.into(), + ); properties }