@@ -1258,8 +1258,7 @@ pub mod pallet {
1258
1258
/// Returns the transaction priority for setting weights.
1259
1259
pub fn get_priority_set_weights ( hotkey : & T :: AccountId , netuid : u16 ) -> u64 {
1260
1260
if let Ok ( uid) = Self :: get_uid_for_net_and_hotkey ( netuid, hotkey) {
1261
- // TODO rethink this.
1262
- let _stake = Self :: get_global_for_hotkey ( hotkey) ;
1261
+ let _stake = Self :: get_stake_for_hotkey_on_subnet ( hotkey, netuid) ;
1263
1262
let current_block_number: u64 = Self :: get_current_block_as_u64 ( ) ;
1264
1263
let default_priority: u64 =
1265
1264
current_block_number. saturating_sub ( Self :: get_last_update_for_uid ( netuid, uid) ) ;
@@ -1271,18 +1270,7 @@ pub mod pallet {
1271
1270
/// Is the caller allowed to set weights
1272
1271
pub fn check_weights_min_stake ( hotkey : & T :: AccountId , netuid : u16 ) -> bool {
1273
1272
// Blacklist weights transactions for low stake peers.
1274
- let min_stake = Self :: get_weights_min_stake ( ) ;
1275
- let hotkey_stake = Self :: get_stake_for_hotkey_on_subnet ( hotkey, netuid) ;
1276
- let result = hotkey_stake >= min_stake;
1277
- log:: info!(
1278
- "Checking weights min stake for hotkey: {:?}, netuid: {}, min_stake: {}, hotkey_stake: {}, result: {}" ,
1279
- hotkey,
1280
- netuid,
1281
- min_stake,
1282
- hotkey_stake,
1283
- result
1284
- ) ;
1285
- result
1273
+ Self :: get_stake_for_hotkey_on_subnet ( hotkey, netuid) >= Self :: get_weights_min_stake ( )
1286
1274
}
1287
1275
1288
1276
/// Helper function to check if register is allowed
@@ -1437,6 +1425,18 @@ where
1437
1425
Err ( InvalidTransaction :: Custom ( 2 ) . into ( ) )
1438
1426
}
1439
1427
}
1428
+ Some ( Call :: batch_reveal_weights { netuid, .. } ) => {
1429
+ if Self :: check_weights_min_stake ( who, * netuid) {
1430
+ let priority: u64 = Self :: get_priority_set_weights ( who, * netuid) ;
1431
+ Ok ( ValidTransaction {
1432
+ priority,
1433
+ longevity : 1 ,
1434
+ ..Default :: default ( )
1435
+ } )
1436
+ } else {
1437
+ Err ( InvalidTransaction :: Custom ( 6 ) . into ( ) )
1438
+ }
1439
+ }
1440
1440
Some ( Call :: set_weights { netuid, .. } ) => {
1441
1441
if Self :: check_weights_min_stake ( who, * netuid) {
1442
1442
let priority: u64 = Self :: get_priority_set_weights ( who, * netuid) ;
@@ -1451,7 +1451,6 @@ where
1451
1451
}
1452
1452
Some ( Call :: set_root_weights { netuid, hotkey, .. } ) => {
1453
1453
if Self :: check_weights_min_stake ( hotkey, * netuid) {
1454
- let priority: u64 = Self :: get_priority_set_weights ( hotkey, * netuid) ;
1455
1454
Ok ( ValidTransaction {
1456
1455
priority,
1457
1456
longevity : 1 ,
0 commit comments