Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: max childkey take #742

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pallets/admin-utils/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ parameter_types! {
pub const InitialMinDelegateTake: u16 = 5_898; // 9%;
pub const InitialDefaultChildKeyTake: u16 = 0; // Allow 0 %
pub const InitialMinChildKeyTake: u16 = 0; // Allow 0 %
pub const InitialMaxChildKeyTake: u16 = 11_796; // 18 %;
pub const InitialWeightsVersionKey: u16 = 0;
pub const InitialServingRateLimit: u64 = 0; // No limit.
pub const InitialTxRateLimit: u64 = 0; // Disable rate limit for testing
Expand Down Expand Up @@ -153,6 +154,7 @@ impl pallet_subtensor::Config for Test {
type InitialMinDelegateTake = InitialMinDelegateTake;
type InitialDefaultChildKeyTake = InitialDefaultChildKeyTake;
type InitialMinChildKeyTake = InitialMinChildKeyTake;
type InitialMaxChildKeyTake = InitialMaxChildKeyTake;
type InitialWeightsVersionKey = InitialWeightsVersionKey;
type InitialMaxDifficulty = InitialMaxDifficulty;
type InitialMinDifficulty = InitialMinDifficulty;
Expand Down
9 changes: 8 additions & 1 deletion pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,19 @@ pub mod pallet {
pub fn DefaultMinDelegateTake<T: Config>() -> u16 {
T::InitialMinDelegateTake::get()
}

#[pallet::type_value]
/// Default minimum childkey take.
pub fn DefaultMinChildKeyTake<T: Config>() -> u16 {
T::InitialMinChildKeyTake::get()
}

#[pallet::type_value]
/// Default maximum childkey take.
pub fn DefaultMaxChildKeyTake<T: Config>() -> u16 {
T::InitialMaxChildKeyTake::get()
}

#[pallet::type_value]
/// Default account take.
pub fn DefaultAccountTake<T: Config>() -> u64 {
Expand Down Expand Up @@ -619,7 +626,7 @@ pub mod pallet {
#[pallet::storage] // --- ITEM ( min_delegate_take )
pub type MinDelegateTake<T> = StorageValue<_, u16, ValueQuery, DefaultMinDelegateTake<T>>;
#[pallet::storage] // --- ITEM ( default_childkey_take )
pub type MaxChildkeyTake<T> = StorageValue<_, u16, ValueQuery, DefaultChildKeyTake<T>>;
pub type MaxChildkeyTake<T> = StorageValue<_, u16, ValueQuery, DefaultMaxChildKeyTake<T>>;
#[pallet::storage] // --- ITEM ( min_childkey_take )
pub type MinChildkeyTake<T> = StorageValue<_, u16, ValueQuery, DefaultMinChildKeyTake<T>>;

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 @@ -122,6 +122,9 @@ mod config {
/// Initial minimum childkey take.
#[pallet::constant]
type InitialMinChildKeyTake: Get<u16>;
/// Initial maximum childkey take.
#[pallet::constant]
type InitialMaxChildKeyTake: Get<u16>;
/// Initial weights version key.
#[pallet::constant]
type InitialWeightsVersionKey: Get<u64>;
Expand Down
2 changes: 1 addition & 1 deletion pallets/subtensor/tests/children.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ fn test_get_network_max_stake() {
let default_max_stake = SubtensorModule::get_network_max_stake(netuid);

// Check that the default value is set correctly
assert_eq!(default_max_stake, 500_000_000_000_000);
assert_eq!(default_max_stake, u64::MAX);

// Set a new max stake value
let new_max_stake: u64 = 1_000_000;
Expand Down
6 changes: 4 additions & 2 deletions pallets/subtensor/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ parameter_types! {
pub const InitialFoundationDistribution: u64 = 0;
pub const InitialDefaultDelegateTake: u16 = 11_796; // 18%, same as in production
pub const InitialMinDelegateTake: u16 = 5_898; // 9%;
pub const InitialDefaultChildKeyTake: u16 = 11_796; // 18%, same as in production
pub const InitialDefaultChildKeyTake: u16 = 0 ;// 0 %
pub const InitialMinChildKeyTake: u16 = 0; // 0 %;
pub const InitialMaxChildKeyTake: u16 = 11_796; // 18 %;
pub const InitialWeightsVersionKey: u16 = 0;
pub const InitialServingRateLimit: u64 = 0; // No limit.
pub const InitialTxRateLimit: u64 = 0; // Disable rate limit for testing
Expand Down Expand Up @@ -172,7 +173,7 @@ parameter_types! {
pub const InitialAlphaLow: u16 = 45875; // Represents 0.7 as per the production default
pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn
pub const InitialHotkeyEmissionTempo: u64 = 0; // Defaults to draining every block.
pub const InitialNetworkMaxStake: u64 = 500_000_000_000_000; // 500,000 TAO
pub const InitialNetworkMaxStake: u64 = u64::MAX; // Maximum possible value for u64

}

Expand Down Expand Up @@ -367,6 +368,7 @@ impl pallet_subtensor::Config for Test {
type InitialMinDelegateTake = InitialMinDelegateTake;
type InitialDefaultChildKeyTake = InitialDefaultChildKeyTake;
type InitialMinChildKeyTake = InitialMinChildKeyTake;
type InitialMaxChildKeyTake = InitialMaxChildKeyTake;
type InitialTxChildKeyTakeRateLimit = InitialTxChildKeyTakeRateLimit;
type InitialWeightsVersionKey = InitialWeightsVersionKey;
type InitialMaxDifficulty = InitialMaxDifficulty;
Expand Down
2 changes: 2 additions & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ parameter_types! {
pub const SubtensorInitialMinDelegateTake: u16 = 0; // Allow 0% delegate take
pub const SubtensorInitialDefaultChildKeyTake: u16 = 0; // Allow 0% childkey take
pub const SubtensorInitialMinChildKeyTake: u16 = 0; // 0 %
pub const SubtensorInitialMaxChildKeyTake: u16 = 11_796; // 18 %
pub const SubtensorInitialWeightsVersionKey: u64 = 0;
pub const SubtensorInitialMinDifficulty: u64 = 10_000_000;
pub const SubtensorInitialMaxDifficulty: u64 = u64::MAX / 4;
Expand Down Expand Up @@ -981,6 +982,7 @@ impl pallet_subtensor::Config for Runtime {
type InitialTxRateLimit = SubtensorInitialTxRateLimit;
type InitialTxDelegateTakeRateLimit = SubtensorInitialTxDelegateTakeRateLimit;
type InitialTxChildKeyTakeRateLimit = SubtensorInitialTxChildKeyTakeRateLimit;
type InitialMaxChildKeyTake = SubtensorInitialMaxChildKeyTake;
type InitialRAORecycledForRegistration = SubtensorInitialRAORecycledForRegistration;
type InitialSenateRequiredStakePercentage = SubtensorInitialSenateRequiredStakePercentage;
type InitialNetworkImmunityPeriod = SubtensorInitialNetworkImmunity;
Expand Down
Loading