diff --git a/coordinator/src/main.rs b/coordinator/src/main.rs index ea310d035..0dc79bd39 100644 --- a/coordinator/src/main.rs +++ b/coordinator/src/main.rs @@ -987,7 +987,10 @@ pub async fn handle_processors( mut new_tributary: broadcast::Receiver>, ) { let mut channels = HashMap::new(); - for network in [NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero] { + for network in serai_client::primitives::NETWORKS { + if network == NetworkId::Serai { + continue; + } let (send, recv) = mpsc::unbounded_channel(); tokio::spawn(handle_processor_messages( db.clone(), diff --git a/message-queue/src/main.rs b/message-queue/src/main.rs index f2ae69c4b..313fd979a 100644 --- a/message-queue/src/main.rs +++ b/message-queue/src/main.rs @@ -183,14 +183,14 @@ async fn main() { Some(::G::from_bytes(&repr).unwrap()) }; - const ALL_EXT_NETWORKS: [NetworkId; 3] = - [NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero]; - let register_service = |service, key| { (*KEYS).write().unwrap().insert(service, key); let mut queues = (*QUEUES).write().unwrap(); if service == Service::Coordinator { - for network in ALL_EXT_NETWORKS { + for network in serai_primitives::NETWORKS { + if network == NetworkId::Serai { + continue; + } queues.insert( (service, Service::Processor(network)), RwLock::new(Queue(db.clone(), service, Service::Processor(network))), @@ -205,7 +205,10 @@ async fn main() { }; // Make queues for each NetworkId, other than Serai - for network in ALL_EXT_NETWORKS { + for network in serai_primitives::NETWORKS { + if network == NetworkId::Serai { + continue; + } // Use a match so we error if the list of NetworkIds changes let Some(key) = read_key(match network { NetworkId::Serai => unreachable!(), diff --git a/substrate/client/tests/validator_sets.rs b/substrate/client/tests/validator_sets.rs index 35b012f59..2a5c9068f 100644 --- a/substrate/client/tests/validator_sets.rs +++ b/substrate/client/tests/validator_sets.rs @@ -3,7 +3,7 @@ use rand_core::{RngCore, OsRng}; use sp_core::{sr25519::Public, Pair}; use serai_client::{ - primitives::{NetworkId, insecure_pair_from_name}, + primitives::{NETWORKS, NetworkId, insecure_pair_from_name}, validator_sets::{ primitives::{Session, ValidatorSet, musig_key}, ValidatorSetsEvent, @@ -38,7 +38,7 @@ serai_test!( .get_new_set_events(serai.get_block_by_number(0).await.unwrap().unwrap().hash()) .await .unwrap(), - [NetworkId::Serai, NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero] + NETWORKS .iter() .copied() .map(|network| ValidatorSetsEvent::NewSet { diff --git a/substrate/node/src/chain_spec.rs b/substrate/node/src/chain_spec.rs index a758b63be..32c32d035 100644 --- a/substrate/node/src/chain_spec.rs +++ b/substrate/node/src/chain_spec.rs @@ -56,8 +56,7 @@ fn testnet_genesis( validator_sets: ValidatorSetsConfig { stake: Amount(1_000_000 * 10_u64.pow(8)), - // TODO: Array of these in primitives - networks: vec![NetworkId::Serai, NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero], + networks: serai_runtime::primitives::NETWORKS.to_vec(), participants: validators.iter().map(|name| account_from_name(name)).collect(), }, session: SessionConfig { keys: validators.iter().map(|name| session_key(*name)).collect() }, diff --git a/substrate/primitives/src/networks.rs b/substrate/primitives/src/networks.rs index 28b4c7dee..22c32ebe3 100644 --- a/substrate/primitives/src/networks.rs +++ b/substrate/primitives/src/networks.rs @@ -31,6 +31,9 @@ pub enum NetworkId { Monero, } +pub const NETWORKS: [NetworkId; 4] = + [NetworkId::Serai, NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero]; + /// The type used to identify coins. #[derive( Clone, diff --git a/substrate/validator-sets/pallet/src/lib.rs b/substrate/validator-sets/pallet/src/lib.rs index 6f4bba60e..fa20632f8 100644 --- a/substrate/validator-sets/pallet/src/lib.rs +++ b/substrate/validator-sets/pallet/src/lib.rs @@ -32,7 +32,7 @@ pub mod pallet { /// /// Every participant at genesis will automatically be assumed to have this much stake. /// This stake cannot be withdrawn however as there's no actual stake behind it. - // TODO: Localize stake to network? + // TODO: Localize stake to network pub stake: Amount, /// Networks to spawn Serai with. pub networks: Vec, @@ -572,9 +572,7 @@ pub mod pallet { } pub fn new_session() { - // TODO: Define an array of all networks in primitives - let networks = [NetworkId::Serai, NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero]; - for network in networks { + for network in serai_primitives::NETWORKS { let current_session = Self::session(network); // Only spawn a NewSet if the current set was actually established with a completed // handover protocol