Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
TarekkMA committed Sep 19, 2024
1 parent 505a999 commit 2028a2e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions pallets/parachain-staking/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! Benchmarking
use crate::{
AwardedPts, BalanceOf, BottomDelegations, Call, CandidateBondLessRequest, Config,
DelegationAction, EnableMarkingOffline, Pallet, ParachainBondConfig, ParachainBondInfo, Points,
DelegationAction, EnableMarkingOffline, Pallet, InflationDistributionConfig, ParachainBondInfo, Points,
Range, RewardPayment, Round, ScheduledRequest, TopDelegations,
};
use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite};
Expand Down Expand Up @@ -280,13 +280,13 @@ benchmarks! {
let parachain_bond_account: T::AccountId = account("TEST", 0u32, USER_SEED);
}: _(RawOrigin::Root, parachain_bond_account.clone())
verify {
assert_eq!(Pallet::<T>::parachain_bond_info().account, parachain_bond_account);
assert_eq!(Pallet::<T>::inflation_distribution_info().account, parachain_bond_account);
}

set_parachain_bond_reserve_percent {
}: _(RawOrigin::Root, Percent::from_percent(33))
verify {
assert_eq!(Pallet::<T>::parachain_bond_info().percent, Percent::from_percent(33));
assert_eq!(Pallet::<T>::inflation_distribution_info().percent, Percent::from_percent(33));
}

// ROOT DISPATCHABLES
Expand Down Expand Up @@ -1564,7 +1564,7 @@ benchmarks! {
0,
min_candidate_stk::<T>(),
).0;
<ParachainBondInfo<T>>::put(ParachainBondConfig {
<ParachainBondInfo<T>>::put(InflationDistributionConfig {
account,
percent: Percent::from_percent(50),
});
Expand Down
22 changes: 11 additions & 11 deletions pallets/parachain-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,10 @@ pub mod pallet {
pub(crate) type TotalSelected<T: Config> = StorageValue<_, u32, ValueQuery>;

#[pallet::storage]
#[pallet::getter(fn parachain_bond_info)]
#[pallet::getter(fn inflation_distribution_info)]
/// Parachain bond config info { account, percent_of_inflation }
pub(crate) type ParachainBondInfo<T: Config> =
StorageValue<_, ParachainBondConfig<T::AccountId>, ValueQuery>;
pub(crate) type InflationDistributionInfo<T: Config> =
StorageValue<_, InflationDistributionConfig<T::AccountId>, ValueQuery>;

#[pallet::storage]
#[pallet::getter(fn round)]
Expand Down Expand Up @@ -787,7 +787,7 @@ pub mod pallet {
// Set collator commission to default config
<CollatorCommission<T>>::put(self.collator_commission);
// Set parachain bond config to default config
<ParachainBondInfo<T>>::put(ParachainBondConfig {
<InflationDistributionInfo<T>>::put(InflationDistributionConfig {
// must be set soon; if not => due inflation will be sent to collators/delegators
account: T::AccountId::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes())
.expect("infinite length input; no invalid inputs for type; qed"),
Expand Down Expand Up @@ -880,12 +880,12 @@ pub mod pallet {
new: T::AccountId,
) -> DispatchResultWithPostInfo {
T::MonetaryGovernanceOrigin::ensure_origin(origin)?;
let ParachainBondConfig {
let InflationDistributionConfig {
account: old,
percent,
} = <ParachainBondInfo<T>>::get();
} = <InflationDistributionInfo<T>>::get();
ensure!(old != new, Error::<T>::NoWritingSameValue);
<ParachainBondInfo<T>>::put(ParachainBondConfig {
<InflationDistributionInfo<T>>::put(InflationDistributionConfig {
account: new.clone(),
percent,
});
Expand All @@ -901,12 +901,12 @@ pub mod pallet {
new: Percent,
) -> DispatchResultWithPostInfo {
T::MonetaryGovernanceOrigin::ensure_origin(origin)?;
let ParachainBondConfig {
let InflationDistributionConfig {
account,
percent: old,
} = <ParachainBondInfo<T>>::get();
} = <InflationDistributionInfo<T>>::get();
ensure!(old != new, Error::<T>::NoWritingSameValue);
<ParachainBondInfo<T>>::put(ParachainBondConfig {
<InflationDistributionInfo<T>>::put(InflationDistributionConfig {
account,
percent: new,
});
Expand Down Expand Up @@ -1839,7 +1839,7 @@ pub mod pallet {

// reserve portion of issuance for parachain bond account
let mut left_issuance = total_issuance;
let bond_config = <ParachainBondInfo<T>>::get();
let bond_config = <InflationDistributionInfo<T>>::get();
let parachain_bond_reserve = bond_config.percent * total_issuance;
if let Ok(imb) =
T::Currency::deposit_into_existing(&bond_config.account, parachain_bond_reserve)
Expand Down
8 changes: 4 additions & 4 deletions pallets/parachain-staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,12 +620,12 @@ fn set_parachain_bond_account_event_emits_correctly() {
#[test]
fn set_parachain_bond_account_storage_updates_correctly() {
ExtBuilder::default().build().execute_with(|| {
assert_eq!(ParachainStaking::parachain_bond_info().account, 0);
assert_eq!(ParachainStaking::inflation_distribution_info().account, 0);
assert_ok!(ParachainStaking::set_parachain_bond_account(
RuntimeOrigin::root(),
11
));
assert_eq!(ParachainStaking::parachain_bond_info().account, 11);
assert_eq!(ParachainStaking::inflation_distribution_info().account, 11);
});
}

Expand All @@ -649,15 +649,15 @@ fn set_parachain_bond_reserve_percent_event_emits_correctly() {
fn set_parachain_bond_reserve_percent_storage_updates_correctly() {
ExtBuilder::default().build().execute_with(|| {
assert_eq!(
ParachainStaking::parachain_bond_info().percent,
ParachainStaking::inflation_distribution_info().percent,
Percent::from_percent(30)
);
assert_ok!(ParachainStaking::set_parachain_bond_reserve_percent(
RuntimeOrigin::root(),
Percent::from_percent(50)
));
assert_eq!(
ParachainStaking::parachain_bond_info().percent,
ParachainStaking::inflation_distribution_info().percent,
Percent::from_percent(50)
);
});
Expand Down
8 changes: 4 additions & 4 deletions pallets/parachain-staking/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1750,15 +1750,15 @@ impl<

#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)]
/// Reserve information { account, percent_of_inflation }
pub struct ParachainBondConfig<AccountId> {
pub struct InflationDistributionConfig<AccountId> {
/// Account which receives funds intended for parachain bond
pub account: AccountId,
/// Percent of inflation set aside for parachain bond account
pub percent: Percent,
}
impl<A: Decode> Default for ParachainBondConfig<A> {
fn default() -> ParachainBondConfig<A> {
ParachainBondConfig {
impl<A: Decode> Default for InflationDistributionConfig<A> {
fn default() -> InflationDistributionConfig<A> {
InflationDistributionConfig {
account: A::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes())
.expect("infinite length input; no invalid inputs for type; qed"),
percent: Percent::zero(),
Expand Down

0 comments on commit 2028a2e

Please sign in to comment.