Skip to content

Commit

Permalink
admin-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
andreea-popescu-reef committed Jan 15, 2025
1 parent bf1f5c7 commit 4ee6910
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 10 deletions.
8 changes: 5 additions & 3 deletions hyperparameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TxRateLimit: u64 = 1; // [1 @ 64,888]
### netuid 1 (text_prompting)
```rust
Rho: u16 = 10;
Kappa: u16 = 32_767; // 0.5 = 65535/2
Kappa: u16 = 32_767; // 0.5 = 65535/2
MaxAllowedUids: u16 = 1024;
Issuance: u64 = 0;
MinAllowedWeights: u16 = 8;
Expand All @@ -32,10 +32,11 @@ ActivityCutoff: u16 = 5000;
MaxRegistrationsPerBlock: u16 = 1;
PruningScore : u16 = u16::MAX;
BondsMovingAverage: u64 = 900_000;
BondsPenalty: u16 = 0;
WeightsVersionKey: u64 = 1020;
MinDifficulty: u64 = 10_000_000;
MaxDifficulty: u64 = u64::MAX / 4;
ServingRateLimit: u64 = 10;
ServingRateLimit: u64 = 10;
Burn: u64 = 1_000_000_000; // 1 tao
MinBurn: u64 = 1_000_000_000; // 1 tao
MaxBurn: u64 = 100_000_000_000; // 100 tao
Expand All @@ -45,7 +46,7 @@ WeightsSetRateLimit: u64 = 100;
### netuid 3 (causallmnext)
```rust
Rho: u16 = 10;
Kappa: u16 = 32_767; // 0.5 = 65535/2
Kappa: u16 = 32_767; // 0.5 = 65535/2
MaxAllowedUids: u16 = 4096;
Issuance: u64 = 0;
MinAllowedWeights: u16 = 50;
Expand All @@ -70,6 +71,7 @@ ActivityCutoff: u16 = 5000; // [5000 @ 7,163]
MaxRegistrationsPerBlock: u16 = 1;
PruningScore : u16 = u16::MAX;
BondsMovingAverage: u64 = 900_000;
BondsPenalty: u16 = 0;
WeightsVersionKey: u64 = 400;
MinDifficulty: u64 = 10_000_000;
MaxDifficulty: u64 = u64::MAX / 4;
Expand Down
8 changes: 8 additions & 0 deletions pallets/admin-utils/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ mod benchmarks {
_(RawOrigin::Root, 1u16/*netuid*/, 100u64/*bonds_moving_average*/)/*sudo_set_bonds_moving_average*/;
}

#[benchmark]
fn sudo_set_bonds_penalty() {
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 100u16/*bonds_penalty*/)/*sudo_set_bonds_penalty*/;
}

#[benchmark]
fn sudo_set_max_allowed_validators() {
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
Expand Down
25 changes: 25 additions & 0 deletions pallets/admin-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,31 @@ pub mod pallet {
Ok(())
}

/// The extrinsic sets the bonds penalty for a subnet.
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the bonds penalty.
#[pallet::call_index(60)]
#[pallet::weight(<T as Config>::WeightInfo::sudo_set_bonds_penalty())]
pub fn sudo_set_bonds_penalty(
origin: OriginFor<T>,
netuid: u16,
bonds_penalty: u16,
) -> DispatchResult {
pallet_subtensor::Pallet::<T>::ensure_subnet_owner_or_root(origin, netuid)?;

ensure!(
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
Error::<T>::SubnetDoesNotExist
);
pallet_subtensor::Pallet::<T>::set_bonds_penalty(netuid, bonds_penalty);
log::debug!(
"BondsPenalty( netuid: {:?} bonds_penalty: {:?} ) ",
netuid,
bonds_penalty
);
Ok(())
}

/// The extrinsic sets the maximum registrations per block for a subnet.
/// It is only callable by the root account.
/// The extrinsic will call the Subtensor pallet to set the maximum registrations per block.
Expand Down
14 changes: 7 additions & 7 deletions pallets/admin-utils/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,26 +746,26 @@ fn test_sudo_set_bonds_penalty() {
new_test_ext().execute_with(|| {
let netuid: u16 = 1;
let to_be_set: u16 = 10;
add_network(netuid, 10);
let init_value: u16 = SubtensorModule::get_bonds_penalty(netuid);
add_network(netuid, 10, 0);
assert_eq!(
SubtensorModule::sudo_set_bonds_penalty(
<<Test as Config>::RuntimeOrigin>::signed(U256::from(0)),
AdminUtils::sudo_set_bonds_penalty(
<<Test as Config>::RuntimeOrigin>::signed(U256::from(1)),
netuid,
to_be_set
),
Err(DispatchError::BadOrigin.into())
Err(DispatchError::BadOrigin)
);
assert_eq!(
SubtensorModule::sudo_set_bonds_penalty(
AdminUtils::sudo_set_bonds_penalty(
<<Test as Config>::RuntimeOrigin>::root(),
netuid + 1,
to_be_set
),
Err(Error::<Test>::NetworkDoesNotExist.into())
Err(Error::<Test>::SubnetDoesNotExist.into())
);
assert_eq!(SubtensorModule::get_bonds_penalty(netuid), init_value);
assert_ok!(SubtensorModule::sudo_set_bonds_penalty(
assert_ok!(AdminUtils::sudo_set_bonds_penalty(
<<Test as Config>::RuntimeOrigin>::root(),
netuid,
to_be_set
Expand Down
27 changes: 27 additions & 0 deletions pallets/admin-utils/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub trait WeightInfo {
fn sudo_set_weights_set_rate_limit() -> Weight;
fn sudo_set_weights_version_key() -> Weight;
fn sudo_set_bonds_moving_average() -> Weight;
fn sudo_set_bonds_penalty() -> Weight;
fn sudo_set_max_allowed_validators() -> Weight;
fn sudo_set_difficulty() -> Weight;
fn sudo_set_adjustment_interval() -> Weight;
Expand Down Expand Up @@ -182,6 +183,19 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
}
/// Storage: SubtensorModule NetworksAdded (r:1 w:0)
/// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured)
/// Storage: SubtensorModule BondsPenalty (r:0 w:1)
/// Proof Skipped: SubtensorModule BondsPenalty (max_values: None, max_size: None, mode: Measured)
fn sudo_set_bonds_penalty() -> Weight {
// Proof Size summary in bytes:
// Measured: `1111`
// Estimated: `4697`
// Minimum execution time: 46_099_000 picoseconds.
Weight::from_parts(47_510_000, 4697)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: SubtensorModule NetworksAdded (r:1 w:0)
/// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured)
/// Storage: SubtensorModule MaxAllowedUids (r:1 w:0)
/// Proof Skipped: SubtensorModule MaxAllowedUids (max_values: None, max_size: None, mode: Measured)
/// Storage: SubtensorModule MaxAllowedValidators (r:0 w:1)
Expand Down Expand Up @@ -559,6 +573,19 @@ impl WeightInfo for () {
}
/// Storage: SubtensorModule NetworksAdded (r:1 w:0)
/// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured)
/// Storage: SubtensorModule BondsPenalty (r:0 w:1)
/// Proof Skipped: SubtensorModule BondsPenalty (max_values: None, max_size: None, mode: Measured)
fn sudo_set_bonds_penalty() -> Weight {
// Proof Size summary in bytes:
// Measured: `1111`
// Estimated: `4697`
// Minimum execution time: 46_099_000 picoseconds.
Weight::from_parts(47_510_000, 4697)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
/// Storage: SubtensorModule NetworksAdded (r:1 w:0)
/// Proof Skipped: SubtensorModule NetworksAdded (max_values: None, max_size: None, mode: Measured)
/// Storage: SubtensorModule MaxAllowedUids (r:1 w:0)
/// Proof Skipped: SubtensorModule MaxAllowedUids (max_values: None, max_size: None, mode: Measured)
/// Storage: SubtensorModule MaxAllowedValidators (r:0 w:1)
Expand Down

0 comments on commit 4ee6910

Please sign in to comment.