Skip to content

Commit

Permalink
chore: add changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
devwckd committed May 13, 2024
1 parent dcddef4 commit f0a1afa
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 19 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@

[Unreleased]

Spec version: `114`

- Deleted, or moved useless code and values of:
- Burn rate
- Min Stake
- The following storage values were deleted and are now accessible through `BurnConfig`:
- `MinBurn`
- `MaxBurn`
- `AdjustmentAlpha`
- `TargetRegistrationsInterval`
- `TargetRegistrationsPerInterval`
- The storage value `RemovedSubnets` is now called `SubnetGaps`

## Version 1.7.3

Expand Down
14 changes: 9 additions & 5 deletions pallets/subspace/src/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use sp_arithmetic::per_things::Percent;
use sp_core::Get;
use sp_runtime::DispatchError;

#[derive(Clone, Debug, TypeInfo, Decode, Encode)]
#[derive(Clone, TypeInfo, Decode, Encode, PartialEq, Eq, frame_support::DebugNoBound)]
#[scale_info(skip_type_params(T))]
pub struct BurnConfiguration<T: Config> {
/// min burn the adjustment algorithm can set
Expand Down Expand Up @@ -76,14 +76,16 @@ impl<T: Config> Pallet<T> {
max_allowed_weights: Self::get_max_allowed_weights_global(),
subnet_stake_threshold: Self::get_subnet_stake_threshold(),
min_weight_stake: Self::get_min_weight_stake(),
//
// proposals
proposal_cost: Self::get_proposal_cost(), // denominated in $COMAI
proposal_expiration: Self::get_proposal_expiration(), /* denominated in the number of
* blocks */
proposal_participation_threshold: Self::get_proposal_participation_threshold(), /* denominated
in percent of the overall network stake */
// s0
general_subnet_application_cost: Self::get_general_subnet_application_cost(),

burn_config: BurnConfig::<T>::get(),
}
}

Expand Down Expand Up @@ -184,11 +186,13 @@ impl<T: Config> Pallet<T> {
Self::set_max_allowed_weights_global(params.max_allowed_weights);
Self::set_min_weight_stake(params.min_weight_stake);

//

// proposals
Self::set_proposal_cost(params.proposal_cost);
Self::set_proposal_expiration(params.proposal_expiration);
Self::set_proposal_participation_threshold(params.proposal_participation_threshold);

// burn
params.burn_config.apply().expect("invalid burn configuration");
}

pub fn get_curator() -> T::AccountId {
Expand Down Expand Up @@ -230,7 +234,7 @@ impl<T: Config> Pallet<T> {
FloorDelegationFee::<T>::put(delegation_fee)
}

//
// Proposals

pub fn get_proposal_cost() -> u64 {
ProposalCost::<T>::get()
Expand Down
22 changes: 14 additions & 8 deletions pallets/subspace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ pub mod pallet {

pub subnet_stake_threshold: Percent,

// porposals
// proposals
pub proposal_cost: u64,
pub proposal_expiration: u32,
pub proposal_participation_threshold: Percent,
Expand All @@ -289,6 +289,8 @@ pub mod pallet {

// founder share
pub floor_founder_share: u8,

pub burn_config: BurnConfiguration<T>,
}

pub struct DefaultSubnetParams<T: Config>(sp_std::marker::PhantomData<((), T)>);
Expand Down Expand Up @@ -1148,16 +1150,16 @@ pub mod pallet {
max_allowed_modules: u16, // max number of modules allowed per subnet
max_registrations_per_block: u16, // max number of registrations per block
max_allowed_weights: u16, // max number of weights per module
_max_burn: u64, // max burn allowed to register
_min_burn: u64, // min burn required to register
max_burn: u64, // max burn allowed to register
min_burn: u64, // min burn required to register
floor_delegation_fee: Percent, // min delegation fee
floor_founder_share: u8, // min founder share
min_weight_stake: u64, // min weight stake required
_target_registrations_per_interval: u16, /* desired number of registrations per
target_registrations_per_interval: u16, /* desired number of registrations per
* interval */
_target_registrations_interval: u16, /* the number of blocks that defines the
* registration interval */
_adjustment_alpha: u64, // adjustment alpha
target_registrations_interval: u16, /* the number of blocks that defines the
* registration interval */
adjustment_alpha: u64, // adjustment alpha
unit_emission: u64, // emission per block
curator: T::AccountId, // subnet 0 dao multisig
subnet_stake_threshold: Percent, // stake needed to start subnet emission
Expand Down Expand Up @@ -1187,7 +1189,11 @@ pub mod pallet {
params.proposal_participation_threshold = proposal_participation_threshold;
params.general_subnet_application_cost = general_subnet_application_cost;

// TODO: re-add burn stuff
params.burn_config.min_burn = min_burn;
params.burn_config.max_burn = max_burn;
params.burn_config.adjustment_alpha = adjustment_alpha;
params.burn_config.adjustment_interval = target_registrations_interval;
params.burn_config.expected_registrations = target_registrations_per_interval;

Self::do_add_global_proposal(origin, params)
}
Expand Down
15 changes: 9 additions & 6 deletions pallets/subspace/tests/voting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ fn creates_global_params_proposal_correctly_and_expires() {
assert_ok!(register_module(0, U256::from(1), 1_000_000_000));
assert_ok!(register_module(0, U256::from(2), 1_000_000_100));

let original = SubspaceModule::global_params();

let mut burn_config = BurnConfiguration::<Test>::default();
burn_config.min_burn = 100_000_000;
assert_ok!(burn_config.apply());

let original = SubspaceModule::global_params();

let BurnConfiguration {
min_burn,
max_burn,
Expand All @@ -62,6 +62,7 @@ fn creates_global_params_proposal_correctly_and_expires() {
proposal_expiration,
proposal_participation_threshold,
general_subnet_application_cost,
..
} = original.clone();

SubspaceModule::add_global_proposal(
Expand Down Expand Up @@ -166,6 +167,7 @@ fn creates_global_params_proposal_correctly_and_is_approved() {
proposal_expiration,
proposal_participation_threshold,
general_subnet_application_cost,
..
} = params.clone();

SubspaceModule::add_global_proposal(
Expand Down Expand Up @@ -235,6 +237,10 @@ fn creates_global_params_proposal_correctly_and_is_refused() {
ProposalCost::<Test>::set(COST);
ProposalExpiration::<Test>::set(200);

let mut burn_config = BurnConfiguration::<Test>::default();
burn_config.min_burn = 100_000_000;
assert_ok!(burn_config.apply());

let original = SubspaceModule::global_params();
let GlobalParams {
floor_founder_share,
Expand All @@ -253,12 +259,9 @@ fn creates_global_params_proposal_correctly_and_is_refused() {
proposal_expiration,
proposal_participation_threshold,
general_subnet_application_cost,
..
} = GlobalParams { ..original.clone() };

let mut burn_config = BurnConfiguration::<Test>::default();
burn_config.min_burn = 100_000_000;
assert_ok!(burn_config.apply());

let BurnConfiguration {
min_burn,
max_burn,
Expand Down

0 comments on commit f0a1afa

Please sign in to comment.