Skip to content

Commit

Permalink
Add extrinsic to change senate stake req, SenateSize -> 12, ReqStake …
Browse files Browse the repository at this point in the history
…-> 1%
  • Loading branch information
Rubberbandits committed Jun 28, 2023
1 parent 02c0a11 commit 7c2d751
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
8 changes: 8 additions & 0 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ pub mod pallet {
RegistrationAllowed( u16, bool ), // --- Event created when registration is allowed/disallowed for a subnet.
TempoSet(u16, u16), // --- Event created when setting tempo on a network
RAORecycledForRegistrationSet( u16, u64 ), // Event created when setting the RAO recycled for registration.
SenateRequiredStakePercentSet( u64 ), // Event created when setting the minimum required stake amount for senate registration.
}

// Errors inform users that something went wrong.
Expand Down Expand Up @@ -1704,6 +1705,13 @@ pub mod pallet {
pub fn sudo_set_registration_allowed( origin:OriginFor<T>, netuid: u16, registration_allowed: bool ) -> DispatchResult {
Self::do_sudo_set_network_registration_allowed( origin, netuid, registration_allowed )
}

#[pallet::call_index(56)]
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
pub fn sudo_set_senate_required_stake_perc(origin: OriginFor<T>, required_percent: u64 ) -> DispatchResult {
Self::do_set_senate_required_stake_perc(origin, required_percent)
}

}

// ---- Subtensor helper functions.
Expand Down
12 changes: 12 additions & 0 deletions pallets/subtensor/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,18 @@ impl<T: Config> Pallet<T> {
Self::deposit_event( Event::RAORecycledForRegistrationSet( netuid, rao_recycled ) );
Ok(())
}

pub fn set_senate_required_stake_perc( required_percent: u64 ) {
SenateRequiredStakePercentage::<T>::put( required_percent );
}

pub fn do_set_senate_required_stake_perc(origin: T::RuntimeOrigin, required_percent: u64) -> DispatchResult {
ensure_root( origin )?;

Self::set_senate_required_stake_perc( required_percent );
Self::deposit_event( Event::SenateRequiredStakePercentSet( required_percent ) );
Ok(())
}
}


Expand Down
4 changes: 2 additions & 2 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ parameter_types! {

// Configure collective pallet for Senate
parameter_types! {
pub const SenateMaxMembers: u32 = 10;
pub const SenateMaxMembers: u32 = 12;
}

use pallet_collective::{CanPropose, CanVote, GetVotingMembers};
Expand Down Expand Up @@ -528,7 +528,7 @@ parameter_types! {
pub const SubtensorInitialMaxBurn: u64 = 100_000_000_000; // 100 tao
pub const SubtensorInitialTxRateLimit: u64 = 1000;
pub const SubtensorInitialRAORecycledForRegistration: u64 = 0; // 0 rao
pub const SubtensorInitialSenateRequiredStakePercentage: u64 = 2; // 2 percent of total stake
pub const SubtensorInitialSenateRequiredStakePercentage: u64 = 1; // 1 percent of total stake
}

impl pallet_subtensor::Config for Runtime {
Expand Down

0 comments on commit 7c2d751

Please sign in to comment.