Skip to content

Commit c17eb3f

Browse files
committed
Update rate limit for setting children to 7200
1 parent 5747644 commit c17eb3f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

pallets/subtensor/src/utils/rate_limiting.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ impl<T: Config> Pallet<T> {
3434
// ==== Rate Limiting =====
3535
// ========================
3636
/// Get the rate limit for a specific transaction type
37-
pub fn get_rate_limit(tx_type: &TransactionType, netuid: u16) -> u64 {
38-
let subnet_tempo = Self::get_tempo(netuid);
37+
pub fn get_rate_limit(tx_type: &TransactionType, _netuid: u16) -> u64 {
3938
match tx_type {
40-
TransactionType::SetChildren => (subnet_tempo.saturating_mul(2)).into(), // Cannot set children twice within the default tempo period.
39+
TransactionType::SetChildren => 7200, // Cannot set children twice within a day
4140
TransactionType::SetChildkeyTake => TxChildkeyTakeRateLimit::<T>::get(),
4241
TransactionType::Unknown => 0, // Default to no limit for unknown types (no limit)
4342
}

pallets/subtensor/tests/children.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ fn test_add_singular_child() {
357357
Err(Error::<Test>::SubNetworkDoesNotExist.into())
358358
);
359359
add_network(netuid, 0, 0);
360+
step_rate_limit(&TransactionType::SetChildren, netuid);
360361
assert_eq!(
361362
SubtensorModule::do_set_children(
362363
RuntimeOrigin::signed(coldkey),
@@ -367,6 +368,7 @@ fn test_add_singular_child() {
367368
Err(Error::<Test>::NonAssociatedColdKey.into())
368369
);
369370
SubtensorModule::create_account_if_non_existent(&coldkey, &hotkey);
371+
step_rate_limit(&TransactionType::SetChildren, netuid);
370372
assert_eq!(
371373
SubtensorModule::do_set_children(
372374
RuntimeOrigin::signed(coldkey),
@@ -377,6 +379,7 @@ fn test_add_singular_child() {
377379
Err(Error::<Test>::InvalidChild.into())
378380
);
379381
let child = U256::from(3);
382+
step_rate_limit(&TransactionType::SetChildren, netuid);
380383
assert_ok!(SubtensorModule::do_set_children(
381384
RuntimeOrigin::signed(coldkey),
382385
hotkey,
@@ -2396,6 +2399,7 @@ fn test_dynamic_parent_child_relationships() {
23962399
step_block(11);
23972400

23982401
// Change parent-child relationships
2402+
step_rate_limit(&TransactionType::SetChildren, netuid);
23992403
assert_ok!(SubtensorModule::do_set_children(
24002404
RuntimeOrigin::signed(coldkey_parent),
24012405
parent,

0 commit comments

Comments
 (0)