chore: regenerate umbrella crate, fix feature propagation
This commit is contained in:
@@ -36,7 +36,7 @@ use pezsp_runtime::DispatchResult;
|
||||
use pezsp_staking::{StakingAccount, StakingInterface};
|
||||
|
||||
use crate::{
|
||||
asset, BalanceOf, Bonded, Config, Error, Ledger, Pezpallet, Payee, RewardDestination,
|
||||
asset, BalanceOf, Bonded, Config, Error, Ledger, Payee, Pezpallet, RewardDestination,
|
||||
StakingLedger, VirtualStakers,
|
||||
};
|
||||
|
||||
@@ -289,7 +289,8 @@ pub struct StakingLedgerInspect<T: Config> {
|
||||
#[codec(compact)]
|
||||
pub active: BalanceOf<T>,
|
||||
pub unlocking: pezframe_support::BoundedVec<UnlockChunk<BalanceOf<T>>, T::MaxUnlockingChunks>,
|
||||
pub legacy_claimed_rewards: pezframe_support::BoundedVec<pezsp_staking::EraIndex, T::HistoryDepth>,
|
||||
pub legacy_claimed_rewards:
|
||||
pezframe_support::BoundedVec<pezsp_staking::EraIndex, T::HistoryDepth>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
//! The Staking pezpallet is the means by which a set of network maintainers (known as _authorities_ in
|
||||
//! some contexts and _validators_ in others) are chosen based upon those who voluntarily place
|
||||
//! The Staking pezpallet is the means by which a set of network maintainers (known as _authorities_
|
||||
//! in some contexts and _validators_ in others) are chosen based upon those who voluntarily place
|
||||
//! funds under deposit. Under deposit, those funds are rewarded under normal operation but are held
|
||||
//! at pain of _slash_ (expropriation) should the staked maintainer be found not to be discharging
|
||||
//! its duties properly.
|
||||
@@ -59,11 +59,11 @@
|
||||
//!
|
||||
//! #### Staking
|
||||
//!
|
||||
//! Almost any interaction with the Staking pezpallet requires a process of _**bonding**_ (also known
|
||||
//! as being a _staker_). To become *bonded*, a fund-holding register known as the _stash account_,
|
||||
//! which holds some or all of the funds that become frozen in place as part of the staking process.
|
||||
//! The controller account, which this pezpallet now assigns the stash account to, issues instructions
|
||||
//! on how funds shall be used.
|
||||
//! Almost any interaction with the Staking pezpallet requires a process of _**bonding**_ (also
|
||||
//! known as being a _staker_). To become *bonded*, a fund-holding register known as the _stash
|
||||
//! account_, which holds some or all of the funds that become frozen in place as part of the
|
||||
//! staking process. The controller account, which this pezpallet now assigns the stash account to,
|
||||
//! issues instructions on how funds shall be used.
|
||||
//!
|
||||
//! An account can become a bonded stash account using the [`bond`](Call::bond) call.
|
||||
//!
|
||||
@@ -108,8 +108,8 @@
|
||||
//!
|
||||
//! #### Rewards and Slash
|
||||
//!
|
||||
//! The **reward and slashing** procedure is the core of the Staking pezpallet, attempting to _embrace
|
||||
//! valid behavior_ while _punishing any misbehavior or lack of availability_.
|
||||
//! The **reward and slashing** procedure is the core of the Staking pezpallet, attempting to
|
||||
//! _embrace valid behavior_ while _punishing any misbehavior or lack of availability_.
|
||||
//!
|
||||
//! Rewards must be claimed for each era before it gets too old by
|
||||
//! [`HistoryDepth`](`Config::HistoryDepth`) using the `payout_stakers` call. Any account can call
|
||||
@@ -147,8 +147,9 @@
|
||||
//!
|
||||
//! ### Dispatchable Functions
|
||||
//!
|
||||
//! The dispatchable functions of the Staking pezpallet enable the steps needed for entities to accept
|
||||
//! and change their role, alongside some helper functions to get/set the metadata of the pezpallet.
|
||||
//! The dispatchable functions of the Staking pezpallet enable the steps needed for entities to
|
||||
//! accept and change their role, alongside some helper functions to get/set the metadata of the
|
||||
//! pezpallet.
|
||||
//!
|
||||
//! ### Public Functions
|
||||
//!
|
||||
@@ -224,8 +225,8 @@
|
||||
//! they received during the era. Points are added to a validator using the method
|
||||
//! [`pezframe_support::traits::RewardsReporter::reward_by_ids`] implemented by the [`Pezpallet`].
|
||||
//!
|
||||
//! [`Pezpallet`] implements [`pezpallet_authorship::EventHandler`] to add reward points to block producer
|
||||
//! and block producer of referenced uncles.
|
||||
//! [`Pezpallet`] implements [`pezpallet_authorship::EventHandler`] to add reward points to block
|
||||
//! producer and block producer of referenced uncles.
|
||||
//!
|
||||
//! The validator and its nominator split their reward as following:
|
||||
//!
|
||||
@@ -275,8 +276,8 @@
|
||||
//!
|
||||
//! ## GenesisConfig
|
||||
//!
|
||||
//! The Staking pezpallet depends on the [`GenesisConfig`]. The `GenesisConfig` is optional and allow
|
||||
//! to set some initial stakers.
|
||||
//! The Staking pezpallet depends on the [`GenesisConfig`]. The `GenesisConfig` is optional and
|
||||
//! allow to set some initial stakers.
|
||||
//!
|
||||
//! ## Related Modules
|
||||
//!
|
||||
@@ -321,7 +322,6 @@ use pezframe_support::{
|
||||
weights::Weight,
|
||||
BoundedVec, CloneNoBound, EqNoBound, PartialEqNoBound, RuntimeDebugNoBound,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::{
|
||||
curve::PiecewiseLinear,
|
||||
traits::{AtLeast32BitUnsigned, Convert, StaticLookup, Zero},
|
||||
@@ -332,6 +332,7 @@ use pezsp_staking::{
|
||||
EraIndex, ExposurePage, OnStakingUpdate, Page, PagedExposureMetadata, SessionIndex,
|
||||
};
|
||||
pub use pezsp_staking::{Exposure, IndividualExposure, StakerStatus};
|
||||
use scale_info::TypeInfo;
|
||||
pub use weights::WeightInfo;
|
||||
|
||||
pub use pezpallet::{pezpallet::*, UseNominatorsAndValidatorsMap, UseValidatorsMap};
|
||||
@@ -350,8 +351,8 @@ macro_rules! log {
|
||||
};
|
||||
}
|
||||
|
||||
/// Alias for the maximum number of winners (aka. active validators), as defined in by this pezpallet's
|
||||
/// config.
|
||||
/// Alias for the maximum number of winners (aka. active validators), as defined in by this
|
||||
/// pezpallet's config.
|
||||
pub type MaxWinnersOf<T> = <T as Config>::MaxValidatorSet;
|
||||
|
||||
/// Alias for the maximum number of winners per page, as expected by the election provider.
|
||||
@@ -367,7 +368,8 @@ pub type RewardPoint = u32;
|
||||
/// The balance type of this pezpallet.
|
||||
pub type BalanceOf<T> = <T as Config>::CurrencyBalance;
|
||||
|
||||
type PositiveImbalanceOf<T> = Debt<<T as pezframe_system::Config>::AccountId, <T as Config>::Currency>;
|
||||
type PositiveImbalanceOf<T> =
|
||||
Debt<<T as pezframe_system::Config>::AccountId, <T as Config>::Currency>;
|
||||
pub type NegativeImbalanceOf<T> =
|
||||
Credit<<T as pezframe_system::Config>::AccountId, <T as Config>::Currency>;
|
||||
|
||||
@@ -1104,8 +1106,8 @@ impl<T: Config> Convert<T::AccountId, Option<Exposure<T::AccountId, BalanceOf<T>
|
||||
/// In the new model, we don't need to identify a validator with their full exposure anymore, and
|
||||
/// therefore [`UnitIdentificationOf`] is perfectly fine. Yet, for runtimes that used to work with
|
||||
/// [`ExposureOf`], we need to be able to decode old identification data, possibly stored in the
|
||||
/// historical session pezpallet in older blocks. Therefore, this type is a good compromise, allowing
|
||||
/// old exposure identifications to be decoded, and returning a few zero bytes
|
||||
/// historical session pezpallet in older blocks. Therefore, this type is a good compromise,
|
||||
/// allowing old exposure identifications to be decoded, and returning a few zero bytes
|
||||
/// (`Exposure::default`) for any new identification request.
|
||||
///
|
||||
/// A typical usage of this type is:
|
||||
|
||||
@@ -161,7 +161,8 @@ pub mod v15 {
|
||||
type DefaultDisablingStrategy = pezpallet_session::disabling::UpToLimitDisablingStrategy;
|
||||
|
||||
#[storage_alias]
|
||||
pub(crate) type DisabledValidators<T: Config> = StorageValue<Pezpallet<T>, Vec<u32>, ValueQuery>;
|
||||
pub(crate) type DisabledValidators<T: Config> =
|
||||
StorageValue<Pezpallet<T>, Vec<u32>, ValueQuery>;
|
||||
|
||||
pub struct VersionUncheckedMigrateV14ToV15<T>(core::marker::PhantomData<T>);
|
||||
impl<T: Config> UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateV14ToV15<T> {
|
||||
|
||||
@@ -148,8 +148,9 @@ impl pezpallet_session::Config for Test {
|
||||
type ValidatorId = AccountId;
|
||||
type ValidatorIdOf = pezsp_runtime::traits::ConvertInto;
|
||||
type NextSessionRotation = pezpallet_session::PeriodicSessions<Period, Offset>;
|
||||
type DisablingStrategy =
|
||||
pezpallet_session::disabling::UpToLimitWithReEnablingDisablingStrategy<DISABLING_LIMIT_FACTOR>;
|
||||
type DisablingStrategy = pezpallet_session::disabling::UpToLimitWithReEnablingDisablingStrategy<
|
||||
DISABLING_LIMIT_FACTOR,
|
||||
>;
|
||||
type WeightInfo = ();
|
||||
type Currency = Balances;
|
||||
type KeyDeposit = ();
|
||||
@@ -454,7 +455,8 @@ impl ExtBuilder {
|
||||
}
|
||||
fn build(self) -> pezsp_io::TestExternalities {
|
||||
pezsp_tracing::try_init_simple();
|
||||
let mut storage = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
|
||||
let mut storage =
|
||||
pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
|
||||
let ed = ExistentialDeposit::get();
|
||||
|
||||
let _ = pezpallet_balances::GenesisConfig::<Test> {
|
||||
|
||||
@@ -456,7 +456,9 @@ impl<T: Config> Pezpallet<T> {
|
||||
// Initial era has been set.
|
||||
let current_era_start_session_index = ErasStartSessionIndex::<T>::get(current_era)
|
||||
.unwrap_or_else(|| {
|
||||
pezframe_support::print("Error: start_session_index must be set for current_era");
|
||||
pezframe_support::print(
|
||||
"Error: start_session_index must be set for current_era",
|
||||
);
|
||||
0
|
||||
});
|
||||
|
||||
@@ -2012,8 +2014,8 @@ impl<T: Config> StakingInterface for Pezpallet<T> {
|
||||
}
|
||||
|
||||
fn set_payee(stash: &Self::AccountId, reward_acc: &Self::AccountId) -> DispatchResult {
|
||||
// Since virtual stakers are not allowed to compound their rewards as this pezpallet does not
|
||||
// manage their locks, we do not allow reward account to be set same as stash. For
|
||||
// Since virtual stakers are not allowed to compound their rewards as this pezpallet does
|
||||
// not manage their locks, we do not allow reward account to be set same as stash. For
|
||||
// external pallets that manage the virtual bond, they can claim rewards and re-bond them.
|
||||
ensure!(
|
||||
!Self::is_virtual_staker(stash) || stash != reward_acc,
|
||||
|
||||
@@ -134,8 +134,8 @@ pub mod pezpallet {
|
||||
|
||||
/// Convert a balance into a number used for election calculation. This must fit into a
|
||||
/// `u64` but is allowed to be sensibly lossy. The `u64` is used to communicate with the
|
||||
/// [`pezframe_election_provider_support`] crate which accepts u64 numbers and does operations
|
||||
/// in 128.
|
||||
/// [`pezframe_election_provider_support`] crate which accepts u64 numbers and does
|
||||
/// operations in 128.
|
||||
/// Consequently, the backward convert is used convert the u128s from sp-elections back to a
|
||||
/// [`BalanceOf`].
|
||||
#[pezpallet::no_default_bounds]
|
||||
@@ -192,7 +192,8 @@ pub mod pezpallet {
|
||||
/// The overarching event type.
|
||||
#[pezpallet::no_default_bounds]
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type RuntimeEvent: From<Event<Self>>
|
||||
+ IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// Handler for the unbalanced reduction when slashing a staker.
|
||||
#[pezpallet::no_default_bounds]
|
||||
@@ -478,10 +479,10 @@ pub mod pezpallet {
|
||||
|
||||
/// Stakers whose funds are managed by other pallets.
|
||||
///
|
||||
/// This pezpallet does not apply any locks on them, therefore they are only virtually bonded. They
|
||||
/// are expected to be keyless accounts and hence should not be allowed to mutate their ledger
|
||||
/// directly via this pezpallet. Instead, these accounts are managed by other pallets and accessed
|
||||
/// via low level apis. We keep track of them to do minimal integrity checks.
|
||||
/// This pezpallet does not apply any locks on them, therefore they are only virtually bonded.
|
||||
/// They are expected to be keyless accounts and hence should not be allowed to mutate their
|
||||
/// ledger directly via this pezpallet. Instead, these accounts are managed by other pallets
|
||||
/// and accessed via low level apis. We keep track of them to do minimal integrity checks.
|
||||
#[pezpallet::storage]
|
||||
pub type VirtualStakers<T: Config> = CountedStorageMap<_, Twox64Concat, T::AccountId, ()>;
|
||||
|
||||
@@ -732,7 +733,8 @@ pub mod pezpallet {
|
||||
|
||||
/// The last planned session scheduled by the session pezpallet.
|
||||
///
|
||||
/// This is basically in sync with the call to [`pezpallet_session::SessionManager::new_session`].
|
||||
/// This is basically in sync with the call to
|
||||
/// [`pezpallet_session::SessionManager::new_session`].
|
||||
#[pezpallet::storage]
|
||||
pub type CurrentPlannedSession<T> = StorageValue<_, SessionIndex, ValueQuery>;
|
||||
|
||||
@@ -1727,7 +1729,9 @@ pub mod pezpallet {
|
||||
///
|
||||
/// If all pages are claimed, it returns an error `InvalidPage`.
|
||||
#[pezpallet::call_index(18)]
|
||||
#[pezpallet::weight(T::WeightInfo::payout_stakers_alive_staked(T::MaxExposurePageSize::get()))]
|
||||
#[pezpallet::weight(T::WeightInfo::payout_stakers_alive_staked(
|
||||
T::MaxExposurePageSize::get()
|
||||
))]
|
||||
pub fn payout_stakers(
|
||||
origin: OriginFor<T>,
|
||||
validator_stash: T::AccountId,
|
||||
@@ -2069,7 +2073,9 @@ pub mod pezpallet {
|
||||
/// and so it should not be assumed the highest staker would be on the topmost page and vice
|
||||
/// versa. If rewards are not claimed in [`Config::HistoryDepth`] eras, they are lost.
|
||||
#[pezpallet::call_index(26)]
|
||||
#[pezpallet::weight(T::WeightInfo::payout_stakers_alive_staked(T::MaxExposurePageSize::get()))]
|
||||
#[pezpallet::weight(T::WeightInfo::payout_stakers_alive_staked(
|
||||
T::MaxExposurePageSize::get()
|
||||
))]
|
||||
pub fn payout_stakers_by_page(
|
||||
origin: OriginFor<T>,
|
||||
validator_stash: T::AccountId,
|
||||
|
||||
@@ -50,8 +50,8 @@
|
||||
//! Based on research at <https://research.web3.foundation/en/latest/polkadot/slashing/npos.html>
|
||||
|
||||
use crate::{
|
||||
asset, BalanceOf, Config, Error, Exposure, NegativeImbalanceOf, NominatorSlashInEra, Pezpallet,
|
||||
Perbill, SpanSlash, UnappliedSlash, ValidatorSlashInEra,
|
||||
asset, BalanceOf, Config, Error, Exposure, NegativeImbalanceOf, NominatorSlashInEra, Perbill,
|
||||
Pezpallet, SpanSlash, UnappliedSlash, ValidatorSlashInEra,
|
||||
};
|
||||
use alloc::vec::Vec;
|
||||
use codec::{Decode, Encode, MaxEncodedLen};
|
||||
@@ -60,12 +60,12 @@ use pezframe_support::{
|
||||
pezpallet_prelude::DecodeWithMemTracking,
|
||||
traits::{Defensive, DefensiveSaturating, Imbalance, OnUnbalanced},
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
use pezsp_runtime::{
|
||||
traits::{Saturating, Zero},
|
||||
DispatchResult, RuntimeDebug,
|
||||
};
|
||||
use pezsp_staking::{EraIndex, StakingInterface};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
/// The proportion of the slashing reward to be paid out on the first slashing detection.
|
||||
/// This is f_1 in the paper.
|
||||
@@ -559,7 +559,9 @@ pub fn do_slash<T: Config>(
|
||||
slash_era: EraIndex,
|
||||
) {
|
||||
let mut ledger =
|
||||
match Pezpallet::<T>::ledger(pezsp_staking::StakingAccount::Stash(stash.clone())).defensive() {
|
||||
match Pezpallet::<T>::ledger(pezsp_staking::StakingAccount::Stash(stash.clone()))
|
||||
.defensive()
|
||||
{
|
||||
Ok(ledger) => ledger,
|
||||
Err(_) => return, // nothing to do.
|
||||
};
|
||||
@@ -586,7 +588,10 @@ pub fn do_slash<T: Config>(
|
||||
.defensive_proof("ledger fetched from storage so it exists in storage; qed.");
|
||||
|
||||
// trigger the event
|
||||
<Pezpallet<T>>::deposit_event(super::Event::<T>::Slashed { staker: stash.clone(), amount: value });
|
||||
<Pezpallet<T>>::deposit_event(super::Event::<T>::Slashed {
|
||||
staker: stash.clone(),
|
||||
amount: value,
|
||||
});
|
||||
}
|
||||
|
||||
/// Apply a previously-unapplied slash.
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
use crate::{Pezpallet as Staking, *};
|
||||
use pezframe_benchmarking::account;
|
||||
use pezframe_system::RawOrigin;
|
||||
use pezsp_io::hashing::blake2_256;
|
||||
use rand_chacha::{
|
||||
rand_core::{RngCore, SeedableRng},
|
||||
ChaChaRng,
|
||||
};
|
||||
use pezsp_io::hashing::blake2_256;
|
||||
|
||||
use pezframe_election_provider_support::SortedListProvider;
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
use super::{ConfigOp, Event, *};
|
||||
use crate::{asset, ledger::StakingLedgerInspect};
|
||||
use bizinikiwi_test_utils::assert_eq_uvec;
|
||||
use mock::*;
|
||||
use pezframe_election_provider_support::{
|
||||
bounds::{DataProviderBounds, ElectionBoundsBuilder},
|
||||
ElectionProvider, SortedListProvider, Support,
|
||||
@@ -33,9 +35,10 @@ use pezframe_support::{
|
||||
ReservableCurrency, RewardsReporter, WithdrawReasons,
|
||||
},
|
||||
};
|
||||
use mock::*;
|
||||
use pezpallet_balances::Error as BalancesError;
|
||||
use pezpallet_session::{disabling::UpToLimitWithReEnablingDisablingStrategy, Event as SessionEvent};
|
||||
use pezpallet_session::{
|
||||
disabling::UpToLimitWithReEnablingDisablingStrategy, Event as SessionEvent,
|
||||
};
|
||||
use pezsp_runtime::{
|
||||
assert_eq_error_rate, bounded_vec,
|
||||
traits::{BadOrigin, Dispatchable},
|
||||
@@ -45,7 +48,6 @@ use pezsp_staking::{
|
||||
offence::{OffenceDetails, OnOffenceHandler},
|
||||
SessionIndex, StakingAccount,
|
||||
};
|
||||
use bizinikiwi_test_utils::assert_eq_uvec;
|
||||
|
||||
#[test]
|
||||
fn set_staking_configs_works() {
|
||||
@@ -3478,7 +3480,9 @@ fn test_multi_page_payout_stakers_by_page() {
|
||||
|
||||
// verify rewards have been paid out but still some left
|
||||
assert!(pezpallet_balances::TotalIssuance::<Test>::get() > pre_payout_total_issuance);
|
||||
assert!(pezpallet_balances::TotalIssuance::<Test>::get() < pre_payout_total_issuance + payout);
|
||||
assert!(
|
||||
pezpallet_balances::TotalIssuance::<Test>::get() < pre_payout_total_issuance + payout
|
||||
);
|
||||
|
||||
// verify the validator has been rewarded
|
||||
assert!(controller_balance_after_p0_payout > controller_balance_before_p0_payout);
|
||||
@@ -3748,7 +3752,9 @@ fn test_multi_page_payout_stakers_backward_compatible() {
|
||||
|
||||
// verify rewards have been paid out but still some left
|
||||
assert!(pezpallet_balances::TotalIssuance::<Test>::get() > pre_payout_total_issuance);
|
||||
assert!(pezpallet_balances::TotalIssuance::<Test>::get() < pre_payout_total_issuance + payout);
|
||||
assert!(
|
||||
pezpallet_balances::TotalIssuance::<Test>::get() < pre_payout_total_issuance + payout
|
||||
);
|
||||
|
||||
// verify the validator has been rewarded
|
||||
assert!(controller_balance_after_p0_payout > controller_balance_before_p0_payout);
|
||||
@@ -8427,8 +8433,8 @@ mod validator_disabling_integration {
|
||||
#[cfg(all(feature = "try-runtime", test))]
|
||||
mod migration_tests {
|
||||
use super::*;
|
||||
use pezframe_support::traits::UncheckedOnRuntimeUpgrade;
|
||||
use migrations::{v15, v16};
|
||||
use pezframe_support::traits::UncheckedOnRuntimeUpgrade;
|
||||
|
||||
#[test]
|
||||
fn migrate_v15_to_v16_with_try_runtime() {
|
||||
|
||||
Reference in New Issue
Block a user