Skip to content
Merged
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
27 changes: 26 additions & 1 deletion pallets/subtensor/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ benchmarks! {
// This is a whitelisted caller who can make transaction without weights.
let caller: T::AccountId = whitelisted_caller::<AccountIdOf<T>>();
let caller_origin = <T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(caller.clone()));
let netuid: u16 = 1;
let netuid: u16 = 0;
let version_key: u64 = 1;
let tempo: u16 = 1;
let modality: u16 = 0;
Expand Down Expand Up @@ -428,4 +428,29 @@ reveal_weights {
let _ = Subtensor::<T>::commit_weights(<T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(hotkey.clone())), netuid, commit_hash);

}: reveal_weights(RawOrigin::Signed(hotkey.clone()), netuid, uids, weight_values, salt, version_key)


adjust_senate {
migration::migrate_create_root_network::<T>();
let netuid: u16 = 1;
let tempo: u16 = 13;
let burn_cost = 1000;
let hotkey: T::AccountId = account("hot", 0, 1);
let coldkey: T::AccountId = account("cold", 0, 2);

Subtensor::<T>::init_new_network(netuid, 100);
Subtensor::<T>::set_burn(netuid, 1);
Subtensor::<T>::set_max_allowed_uids( netuid, 4096 );
assert_eq!(Subtensor::<T>::get_max_allowed_uids(netuid), 4096);
Subtensor::<T>::set_burn(netuid, burn_cost);

let amount_to_be_staked = 100_000_000_000;
Subtensor::<T>::add_balance_to_coldkey_account(&coldkey.clone(), amount_to_be_staked);

assert_ok!(Subtensor::<T>::burned_register(RawOrigin::Signed(coldkey.clone()).into(), netuid, hotkey.clone()));
assert_ok!(Subtensor::<T>::become_delegate(RawOrigin::Signed(coldkey.clone()).into(), hotkey.clone()));
assert_ok!(Subtensor::<T>::root_register(RawOrigin::Signed(coldkey.clone()).into(), hotkey.clone()));
T::SenateMembers::remove_member(&hotkey).map_err(|_| "Failed to remove member")?;

}: adjust_senate(RawOrigin::Signed(coldkey.clone()), hotkey.clone())
}
7 changes: 4 additions & 3 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1950,9 +1950,10 @@ pub mod pallet {

/// Attempt to adjust the senate membership to include a hotkey
#[pallet::call_index(63)]
#[pallet::weight((Weight::from_parts(0, 0)
.saturating_add(T::DbWeight::get().reads(0))
.saturating_add(T::DbWeight::get().writes(0)), DispatchClass::Normal, Pays::Yes))]
#[pallet::weight((Weight::from_parts(50_000_000, 0)
.saturating_add(Weight::from_parts(0, 4632))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::Yes))]
pub fn adjust_senate(origin: OriginFor<T>, hotkey: T::AccountId) -> DispatchResult {
Self::do_adjust_senate(origin, hotkey)
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// `spec_version`, and `authoring_version` are the same between Wasm and native.
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
// the compatible custom types.
spec_version: 153,
spec_version: 186,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down
2 changes: 1 addition & 1 deletion scripts/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $BIN_PATH build-spec --disable-default-bootnode --raw --chain local > $TMP_SPEC
$BIN_PATH benchmark pallet \
--chain=$TMP_SPEC \
--execution=native --wasm-execution=compiled \
--pallet pallet-subtensor --extrinsic 'benchmark_dissolve_network' \
--pallet pallet-subtensor --extrinsic 'adjust_senate' \
--output $OUTPUT_FILE

rm $TMP_SPEC