Skip to content

Commit b46dc4b

Browse files
authored
Merge pull request #1370 from opentensor/feat/1367-add-fast-blocks-setting-for-chk-cooldown
use smaller DefaultPendingCooldown for fast-blocks
2 parents 738baca + 1878e20 commit b46dc4b

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

pallets/subtensor/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,10 @@ pub mod pallet {
728728
#[pallet::type_value]
729729
/// Default value for applying pending items (e.g. childkeys).
730730
pub fn DefaultPendingCooldown<T: Config>() -> u64 {
731+
if cfg!(feature = "fast-blocks") {
732+
return 15;
733+
}
734+
731735
7_200
732736
}
733737

pallets/subtensor/src/tests/children.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3949,3 +3949,44 @@ fn test_dividend_distribution_with_children_same_coldkey_owner() {
39493949
);
39503950
});
39513951
}
3952+
3953+
#[test]
3954+
fn test_pending_cooldown_one_day() {
3955+
let curr_block = 1;
3956+
3957+
let expected_cooldown = if cfg!(feature = "fast-blocks") {
3958+
15
3959+
} else {
3960+
7_200
3961+
};
3962+
3963+
new_test_ext(curr_block).execute_with(|| {
3964+
let coldkey = U256::from(1);
3965+
let hotkey = U256::from(2);
3966+
let child1 = U256::from(3);
3967+
let child2 = U256::from(4);
3968+
let netuid: u16 = 1;
3969+
let proportion1: u64 = 1000;
3970+
let proportion2: u64 = 2000;
3971+
3972+
// Add network and register hotkey
3973+
add_network(netuid, 13, 0);
3974+
register_ok_neuron(netuid, hotkey, coldkey, 0);
3975+
3976+
// Set multiple children
3977+
mock_schedule_children(
3978+
&coldkey,
3979+
&hotkey,
3980+
netuid,
3981+
&[(proportion1, child1), (proportion2, child2)],
3982+
);
3983+
3984+
// Verify pending map
3985+
let pending_children = PendingChildKeys::<Test>::get(netuid, hotkey);
3986+
assert_eq!(
3987+
pending_children.0,
3988+
vec![(proportion1, child1), (proportion2, child2)]
3989+
);
3990+
assert_eq!(pending_children.1, curr_block + expected_cooldown);
3991+
});
3992+
}

0 commit comments

Comments
 (0)