@@ -10,10 +10,10 @@ use pallet_rate_limiting::{
1010} ;
1111use pallet_subtensor:: {
1212 self , AssociatedEvmAddress , Axons , Config as SubtensorConfig , HasMigrationRun ,
13- LastRateLimitedBlock , LastUpdate , MaxUidsTrimmingRateLimit , MechanismCountCurrent ,
14- MechanismCountSetRateLimit , MechanismEmissionRateLimit , NetworkRateLimit ,
15- OwnerHyperparamRateLimit , Pallet , Prometheus , RateLimitKey , TransactionKeyLastBlock ,
16- TxChildkeyTakeRateLimit , TxDelegateTakeRateLimit , TxRateLimit , WeightsVersionKeyRateLimit ,
13+ LastRateLimitedBlock , LastUpdate , MaxUidsTrimmingRateLimit , MechanismCountSetRateLimit ,
14+ MechanismEmissionRateLimit , NetworkRateLimit , OwnerHyperparamRateLimit , Pallet , Prometheus ,
15+ RateLimitKey , TransactionKeyLastBlock , TxChildkeyTakeRateLimit , TxDelegateTakeRateLimit ,
16+ TxRateLimit , WeightsVersionKeyRateLimit ,
1717 utils:: rate_limiting:: { Hyperparameter , TransactionType } ,
1818} ;
1919use sp_runtime:: traits:: SaturatedConversion ;
@@ -22,7 +22,7 @@ use sp_std::{
2222 vec,
2323 vec:: Vec ,
2424} ;
25- use subtensor_runtime_common:: { MechId , NetUid } ;
25+ use subtensor_runtime_common:: NetUid ;
2626
2727use super :: { RateLimitScope , RateLimitUsageKey } ;
2828
@@ -240,13 +240,6 @@ fn weight_calls_subnet(grouping: &Grouping) -> Vec<TransactionIdentifier> {
240240 . unwrap_or_default ( )
241241}
242242
243- fn weight_calls_mechanism ( grouping : & Grouping ) -> Vec < TransactionIdentifier > {
244- grouping
245- . members ( GROUP_WEIGHTS_MECHANISM )
246- . map ( |m| m. iter ( ) . copied ( ) . collect ( ) )
247- . unwrap_or_default ( )
248- }
249-
250243fn build_grouping ( ) -> Grouping {
251244 let mut grouping = Grouping :: default ( ) ;
252245
@@ -469,13 +462,10 @@ fn gather_weight_limits<T: SubtensorConfig>(
469462 let mut reads: u64 = 0 ;
470463 let netuids = Pallet :: < T > :: get_all_subnet_netuids ( ) ;
471464
472- let mut subnet_limits = BTreeMap :: < NetUid , BlockNumberFor < T > > :: new ( ) ;
473465 let subnet_calls = weight_calls_subnet ( grouping) ;
474- let mechanism_calls = weight_calls_mechanism ( grouping) ;
475466 for netuid in & netuids {
476467 reads += 1 ;
477468 if let Some ( span) = block_number :: < T > ( Pallet :: < T > :: get_weights_set_rate_limit ( * netuid) ) {
478- subnet_limits. insert ( * netuid, span) ;
479469 for call in & subnet_calls {
480470 set_scoped_limit :: < T > (
481471 limits,
@@ -487,26 +477,6 @@ fn gather_weight_limits<T: SubtensorConfig>(
487477 }
488478 }
489479
490- for netuid in & netuids {
491- reads += 1 ;
492- let mech_count: u8 = MechanismCountCurrent :: < T > :: get ( * netuid) . into ( ) ;
493- if mech_count <= 1 {
494- continue ;
495- }
496- let Some ( span) = subnet_limits. get ( netuid) . copied ( ) else {
497- continue ;
498- } ;
499- for mecid in 1 ..mech_count {
500- let scope = RateLimitScope :: SubnetMechanism {
501- netuid : * netuid,
502- mecid : MechId :: from ( mecid) ,
503- } ;
504- for call in & mechanism_calls {
505- set_scoped_limit :: < T > ( limits, grouping. config_target ( * call) , scope. clone ( ) , span) ;
506- }
507- }
508- }
509-
510480 reads
511481}
512482
@@ -621,18 +591,9 @@ fn import_last_update_entries<T: SubtensorConfig>(
621591) -> u64 {
622592 let mut reads: u64 = 0 ;
623593 let subnet_calls = weight_calls_subnet ( grouping) ;
624- let mechanism_calls = weight_calls_mechanism ( grouping) ;
625594 for ( index, blocks) in LastUpdate :: < T > :: iter ( ) {
626595 reads += 1 ;
627596 let netuid = Pallet :: < T > :: get_netuid ( index) ;
628- let sub_id = u16:: from ( index)
629- . checked_div ( pallet_subtensor:: subnets:: mechanism:: GLOBAL_MAX_SUBNET_COUNT )
630- . unwrap_or_default ( ) ;
631- let is_mechanism = sub_id != 0 ;
632- let Ok ( sub_id) = u8:: try_from ( sub_id) else {
633- continue ;
634- } ;
635- let mecid = MechId :: from ( sub_id) ;
636597
637598 for ( uid, last_block) in blocks. into_iter ( ) . enumerate ( ) {
638599 if last_block == 0 {
@@ -641,26 +602,12 @@ fn import_last_update_entries<T: SubtensorConfig>(
641602 let Ok ( uid_u16) = u16:: try_from ( uid) else {
642603 continue ;
643604 } ;
644- let usage = if is_mechanism {
645- RateLimitUsageKey :: SubnetMechanismNeuron {
646- netuid,
647- mecid,
648- uid : uid_u16,
649- }
650- } else {
651- RateLimitUsageKey :: SubnetNeuron {
652- netuid,
653- uid : uid_u16,
654- }
655- } ;
656-
657- let call_set: & [ TransactionIdentifier ] = if is_mechanism {
658- mechanism_calls. as_slice ( )
659- } else {
660- subnet_calls. as_slice ( )
605+ let usage = RateLimitUsageKey :: SubnetNeuron {
606+ netuid,
607+ uid : uid_u16,
661608 } ;
662609
663- for call in call_set {
610+ for call in & subnet_calls {
664611 record_last_seen_entry :: < T > (
665612 entries,
666613 grouping. usage_target ( * call) ,
0 commit comments