From c17eb3fd0561a6d94d81e059cb4ff1de4494c286 Mon Sep 17 00:00:00 2001 From: Greg Zaitsev Date: Fri, 29 Nov 2024 12:17:18 -0500 Subject: [PATCH] Update rate limit for setting children to 7200 --- pallets/subtensor/src/utils/rate_limiting.rs | 5 ++--- pallets/subtensor/tests/children.rs | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/utils/rate_limiting.rs b/pallets/subtensor/src/utils/rate_limiting.rs index abe4bdab..b00e7231 100644 --- a/pallets/subtensor/src/utils/rate_limiting.rs +++ b/pallets/subtensor/src/utils/rate_limiting.rs @@ -34,10 +34,9 @@ impl Pallet { // ==== Rate Limiting ===== // ======================== /// Get the rate limit for a specific transaction type - pub fn get_rate_limit(tx_type: &TransactionType, netuid: u16) -> u64 { - let subnet_tempo = Self::get_tempo(netuid); + pub fn get_rate_limit(tx_type: &TransactionType, _netuid: u16) -> u64 { match tx_type { - TransactionType::SetChildren => (subnet_tempo.saturating_mul(2)).into(), // Cannot set children twice within the default tempo period. + TransactionType::SetChildren => 7200, // Cannot set children twice within a day TransactionType::SetChildkeyTake => TxChildkeyTakeRateLimit::::get(), TransactionType::Unknown => 0, // Default to no limit for unknown types (no limit) } diff --git a/pallets/subtensor/tests/children.rs b/pallets/subtensor/tests/children.rs index 234fb0e8..3472f75d 100644 --- a/pallets/subtensor/tests/children.rs +++ b/pallets/subtensor/tests/children.rs @@ -357,6 +357,7 @@ fn test_add_singular_child() { Err(Error::::SubNetworkDoesNotExist.into()) ); add_network(netuid, 0, 0); + step_rate_limit(&TransactionType::SetChildren, netuid); assert_eq!( SubtensorModule::do_set_children( RuntimeOrigin::signed(coldkey), @@ -367,6 +368,7 @@ fn test_add_singular_child() { Err(Error::::NonAssociatedColdKey.into()) ); SubtensorModule::create_account_if_non_existent(&coldkey, &hotkey); + step_rate_limit(&TransactionType::SetChildren, netuid); assert_eq!( SubtensorModule::do_set_children( RuntimeOrigin::signed(coldkey), @@ -377,6 +379,7 @@ fn test_add_singular_child() { Err(Error::::InvalidChild.into()) ); let child = U256::from(3); + step_rate_limit(&TransactionType::SetChildren, netuid); assert_ok!(SubtensorModule::do_set_children( RuntimeOrigin::signed(coldkey), hotkey, @@ -2396,6 +2399,7 @@ fn test_dynamic_parent_child_relationships() { step_block(11); // Change parent-child relationships + step_rate_limit(&TransactionType::SetChildren, netuid); assert_ok!(SubtensorModule::do_set_children( RuntimeOrigin::signed(coldkey_parent), parent,