Skip to content

Commit 986c688

Browse files
committed
childkey tax rate
1 parent 121964f commit 986c688

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

pallets/admin-utils/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,17 @@ pub mod pallet {
16821682
pallet_subtensor::Pallet::<T>::set_owner_immune_neuron_limit(netuid, immune_neurons)?;
16831683
Ok(())
16841684
}
1685+
1686+
#[pallet::call_index(73)]
1687+
#[pallet::weight(Weight::from_parts(15_000_000, 0))]
1688+
pub fn sudo_set_childkey_tax_rate(
1689+
origin: OriginFor<T>,
1690+
childkey_tax_rate: u16,
1691+
) -> DispatchResult {
1692+
ensure_root(origin)?;
1693+
pallet_subtensor::Pallet::<T>::set_childkey_tax_rate(childkey_tax_rate)?;
1694+
Ok(())
1695+
}
16851696
}
16861697
}
16871698

pallets/subtensor/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,14 @@ pub mod pallet {
14821482
pub type ImmuneOwnerUidsLimit<T> =
14831483
StorageMap<_, Identity, NetUid, u16, ValueQuery, DefaultImmuneOwnerUidsLimit<T>>;
14841484

1485+
#[pallet::type_value]
1486+
/// Default value for childkey tax rate
1487+
pub fn DefaultChildkeyTaxRate<T: Config>() -> u16 {
1488+
18
1489+
}
1490+
#[pallet::storage]
1491+
pub type ChildkeyTaxRate<T> = StorageValue<_, u16, ValueQuery, DefaultChildkeyTaxRate<T>>;
1492+
14851493
/// =======================================
14861494
/// ==== Subnetwork Consensus Storage ====
14871495
/// =======================================

pallets/subtensor/src/utils/misc.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,4 +829,28 @@ impl<T: Config> Pallet<T> {
829829
ImmuneOwnerUidsLimit::<T>::insert(netuid, limit);
830830
Ok(())
831831
}
832+
833+
/// Get the childkey tax rate
834+
///
835+
/// # Returns
836+
/// - `u16` - The childkey tax rate.
837+
pub fn get_childkey_tax_rate() -> u16 {
838+
ChildkeyTaxRate::<T>::get()
839+
}
840+
841+
/// Set the childkey tax rate
842+
///
843+
/// # Arguments
844+
///
845+
/// * `childkey_tax_rate` - The new childkey tax rate.
846+
///
847+
/// # Returns
848+
/// - `Ok(())` on success.
849+
/// - `Err(Error::<T>::InvalidValue)` if `childkey_tax_rate` is outside `[0, 100]`.
850+
pub fn set_childkey_tax_rate(childkey_tax_rate: u16) -> DispatchResult {
851+
ensure!(childkey_tax_rate <= 100, Error::<T>::InvalidValue);
852+
853+
ChildkeyTaxRate::<T>::set(childkey_tax_rate);
854+
Ok(())
855+
}
832856
}

0 commit comments

Comments
 (0)