Skip to content

Commit dc6de01

Browse files
authored
Merge pull request #1320 from opentensor/fix/initial-tempo-to-360
Set initial tempo to 360
2 parents 1216f49 + d696695 commit dc6de01

File tree

4 files changed

+47
-11
lines changed

4 files changed

+47
-11
lines changed

pallets/subtensor/src/tests/children.rs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use super::mock::*;
55
use approx::assert_abs_diff_eq;
66
use frame_support::{assert_err, assert_noop, assert_ok};
7-
use substrate_fixed::types::I96F32;
7+
use substrate_fixed::types::{I64F64, I96F32};
88

99
use crate::{utils::rate_limiting::TransactionType, *};
1010
use sp_core::U256;
@@ -2852,13 +2852,23 @@ fn test_set_weights_no_parent() {
28522852
let values: Vec<u16> = vec![u16::MAX]; // Use maximum value for u16
28532853
let version_key = SubtensorModule::get_weights_version_key(netuid);
28542854

2855-
// Set the min stake very high
2856-
SubtensorModule::set_stake_threshold(stake_to_give_child * 5);
2855+
// Check the stake weight
2856+
let curr_stake_weight =
2857+
SubtensorModule::get_stake_weights_for_hotkey_on_subnet(&hotkey, netuid).0;
2858+
2859+
// Set the min stake very high, above the stake weight of the key
2860+
SubtensorModule::set_stake_threshold(
2861+
curr_stake_weight
2862+
.saturating_mul(I64F64::saturating_from_num(5))
2863+
.saturating_to_num::<u64>(),
2864+
);
28572865

2858-
// Check the key has less stake than required
2866+
let curr_stake_threshold = SubtensorModule::get_stake_threshold();
28592867
assert!(
2860-
SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey, netuid)
2861-
< SubtensorModule::get_stake_threshold()
2868+
curr_stake_weight < curr_stake_threshold,
2869+
"{:?} is not less than {:?} ",
2870+
curr_stake_weight,
2871+
curr_stake_threshold
28622872
);
28632873

28642874
// Check the hotkey cannot set weights
@@ -2876,12 +2886,21 @@ fn test_set_weights_no_parent() {
28762886
assert!(!SubtensorModule::check_weights_min_stake(&hotkey, netuid));
28772887

28782888
// Set a minimum stake to set weights
2879-
SubtensorModule::set_stake_threshold(stake_to_give_child - 5);
2889+
SubtensorModule::set_stake_threshold(
2890+
curr_stake_weight
2891+
.saturating_sub(I64F64::saturating_from_num(5))
2892+
.saturating_to_num::<u64>(),
2893+
);
28802894

28812895
// Check if the stake for the hotkey is above
2896+
let new_stake_weight =
2897+
SubtensorModule::get_stake_weights_for_hotkey_on_subnet(&hotkey, netuid).0;
2898+
let new_stake_threshold = SubtensorModule::get_stake_threshold();
28822899
assert!(
2883-
SubtensorModule::get_stake_for_hotkey_on_subnet(&hotkey, netuid)
2884-
>= SubtensorModule::get_stake_threshold()
2900+
new_stake_weight >= new_stake_threshold,
2901+
"{:?} is not greater than or equal to {:?} ",
2902+
new_stake_weight,
2903+
new_stake_threshold
28852904
);
28862905

28872906
// Check the hotkey can set weights

pallets/subtensor/src/tests/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ parameter_types! {
133133
pub const SDebug:u64 = 1;
134134
pub const InitialRho: u16 = 30;
135135
pub const InitialKappa: u16 = 32_767;
136-
pub const InitialTempo: u16 = 0;
136+
pub const InitialTempo: u16 = 360;
137137
pub const SelfOwnership: u64 = 2;
138138
pub const InitialImmunityPeriod: u16 = 2;
139139
pub const InitialMaxAllowedUids: u16 = 2;

pallets/subtensor/src/tests/networks.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,3 +326,20 @@ fn test_register_subnet_high_lock_cost() {
326326
assert_eq!(SubnetAlphaIn::<Test>::get(netuid), lock_cost);
327327
})
328328
}
329+
330+
#[test]
331+
fn test_tempo_greater_than_weight_set_rate_limit() {
332+
new_test_ext(1).execute_with(|| {
333+
let subnet_owner_hotkey = U256::from(1);
334+
let subnet_owner_coldkey = U256::from(2);
335+
336+
let netuid = add_dynamic_network(&subnet_owner_hotkey, &subnet_owner_coldkey);
337+
338+
// Get tempo
339+
let tempo = SubtensorModule::get_tempo(netuid);
340+
341+
let weights_set_rate_limit = SubtensorModule::get_weights_set_rate_limit(netuid);
342+
343+
assert!(tempo as u64 >= weights_set_rate_limit);
344+
})
345+
}

runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ impl pallet_commitments::Config for Runtime {
10231023
}
10241024

10251025
#[cfg(not(feature = "fast-blocks"))]
1026-
pub const INITIAL_SUBNET_TEMPO: u16 = 99;
1026+
pub const INITIAL_SUBNET_TEMPO: u16 = 360;
10271027

10281028
#[cfg(feature = "fast-blocks")]
10291029
pub const INITIAL_SUBNET_TEMPO: u16 = 10;

0 commit comments

Comments
 (0)