Skip to content

Commit

Permalink
remove commit_reveal_weights_enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
andreea-popescu-reef committed Nov 21, 2024
1 parent 88fe02d commit 3e65beb
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 483 deletions.
11 changes: 0 additions & 11 deletions pallets/admin-utils/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,6 @@ mod benchmarks {
_(RawOrigin::Root, 1u16/*netuid*/, 3u64/*interval*/)/*sudo_set_commit_reveal_weights_interval()*/;
}

#[benchmark]
fn sudo_set_commit_reveal_weights_enabled() {
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() {
pallet_subtensor::Pallet::<T>::init_new_network(
Expand Down
22 changes: 0 additions & 22 deletions pallets/admin-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,28 +960,6 @@ pub mod pallet {
Ok(())
}

/// The extrinsic enabled/disables commit/reaveal for a given subnet.
/// It is only callable by the root account or subnet owner.
/// The extrinsic will call the Subtensor pallet to set the value.
#[pallet::call_index(49)]
#[pallet::weight(T::WeightInfo::sudo_set_commit_reveal_weights_enabled())]
pub fn sudo_set_commit_reveal_weights_enabled(
origin: OriginFor<T>,
netuid: u16,
enabled: bool,
) -> DispatchResult {
pallet_subtensor::Pallet::<T>::ensure_subnet_owner_or_root(origin, netuid)?;

ensure!(
pallet_subtensor::Pallet::<T>::if_subnet_exist(netuid),
Error::<T>::SubnetDoesNotExist
);

pallet_subtensor::Pallet::<T>::set_commit_reveal_weights_enabled(netuid, enabled);
log::debug!("ToggleSetWeightsCommitReveal( netuid: {:?} ) ", netuid);
Ok(())
}

/// Enables or disables Liquid Alpha for a given subnet.
///
/// # Parameters
Expand Down
24 changes: 1 addition & 23 deletions pallets/admin-utils/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ pub trait WeightInfo {
fn sudo_set_network_registration_allowed() -> Weight;
fn sudo_set_tempo() -> Weight;
fn sudo_set_commit_reveal_weights_interval() -> Weight;
fn sudo_set_commit_reveal_weights_enabled() -> Weight;
}

/// Weights for `pallet_admin_utils` using the Substrate node and recommended hardware.
Expand Down Expand Up @@ -422,15 +421,6 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
fn sudo_set_commit_reveal_weights_enabled() -> Weight {
// Proof Size summary in bytes:
// Measured: `1111`
// Estimated: `4697`
// Minimum execution time: 46_450_000 picoseconds.
Weight::from_parts(47_279_000, 4697)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
}

// For backwards compatibility and tests.
Expand Down Expand Up @@ -793,16 +783,4 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
}
fn sudo_set_commit_reveal_weights_enabled() -> Weight {
// -- Extrinsic Time --
// Model:
// Time ~= 19.78
// µs
// Reads = 1
// Writes = 1
// Recorded proof Size = 456
Weight::from_parts(19_780_000, 456)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
}
}
23 changes: 0 additions & 23 deletions pallets/admin-utils/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1113,29 +1113,6 @@ fn test_sudo_set_min_delegate_take() {
});
}

#[test]
fn test_sudo_set_commit_reveal_weights_enabled() {
new_test_ext().execute_with(|| {
let netuid: u16 = 1;
add_network(netuid, 10);

let to_be_set: bool = true;
let init_value: bool = SubtensorModule::get_commit_reveal_weights_enabled(netuid);

assert_ok!(AdminUtils::sudo_set_commit_reveal_weights_enabled(
<<Test as Config>::RuntimeOrigin>::root(),
netuid,
to_be_set
));

assert!(init_value != to_be_set);
assert_eq!(
SubtensorModule::get_commit_reveal_weights_enabled(netuid),
to_be_set
);
});
}

#[test]
fn test_sudo_set_target_stakes_per_interval() {
new_test_ext().execute_with(|| {
Expand Down
1 change: 0 additions & 1 deletion pallets/subtensor/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ batch_reveal_weights {
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_commit_reveal_weights_enabled(netuid, true);
Subtensor::<T>::set_weights_set_rate_limit(netuid, 0); // Disable rate limiting for benchmarking

let block_number: u64 = Subtensor::<T>::get_current_block_as_u64();
Expand Down
7 changes: 2 additions & 5 deletions pallets/subtensor/src/macros/dispatches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,8 @@ mod dispatches {
weights: Vec<u16>,
version_key: u64,
) -> DispatchResult {
if !Self::get_commit_reveal_weights_enabled(netuid) {
return Self::do_set_weights(origin, netuid, dests, weights, version_key);
}

Err(Error::<T>::CommitRevealEnabled.into())
return Self::do_set_weights(origin, netuid, dests, weights, version_key);
// Err(Error::<T>::CommitRevealEnabled.into())
}

/// ---- Used to commit a hash of your weight values to later be revealed.
Expand Down
5 changes: 1 addition & 4 deletions pallets/subtensor/src/rpc_info/subnet_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct SubnetInfov2<T: Config> {
identity: Option<SubnetIdentity>,
}

#[freeze_struct("55b472510f10e76a")]
#[freeze_struct("61ae927da2880759")]
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)]
pub struct SubnetHyperparams {
rho: Compact<u16>,
Expand All @@ -77,7 +77,6 @@ pub struct SubnetHyperparams {
adjustment_alpha: Compact<u64>,
difficulty: Compact<u64>,
commit_reveal_weights_interval: Compact<u64>,
commit_reveal_weights_enabled: bool,
alpha_high: Compact<u16>,
alpha_low: Compact<u16>,
liquid_alpha_enabled: bool,
Expand Down Expand Up @@ -253,7 +252,6 @@ impl<T: Config> Pallet<T> {
let adjustment_alpha = Self::get_adjustment_alpha(netuid);
let difficulty = Self::get_difficulty_as_u64(netuid);
let commit_reveal_periods = Self::get_reveal_period(netuid);
let commit_reveal_weights_enabled = Self::get_commit_reveal_weights_enabled(netuid);
let liquid_alpha_enabled = Self::get_liquid_alpha_enabled(netuid);
let (alpha_low, alpha_high): (u16, u16) = Self::get_alpha_values(netuid);

Expand Down Expand Up @@ -281,7 +279,6 @@ impl<T: Config> Pallet<T> {
adjustment_alpha: adjustment_alpha.into(),
difficulty: difficulty.into(),
commit_reveal_weights_interval: commit_reveal_periods.into(),
commit_reveal_weights_enabled,
alpha_high: alpha_high.into(),
alpha_low: alpha_low.into(),
liquid_alpha_enabled,
Expand Down
Loading

0 comments on commit 3e65beb

Please sign in to comment.