diff --git a/pallets/governance/src/lib.rs b/pallets/governance/src/lib.rs index 1128067e2..13c715719 100644 --- a/pallets/governance/src/lib.rs +++ b/pallets/governance/src/lib.rs @@ -37,7 +37,7 @@ pub mod pallet { PalletId, }; use frame_system::pallet_prelude::{ensure_signed, BlockNumberFor}; - use pallet_subspace::DefaultKey; + use pallet_subspace::{global::GeneralBurnConfiguration, DefaultKey}; use sp_runtime::traits::AccountIdConversion; const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); @@ -236,12 +236,7 @@ pub mod pallet { maximum_set_weight_calls_per_epoch: u16, vote_mode: VoteMode, bonds_ma: u64, - min_burn: u64, - max_burn: u64, - target_registrations_interval: u16, - target_registrations_per_interval: u16, - max_registrations_per_interval: u16, - adjustment_alpha: u64, + module_burn_config: GeneralBurnConfiguration, min_validator_stake: u64, max_allowed_validators: Option, ) -> DispatchResult { @@ -261,12 +256,7 @@ pub mod pallet { params.maximum_set_weight_calls_per_epoch = maximum_set_weight_calls_per_epoch; params.governance_config.vote_mode = vote_mode; params.bonds_ma = bonds_ma; - params.min_burn = min_burn; - params.max_burn = max_burn; - params.target_registrations_interval = target_registrations_interval; - params.target_registrations_per_interval = target_registrations_per_interval; - params.max_registrations_per_interval = max_registrations_per_interval; - params.adjustment_alpha = adjustment_alpha; + params.module_burn_config = module_burn_config; params.min_validator_stake = min_validator_stake; params.max_allowed_validators = max_allowed_validators; Self::do_add_subnet_params_proposal(origin, netuid, data, params) diff --git a/pallets/subspace/src/lib.rs b/pallets/subspace/src/lib.rs index f4b4623e8..c44a67dad 100644 --- a/pallets/subspace/src/lib.rs +++ b/pallets/subspace/src/lib.rs @@ -339,8 +339,6 @@ pub mod pallet { // TODO: not hardcode values here, get them from the storages instead, // if they implement default already. pub fn get() -> SubnetParams { - let module_burn_defaults = GeneralBurnConfiguration::::default_for(BurnType::Module); - SubnetParams { name: BoundedVec::default(), tempo: 100, @@ -357,14 +355,7 @@ pub mod pallet { bonds_ma: 900_000, // registrations - min_burn: module_burn_defaults.min_burn, - max_burn: module_burn_defaults.max_burn, - target_registrations_interval: module_burn_defaults.target_registrations_interval, - target_registrations_per_interval: module_burn_defaults - .target_registrations_per_interval, - max_registrations_per_interval: module_burn_defaults.max_registrations_per_interval, - adjustment_alpha: module_burn_defaults.adjustment_alpha, - + module_burn_config: GeneralBurnConfiguration::::default_for(BurnType::Module), min_validator_stake: DefaultMinValidatorStake::::get(), max_allowed_validators: None, governance_config: GovernanceConfiguration { @@ -399,13 +390,7 @@ pub mod pallet { pub maximum_set_weight_calls_per_epoch: u16, // consensus pub bonds_ma: u64, - // registrations - pub min_burn: u64, - pub max_burn: u64, - pub target_registrations_interval: u16, - pub target_registrations_per_interval: u16, - pub max_registrations_per_interval: u16, - pub adjustment_alpha: u64, + pub module_burn_config: GeneralBurnConfiguration, pub min_validator_stake: u64, pub max_allowed_validators: Option, pub governance_config: GovernanceConfiguration, @@ -1013,12 +998,7 @@ pub mod pallet { maximum_set_weight_calls_per_epoch: u16, vote_mode: VoteMode, bonds_ma: u64, - min_burn: u64, - max_burn: u64, - target_registrations_interval: u16, - target_registrations_per_interval: u16, - max_registrations_per_interval: u16, - adjustment_alpha: u64, + module_burn_config: GeneralBurnConfiguration, min_validator_stake: u64, max_allowed_validators: Option, ) -> DispatchResult { @@ -1036,12 +1016,7 @@ pub mod pallet { trust_ratio, maximum_set_weight_calls_per_epoch, bonds_ma, - min_burn, - max_burn, - target_registrations_interval, - target_registrations_per_interval, - max_registrations_per_interval, - adjustment_alpha, + module_burn_config, min_validator_stake, max_allowed_validators, governance_config: GovernanceConfiguration { diff --git a/pallets/subspace/src/subnet.rs b/pallets/subspace/src/subnet.rs index 9a4dc222f..5e9c8cdcb 100644 --- a/pallets/subspace/src/subnet.rs +++ b/pallets/subspace/src/subnet.rs @@ -44,16 +44,7 @@ impl SubnetChangeset { TrustRatio::::insert(netuid, self.params.trust_ratio); IncentiveRatio::::insert(netuid, self.params.incentive_ratio); BondsMovingAverage::::insert(netuid, self.params.bonds_ma); - let burn_config: GeneralBurnConfiguration = GeneralBurnConfiguration { - min_burn: self.params.min_burn, - max_burn: self.params.max_burn, - adjustment_alpha: self.params.adjustment_alpha, - target_registrations_interval: self.params.target_registrations_interval, - target_registrations_per_interval: self.params.target_registrations_per_interval, - max_registrations_per_interval: self.params.max_registrations_per_interval, - _pd: PhantomData, - }; - burn_config.apply_module_burn(netuid)?; + self.params.module_burn_config.apply_module_burn(netuid)?; MinValidatorStake::::insert(netuid, self.params.min_validator_stake); if self.params.maximum_set_weight_calls_per_epoch == 0 { MaximumSetWeightCallsPerEpoch::::remove(netuid); @@ -169,8 +160,6 @@ impl SubnetChangeset { impl Pallet { pub fn subnet_params(netuid: u16) -> SubnetParams { - let module_burn_config = ModuleBurnConfig::::get(netuid); - SubnetParams { founder: Founder::::get(netuid), founder_share: FounderShare::::get(netuid), @@ -188,13 +177,7 @@ impl Pallet { bonds_ma: BondsMovingAverage::::get(netuid), // Registrations - min_burn: module_burn_config.min_burn, - max_burn: module_burn_config.max_burn, - target_registrations_interval: module_burn_config.target_registrations_interval, - target_registrations_per_interval: module_burn_config.target_registrations_per_interval, - max_registrations_per_interval: module_burn_config.max_registrations_per_interval, - adjustment_alpha: module_burn_config.adjustment_alpha, - + module_burn_config: ModuleBurnConfig::::get(netuid), min_validator_stake: MinValidatorStake::::get(netuid), max_allowed_validators: MaxAllowedValidators::::get(netuid), governance_config: T::get_subnet_governance_configuration(netuid), diff --git a/tests/src/governance.rs b/tests/src/governance.rs index d889c74a0..7de08e353 100644 --- a/tests/src/governance.rs +++ b/tests/src/governance.rs @@ -325,12 +325,7 @@ fn subnet_params_proposal_accepted() { trust_ratio, maximum_set_weight_calls_per_epoch, bonds_ma, - min_burn, - max_burn, - target_registrations_interval, - target_registrations_per_interval, - max_registrations_per_interval, - adjustment_alpha, + module_burn_config, min_validator_stake, max_allowed_validators, mut governance_config, @@ -358,12 +353,7 @@ fn subnet_params_proposal_accepted() { maximum_set_weight_calls_per_epoch, governance_config.vote_mode, bonds_ma, - min_burn, - max_burn, - target_registrations_interval, - target_registrations_per_interval, - max_registrations_per_interval, - adjustment_alpha, + module_burn_config, min_validator_stake, max_allowed_validators, ) diff --git a/tests/src/subspace/subnet.rs b/tests/src/subspace/subnet.rs index a416b4da3..d46dc9214 100644 --- a/tests/src/subspace/subnet.rs +++ b/tests/src/subspace/subnet.rs @@ -1,5 +1,6 @@ use crate::mock::*; use frame_support::assert_err; +use global::GeneralBurnConfiguration; use pallet_governance::{GovernanceConfiguration, SubnetGovernanceConfig, VoteMode}; use pallet_subspace::*; use sp_runtime::Percent; @@ -59,10 +60,6 @@ fn subnet_update_changes_all_parameter_values() { trust_ratio: 11, maximum_set_weight_calls_per_epoch: 12, bonds_ma: 13, - target_registrations_interval: 14, - target_registrations_per_interval: 15, - max_registrations_per_interval: 16, - adjustment_alpha: 17, min_validator_stake: to_nano(50_000), max_allowed_validators: Some(18), governance_config: GovernanceConfiguration { @@ -73,8 +70,15 @@ fn subnet_update_changes_all_parameter_values() { max_proposal_reward_treasury_allocation: 21, proposal_reward_interval: 22, }, - min_burn: 20000000000, - max_burn: 21000000000, + module_burn_config: GeneralBurnConfiguration { + min_burn: to_nano(15), + max_burn: to_nano(24), + target_registrations_interval: 25, + target_registrations_per_interval: 26, + max_registrations_per_interval: 27, + adjustment_alpha: 28, + ..Default::default() + }, }; let SubnetParams { @@ -92,19 +96,13 @@ fn subnet_update_changes_all_parameter_values() { trust_ratio, maximum_set_weight_calls_per_epoch, bonds_ma, - min_burn, - max_burn, - target_registrations_interval, - target_registrations_per_interval, - max_registrations_per_interval, - adjustment_alpha, + module_burn_config, min_validator_stake, max_allowed_validators, governance_config, } = params.clone(); SubnetChangeset::::update(netuid, params).unwrap().apply(netuid).unwrap(); - assert_eq!(Founder::::get(netuid), founder); assert_eq!(FounderShare::::get(netuid), founder_share); assert_eq!(ImmunityPeriod::::get(netuid), immunity_period); @@ -121,31 +119,13 @@ fn subnet_update_changes_all_parameter_values() { Some(maximum_set_weight_calls_per_epoch) ); assert_eq!(BondsMovingAverage::::get(netuid), bonds_ma); - assert_eq!(ModuleBurnConfig::::get(netuid).min_burn, min_burn); - assert_eq!(ModuleBurnConfig::::get(netuid).max_burn, max_burn); - assert_eq!( - ModuleBurnConfig::::get(netuid).target_registrations_interval, - target_registrations_interval - ); - assert_eq!( - ModuleBurnConfig::::get(netuid).target_registrations_per_interval, - target_registrations_per_interval - ); - assert_eq!( - ModuleBurnConfig::::get(netuid).max_registrations_per_interval, - max_registrations_per_interval - ); - assert_eq!( - ModuleBurnConfig::::get(netuid).adjustment_alpha, - adjustment_alpha - ); + assert_eq!(ModuleBurnConfig::::get(netuid), module_burn_config); + assert_eq!(MinValidatorStake::::get(netuid), min_validator_stake); assert_eq!(MinValidatorStake::::get(netuid), min_validator_stake); - assert_eq!( SubnetGovernanceConfig::::get(netuid), governance_config ); - assert_eq!(SubspaceMod::get_total_subnets(), 1); assert_eq!(N::::get(netuid), 1); assert_eq!(SubnetMetadata::::get(netuid), metadata); @@ -252,12 +232,7 @@ fn update_subnet_verifies_names_uniquiness_integrity() { params.maximum_set_weight_calls_per_epoch, params.governance_config.vote_mode, params.bonds_ma, - params.min_burn, - params.max_burn, - params.target_registrations_interval, - params.target_registrations_per_interval, - params.max_registrations_per_interval, - params.adjustment_alpha, + params.module_burn_config, params.min_validator_stake, params.max_allowed_validators, )