Skip to content

Commit

Permalink
feat: adding missing parameters (#79)
Browse files Browse the repository at this point in the history
* chore: bump versions

* feat: adding missing subnet parameter

* feat: updating max allowed validators

* feat: adding missing error
  • Loading branch information
functor-flow authored Aug 10, 2024
1 parent efe5419 commit 7c6bb45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pallets/subspace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,8 @@ pub mod pallet {
RootnetSubnetNotFound,
/// MinValidatorStake must be lower than 250k
InvalidMinValidatorStake,
/// The maximum allowed validators value is invalid, minimum is 10.
InvalidMaxAllowedValidators,
}

// ---------------------------------
Expand Down
8 changes: 8 additions & 0 deletions pallets/subspace/src/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ impl<T: Config> SubnetChangeset<T> {
Pallet::<T>::deposit_event(Event::SubnetParamsUpdated(netuid));

SubnetMetadata::<T>::set(netuid, self.params.metadata);
MaxAllowedValidators::<T>::insert(netuid, self.params.max_allowed_validators);

Ok(())
}
Expand Down Expand Up @@ -141,6 +142,13 @@ impl<T: Config> SubnetChangeset<T> {
Error::<T>::InvalidMinValidatorStake
);

if let Some(max_allowed_validators) = params.max_allowed_validators {
ensure!(
max_allowed_validators >= 10,
Error::<T>::InvalidMaxAllowedValidators
);
}

match Pallet::<T>::get_netuid_for_name(&params.name) {
Some(id) if netuid.is_some_and(|netuid| netuid == id) => { /* subnet kept same name */ }
Some(_) => return Err(Error::<T>::SubnetNameAlreadyExists.into()),
Expand Down

0 comments on commit 7c6bb45

Please sign in to comment.