Skip to content

use smaller DefaultPendingCooldown for fast-blocks #1370

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

Merged
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
4 changes: 4 additions & 0 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,10 @@ pub mod pallet {
#[pallet::type_value]
/// Default value for applying pending items (e.g. childkeys).
pub fn DefaultPendingCooldown<T: Config>() -> u64 {
if cfg!(feature = "fast-blocks") {
return 15;
}

7_200
}

Expand Down
41 changes: 41 additions & 0 deletions pallets/subtensor/src/tests/children.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3949,3 +3949,44 @@ fn test_dividend_distribution_with_children_same_coldkey_owner() {
);
});
}

#[test]
fn test_pending_cooldown_one_day() {
let curr_block = 1;

let expected_cooldown = if cfg!(feature = "fast-blocks") {
15
} else {
7_200
};

new_test_ext(curr_block).execute_with(|| {
let coldkey = U256::from(1);
let hotkey = U256::from(2);
let child1 = U256::from(3);
let child2 = U256::from(4);
let netuid: u16 = 1;
let proportion1: u64 = 1000;
let proportion2: u64 = 2000;

// Add network and register hotkey
add_network(netuid, 13, 0);
register_ok_neuron(netuid, hotkey, coldkey, 0);

// Set multiple children
mock_schedule_children(
&coldkey,
&hotkey,
netuid,
&[(proportion1, child1), (proportion2, child2)],
);

// Verify pending map
let pending_children = PendingChildKeys::<Test>::get(netuid, hotkey);
assert_eq!(
pending_children.0,
vec![(proportion1, child1), (proportion2, child2)]
);
assert_eq!(pending_children.1, curr_block + expected_cooldown);
});
}
Loading