Skip to content

Commit

Permalink
fix: correct subnet creation
Browse files Browse the repository at this point in the history
  • Loading branch information
saiintbrisson committed Apr 16, 2024
1 parent e0fc2e3 commit af1b48c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pallets/subspace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ pub mod pallet {
};

let changeset: SubnetChangeset<T> =
SubnetChangeset::new(&params.name, &params.founder, Some(params.clone()));
SubnetChangeset::new(&params.name, &params.founder, params.clone());
let _ = self::Pallet::<T>::add_subnet(changeset, Some(netuid))
.expect("Failed to register genesis subnet");
for (uid_usize, (key, name, address, weights)) in
Expand Down
7 changes: 6 additions & 1 deletion pallets/subspace/src/registration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ impl<T: Config> Pallet<T> {
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::<T>::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)?
};
Expand Down
4 changes: 2 additions & 2 deletions pallets/subspace/src/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ pub struct SubnetChangeset<T: Config> {

impl<T: Config> SubnetChangeset<T> {
#[must_use]
pub fn new(name: &[u8], founder_key: &T::AccountId, params: Option<SubnetParams<T>>) -> Self {
pub fn new(name: &[u8], founder_key: &T::AccountId, params: SubnetParams<T>) -> Self {
Self {
name: Some(name.to_vec()),
founder_key: Some(founder_key.clone()),
params,
params: Some(params),
}
}

Expand Down
2 changes: 1 addition & 1 deletion pallets/subspace/tests/burn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
});
}
2 changes: 1 addition & 1 deletion pallets/subspace/tests/step_yuma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}

0 comments on commit af1b48c

Please sign in to comment.