From 0b447e8d0b0fed8a4bd83d7126b451c3e80d8b4a Mon Sep 17 00:00:00 2001 From: Ayden Brewer Date: Thu, 13 Jul 2023 11:27:56 -0700 Subject: [PATCH] Remove unused validator-related hyperparameters --- pallets/subtensor/src/benchmarks.rs | 70 -------- pallets/subtensor/src/lib.rs | 109 ------------ pallets/subtensor/src/networks.rs | 8 - pallets/subtensor/src/subnet_info.rs | 15 -- pallets/subtensor/src/utils.rs | 82 +-------- pallets/subtensor/tests/mock.rs | 14 -- pallets/subtensor/tests/sudo.rs | 238 --------------------------- runtime/src/lib.rs | 14 -- 8 files changed, 1 insertion(+), 549 deletions(-) diff --git a/pallets/subtensor/src/benchmarks.rs b/pallets/subtensor/src/benchmarks.rs index 95897be009..bd4348acbb 100644 --- a/pallets/subtensor/src/benchmarks.rs +++ b/pallets/subtensor/src/benchmarks.rs @@ -455,46 +455,6 @@ benchmarks! { }: sudo_set_min_allowed_weights(RawOrigin::>::Root, netuid, min_allowed_weights) - benchmark_sudo_set_validator_batch_size{ - let netuid: u16 = 1; - let tempo: u16 = 1; - let modality: u16 = 0; - let validator_batch_size: u16 = 10; - - assert_ok!( Subtensor::::do_add_network( RawOrigin::Root.into(), netuid.try_into().unwrap(), tempo.into(), modality.into())); - - }: sudo_set_validator_batch_size(RawOrigin::>::Root, netuid, validator_batch_size) - - benchmark_sudo_set_validator_sequence_length{ - let netuid: u16 = 1; - let tempo: u16 = 1; - let modality: u16 = 0; - let validator_sequence_length: u16 = 10; - - assert_ok!( Subtensor::::do_add_network( RawOrigin::Root.into(), netuid.try_into().unwrap(), tempo.into(), modality.into())); - - }: sudo_set_validator_sequence_length(RawOrigin::>::Root, netuid, validator_sequence_length) - - benchmark_sudo_set_validator_epochs_per_reset { - let netuid: u16 = 1; - let tempo: u16 = 1; - let modality: u16 = 0; - let validator_epochs_per_reset: u16 = 10; - - assert_ok!( Subtensor::::do_add_network( RawOrigin::Root.into(), netuid.try_into().unwrap(), tempo.into(), modality.into())); - - }: sudo_set_validator_epochs_per_reset(RawOrigin::>::Root, netuid, validator_epochs_per_reset) - - benchmark_sudo_set_validator_exclude_quantile { - let netuid: u16 = 1; - let tempo: u16 = 1; - let modality: u16 = 0; - let validator_exclude_quantile: u16 = 10; - - assert_ok!( Subtensor::::do_add_network( RawOrigin::Root.into(), netuid.try_into().unwrap(), tempo.into(), modality.into())); - - }: sudo_set_validator_exclude_quantile(RawOrigin::>::Root, netuid, validator_exclude_quantile) - benchmark_sudo_set_validator_prune_len { let netuid: u16 = 1; let tempo: u16 = 1; @@ -505,16 +465,6 @@ benchmarks! { }: sudo_set_validator_prune_len(RawOrigin::>::Root, netuid, validator_prune_len) - benchmark_sudo_set_validator_logits_divergence { - let netuid: u16 = 1; - let tempo: u16 = 1; - let modality: u16 = 0; - let validator_logits_divergence: u16 = 100; - - assert_ok!( Subtensor::::do_add_network( RawOrigin::Root.into(), netuid.try_into().unwrap(), tempo.into(), modality.into())); - - }: sudo_set_validator_logits_divergence(RawOrigin::>::Root, netuid, validator_logits_divergence) - benchmark_sudo_set_scaling_law_power { let netuid: u16 = 1; let tempo: u16 = 1; @@ -525,16 +475,6 @@ benchmarks! { }: sudo_set_scaling_law_power(RawOrigin::>::Root, netuid, scaling_law_power) - benchmark_sudo_set_synergy_scaling_law_power { - let netuid: u16 = 1; - let tempo: u16 = 1; - let modality: u16 = 0; - let synergy_scaling_law_power: u16 = 100; - - assert_ok!( Subtensor::::do_add_network( RawOrigin::Root.into(), netuid.try_into().unwrap(), tempo.into(), modality.into())); - - }: sudo_set_synergy_scaling_law_power(RawOrigin::>::Root, netuid, synergy_scaling_law_power) - benchmark_sudo_set_immunity_period { let netuid: u16 = 1; let tempo: u16 = 1; @@ -581,16 +521,6 @@ benchmarks! { }: burned_register(RawOrigin::Signed( coldkey.clone() ), netuid, hotkey) - benchmark_sudo_set_validator_epoch_length { - let netuid: u16 = 1; - let tempo: u16 = 1; - let modality: u16 = 0; - let validator_epoch_len: u16 = 10; - - assert_ok!( Subtensor::::do_add_network( RawOrigin::Root.into(), netuid.try_into().unwrap(), tempo.into(), modality.into())); - - }: sudo_set_validator_epoch_len(RawOrigin::>::Root, netuid, validator_epoch_len) - benchmark_sudo_set_burn { let netuid: u16 = 1; let tempo: u16 = 1; diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 98cdf9dbd3..38c9a0ac6a 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -161,24 +161,10 @@ pub mod pallet { type InitialKappa: Get; #[pallet::constant] // Max UID constant. type InitialMaxAllowedUids: Get; - #[pallet::constant] // Default batch size. - type InitialValidatorBatchSize: Get; - #[pallet::constant] // Default Sequence length. - type InitialValidatorSequenceLen: Get; - #[pallet::constant] // Default Epoch length. - type InitialValidatorEpochLen: Get; - #[pallet::constant] // Default Reset length. - type InitialValidatorEpochsPerReset: Get; - #[pallet::constant] // Initial validator exclude quantile. - type InitialValidatorExcludeQuantile: Get; - #[pallet::constant] // Initial validator logits divergence penalty/threshold. - type InitialValidatorLogitsDivergence: Get; #[pallet::constant] // Initial validator context pruning length. type InitialValidatorPruneLen: Get; #[pallet::constant] // Initial scaling law power. type InitialScalingLawPower: Get; - #[pallet::constant] // Initial synergy scaling law power. - type InitialSynergyScalingLawPower: Get; #[pallet::constant] // Immunity Period Constant. type InitialImmunityPeriod: Get; #[pallet::constant] // Activity constant. @@ -427,8 +413,6 @@ pub mod pallet { #[pallet::type_value] pub fn DefaultMinAllowedWeights() -> u16 { T::InitialMinAllowedWeights::get() } #[pallet::type_value] - pub fn DefaultValidatorEpochLen() -> u16 { T::InitialValidatorEpochLen::get() } - #[pallet::type_value] pub fn DefaultMaxAllowedValidators() -> u16 { T::InitialMaxAllowedValidators::get() } #[pallet::type_value] pub fn DefaultAdjustmentInterval() -> u16 { T::InitialAdjustmentInterval::get() } @@ -436,20 +420,8 @@ pub mod pallet { pub fn DefaultBondsMovingAverage() -> u64 { T::InitialBondsMovingAverage::get() } #[pallet::type_value] pub fn DefaultValidatorPruneLen() -> u64 { T::InitialValidatorPruneLen::get() } - #[pallet::type_value] - pub fn DefaultValidatorBatchSize() -> u16 { T::InitialValidatorBatchSize::get() } - #[pallet::type_value] - pub fn DefaultValidatorSequenceLen() -> u16 { T::InitialValidatorSequenceLen::get() } - #[pallet::type_value] - pub fn DefaultValidatorEpochsPerReset() -> u16 { T::InitialValidatorEpochsPerReset::get() } - #[pallet::type_value] - pub fn DefaultValidatorExcludeQuantile() -> u16 { T::InitialValidatorExcludeQuantile::get() } - #[pallet::type_value] - pub fn DefaultValidatorLogitsDivergence() -> u16 { T::InitialValidatorLogitsDivergence::get() } #[pallet::type_value] pub fn DefaultScalingLawPower() -> u16 { T::InitialScalingLawPower::get() } - #[pallet::type_value] - pub fn DefaultSynergyScalingLawPower() -> u16 { T::InitialSynergyScalingLawPower::get() } #[pallet::type_value] pub fn DefaultTargetRegistrationsPerInterval() -> u16 { T::InitialTargetRegistrationsPerInterval::get() } #[pallet::type_value] @@ -478,8 +450,6 @@ pub mod pallet { pub type MaxWeightsLimit = StorageMap< _, Identity, u16, u16, ValueQuery, DefaultMaxWeightsLimit >; #[pallet::storage] // --- MAP ( netuid ) --> weights_version_key pub type WeightsVersionKey = StorageMap<_, Identity, u16, u64, ValueQuery, DefaultWeightsVersionKey >; - #[pallet::storage] // --- MAP ( netuid ) --> validator_epoch_len - pub type ValidatorEpochLen = StorageMap<_, Identity, u16, u16, ValueQuery, DefaultValidatorEpochLen >; #[pallet::storage] // --- MAP ( netuid ) --> min_allowed_weights pub type MinAllowedWeights = StorageMap< _, Identity, u16, u16, ValueQuery, DefaultMinAllowedWeights >; #[pallet::storage] // --- MAP ( netuid ) --> max_allowed_validators @@ -488,24 +458,12 @@ pub mod pallet { pub type AdjustmentInterval = StorageMap<_, Identity, u16, u16, ValueQuery, DefaultAdjustmentInterval >; #[pallet::storage] // --- MAP ( netuid ) --> bonds_moving_average pub type BondsMovingAverage = StorageMap<_, Identity, u16, u64, ValueQuery, DefaultBondsMovingAverage >; - #[pallet::storage] // --- MAP ( netuid ) --> validator_batch_size - pub type ValidatorBatchSize = StorageMap<_, Identity, u16, u16, ValueQuery, DefaultValidatorBatchSize >; #[pallet::storage] // --- MAP ( netuid ) --> weights_set_rate_limit pub type WeightsSetRateLimit = StorageMap<_, Identity, u16, u64, ValueQuery, DefaultWeightsSetRateLimit >; #[pallet::storage] // --- MAP ( netuid ) --> validator_prune_len pub type ValidatorPruneLen = StorageMap<_, Identity, u16, u64, ValueQuery, DefaultValidatorPruneLen >; - #[pallet::storage] // --- MAP ( netuid ) --> validator_sequence_length - pub type ValidatorSequenceLength = StorageMap<_, Identity, u16, u16, ValueQuery, DefaultValidatorSequenceLen >; - #[pallet::storage] // --- MAP ( netuid ) --> validator_epochs_per_reset - pub type ValidatorEpochsPerReset = StorageMap<_, Identity, u16, u16, ValueQuery, DefaultValidatorEpochsPerReset >; - #[pallet::storage] // --- MAP ( netuid ) --> validator_exclude_quantile - pub type ValidatorExcludeQuantile = StorageMap<_, Identity, u16, u16, ValueQuery, DefaultValidatorExcludeQuantile >; - #[pallet::storage] // --- MAP ( netuid ) --> validator_logits_divergence - pub type ValidatorLogitsDivergence = StorageMap<_, Identity, u16, u16, ValueQuery, DefaultValidatorLogitsDivergence >; #[pallet::storage] // --- MAP ( netuid ) --> scaling_law_power pub type ScalingLawPower = StorageMap<_, Identity, u16, u16, ValueQuery, DefaultScalingLawPower >; - #[pallet::storage] // --- MAP ( netuid ) --> synergy_scaling_law_power - pub type SynergyScalingLawPower = StorageMap<_, Identity, u16, u16, ValueQuery, DefaultSynergyScalingLawPower >; #[pallet::storage] // --- MAP ( netuid ) --> target_registrations_this_interval pub type TargetRegistrationsPerInterval = StorageMap<_, Identity, u16, u16, ValueQuery, DefaultTargetRegistrationsPerInterval >; #[pallet::storage] // --- DMAP ( netuid, uid ) --> block_at_registration @@ -589,15 +547,8 @@ pub mod pallet { RhoSet( u16, u16 ), // --- Event created when Rho value is set. KappaSet( u16, u16 ), // --- Event created when Kappa is set for a subnet. MinAllowedWeightSet( u16, u16 ), // --- Event created when minimun allowed weight is set for a subnet. - ValidatorBatchSizeSet( u16, u16 ), // --- Event created when validator batch size is set for a subnet. - ValidatorSequenceLengthSet( u16, u16 ), // --- Event created when validator sequence length is set for a subnet. - ValidatorEpochPerResetSet( u16, u16 ), // --- Event created when validator epoch per reset is set for a subnet. - ValidatorExcludeQuantileSet( u16, u16 ), // --- Event created when the validator exclude quantile has been set for a subnet. - ValidatorEpochLengthSet( u16, u16 ), // --- Event created when the validator epoch length has been set for a subnet. - ValidatorLogitsDivergenceSet( u16, u16 ), // --- Event created when the validator logits divergence value has been set. ValidatorPruneLenSet( u16, u64 ), // --- Event created when the validator pruning length has been set. ScalingLawPowerSet( u16, u16 ), // --- Event created when the scaling law power has been set for a subnet. - SynergyScalingLawPowerSet( u16, u16 ), // --- Event created when the synergy scaling law has been set for a subnet. WeightsSetRateLimitSet( u16, u64 ), // --- Event created when weights set rate limit has been set for a subnet. ImmunityPeriodSet( u16, u16), // --- Event created when immunity period is set for a subnet. BondsMovingAverageSet( u16, u64), // --- Event created when bonds moving average is set for a subnet. @@ -733,11 +684,7 @@ pub mod pallet { if !ActivityCutoff::::contains_key( netuid ) { ActivityCutoff::::insert( netuid, ActivityCutoff::::get( netuid ));} if !EmissionValues::::contains_key( netuid ) { EmissionValues::::insert( netuid, EmissionValues::::get( netuid ));} if !MaxWeightsLimit::::contains_key( netuid ) { MaxWeightsLimit::::insert( netuid, MaxWeightsLimit::::get( netuid ));} - if !ValidatorEpochLen::::contains_key( netuid ) { ValidatorEpochLen::::insert( netuid, ValidatorEpochLen::::get( netuid ));} if !MinAllowedWeights::::contains_key( netuid ) { MinAllowedWeights::::insert( netuid, MinAllowedWeights::::get( netuid )); } - if !ValidatorBatchSize::::contains_key( netuid ) { ValidatorBatchSize::::insert( netuid, ValidatorBatchSize::::get( netuid ));} - if !ValidatorEpochsPerReset::::contains_key( netuid ) { ValidatorEpochsPerReset::::insert( netuid, ValidatorEpochsPerReset::::get( netuid ));} - if !ValidatorSequenceLength::::contains_key( netuid ) { ValidatorSequenceLength::::insert( netuid, ValidatorSequenceLength::::get( netuid ));} if !RegistrationsThisInterval::::contains_key( netuid ) { RegistrationsThisInterval::::insert( netuid, RegistrationsThisInterval::::get( netuid ));} if !POWRegistrationsThisInterval::::contains_key( netuid ) { POWRegistrationsThisInterval::::insert( netuid, POWRegistrationsThisInterval::::get( netuid ));} if !BurnRegistrationsThisInterval::::contains_key( netuid ) { BurnRegistrationsThisInterval::::insert( netuid, BurnRegistrationsThisInterval::::get( netuid ));} @@ -1503,38 +1450,6 @@ pub mod pallet { Self::do_sudo_set_min_allowed_weights( origin, netuid, min_allowed_weights ) } - #[pallet::call_index(34)] - #[pallet::weight((Weight::from_ref_time(14_000_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Operational, Pays::No))] - pub fn sudo_set_validator_batch_size( origin:OriginFor, netuid: u16, validator_batch_size: u16 ) -> DispatchResult { - Self::do_sudo_set_validator_batch_size( origin, netuid, validator_batch_size ) - } - - #[pallet::call_index(35)] - #[pallet::weight((Weight::from_ref_time(14_000_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Operational, Pays::No))] - pub fn sudo_set_validator_sequence_length( origin:OriginFor, netuid: u16, validator_sequence_length: u16 ) -> DispatchResult { - Self::do_sudo_set_validator_sequence_length(origin, netuid, validator_sequence_length ) - } - - #[pallet::call_index(36)] - #[pallet::weight((Weight::from_ref_time(13_000_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Operational, Pays::No))] - pub fn sudo_set_validator_epochs_per_reset( origin:OriginFor, netuid: u16, validator_epochs_per_reset: u16 ) -> DispatchResult { - Self::do_sudo_set_validator_epochs_per_reset( origin, netuid, validator_epochs_per_reset ) - } - - #[pallet::call_index(37)] - #[pallet::weight((Weight::from_ref_time(13_000_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Operational, Pays::No))] - pub fn sudo_set_validator_exclude_quantile( origin:OriginFor, netuid: u16, validator_exclude_quantile: u16 ) -> DispatchResult { - Self::do_sudo_set_validator_exclude_quantile( origin, netuid, validator_exclude_quantile ) - } - #[pallet::call_index(38)] #[pallet::weight((Weight::from_ref_time(14_000_000) .saturating_add(T::DbWeight::get().reads(1)) @@ -1543,22 +1458,6 @@ pub mod pallet { Self::do_sudo_set_validator_prune_len( origin, netuid, validator_prune_len ) } - #[pallet::call_index(39)] - #[pallet::weight((Weight::from_ref_time(14_000_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Operational, Pays::No))] - pub fn sudo_set_validator_logits_divergence( origin:OriginFor, netuid: u16,validator_logits_divergence: u16 ) -> DispatchResult { - Self::do_sudo_set_validator_logits_divergence( origin, netuid, validator_logits_divergence ) - } - - #[pallet::call_index(40)] - #[pallet::weight((Weight::from_ref_time(14_000_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Operational, Pays::No))] - pub fn sudo_set_validator_epoch_len( origin:OriginFor, netuid: u16,validator_epoch_length: u16 ) -> DispatchResult { - Self::do_sudo_set_validator_epoch_length( origin, netuid, validator_epoch_length ) - } - #[pallet::call_index(41)] #[pallet::weight((Weight::from_ref_time(13_000_000) .saturating_add(T::DbWeight::get().reads(1)) @@ -1567,14 +1466,6 @@ pub mod pallet { Self::do_sudo_set_scaling_law_power( origin, netuid, scaling_law_power ) } - #[pallet::call_index(42)] - #[pallet::weight((Weight::from_ref_time(13_000_000) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Operational, Pays::No))] - pub fn sudo_set_synergy_scaling_law_power( origin:OriginFor, netuid: u16, synergy_scaling_law_power: u16 ) -> DispatchResult { - Self::do_sudo_set_synergy_scaling_law_power( origin, netuid, synergy_scaling_law_power ) - } - #[pallet::call_index(43)] #[pallet::weight((Weight::from_ref_time(13_000_000) .saturating_add(T::DbWeight::get().reads(1)) diff --git a/pallets/subtensor/src/networks.rs b/pallets/subtensor/src/networks.rs index f827ffb9e3..1e4f5315a8 100644 --- a/pallets/subtensor/src/networks.rs +++ b/pallets/subtensor/src/networks.rs @@ -273,11 +273,7 @@ impl Pallet { if !ActivityCutoff::::contains_key( netuid ) { ActivityCutoff::::insert( netuid, ActivityCutoff::::get( netuid ));} if !EmissionValues::::contains_key( netuid ) { EmissionValues::::insert( netuid, EmissionValues::::get( netuid ));} if !MaxWeightsLimit::::contains_key( netuid ) { MaxWeightsLimit::::insert( netuid, MaxWeightsLimit::::get( netuid ));} - if !ValidatorEpochLen::::contains_key( netuid ) { ValidatorEpochLen::::insert( netuid, ValidatorEpochLen::::get( netuid ));} if !MinAllowedWeights::::contains_key( netuid ) { MinAllowedWeights::::insert( netuid, MinAllowedWeights::::get( netuid )); } - if !ValidatorBatchSize::::contains_key( netuid ) { ValidatorBatchSize::::insert( netuid, ValidatorBatchSize::::get( netuid ));} - if !ValidatorEpochsPerReset::::contains_key( netuid ) { ValidatorEpochsPerReset::::insert( netuid, ValidatorEpochsPerReset::::get( netuid ));} - if !ValidatorSequenceLength::::contains_key( netuid ) { ValidatorSequenceLength::::insert( netuid, ValidatorSequenceLength::::get( netuid ));} if !RegistrationsThisInterval::::contains_key( netuid ) { RegistrationsThisInterval::::insert( netuid, RegistrationsThisInterval::::get( netuid ));} if !POWRegistrationsThisInterval::::contains_key( netuid ) { POWRegistrationsThisInterval::::insert( netuid, POWRegistrationsThisInterval::::get( netuid ));} if !BurnRegistrationsThisInterval::::contains_key( netuid ) { BurnRegistrationsThisInterval::::insert( netuid, BurnRegistrationsThisInterval::::get( netuid ));} @@ -314,11 +310,7 @@ impl Pallet { ActivityCutoff::::remove( netuid ); EmissionValues::::remove( netuid ); MaxWeightsLimit::::remove( netuid ); - ValidatorEpochLen::::remove( netuid ); MinAllowedWeights::::remove( netuid ); - ValidatorBatchSize::::remove( netuid ); - ValidatorEpochsPerReset::::remove( netuid ); - ValidatorSequenceLength::::remove( netuid ); RegistrationsThisInterval::::remove( netuid ); POWRegistrationsThisInterval::::remove( netuid ); BurnRegistrationsThisInterval::::remove( netuid ); diff --git a/pallets/subtensor/src/subnet_info.rs b/pallets/subtensor/src/subnet_info.rs index 77a2afd036..3074212d7a 100644 --- a/pallets/subtensor/src/subnet_info.rs +++ b/pallets/subtensor/src/subnet_info.rs @@ -13,15 +13,10 @@ pub struct SubnetInfo { kappa: Compact, difficulty: Compact, immunity_period: Compact, - validator_batch_size: Compact, - validator_sequence_length: Compact, - validator_epochs_per_reset: Compact, - validator_epoch_length: Compact, max_allowed_validators: Compact, min_allowed_weights: Compact, max_weights_limit: Compact, scaling_law_power: Compact, - synergy_scaling_law_power: Compact, subnetwork_n: Compact, max_allowed_uids: Compact, blocks_since_last_step: Compact, @@ -42,15 +37,10 @@ impl Pallet { let kappa = Self::get_kappa(netuid); let difficulty = Self::get_difficulty_as_u64(netuid); let immunity_period = Self::get_immunity_period(netuid); - let validator_batch_size = Self::get_validator_batch_size(netuid); - let validator_sequence_length = Self::get_validator_sequence_length(netuid); - let validator_epochs_per_reset = Self::get_validator_epochs_per_reset(netuid); - let validator_epoch_length = Self::get_validator_epoch_length(netuid); let max_allowed_validators = Self::get_max_allowed_validators(netuid); let min_allowed_weights = Self::get_min_allowed_weights(netuid); let max_weights_limit = Self::get_max_weight_limit(netuid); let scaling_law_power = Self::get_scaling_law_power(netuid); - let synergy_scaling_law_power = Self::get_synergy_scaling_law_power(netuid); let subnetwork_n = Self::get_subnetwork_n(netuid); let max_allowed_uids = Self::get_max_allowed_uids(netuid); let blocks_since_last_step = Self::get_blocks_since_last_step(netuid); @@ -72,15 +62,10 @@ impl Pallet { difficulty: difficulty.into(), immunity_period: immunity_period.into(), netuid: netuid.into(), - validator_batch_size: validator_batch_size.into(), - validator_sequence_length: validator_sequence_length.into(), - validator_epochs_per_reset: validator_epochs_per_reset.into(), - validator_epoch_length: validator_epoch_length.into(), max_allowed_validators: max_allowed_validators.into(), min_allowed_weights: min_allowed_weights.into(), max_weights_limit: max_weights_limit.into(), scaling_law_power: scaling_law_power.into(), - synergy_scaling_law_power: synergy_scaling_law_power.into(), subnetwork_n: subnetwork_n.into(), max_allowed_uids: max_allowed_uids.into(), blocks_since_last_step: blocks_since_last_step.into(), diff --git a/pallets/subtensor/src/utils.rs b/pallets/subtensor/src/utils.rs index 31b55344c7..792a6bf3e5 100644 --- a/pallets/subtensor/src/utils.rs +++ b/pallets/subtensor/src/utils.rs @@ -215,18 +215,6 @@ impl Pallet { Ok(()) } - pub fn get_validator_exclude_quantile( netuid: u16 ) -> u16 { ValidatorExcludeQuantile::::get( netuid ) } - pub fn set_validator_exclude_quantile( netuid: u16, validator_exclude_quantile: u16 ) { ValidatorExcludeQuantile::::insert( netuid, validator_exclude_quantile ); } - pub fn do_sudo_set_validator_exclude_quantile( origin:T::RuntimeOrigin, netuid: u16, validator_exclude_quantile: u16 ) -> DispatchResult { - ensure_root( origin )?; - ensure!( Self::if_subnet_exist(netuid), Error::::NetworkDoesNotExist ); - ensure!( validator_exclude_quantile <= u16::MAX, Error::::StorageValueOutOfRange ); // The quantile must be between 0 and u16::MAX => 0% and 100% - Self::set_validator_exclude_quantile( netuid, validator_exclude_quantile ); - log::info!("ValidatorExcludeQuantileSet( netuid: {:?} validator_exclude_quantile: {:?} ) ", netuid, validator_exclude_quantile); - Self::deposit_event( Event::ValidatorExcludeQuantileSet( netuid, validator_exclude_quantile )); - Ok(()) - } - pub fn get_validator_prune_len( netuid: u16 ) -> u64 { ValidatorPruneLen::::get( netuid ) } pub fn set_validator_prune_len( netuid: u16, validator_prune_len: u64 ) { ValidatorPruneLen::::insert( netuid, validator_prune_len ); } pub fn do_sudo_set_validator_prune_len( origin:T::RuntimeOrigin, netuid: u16, validator_prune_len: u64 ) -> DispatchResult { @@ -238,17 +226,6 @@ impl Pallet { Ok(()) } - pub fn get_validator_logits_divergence( netuid: u16 ) -> u16 { ValidatorLogitsDivergence::::get( netuid ) } - pub fn set_validator_logits_divergence( netuid: u16, validator_logits_divergence: u16 ) { ValidatorLogitsDivergence::::insert( netuid, validator_logits_divergence ); } - pub fn do_sudo_set_validator_logits_divergence( origin:T::RuntimeOrigin, netuid: u16, validator_logits_divergence: u16 ) -> DispatchResult { - ensure_root( origin )?; - ensure!( Self::if_subnet_exist(netuid), Error::::NetworkDoesNotExist ); - Self::set_validator_logits_divergence(netuid, validator_logits_divergence); - log::info!("ValidatorLogitsDivergenceSet( netuid: {:?} validator_logits_divergence: {:?} ) ", netuid, validator_logits_divergence); - Self::deposit_event( Event::ValidatorLogitsDivergenceSet( netuid, validator_logits_divergence )); - Ok(()) - } - pub fn get_scaling_law_power( netuid: u16 ) -> u16 { ScalingLawPower::::get( netuid ) } pub fn set_scaling_law_power( netuid: u16, scaling_law_power: u16 ) { ScalingLawPower::::insert( netuid, scaling_law_power ); } pub fn do_sudo_set_scaling_law_power( origin:T::RuntimeOrigin, netuid: u16, scaling_law_power: u16 ) -> DispatchResult { @@ -261,18 +238,6 @@ impl Pallet { Ok(()) } - pub fn get_synergy_scaling_law_power( netuid: u16 ) -> u16 { SynergyScalingLawPower::::get( netuid ) } - pub fn set_synergy_scaling_law_power( netuid: u16, synergy_scaling_law_power: u16 ) { SynergyScalingLawPower::::insert( netuid, synergy_scaling_law_power ); } - pub fn do_sudo_set_synergy_scaling_law_power( origin:T::RuntimeOrigin, netuid: u16, synergy_scaling_law_power: u16 ) -> DispatchResult { - ensure_root( origin )?; - ensure!( Self::if_subnet_exist(netuid), Error::::NetworkDoesNotExist ); - ensure!( synergy_scaling_law_power <= 100, Error::::StorageValueOutOfRange ); // The synergy scaling law power must be between 0 and 100 => 0% and 100% - Self::set_synergy_scaling_law_power( netuid, synergy_scaling_law_power ); - log::info!("SynergyScalingLawPowerSet( netuid: {:?} synergy_scaling_law_power: {:?} ) ", netuid, synergy_scaling_law_power); - Self::deposit_event( Event::SynergyScalingLawPowerSet( netuid, synergy_scaling_law_power )); - Ok(()) - } - pub fn get_max_weight_limit( netuid: u16) -> u16 { MaxWeightsLimit::::get( netuid ) } pub fn set_max_weight_limit( netuid: u16, max_weight_limit: u16 ) { MaxWeightsLimit::::insert( netuid, max_weight_limit ); } pub fn do_sudo_set_max_weight_limit( origin:T::RuntimeOrigin, netuid: u16, max_weight_limit: u16 ) -> DispatchResult { @@ -294,52 +259,7 @@ impl Pallet { Self::deposit_event(Event::ImmunityPeriodSet(netuid, immunity_period)); Ok(()) } - - pub fn get_validator_epochs_per_reset( netuid: u16 )-> u16 { ValidatorEpochsPerReset::::get( netuid ) } - pub fn set_validator_epochs_per_reset( netuid: u16, validator_epochs_per_reset: u16 ) { ValidatorEpochsPerReset::::insert( netuid, validator_epochs_per_reset ); } - pub fn do_sudo_set_validator_epochs_per_reset( origin:T::RuntimeOrigin, netuid: u16, validator_epochs_per_reset: u16 ) -> DispatchResult { - ensure_root( origin )?; - ensure!(Self::if_subnet_exist(netuid), Error::::NetworkDoesNotExist); - Self::set_validator_epochs_per_reset( netuid, validator_epochs_per_reset ); - log::info!("ValidatorEpochPerResetSet( netuid: {:?} validator_epochs_per_reset: {:?} ) ", netuid, validator_epochs_per_reset ); - Self::deposit_event(Event::ValidatorEpochPerResetSet(netuid, validator_epochs_per_reset)); - Ok(()) - } - - pub fn get_validator_sequence_length( netuid: u16 )-> u16 {ValidatorSequenceLength::::get( netuid ) } - pub fn set_validator_sequence_length( netuid: u16, validator_sequence_length: u16 ) { ValidatorSequenceLength::::insert( netuid, validator_sequence_length ); } - pub fn do_sudo_set_validator_sequence_length( origin:T::RuntimeOrigin, netuid: u16, validator_sequence_length: u16 ) -> DispatchResult { - ensure_root( origin )?; - ensure!(Self::if_subnet_exist(netuid), Error::::NetworkDoesNotExist); - ValidatorSequenceLength::::insert( netuid, validator_sequence_length ); - log::info!("ValidatorSequenceLengthSet( netuid: {:?} validator_sequence_length: {:?} ) ", netuid, validator_sequence_length ); - Self::deposit_event(Event::ValidatorSequenceLengthSet(netuid, validator_sequence_length)); - Ok(()) - } - - - pub fn get_validator_epoch_length( netuid: u16 )-> u16 {ValidatorEpochLen::::get( netuid ) } - pub fn set_validator_epoch_length( netuid: u16, validator_epoch_length: u16 ) { ValidatorEpochLen::::insert( netuid, validator_epoch_length ); } - pub fn do_sudo_set_validator_epoch_length( origin:T::RuntimeOrigin, netuid: u16, validator_epoch_length: u16 ) -> DispatchResult { - ensure_root( origin )?; - ensure!(Self::if_subnet_exist(netuid), Error::::NetworkDoesNotExist); - ValidatorEpochLen::::insert( netuid, validator_epoch_length ); - log::info!("ValidatorEpochLengthSet( netuid: {:?} validator_epoch_length: {:?} ) ", netuid, validator_epoch_length ); - Self::deposit_event(Event::ValidatorEpochLengthSet(netuid, validator_epoch_length)); - Ok(()) - } - - pub fn get_validator_batch_size( netuid: u16 ) -> u16 { ValidatorBatchSize::::get( netuid ) } - pub fn set_validator_batch_size( netuid: u16, validator_batch_size: u16 ) { ValidatorBatchSize::::insert( netuid, validator_batch_size ); } - pub fn do_sudo_set_validator_batch_size( origin:T::RuntimeOrigin, netuid: u16, validator_batch_size: u16 ) -> DispatchResult { - ensure_root( origin )?; - ensure!(Self::if_subnet_exist(netuid), Error::::NetworkDoesNotExist); - Self::set_validator_batch_size( netuid, validator_batch_size ); - log::info!("ValidatorBatchSizeSet( netuid: {:?} validator_batch_size: {:?} ) ", netuid, validator_batch_size); - Self::deposit_event(Event::ValidatorBatchSizeSet(netuid, validator_batch_size)); - Ok(()) - } - + pub fn get_min_allowed_weights( netuid:u16 ) -> u16 { MinAllowedWeights::::get( netuid ) } pub fn set_min_allowed_weights( netuid: u16, min_allowed_weights: u16 ) { MinAllowedWeights::::insert( netuid, min_allowed_weights ); } pub fn do_sudo_set_min_allowed_weights( origin:T::RuntimeOrigin, netuid: u16, min_allowed_weights: u16 ) -> DispatchResult { diff --git a/pallets/subtensor/tests/mock.rs b/pallets/subtensor/tests/mock.rs index c79a8bce48..5b9bd7cbc1 100644 --- a/pallets/subtensor/tests/mock.rs +++ b/pallets/subtensor/tests/mock.rs @@ -131,15 +131,8 @@ parameter_types! { pub const InitialMinBurn: u64 = 0; pub const InitialMaxBurn: u64 = 1_000_000_000; - pub const InitialValidatorBatchSize: u16 = 10; - pub const InitialValidatorSequenceLen: u16 = 10; pub const InitialValidatorPruneLen: u64 = 0; - pub const InitialValidatorEpochLen: u16 = 10; - pub const InitialValidatorEpochsPerReset: u16 = 10; - pub const InitialValidatorExcludeQuantile: u16 = 10; - pub const InitialValidatorLogitsDivergence: u16 = 0; pub const InitialScalingLawPower: u16 = 50; - pub const InitialSynergyScalingLawPower: u16 = 50; pub const InitialMaxAllowedValidators: u16 = 100; pub const InitialIssuance: u64 = 548833985028256; @@ -318,15 +311,8 @@ impl pallet_subtensor::Config for Test { type InitialRho = InitialRho; type InitialKappa = InitialKappa; type InitialMaxAllowedUids = InitialMaxAllowedUids; - type InitialValidatorBatchSize = InitialValidatorBatchSize; - type InitialValidatorSequenceLen = InitialValidatorSequenceLen; type InitialValidatorPruneLen = InitialValidatorPruneLen; - type InitialValidatorEpochLen = InitialValidatorEpochLen; - type InitialValidatorEpochsPerReset = InitialValidatorEpochsPerReset; - type InitialValidatorExcludeQuantile = InitialValidatorExcludeQuantile; - type InitialValidatorLogitsDivergence = InitialValidatorLogitsDivergence; type InitialScalingLawPower = InitialScalingLawPower; - type InitialSynergyScalingLawPower = InitialSynergyScalingLawPower; type InitialImmunityPeriod = InitialImmunityPeriod; type InitialActivityCutoff = InitialActivityCutoff; type InitialMaxRegistrationsPerBlock = InitialMaxRegistrationsPerBlock; diff --git a/pallets/subtensor/tests/sudo.rs b/pallets/subtensor/tests/sudo.rs index 9b1894ecc3..00b5e64224 100644 --- a/pallets/subtensor/tests/sudo.rs +++ b/pallets/subtensor/tests/sudo.rs @@ -28,18 +28,12 @@ fn test_defaults() { assert_eq!(SubtensorModule::get_min_allowed_weights(netuid), 0); assert_eq!(SubtensorModule::get_adjustment_interval(netuid), 100); assert_eq!(SubtensorModule::get_bonds_moving_average(netuid), 900_000); - assert_eq!(SubtensorModule::get_validator_batch_size(netuid), 10); assert_eq!(SubtensorModule::get_last_adjustment_block(netuid), 0); assert_eq!(SubtensorModule::get_last_mechanism_step_block(netuid), 0); assert_eq!(SubtensorModule::get_blocks_since_last_step(netuid), 0); assert_eq!(SubtensorModule::get_registrations_this_block(netuid), 0); - assert_eq!(SubtensorModule::get_validator_epochs_per_reset(netuid), 10); - assert_eq!(SubtensorModule::get_validator_sequence_length(netuid), 10); - assert_eq!(SubtensorModule::get_validator_exclude_quantile(netuid), 10); - assert_eq!(SubtensorModule::get_validator_logits_divergence(netuid), 0); assert_eq!(SubtensorModule::get_validator_prune_len(netuid), 0); assert_eq!(SubtensorModule::get_scaling_law_power(netuid), 50); - assert_eq!(SubtensorModule::get_synergy_scaling_law_power(netuid), 50); assert_eq!(SubtensorModule::get_registrations_this_interval(netuid), 0); assert_eq!(SubtensorModule::get_max_registrations_per_block(netuid), 3); assert_eq!( @@ -436,45 +430,6 @@ fn test_sudo_set_adjustment_alpha() { }); } -#[test] -fn test_sudo_set_validator_exclude_quantile() { - new_test_ext().execute_with(|| { - let netuid: u16 = 1; - let to_be_set: u16 = 10; - let init_value: u16 = SubtensorModule::get_validator_exclude_quantile(netuid); - add_network(netuid, 10, 0); - assert_eq!( - SubtensorModule::sudo_set_validator_exclude_quantile( - <::RuntimeOrigin>::signed(U256::from(0)), - netuid, - to_be_set - ), - Err(DispatchError::BadOrigin.into()) - ); - assert_eq!( - SubtensorModule::sudo_set_validator_exclude_quantile( - <::RuntimeOrigin>::root(), - netuid + 1, - to_be_set - ), - Err(Error::::NetworkDoesNotExist.into()) - ); - assert_eq!( - SubtensorModule::get_validator_exclude_quantile(netuid), - init_value - ); - assert_ok!(SubtensorModule::sudo_set_validator_exclude_quantile( - <::RuntimeOrigin>::root(), - netuid, - to_be_set - )); - assert_eq!( - SubtensorModule::get_validator_exclude_quantile(netuid), - to_be_set - ); - }); -} - #[test] fn test_sudo_validator_prune_len() { new_test_ext().execute_with(|| { @@ -509,46 +464,6 @@ fn test_sudo_validator_prune_len() { }); } -#[test] -fn test_sudo_validator_logits_divergence() { - new_test_ext().execute_with(|| { - let netuid: u16 = 1; - let to_be_set: u16 = 10; - let init_value: u16 = SubtensorModule::get_validator_logits_divergence(netuid); - add_network(netuid, 10, 0); - - assert_eq!( - SubtensorModule::sudo_set_validator_logits_divergence( - <::RuntimeOrigin>::signed(U256::from(0)), - netuid, - to_be_set - ), - Err(DispatchError::BadOrigin.into()) - ); - assert_eq!( - SubtensorModule::sudo_set_validator_logits_divergence( - <::RuntimeOrigin>::root(), - netuid + 1, - to_be_set - ), - Err(Error::::NetworkDoesNotExist.into()) - ); - assert_eq!( - SubtensorModule::get_validator_logits_divergence(netuid), - init_value - ); - assert_ok!(SubtensorModule::sudo_set_validator_logits_divergence( - <::RuntimeOrigin>::root(), - netuid, - to_be_set - )); - assert_eq!( - SubtensorModule::get_validator_logits_divergence(netuid), - to_be_set - ); - }); -} - #[test] fn test_sudo_set_scaling_law_power() { new_test_ext().execute_with(|| { @@ -582,45 +497,6 @@ fn test_sudo_set_scaling_law_power() { }); } -#[test] -fn test_sudo_set_synergy_scaling_law_power() { - new_test_ext().execute_with(|| { - let netuid: u16 = 1; - let to_be_set: u16 = 50; - let init_value: u16 = SubtensorModule::get_synergy_scaling_law_power(netuid); - add_network(netuid, 10, 0); - assert_eq!( - SubtensorModule::sudo_set_synergy_scaling_law_power( - <::RuntimeOrigin>::signed(U256::from(0)), - netuid, - to_be_set - ), - Err(DispatchError::BadOrigin.into()) - ); - assert_eq!( - SubtensorModule::sudo_set_synergy_scaling_law_power( - <::RuntimeOrigin>::root(), - netuid + 1, - to_be_set - ), - Err(Error::::NetworkDoesNotExist.into()) - ); - assert_eq!( - SubtensorModule::get_synergy_scaling_law_power(netuid), - init_value - ); - assert_ok!(SubtensorModule::sudo_set_synergy_scaling_law_power( - <::RuntimeOrigin>::root(), - netuid, - to_be_set - )); - assert_eq!( - SubtensorModule::get_synergy_scaling_law_power(netuid), - to_be_set - ); - }); -} - #[test] fn test_sudo_set_max_weight_limit() { new_test_ext().execute_with(|| { @@ -706,120 +582,6 @@ fn test_sudo_set_immunity_period() { }); } -#[test] -fn test_sudo_set_validator_epochs_per_reset() { - new_test_ext().execute_with(|| { - let netuid: u16 = 1; - let to_be_set: u16 = 10; - let init_value: u16 = SubtensorModule::get_validator_epochs_per_reset(netuid); - add_network(netuid, 10, 0); - assert_eq!( - SubtensorModule::sudo_set_validator_epochs_per_reset( - <::RuntimeOrigin>::signed(U256::from(0)), - netuid, - to_be_set - ), - Err(DispatchError::BadOrigin.into()) - ); - assert_eq!( - SubtensorModule::sudo_set_validator_epochs_per_reset( - <::RuntimeOrigin>::root(), - netuid + 1, - to_be_set - ), - Err(Error::::NetworkDoesNotExist.into()) - ); - assert_eq!( - SubtensorModule::get_validator_epochs_per_reset(netuid), - init_value - ); - assert_ok!(SubtensorModule::sudo_set_validator_epochs_per_reset( - <::RuntimeOrigin>::root(), - netuid, - to_be_set - )); - assert_eq!( - SubtensorModule::get_validator_epochs_per_reset(netuid), - to_be_set - ); - }); -} - -#[test] -fn test_sudo_set_validator_sequence_length() { - new_test_ext().execute_with(|| { - let netuid: u16 = 1; - let to_be_set: u16 = 10; - let init_value: u16 = SubtensorModule::get_validator_sequence_length(netuid); - add_network(netuid, 10, 0); - assert_eq!( - SubtensorModule::sudo_set_validator_sequence_length( - <::RuntimeOrigin>::signed(U256::from(0)), - netuid, - to_be_set - ), - Err(DispatchError::BadOrigin.into()) - ); - assert_eq!( - SubtensorModule::sudo_set_validator_sequence_length( - <::RuntimeOrigin>::root(), - netuid + 1, - to_be_set - ), - Err(Error::::NetworkDoesNotExist.into()) - ); - assert_eq!( - SubtensorModule::get_validator_sequence_length(netuid), - init_value - ); - assert_ok!(SubtensorModule::sudo_set_validator_sequence_length( - <::RuntimeOrigin>::root(), - netuid, - to_be_set - )); - assert_eq!( - SubtensorModule::get_validator_sequence_length(netuid), - to_be_set - ); - }); -} - -#[test] -fn test_sudo_set_validator_batch_size() { - new_test_ext().execute_with(|| { - let netuid: u16 = 1; - let to_be_set: u16 = 10; - let init_value: u16 = SubtensorModule::get_validator_batch_size(netuid); - add_network(netuid, 10, 0); - assert_eq!( - SubtensorModule::sudo_set_validator_batch_size( - <::RuntimeOrigin>::signed(U256::from(0)), - netuid, - to_be_set - ), - Err(DispatchError::BadOrigin.into()) - ); - assert_eq!( - SubtensorModule::sudo_set_validator_batch_size( - <::RuntimeOrigin>::root(), - netuid + 1, - to_be_set - ), - Err(Error::::NetworkDoesNotExist.into()) - ); - assert_eq!( - SubtensorModule::get_validator_batch_size(netuid), - init_value - ); - assert_ok!(SubtensorModule::sudo_set_validator_batch_size( - <::RuntimeOrigin>::root(), - netuid, - to_be_set - )); - assert_eq!(SubtensorModule::get_validator_batch_size(netuid), to_be_set); - }); -} - #[test] fn test_sudo_set_min_allowed_weights() { new_test_ext().execute_with(|| { diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 5bb9a1be38..e2b0feebe5 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -500,15 +500,8 @@ parameter_types! { pub const SubtensorInitialMinAllowedWeights: u16 = 1024; pub const SubtensorInitialEmissionValue: u16 = 0; pub const SubtensorInitialMaxWeightsLimit: u16 = 1000; // 1000/2^16 = 0.015 - pub const SubtensorInitialValidatorBatchSize: u16 = 32; // 32 - pub const SubtensorInitialValidatorSequenceLen: u16 = 256; // 256 - pub const SubtensorInitialValidatorEpochLen: u16 = 100; - pub const SubtensorInitialValidatorEpochsPerReset: u16 = 60; - pub const SubtensorInitialValidatorExcludeQuantile: u16 = 6554; // 10% of u16 pub const SubtensorInitialValidatorPruneLen: u64 = 1; - pub const SubtensorInitialValidatorLogitsDivergence: u16 = 1310; // 2% of u16 pub const SubtensorInitialScalingLawPower: u16 = 50; // 0.5 - pub const SubtensorInitialSynergyScalingLawPower: u16 = 50; // 0.5 pub const SubtensorInitialMaxAllowedValidators: u16 = 128; pub const SubtensorInitialTempo: u16 = 99; pub const SubtensorInitialDifficulty: u64 = 10_000_000; @@ -549,15 +542,8 @@ impl pallet_subtensor::Config for Runtime { type InitialMinAllowedWeights = SubtensorInitialMinAllowedWeights; type InitialEmissionValue = SubtensorInitialEmissionValue; type InitialMaxWeightsLimit = SubtensorInitialMaxWeightsLimit; - type InitialValidatorBatchSize = SubtensorInitialValidatorBatchSize; - type InitialValidatorSequenceLen = SubtensorInitialValidatorSequenceLen; - type InitialValidatorEpochLen = SubtensorInitialValidatorEpochLen; - type InitialValidatorEpochsPerReset = SubtensorInitialValidatorEpochsPerReset; - type InitialValidatorExcludeQuantile = SubtensorInitialValidatorExcludeQuantile; type InitialValidatorPruneLen = SubtensorInitialValidatorPruneLen; - type InitialValidatorLogitsDivergence = SubtensorInitialValidatorLogitsDivergence; type InitialScalingLawPower = SubtensorInitialScalingLawPower; - type InitialSynergyScalingLawPower = SubtensorInitialSynergyScalingLawPower; type InitialTempo = SubtensorInitialTempo; type InitialDifficulty = SubtensorInitialDifficulty; type InitialAdjustmentInterval = SubtensorInitialAdjustmentInterval;