Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pallets/admin-utils/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ use super::*;
#[benchmarks]
mod benchmarks {
use super::*;
#[cfg(test)]
use crate::tests::mock;
use subtensor_runtime_common::NetUid;

#[benchmark]
Expand Down Expand Up @@ -651,5 +653,5 @@ mod benchmarks {
); /* sudo_set_min_non_immune_uids() */
}

//impl_benchmark_test_suite!(AdminUtils, crate::mock::new_test_ext(), crate::mock::Test);
impl_benchmark_test_suite!(AdminUtils, mock::new_test_ext(), mock::Test);
}
2 changes: 1 addition & 1 deletion pallets/admin-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use sp_runtime::{DispatchResult, RuntimeAppPublic, Vec, traits::Member};
mod benchmarking;

#[cfg(test)]
mod tests;
pub(crate) mod tests;

#[deny(missing_docs)]
#[frame_support::pallet]
Expand Down
2 changes: 1 addition & 1 deletion pallets/admin-utils/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::Error;
use crate::pallet::PrecompileEnable;
use mock::*;

mod mock;
pub(crate) mod mock;

#[test]
fn test_sudo_set_default_take() {
Expand Down
35 changes: 31 additions & 4 deletions pallets/subtensor/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ mod pallet_benchmarks {
Subtensor::<T>::set_max_registrations_per_block(netuid, 4096);
Subtensor::<T>::set_target_registrations_per_interval(netuid, 4096);
Subtensor::<T>::set_commit_reveal_weights_enabled(netuid, false);
Subtensor::<T>::set_weights_set_rate_limit(netuid, 0);

let mut seed: u32 = 1;
let mut dests = Vec::new();
Expand Down Expand Up @@ -243,6 +244,11 @@ mod pallet_benchmarks {
Subtensor::<T>::set_network_registration_allowed(netuid, true);
Subtensor::<T>::set_max_allowed_uids(netuid, 4096);
assert_eq!(Subtensor::<T>::get_max_allowed_uids(netuid), 4096);
Subtensor::<T>::init_new_network(NetUid::ROOT, 1);
Subtensor::<T>::set_network_registration_allowed(NetUid::ROOT, true);
Subtensor::<T>::set_network_pow_registration_allowed(NetUid::ROOT, true);
FirstEmissionBlockNumber::<T>::insert(NetUid::ROOT, 1);
SubtokenEnabled::<T>::insert(NetUid::ROOT, true);

let amount: u64 = 100_000_000_000_000;
Subtensor::<T>::add_balance_to_coldkey_account(&coldkey, amount);
Expand Down Expand Up @@ -292,6 +298,7 @@ mod pallet_benchmarks {

Subtensor::<T>::init_new_network(netuid, tempo);
Subtensor::<T>::set_network_pow_registration_allowed(netuid, true);
Subtensor::<T>::set_weights_set_rate_limit(netuid, 0);

let block_number: u64 = Subtensor::<T>::get_current_block_as_u64();
let (nonce, work) = Subtensor::<T>::create_work_for_block_number(
Expand Down Expand Up @@ -330,6 +337,7 @@ mod pallet_benchmarks {
Subtensor::<T>::init_new_network(netuid, tempo);
Subtensor::<T>::set_network_registration_allowed(netuid, true);
Subtensor::<T>::set_network_pow_registration_allowed(netuid, true);
Subtensor::<T>::set_weights_set_rate_limit(netuid, 0);

let block_number: u64 = Subtensor::<T>::get_current_block_as_u64();
let (nonce, work) =
Expand All @@ -356,11 +364,19 @@ mod pallet_benchmarks {
salt.clone(),
version_key,
));
let _ = Subtensor::<T>::commit_weights(
let commit_block = Subtensor::<T>::get_current_block_as_u64();
assert_ok!(Subtensor::<T>::commit_weights(
RawOrigin::Signed(hotkey.clone()).into(),
netuid,
commit_hash,
);
));

let (first_reveal_block, _) = Subtensor::<T>::get_reveal_blocks(netuid, commit_block);
let reveal_block: BlockNumberFor<T> = first_reveal_block
.try_into()
.ok()
.expect("can't convert to block number");
frame_system::Pallet::<T>::set_block_number(reveal_block);

#[extrinsic_call]
_(
Expand Down Expand Up @@ -556,6 +572,7 @@ mod pallet_benchmarks {
let mut salts_list = Vec::new();
let mut version_keys = Vec::new();

let commit_block = Subtensor::<T>::get_current_block_as_u64();
for i in 0..num_commits {
let uids = vec![0u16];
let values = vec![i as u16];
Expand Down Expand Up @@ -583,6 +600,13 @@ mod pallet_benchmarks {
version_keys.push(version_key_i);
}

let (first_reveal_block, _) = Subtensor::<T>::get_reveal_blocks(netuid, commit_block);
let reveal_block: BlockNumberFor<T> = first_reveal_block
.try_into()
.ok()
.expect("can't convert to block number");
frame_system::Pallet::<T>::set_block_number(reveal_block);

#[extrinsic_call]
_(
RawOrigin::Signed(hotkey.clone()),
Expand Down Expand Up @@ -1052,6 +1076,7 @@ mod pallet_benchmarks {
Subtensor::<T>::init_new_network(netuid, 1);
Subtensor::<T>::set_network_pow_registration_allowed(netuid, true);
SubtokenEnabled::<T>::insert(netuid, true);
Subtensor::<T>::set_weights_set_rate_limit(netuid, 0);

let reg_fee = Subtensor::<T>::get_burn(netuid);
Subtensor::<T>::add_balance_to_coldkey_account(&hotkey, reg_fee.to_u64().saturating_mul(2));
Expand Down Expand Up @@ -1115,9 +1140,11 @@ mod pallet_benchmarks {
fn decrease_take() {
let coldkey: T::AccountId = whitelisted_caller();
let hotkey: T::AccountId = account("Alice", 0, 1);
let take: u16 = 100;
let min_take = Subtensor::<T>::get_min_delegate_take();
let take: u16 = min_take;
let current_take = min_take.saturating_add(1);

Delegates::<T>::insert(&hotkey, 200u16);
Delegates::<T>::insert(&hotkey, current_take);
Owner::<T>::insert(&hotkey, &coldkey);

#[extrinsic_call]
Expand Down
6 changes: 3 additions & 3 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub use extensions::*;
pub use guards::*;

#[cfg(test)]
mod tests;
pub(crate) mod tests;

// apparently this is stabilized since rust 1.36
extern crate alloc;
Expand Down Expand Up @@ -1227,7 +1227,7 @@ pub mod pallet {
/// ==================
/// ==== Coinbase ====
/// ==================
/// --- ITEM ( global_block_emission )
/// --- ITEM ( global_block_emission )
#[pallet::storage]
pub type BlockEmission<T> = StorageValue<_, u64, ValueQuery, DefaultBlockEmission<T>>;

Expand Down Expand Up @@ -1267,7 +1267,7 @@ pub mod pallet {
#[pallet::storage]
pub type TotalStake<T> = StorageValue<_, TaoCurrency, ValueQuery, DefaultZeroTao<T>>;

/// --- ITEM ( moving_alpha ) -- subnet moving alpha.
/// --- ITEM ( moving_alpha ) -- subnet moving alpha.
#[pallet::storage]
pub type SubnetMovingAlpha<T> = StorageValue<_, I96F32, ValueQuery, DefaultMovingAlpha<T>>;

Expand Down
Loading