Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace SubtensorInterface with tight pallet coupling #709

Merged
merged 11 commits into from
Aug 19, 2024
64 changes: 38 additions & 26 deletions pallets/admin-utils/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,159 +47,162 @@ mod benchmarks {

#[benchmark]
fn sudo_set_max_difficulty() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 10000u64/*max_difficulty*/)/*sudo_set_max_difficulty*/;
}

#[benchmark]
fn sudo_set_min_difficulty() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 1000u64/*min_difficulty*/)/*sudo_set_min_difficulty*/;
}

#[benchmark]
fn sudo_set_weights_set_rate_limit() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 3u64/*rate_limit*/)/*sudo_set_weights_set_rate_limit*/;
}

#[benchmark]
fn sudo_set_weights_version_key() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 1u64/*version_key*/)/*sudo_set_weights_version_key*/;
}

#[benchmark]
fn sudo_set_bonds_moving_average() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 100u64/*bonds_moving_average*/)/*sudo_set_bonds_moving_average*/;
}

#[benchmark]
fn sudo_set_max_allowed_validators() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 10u16/*max_allowed_validators*/)/*sudo_set_max_allowed_validators*/;
}

#[benchmark]
fn sudo_set_difficulty() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 1200000u64/*difficulty*/)/*sudo_set_difficulty*/;
}

#[benchmark]
fn sudo_set_adjustment_interval() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 12u16/*adjustment_interval*/)/*sudo_set_adjustment_interval*/;
}

#[benchmark]
fn sudo_set_target_registrations_per_interval() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 300u16/*target_registrations*/)/*sudo_set_target_registrations_per_interval*/;
}

#[benchmark]
fn sudo_set_activity_cutoff() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 300u16/*activity_cutoff*/)/*sudo_set_activity_cutoff*/;
}

#[benchmark]
fn sudo_set_rho() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 300u16/*rho*/)/*sudo_set_rho*/;
}

#[benchmark]
fn sudo_set_kappa() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*sudo_tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(
1u16, /*netuid*/
1u16, /*sudo_tempo*/
);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 3u16/*kappa*/)/*set_kappa*/;
}

#[benchmark]
fn sudo_set_max_allowed_uids() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 4097u16/*max_allowed_uids*/)/*sudo_set_max_allowed_uids*/;
}

#[benchmark]
fn sudo_set_min_allowed_weights() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 10u16/*max_allowed_uids*/)/*sudo_set_min_allowed_weights*/;
}

#[benchmark]
fn sudo_set_immunity_period() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 100u16/*immunity_period*/)/*sudo_set_immunity_period*/;
}

#[benchmark]
fn sudo_set_max_weight_limit() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 100u16/*max_weight_limit*/)/*sudo_set_max_weight_limit*/;
}

#[benchmark]
fn sudo_set_max_registrations_per_block() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 100u16/*max_registrations*/)/*sudo_set_max_registrations_per_block*/;
}

#[benchmark]
fn sudo_set_max_burn() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 10u64/*max_burn*/)/*sudo_set_max_burn*/;
}

#[benchmark]
fn sudo_set_min_burn() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 10u64/*min_burn*/)/*sudo_set_min_burn*/;
}

#[benchmark]
fn sudo_set_network_registration_allowed() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, true/*registration_allowed*/)/*sudo_set_network_registration_allowed*/;
Expand All @@ -212,45 +215,54 @@ mod benchmarks {
let tempo: u16 = 15;
let modality: u16 = 0;

T::Subtensor::init_new_network(netuid, tempo);
pallet_subtensor::Pallet::<T>::init_new_network(netuid, tempo);

}: sudo_set_tempo(RawOrigin::<AccountIdOf<T>>::Root, netuid, tempo)
*/
#[benchmark]
fn sudo_set_tempo() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 1u16/*tempo*/)/*sudo_set_tempo*/;
}

#[benchmark]
fn sudo_set_commit_reveal_weights_interval() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*sudo_tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(
1u16, /*netuid*/
1u16, /*sudo_tempo*/
);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 3u64/*interval*/)/*set_commit_reveal_weights_interval()*/;
}

#[benchmark]
fn sudo_set_commit_reveal_weights_enabled() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*sudo_tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(
1u16, /*netuid*/
1u16, /*sudo_tempo*/
);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, true/*enabled*/)/*set_commit_reveal_weights_enabled*/;
}

#[benchmark]
fn sudo_set_hotkey_emission_tempo() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*sudo_tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(
1u16, /*netuid*/
1u16, /*sudo_tempo*/
);

#[extrinsic_call]
_(RawOrigin::Root, 1u64/*emission_tempo*/)/*set_hotkey_emission_tempo*/;
}

#[benchmark]
fn sudo_set_network_max_stake() {
T::Subtensor::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);
pallet_subtensor::Pallet::<T>::init_new_network(1u16 /*netuid*/, 1u16 /*tempo*/);

#[extrinsic_call]
_(RawOrigin::Root, 1u16/*netuid*/, 1_000_000_000_000_000u64/*max_stake*/)/*sudo_set_network_max_stake*/;
Expand Down
Loading
Loading