Skip to content

Commit 0d17d0a

Browse files
committed
Merge branch 'devnet-ready' into feat/rao-devnet-ready
2 parents a3efc24 + 31d801e commit 0d17d0a

18 files changed

+2406
-88
lines changed

node/src/service.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ use node_subtensor_runtime::{
3535
/// imported and generated.
3636
const GRANDPA_JUSTIFICATION_PERIOD: u32 = 512;
3737

38-
/// Only enable the benchmarking host functions when we actually want to benchmark.
39-
#[cfg(feature = "runtime-benchmarks")]
38+
/// Always enable runtime benchmark host functions, the genesis state
39+
/// was built with them so we're stuck with them forever.
40+
///
41+
/// They're just a noop, never actually get used if the runtime was not compiled with
42+
/// `runtime-benchmarks`.
4043
pub type HostFunctions = (
4144
sp_io::SubstrateHostFunctions,
4245
frame_benchmarking::benchmarking::HostFunctions,
4346
);
44-
/// Otherwise we use empty host functions for ext host functions.
45-
#[cfg(not(feature = "runtime-benchmarks"))]
46-
pub type HostFunctions = sp_io::SubstrateHostFunctions;
4747

4848
pub type Backend = FullBackend<Block>;
4949
pub type Client = FullClient<Block, RuntimeApi, HostFunctions>;

pallets/subtensor/src/lib.rs

+14-15
Original file line numberDiff line numberDiff line change
@@ -1258,8 +1258,7 @@ pub mod pallet {
12581258
/// Returns the transaction priority for setting weights.
12591259
pub fn get_priority_set_weights(hotkey: &T::AccountId, netuid: u16) -> u64 {
12601260
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);
12631262
let current_block_number: u64 = Self::get_current_block_as_u64();
12641263
let default_priority: u64 =
12651264
current_block_number.saturating_sub(Self::get_last_update_for_uid(netuid, uid));
@@ -1271,18 +1270,7 @@ pub mod pallet {
12711270
/// Is the caller allowed to set weights
12721271
pub fn check_weights_min_stake(hotkey: &T::AccountId, netuid: u16) -> bool {
12731272
// 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()
12861274
}
12871275

12881276
/// Helper function to check if register is allowed
@@ -1437,6 +1425,18 @@ where
14371425
Err(InvalidTransaction::Custom(2).into())
14381426
}
14391427
}
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+
}
14401440
Some(Call::set_weights { netuid, .. }) => {
14411441
if Self::check_weights_min_stake(who, *netuid) {
14421442
let priority: u64 = Self::get_priority_set_weights(who, *netuid);
@@ -1451,7 +1451,6 @@ where
14511451
}
14521452
Some(Call::set_root_weights { netuid, hotkey, .. }) => {
14531453
if Self::check_weights_min_stake(hotkey, *netuid) {
1454-
let priority: u64 = Self::get_priority_set_weights(hotkey, *netuid);
14551454
Ok(ValidTransaction {
14561455
priority,
14571456
longevity: 1,

0 commit comments

Comments
 (0)