Skip to content

Commit 488e2cf

Browse files
authored
Merge pull request #742 from opentensor/feat/maxchildkeytake
chore: max childkey take
2 parents 2fc1e3c + b60176d commit 488e2cf

File tree

6 files changed

+20
-4
lines changed

6 files changed

+20
-4
lines changed

pallets/admin-utils/tests/mock.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ parameter_types! {
8181
pub const InitialMinDelegateTake: u16 = 5_898; // 9%;
8282
pub const InitialDefaultChildKeyTake: u16 = 0; // Allow 0 %
8383
pub const InitialMinChildKeyTake: u16 = 0; // Allow 0 %
84+
pub const InitialMaxChildKeyTake: u16 = 11_796; // 18 %;
8485
pub const InitialWeightsVersionKey: u16 = 0;
8586
pub const InitialServingRateLimit: u64 = 0; // No limit.
8687
pub const InitialTxRateLimit: u64 = 0; // Disable rate limit for testing
@@ -153,6 +154,7 @@ impl pallet_subtensor::Config for Test {
153154
type InitialMinDelegateTake = InitialMinDelegateTake;
154155
type InitialDefaultChildKeyTake = InitialDefaultChildKeyTake;
155156
type InitialMinChildKeyTake = InitialMinChildKeyTake;
157+
type InitialMaxChildKeyTake = InitialMaxChildKeyTake;
156158
type InitialWeightsVersionKey = InitialWeightsVersionKey;
157159
type InitialMaxDifficulty = InitialMaxDifficulty;
158160
type InitialMinDifficulty = InitialMinDifficulty;

pallets/subtensor/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,19 @@ pub mod pallet {
181181
pub fn DefaultMinDelegateTake<T: Config>() -> u16 {
182182
T::InitialMinDelegateTake::get()
183183
}
184+
184185
#[pallet::type_value]
185186
/// Default minimum childkey take.
186187
pub fn DefaultMinChildKeyTake<T: Config>() -> u16 {
187188
T::InitialMinChildKeyTake::get()
188189
}
189190

191+
#[pallet::type_value]
192+
/// Default maximum childkey take.
193+
pub fn DefaultMaxChildKeyTake<T: Config>() -> u16 {
194+
T::InitialMaxChildKeyTake::get()
195+
}
196+
190197
#[pallet::type_value]
191198
/// Default account take.
192199
pub fn DefaultAccountTake<T: Config>() -> u64 {
@@ -619,7 +626,7 @@ pub mod pallet {
619626
#[pallet::storage] // --- ITEM ( min_delegate_take )
620627
pub type MinDelegateTake<T> = StorageValue<_, u16, ValueQuery, DefaultMinDelegateTake<T>>;
621628
#[pallet::storage] // --- ITEM ( default_childkey_take )
622-
pub type MaxChildkeyTake<T> = StorageValue<_, u16, ValueQuery, DefaultChildKeyTake<T>>;
629+
pub type MaxChildkeyTake<T> = StorageValue<_, u16, ValueQuery, DefaultMaxChildKeyTake<T>>;
623630
#[pallet::storage] // --- ITEM ( min_childkey_take )
624631
pub type MinChildkeyTake<T> = StorageValue<_, u16, ValueQuery, DefaultMinChildKeyTake<T>>;
625632

pallets/subtensor/src/macros/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ mod config {
122122
/// Initial minimum childkey take.
123123
#[pallet::constant]
124124
type InitialMinChildKeyTake: Get<u16>;
125+
/// Initial maximum childkey take.
126+
#[pallet::constant]
127+
type InitialMaxChildKeyTake: Get<u16>;
125128
/// Initial weights version key.
126129
#[pallet::constant]
127130
type InitialWeightsVersionKey: Get<u64>;

pallets/subtensor/tests/children.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ fn test_get_network_max_stake() {
14991499
let default_max_stake = SubtensorModule::get_network_max_stake(netuid);
15001500

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

15041504
// Set a new max stake value
15051505
let new_max_stake: u64 = 1_000_000;

pallets/subtensor/tests/mock.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ parameter_types! {
133133
pub const InitialFoundationDistribution: u64 = 0;
134134
pub const InitialDefaultDelegateTake: u16 = 11_796; // 18%, same as in production
135135
pub const InitialMinDelegateTake: u16 = 5_898; // 9%;
136-
pub const InitialDefaultChildKeyTake: u16 = 11_796; // 18%, same as in production
136+
pub const InitialDefaultChildKeyTake: u16 = 0 ;// 0 %
137137
pub const InitialMinChildKeyTake: u16 = 0; // 0 %;
138+
pub const InitialMaxChildKeyTake: u16 = 11_796; // 18 %;
138139
pub const InitialWeightsVersionKey: u16 = 0;
139140
pub const InitialServingRateLimit: u64 = 0; // No limit.
140141
pub const InitialTxRateLimit: u64 = 0; // Disable rate limit for testing
@@ -172,7 +173,7 @@ parameter_types! {
172173
pub const InitialAlphaLow: u16 = 45875; // Represents 0.7 as per the production default
173174
pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn
174175
pub const InitialHotkeyEmissionTempo: u64 = 0; // Defaults to draining every block.
175-
pub const InitialNetworkMaxStake: u64 = 500_000_000_000_000; // 500,000 TAO
176+
pub const InitialNetworkMaxStake: u64 = u64::MAX; // Maximum possible value for u64
176177

177178
}
178179

@@ -367,6 +368,7 @@ impl pallet_subtensor::Config for Test {
367368
type InitialMinDelegateTake = InitialMinDelegateTake;
368369
type InitialDefaultChildKeyTake = InitialDefaultChildKeyTake;
369370
type InitialMinChildKeyTake = InitialMinChildKeyTake;
371+
type InitialMaxChildKeyTake = InitialMaxChildKeyTake;
370372
type InitialTxChildKeyTakeRateLimit = InitialTxChildKeyTakeRateLimit;
371373
type InitialWeightsVersionKey = InitialWeightsVersionKey;
372374
type InitialMaxDifficulty = InitialMaxDifficulty;

runtime/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ parameter_types! {
910910
pub const SubtensorInitialMinDelegateTake: u16 = 0; // Allow 0% delegate take
911911
pub const SubtensorInitialDefaultChildKeyTake: u16 = 0; // Allow 0% childkey take
912912
pub const SubtensorInitialMinChildKeyTake: u16 = 0; // 0 %
913+
pub const SubtensorInitialMaxChildKeyTake: u16 = 11_796; // 18 %
913914
pub const SubtensorInitialWeightsVersionKey: u64 = 0;
914915
pub const SubtensorInitialMinDifficulty: u64 = 10_000_000;
915916
pub const SubtensorInitialMaxDifficulty: u64 = u64::MAX / 4;
@@ -981,6 +982,7 @@ impl pallet_subtensor::Config for Runtime {
981982
type InitialTxRateLimit = SubtensorInitialTxRateLimit;
982983
type InitialTxDelegateTakeRateLimit = SubtensorInitialTxDelegateTakeRateLimit;
983984
type InitialTxChildKeyTakeRateLimit = SubtensorInitialTxChildKeyTakeRateLimit;
985+
type InitialMaxChildKeyTake = SubtensorInitialMaxChildKeyTake;
984986
type InitialRAORecycledForRegistration = SubtensorInitialRAORecycledForRegistration;
985987
type InitialSenateRequiredStakePercentage = SubtensorInitialSenateRequiredStakePercentage;
986988
type InitialNetworkImmunityPeriod = SubtensorInitialNetworkImmunity;

0 commit comments

Comments
 (0)