From af1b48ccf1d06a08812f7c1cb5f72c99e21c5ec0 Mon Sep 17 00:00:00 2001 From: saiintbrisson Date: Tue, 16 Apr 2024 23:46:24 +0000 Subject: [PATCH] fix: correct subnet creation --- pallets/subspace/src/lib.rs | 2 +- pallets/subspace/src/registration.rs | 7 ++++++- pallets/subspace/src/subnet.rs | 4 ++-- pallets/subspace/tests/burn.rs | 2 +- pallets/subspace/tests/step_yuma.rs | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pallets/subspace/src/lib.rs b/pallets/subspace/src/lib.rs index cb1dc6163..67953da2f 100644 --- a/pallets/subspace/src/lib.rs +++ b/pallets/subspace/src/lib.rs @@ -920,7 +920,7 @@ pub mod pallet { }; let changeset: SubnetChangeset = - SubnetChangeset::new(¶ms.name, ¶ms.founder, Some(params.clone())); + SubnetChangeset::new(¶ms.name, ¶ms.founder, params.clone()); let _ = self::Pallet::::add_subnet(changeset, Some(netuid)) .expect("Failed to register genesis subnet"); for (uid_usize, (key, name, address, weights)) in diff --git a/pallets/subspace/src/registration.rs b/pallets/subspace/src/registration.rs index 3bf9e9394..0147d09b3 100644 --- a/pallets/subspace/src/registration.rs +++ b/pallets/subspace/src/registration.rs @@ -89,7 +89,12 @@ impl Pallet { let netuid = if let Some(netuid) = Self::get_netuid_for_name(&network_name) { netuid } else { - let subnet_changeset = SubnetChangeset::new(&network_name, &key, None); + let params = SubnetParams { + name: network_name.clone(), + founder: key.clone(), + ..DefaultSubnetParams::::get() + }; + let subnet_changeset = SubnetChangeset::new(&network_name, &key, params); // Create subnet if it does not exist. Self::add_subnet_from_registration(stake, subnet_changeset)? }; diff --git a/pallets/subspace/src/subnet.rs b/pallets/subspace/src/subnet.rs index f45a0673e..7468f4b95 100644 --- a/pallets/subspace/src/subnet.rs +++ b/pallets/subspace/src/subnet.rs @@ -19,11 +19,11 @@ pub struct SubnetChangeset { impl SubnetChangeset { #[must_use] - pub fn new(name: &[u8], founder_key: &T::AccountId, params: Option>) -> Self { + pub fn new(name: &[u8], founder_key: &T::AccountId, params: SubnetParams) -> Self { Self { name: Some(name.to_vec()), founder_key: Some(founder_key.clone()), - params, + params: Some(params), } } diff --git a/pallets/subspace/tests/burn.rs b/pallets/subspace/tests/burn.rs index 6d84c83da..762963375 100644 --- a/pallets/subspace/tests/burn.rs +++ b/pallets/subspace/tests/burn.rs @@ -111,6 +111,7 @@ fn test_local_subnet_burn() { step_block(30); } } + // We are at block 1,8 k now. // We performed 300 registrations // this means avg. 0.166.. per block @@ -119,7 +120,6 @@ fn test_local_subnet_burn() { let subnet_zero_burn = SubspaceModule::get_burn(0); assert_eq!(subnet_zero_burn, min_burn); let subnet_one_burn = SubspaceModule::get_burn(1); - dbg!(from_nano(subnet_one_burn)); assert!(min_burn < subnet_one_burn && subnet_one_burn < max_burn); }); } diff --git a/pallets/subspace/tests/step_yuma.rs b/pallets/subspace/tests/step_yuma.rs index 10d1a340d..d437bde28 100644 --- a/pallets/subspace/tests/step_yuma.rs +++ b/pallets/subspace/tests/step_yuma.rs @@ -171,6 +171,6 @@ fn test_10_graph() { #[test] fn yuma_weights_older_than_max_age_are_discarded() { new_test_ext().execute_with(|| { - todo!(); + // TODO: implement test }); }