@@ -1299,7 +1299,7 @@ pub mod pallet {
1299
1299
/// Returns the transaction priority for setting weights.
1300
1300
pub fn get_priority_set_weights ( hotkey : & T :: AccountId , netuid : u16 ) -> u64 {
1301
1301
if let Ok ( uid) = Self :: get_uid_for_net_and_hotkey ( netuid, hotkey) {
1302
- let _stake = Self :: get_total_stake_for_hotkey ( hotkey) ;
1302
+ let _stake = Self :: get_stake_for_hotkey_on_subnet ( hotkey, netuid ) ;
1303
1303
let current_block_number: u64 = Self :: get_current_block_as_u64 ( ) ;
1304
1304
let default_priority: u64 =
1305
1305
current_block_number. saturating_sub ( Self :: get_last_update_for_uid ( netuid, uid) ) ;
@@ -1309,9 +1309,9 @@ pub mod pallet {
1309
1309
}
1310
1310
1311
1311
/// Is the caller allowed to set weights
1312
- pub fn check_weights_min_stake ( hotkey : & T :: AccountId ) -> bool {
1312
+ pub fn check_weights_min_stake ( hotkey : & T :: AccountId , netuid : u16 ) -> bool {
1313
1313
// Blacklist weights transactions for low stake peers.
1314
- Self :: get_total_stake_for_hotkey ( hotkey) >= Self :: get_weights_min_stake ( )
1314
+ Self :: get_stake_for_hotkey_on_subnet ( hotkey, netuid ) >= Self :: get_weights_min_stake ( )
1315
1315
}
1316
1316
1317
1317
/// Helper function to check if register is allowed
@@ -1404,8 +1404,8 @@ where
1404
1404
Pallet :: < T > :: get_priority_set_weights ( who, netuid)
1405
1405
}
1406
1406
1407
- pub fn check_weights_min_stake ( who : & T :: AccountId ) -> bool {
1408
- Pallet :: < T > :: check_weights_min_stake ( who)
1407
+ pub fn check_weights_min_stake ( who : & T :: AccountId , netuid : u16 ) -> bool {
1408
+ Pallet :: < T > :: check_weights_min_stake ( who, netuid )
1409
1409
}
1410
1410
}
1411
1411
@@ -1443,7 +1443,7 @@ where
1443
1443
) -> TransactionValidity {
1444
1444
match call. is_sub_type ( ) {
1445
1445
Some ( Call :: commit_weights { netuid, .. } ) => {
1446
- if Self :: check_weights_min_stake ( who) {
1446
+ if Self :: check_weights_min_stake ( who, * netuid ) {
1447
1447
let priority: u64 = Self :: get_priority_set_weights ( who, * netuid) ;
1448
1448
Ok ( ValidTransaction {
1449
1449
priority,
@@ -1455,7 +1455,7 @@ where
1455
1455
}
1456
1456
}
1457
1457
Some ( Call :: reveal_weights { netuid, .. } ) => {
1458
- if Self :: check_weights_min_stake ( who) {
1458
+ if Self :: check_weights_min_stake ( who, * netuid ) {
1459
1459
let priority: u64 = Self :: get_priority_set_weights ( who, * netuid) ;
1460
1460
Ok ( ValidTransaction {
1461
1461
priority,
@@ -1467,7 +1467,7 @@ where
1467
1467
}
1468
1468
}
1469
1469
Some ( Call :: batch_reveal_weights { netuid, .. } ) => {
1470
- if Self :: check_weights_min_stake ( who) {
1470
+ if Self :: check_weights_min_stake ( who, * netuid ) {
1471
1471
let priority: u64 = Self :: get_priority_set_weights ( who, * netuid) ;
1472
1472
Ok ( ValidTransaction {
1473
1473
priority,
@@ -1479,7 +1479,7 @@ where
1479
1479
}
1480
1480
}
1481
1481
Some ( Call :: set_weights { netuid, .. } ) => {
1482
- if Self :: check_weights_min_stake ( who) {
1482
+ if Self :: check_weights_min_stake ( who, * netuid ) {
1483
1483
let priority: u64 = Self :: get_priority_set_weights ( who, * netuid) ;
1484
1484
Ok ( ValidTransaction {
1485
1485
priority,
@@ -1491,7 +1491,7 @@ where
1491
1491
}
1492
1492
}
1493
1493
Some ( Call :: set_root_weights { netuid, hotkey, .. } ) => {
1494
- if Self :: check_weights_min_stake ( hotkey) {
1494
+ if Self :: check_weights_min_stake ( hotkey, * netuid ) {
1495
1495
let priority: u64 = Self :: get_priority_set_weights ( hotkey, * netuid) ;
1496
1496
Ok ( ValidTransaction {
1497
1497
priority,
0 commit comments