Skip to content

Commit

Permalink
add constants
Browse files Browse the repository at this point in the history
  • Loading branch information
camfairchild committed Nov 27, 2024
1 parent a5e23ac commit 083e334
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pallets/admin-utils/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ parameter_types! {
pub const InitialColdkeySwapScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // 5 days
pub const InitialGlobalWeight: u64 = u64::MAX/2; // 50% global weight.
pub const InitialRootWeight: u64 = 3_320_413_900_000_000_000; // 18% root weight
pub const InitialMaxNominators: u16 = 10_000; // Per-subnet maximum amount of nominators.
}

impl pallet_subtensor::Config for Test {
Expand Down Expand Up @@ -192,6 +193,7 @@ impl pallet_subtensor::Config for Test {
type InitialColdkeySwapScheduleDuration = InitialColdkeySwapScheduleDuration;
type InitialGlobalWeight = InitialGlobalWeight;
type InitialRootWeight = InitialRootWeight;
type InitialMaxNominators = InitialMaxNominators;
}

#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
Expand Down
10 changes: 10 additions & 0 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,16 @@ pub mod pallet {
pub fn DefaultStakeDelta<T: Config>() -> i128 {
0
}
#[pallet::type_value]
/// Default value for maximum nominator count.
pub fn DefaultMaxNominators<T: Config>() -> u16 {
T::InitialMaxNominators::get()
}
#[pallet::type_value]
/// Default value for minimum stake a nominator has.
pub fn DefaultMinNominatorStake<T: Config>() -> u64 {
u64::MAX
}

#[pallet::storage]
pub type ColdkeySwapScheduleDuration<T: Config> =
Expand Down
3 changes: 3 additions & 0 deletions pallets/subtensor/src/macros/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,8 @@ mod config {
/// Coldkey swap schedule duartion.
#[pallet::constant]
type InitialColdkeySwapScheduleDuration: Get<BlockNumberFor<Self>>;
/// Default value for maximum nominator count.
#[pallet::constant]
type InitialMaxNominators: Get<u16>;
}
}
2 changes: 2 additions & 0 deletions pallets/subtensor/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ parameter_types! {
pub const InitialColdkeySwapScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // Default as 5 days
pub const InitialGlobalWeight: u64 = 0; // zero global weight.
pub const InitialRootWeight: u64 = 3_320_413_900_000_000_000; // 18% root weight
pub const InitialMaxNominators: u16 = 10_000; // Per-subnet maximum amount of nominators.
}

// Configure collective pallet for council
Expand Down Expand Up @@ -404,6 +405,7 @@ impl pallet_subtensor::Config for Test {
type InitialColdkeySwapScheduleDuration = InitialColdkeySwapScheduleDuration;
type InitialGlobalWeight = InitialGlobalWeight;
type InitialRootWeight = InitialRootWeight;
type InitialMaxNominators = InitialMaxNominators;
}

pub struct OriginPrivilegeCmp;
Expand Down
4 changes: 3 additions & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ parameter_types! {
pub const SubtensorInitialGlobalWeight: u64 = u64::MAX; // 100% global weight.
pub const SubtensorInitialRootWeight: u64 = 3_320_413_900_000_000_000; // 18% root weight
pub const SubtensorInitialColdkeySwapScheduleDuration: BlockNumber = 5 * 24 * 60 * 60 / 12; // 5 days
pub const SubtensorInitialMaxNominators: u16 = 100; // Per-subnet maximum amount of nominators. TODO (cam): pick decent value
}

impl pallet_subtensor::Config for Runtime {
Expand Down Expand Up @@ -1049,7 +1050,8 @@ impl pallet_subtensor::Config for Runtime {
type Preimages = Preimage;
type InitialColdkeySwapScheduleDuration = SubtensorInitialColdkeySwapScheduleDuration;
type InitialGlobalWeight = SubtensorInitialGlobalWeight;
type InitialRootWeight = SubtensorRootWeight;
type InitialRootWeight = SubtensorInitialRootWeight;
type InitialMaxNominators = SubtensorInitialMaxNominators;
}

use sp_runtime::BoundedVec;
Expand Down

0 comments on commit 083e334

Please sign in to comment.