chore: regenerate umbrella crate, fix feature propagation

This commit is contained in:
2025-12-16 11:28:32 +03:00
parent dd6d48f528
commit 620b0e3aa0
1358 changed files with 9464 additions and 7656 deletions
@@ -181,8 +181,8 @@ impl OperatingMode {
}
}
/// See `pezpallet_staking::DefaultExposureOf`. This type is the same, except it is duplicated here so
/// that an rc-runtime can use it after `pezpallet-staking` is fully removed as a dependency.
/// See `pezpallet_staking::DefaultExposureOf`. This type is the same, except it is duplicated here
/// so that an rc-runtime can use it after `pezpallet-staking` is fully removed as a dependency.
pub struct DefaultExposureOf<T>(core::marker::PhantomData<T>);
impl<T: Config>
@@ -255,9 +255,9 @@ pub mod pezpallet {
///
/// Note that in case a single session report is larger than a single DMP message, it might
/// still be sent over if we use
/// [`pezpallet_staking_async_rc_client::XCMSender::split_then_send`]. This will make the size
/// of each individual message smaller, yet, it will still try and push them all to the
/// queue at the same time.
/// [`pezpallet_staking_async_rc_client::XCMSender::split_then_send`]. This will make the
/// size of each individual message smaller, yet, it will still try and push them all to
/// the queue at the same time.
type MaximumValidatorsWithPoints: Get<u32>;
/// A type that gives us a reliable unix timestamp.
@@ -323,8 +323,9 @@ pub mod pezpallet {
/// Indicates the current operating mode of the pezpallet.
///
/// This value determines how the pezpallet behaves in response to incoming and outgoing messages,
/// particularly whether it should execute logic directly, defer it, or delegate it entirely.
/// This value determines how the pezpallet behaves in response to incoming and outgoing
/// messages, particularly whether it should execute logic directly, defer it, or delegate it
/// entirely.
#[pezpallet::storage]
pub type Mode<T: Config> = StorageValue<_, OperatingMode, ValueQuery>;
@@ -698,8 +699,10 @@ pub mod pezpallet {
}
impl<T: Config>
historical::SessionManager<T::AccountId, pezsp_staking::Exposure<T::AccountId, BalanceOf<T>>>
for Pezpallet<T>
historical::SessionManager<
T::AccountId,
pezsp_staking::Exposure<T::AccountId, BalanceOf<T>>,
> for Pezpallet<T>
{
fn new_session(
new_index: pezsp_staking::SessionIndex,
@@ -718,7 +721,10 @@ pub mod pezpallet {
) -> Option<Vec<(T::AccountId, pezsp_staking::Exposure<T::AccountId, BalanceOf<T>>)>> {
if Mode::<T>::get() == OperatingMode::Passive {
T::Fallback::new_session_genesis(new_index).map(|validators| {
validators.into_iter().map(|v| (v, pezsp_staking::Exposure::default())).collect()
validators
.into_iter()
.map(|v| (v, pezsp_staking::Exposure::default()))
.collect()
})
} else {
None
@@ -805,7 +811,9 @@ pub mod pezpallet {
}
}
impl<T: Config> pezpallet_authorship::EventHandler<T::AccountId, BlockNumberFor<T>> for Pezpallet<T> {
impl<T: Config> pezpallet_authorship::EventHandler<T::AccountId, BlockNumberFor<T>>
for Pezpallet<T>
{
fn note_author(author: T::AccountId) {
match Mode::<T>::get() {
OperatingMode::Passive => T::Fallback::note_author(author),
@@ -817,9 +825,9 @@ pub mod pezpallet {
impl<T: Config> Pezpallet<T> {
/// Hook to be called when the AssetHub migration begins.
///
/// This transitions the pezpallet into [`OperatingMode::Buffered`], meaning it will act as the
/// primary staking module on the relay chain but will buffer outgoing messages instead of
/// sending them to AssetHub.
/// This transitions the pezpallet into [`OperatingMode::Buffered`], meaning it will act as
/// the primary staking module on the relay chain but will buffer outgoing messages
/// instead of sending them to AssetHub.
///
/// While in this mode, the pezpallet stops delegating to the fallback implementation and
/// temporarily accumulates events for later processing.
@@ -834,11 +842,11 @@ pub mod pezpallet {
/// Hook to be called when the AssetHub migration is complete.
///
/// This transitions the pezpallet into [`OperatingMode::Active`], meaning the counterpart
/// pezpallet on AssetHub is ready to accept incoming messages, and this pezpallet can resume
/// sending them.
/// pezpallet on AssetHub is ready to accept incoming messages, and this pezpallet can
/// resume sending them.
///
/// In this mode, the pezpallet becomes fully active and processes all staking-related events
/// directly.
/// In this mode, the pezpallet becomes fully active and processes all staking-related
/// events directly.
pub fn on_migration_end() {
debug_assert!(
Mode::<T>::get() == OperatingMode::Buffered,
@@ -108,5 +108,8 @@ impl Config for Test {
#[cfg(test)]
pub fn new_test_ext() -> pezsp_io::TestExternalities {
pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap().into()
pezframe_system::GenesisConfig::<Test>::default()
.build_storage()
.unwrap()
.into()
}
@@ -90,7 +90,9 @@ pub(crate) fn roll_until_next_active(mut end_index: SessionIndex) -> Vec<Account
let planned_era = pezpallet_staking_async::session_rotation::Rotator::<Runtime>::planned_era();
let active_era = pezpallet_staking_async::session_rotation::Rotator::<Runtime>::active_era();
while pezpallet_staking_async::session_rotation::Rotator::<Runtime>::planned_era() == planned_era {
while pezpallet_staking_async::session_rotation::Rotator::<Runtime>::planned_era() ==
planned_era
{
let report = SessionReport {
end_index,
activation_timestamp: None,
@@ -539,7 +541,8 @@ parameter_types! {
static RcClientEventsIndex: usize = 0;
}
pub(crate) fn rc_client_events_since_last_call() -> Vec<pezpallet_staking_async_rc_client::Event<T>> {
pub(crate) fn rc_client_events_since_last_call() -> Vec<pezpallet_staking_async_rc_client::Event<T>>
{
let all: Vec<_> = System::events()
.into_iter()
.filter_map(
@@ -71,7 +71,10 @@ mod tests {
);
// then
assert_eq!(pezframe_system::Pezpallet::<rc::Runtime>::block_number(), rc::Period::get());
assert_eq!(
pezframe_system::Pezpallet::<rc::Runtime>::block_number(),
rc::Period::get()
);
});
shared::in_rc(|| {
@@ -194,7 +197,8 @@ mod tests {
},
true,
);
let migration_start_block_number = pezframe_system::Pezpallet::<rc::Runtime>::block_number();
let migration_start_block_number =
pezframe_system::Pezpallet::<rc::Runtime>::block_number();
// ensure era is still 1 on RC.
// (Session events are received by AHClient and never passed on to staking-classic once
@@ -420,7 +424,10 @@ mod tests {
pezpallet_staking_async::ErasRewardPoints::<ah::Runtime>::get(1).total;
// staking async has always been in NotForcing, not doing anything since no session
// reports come in
assert_eq!(pezpallet_staking_async::ForceEra::<ah::Runtime>::get(), Forcing::NotForcing);
assert_eq!(
pezpallet_staking_async::ForceEra::<ah::Runtime>::get(),
Forcing::NotForcing
);
// Verify all offences were properly queued in staking-async.
// Should have offences for validators 1, 2, and 5 from different sessions (all map to
@@ -580,21 +587,24 @@ mod tests {
// Check for unapplied slashes for all validators with any of the slash fractions
// Check validator 2 slashes
let slash_v2_100_present = pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(2, Perbill::from_percent(100), 0),
)
.is_some();
let slash_v2_90_present = pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(2, Perbill::from_percent(90), 0),
)
.is_some();
let slash_v2_70_present = pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(2, Perbill::from_percent(70), 0),
)
.is_some();
let slash_v2_100_present =
pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(2, Perbill::from_percent(100), 0),
)
.is_some();
let slash_v2_90_present =
pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(2, Perbill::from_percent(90), 0),
)
.is_some();
let slash_v2_70_present =
pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(2, Perbill::from_percent(70), 0),
)
.is_some();
let total_slashes_v2 =
slash_v2_100_present as u8 + slash_v2_90_present as u8 + slash_v2_70_present as u8;
@@ -605,21 +615,24 @@ mod tests {
);
// Check validator 1 slashes
let slash_v1_75_present = pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(1, Perbill::from_percent(75), 0),
)
.is_some();
let slash_v1_85_present = pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(1, Perbill::from_percent(85), 0),
)
.is_some();
let slash_v1_65_present = pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(1, Perbill::from_percent(65), 0),
)
.is_some();
let slash_v1_75_present =
pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(1, Perbill::from_percent(75), 0),
)
.is_some();
let slash_v1_85_present =
pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(1, Perbill::from_percent(85), 0),
)
.is_some();
let slash_v1_65_present =
pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(1, Perbill::from_percent(65), 0),
)
.is_some();
let total_slashes_v1 =
slash_v1_75_present as u8 + slash_v1_85_present as u8 + slash_v1_65_present as u8;
@@ -630,21 +643,24 @@ mod tests {
);
// Check validator 5 slashes
let slash_v5_55_present = pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(5, Perbill::from_percent(55), 0),
)
.is_some();
let slash_v5_45_present = pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(5, Perbill::from_percent(45), 0),
)
.is_some();
let slash_v5_40_present = pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(5, Perbill::from_percent(40), 0),
)
.is_some();
let slash_v5_55_present =
pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(5, Perbill::from_percent(55), 0),
)
.is_some();
let slash_v5_45_present =
pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(5, Perbill::from_percent(45), 0),
)
.is_some();
let slash_v5_40_present =
pezpallet_staking_async::UnappliedSlashes::<ah::Runtime>::get(
3,
(5, Perbill::from_percent(40), 0),
)
.is_some();
let total_slashes_v5 =
slash_v5_55_present as u8 + slash_v5_45_present as u8 + slash_v5_40_present as u8;
@@ -722,9 +738,18 @@ mod tests {
assert_eq!(
ah::staking_events_since_last_call(),
vec![
pezpallet_staking_async::Event::PagedElectionProceeded { page: 2, result: Ok(4) },
pezpallet_staking_async::Event::PagedElectionProceeded { page: 1, result: Ok(0) },
pezpallet_staking_async::Event::PagedElectionProceeded { page: 0, result: Ok(0) }
pezpallet_staking_async::Event::PagedElectionProceeded {
page: 2,
result: Ok(4)
},
pezpallet_staking_async::Event::PagedElectionProceeded {
page: 1,
result: Ok(0)
},
pezpallet_staking_async::Event::PagedElectionProceeded {
page: 0,
result: Ok(0)
}
]
);
});
@@ -387,23 +387,27 @@ pub fn historical_events_since_last_call() -> Vec<pezpallet_session::historical:
}
pub fn offence_events_since_last_call() -> Vec<pezpallet_offences::Event> {
let all = pezframe_system::Pezpallet::<Runtime>::read_events_for_pallet::<pezpallet_offences::Event>();
let all = pezframe_system::Pezpallet::<Runtime>::read_events_for_pallet::<
pezpallet_offences::Event,
>();
let seen = OffenceEventsIndex::get();
OffenceEventsIndex::set(all.len());
all.into_iter().skip(seen).collect()
}
pub fn session_events_since_last_call() -> Vec<pezpallet_session::Event<Runtime>> {
let all =
pezframe_system::Pezpallet::<Runtime>::read_events_for_pallet::<pezpallet_session::Event<Runtime>>();
let all = pezframe_system::Pezpallet::<Runtime>::read_events_for_pallet::<
pezpallet_session::Event<Runtime>,
>();
let seen = SessionEventsIndex::get();
SessionEventsIndex::set(all.len());
all.into_iter().skip(seen).collect()
}
pub fn ah_client_events_since_last_call() -> Vec<ah_client::Event<Runtime>> {
let all =
pezframe_system::Pezpallet::<Runtime>::read_events_for_pallet::<ah_client::Event<Runtime>>();
let all = pezframe_system::Pezpallet::<Runtime>::read_events_for_pallet::<
ah_client::Event<Runtime>,
>();
let seen = AhClientEventsIndex::get();
AhClientEventsIndex::set(all.len());
all.into_iter().skip(seen).collect()
@@ -487,7 +491,9 @@ impl ExtBuilder {
(112, vec![8, 1]),
]
.into_iter()
.map(|(x, y)| (x, x, INITIAL_STAKE, pezpallet_staking_async::StakerStatus::Nominator(y)));
.map(|(x, y)| {
(x, x, INITIAL_STAKE, pezpallet_staking_async::StakerStatus::Nominator(y))
});
let stakers = validators.chain(nominators).collect::<Vec<_>>();
let balances = stakers
@@ -541,7 +547,8 @@ impl ExtBuilder {
}
/// Progress until `sessions`, receive a `new_validator_set` with `id`, and go forward to `sessions
/// + 1` such that it is queued in pezpallet-session. If `active`, then progress until `sessions + 2`
/// + 1` such that it is queued in pezpallet-session. If `active`, then progress until `sessions +
/// 2`
/// such that it is in the active session validators.
pub(crate) fn receive_validator_set_at(
sessions: SessionIndex,
@@ -193,7 +193,10 @@ fn upon_receiving_election_queue_and_activate_next_session() {
new_validator_set: vec![1, 2, 3, 4],
};
assert_ok!(ah_client::Pezpallet::<Runtime>::validator_set(RuntimeOrigin::root(), report));
assert_ok!(ah_client::Pezpallet::<Runtime>::validator_set(
RuntimeOrigin::root(),
report
));
// session validators are not set yet.
assert!(pezpallet_session::Validators::<Runtime>::get().is_empty());
@@ -275,7 +278,10 @@ fn upon_receiving_election_queue_and_activate_next_session() {
leftover: false,
new_validator_set: vec![1, 2, 3, 5],
};
assert_ok!(ah_client::Pezpallet::<Runtime>::validator_set(RuntimeOrigin::root(), report));
assert_ok!(ah_client::Pezpallet::<Runtime>::validator_set(
RuntimeOrigin::root(),
report
));
// rotate one more session
roll_until_matches(|| pezpallet_session::CurrentIndex::<Runtime>::get() == 6, false);
@@ -971,11 +977,14 @@ mod session_pruning {
);
assert_eq!(
historical_events_since_last_call(),
vec![pezpallet_session::historical::Event::<T>::RootStored { index: i + 1 }]
vec![pezpallet_session::historical::Event::<T>::RootStored {
index: i + 1
}]
)
}
// ensure that we have the root for these recorded in the historical session pezpallet
// ensure that we have the root for these recorded in the historical session
// pezpallet
assert_eq!(pezpallet_session::historical::StoredRange::<T>::get(), Some((2, 12)));
// send back a new validator set, but with some pruning info.
@@ -1374,8 +1383,9 @@ mod splitting {
assert!(ah_client::ValidatorSet::<Runtime>::get().is_none());
assert_eq!(
pezframe_system::Pezpallet::<Runtime>::read_events_for_pallet::<ah_client::Event<Runtime>>(
),
pezframe_system::Pezpallet::<Runtime>::read_events_for_pallet::<
ah_client::Event<Runtime>,
>(),
vec![
ah_client::Event::<T>::ValidatorSetReceived {
id: 0,
@@ -1435,7 +1445,9 @@ mod key_proofs {
assert_eq!(pezpallet_session::historical::StoredRange::<T>::get(), Some((2, 5)));
// generate the proof for one of the validators
use pezsp_runtime::{key_types::DUMMY, testing::UintAuthorityId, traits::OpaqueKeys};
use pezsp_runtime::{
key_types::DUMMY, testing::UintAuthorityId, traits::OpaqueKeys,
};
let key_ids = <SessionKeys as OpaqueKeys>::key_ids();
assert_eq!(key_ids.len(), 1, "we have inserted only one key type in mock");
@@ -1444,9 +1456,11 @@ mod key_proofs {
let our_key = keys.get::<UintAuthorityId>(key_ids[0]);
assert_eq!(key_ids[0], DUMMY);
let proof =
pezpallet_session::historical::Pezpallet::<T>::prove((DUMMY, &our_key.encode()[..]))
.unwrap();
let proof = pezpallet_session::historical::Pezpallet::<T>::prove((
DUMMY,
&our_key.encode()[..],
))
.unwrap();
assert_eq!(proof.session, 3);
assert_eq!(proof.validator_count, 4);
@@ -89,7 +89,8 @@ pub fn migrate_state() {
}
// exposure
for (era, account, overview) in pezpallet_staking::ErasStakersOverview::<rc::Runtime>::drain()
for (era, account, overview) in
pezpallet_staking::ErasStakersOverview::<rc::Runtime>::drain()
{
shared::in_ah(|| {
pezpallet_staking_async::ErasStakersOverview::<ah::Runtime>::insert(
@@ -53,10 +53,10 @@
//! Within this pezpallet, we need to talk to the staking-async pezpallet in AH. This is done via
//! [`AHStakingInterface`] trait.
//!
//! The staking pezpallet in AH has no communication with session pezpallet whatsoever, therefore its
//! implementation of `SessionManager`, and it associated type `SessionInterface` no longer exists.
//! Moreover, pezpallet-staking-async no longer has a notion of timestamp locally, and only relies in
//! the timestamp passed in in the `SessionReport`.
//! The staking pezpallet in AH has no communication with session pezpallet whatsoever, therefore
//! its implementation of `SessionManager`, and it associated type `SessionInterface` no longer
//! exists. Moreover, pezpallet-staking-async no longer has a notion of timestamp locally, and only
//! relies in the timestamp passed in in the `SessionReport`.
//!
//! ## Shared Types
//!
@@ -98,8 +98,8 @@
//!
//! ### Asynchronous Model
//!
//! Now, if staking lives in AH and the session pezpallet lives in the relay chain, how will this look
//! like?
//! Now, if staking lives in AH and the session pezpallet lives in the relay chain, how will this
//! look like?
//!
//! Staking knows that by the time the relay-chain session index `3` (and later on `6` and so on) is
//! _planned_, it must have already returned a validator set via XCM.
@@ -144,8 +144,8 @@ macro_rules! log {
/// This trait should only encapsulate our _outgoing_ communication to the RC. Any incoming
/// communication comes it directly via our calls.
///
/// In a real runtime, this is implemented via XCM calls, much like how the core-time pezpallet works.
/// In a test runtime, it can be wired to direct function calls.
/// In a real runtime, this is implemented via XCM calls, much like how the core-time pezpallet
/// works. In a test runtime, it can be wired to direct function calls.
pub trait SendToRelayChain {
/// The validator account ids.
type AccountId;
@@ -168,8 +168,8 @@ impl SendToRelayChain for () {
/// This trait should only encapsulate our outgoing communications. Any incoming message is handled
/// with `Call`s.
///
/// In a real runtime, this is implemented via XCM calls, much like how the coretime pezpallet works.
/// In a test runtime, it can be wired to direct function call.
/// In a real runtime, this is implemented via XCM calls, much like how the coretime pezpallet
/// works. In a test runtime, it can be wired to direct function call.
pub trait SendToAssetHub {
/// The validator account ids.
type AccountId;
@@ -15,7 +15,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//! Simple pezpallet that stores the preset that was used to generate the genesis state in the state.
//! Simple pezpallet that stores the preset that was used to generate the genesis state in the
//! state.
#![cfg_attr(not(feature = "std"), no_std)]
@@ -63,8 +63,8 @@ pub mod fee {
WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
};
use pezkuwi_primitives::Balance;
use smallvec::smallvec;
pub use pezsp_runtime::Perbill;
use smallvec::smallvec;
/// The block saturation level. Fees will be updates based on this value.
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
@@ -25,8 +25,8 @@ use alloc::format;
use alloc::{string::ToString, vec, vec::Vec};
use core::panic;
use pezframe_support::build_struct_json_patch;
use pezpallet_staking_async_rc_runtime_constants::currency::UNITS as ZGR;
use pezkuwi_primitives::{AccountId, AssignmentId, SchedulerParams, ValidatorId};
use pezpallet_staking_async_rc_runtime_constants::currency::UNITS as ZGR;
use pezsp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use pezsp_consensus_babe::AuthorityId as BabeId;
use pezsp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId;
@@ -20,9 +20,9 @@ use codec::{Decode, Encode};
use core::marker::PhantomData;
use pezframe_support::pezpallet_prelude::DispatchResult;
use pezframe_system::RawOrigin;
use pezpallet_staking_async_rc_runtime_constants::currency::*;
use pezkuwi_primitives::Balance;
use pezkuwi_runtime_common::identity_migrator::{OnReapIdentity, WeightInfo};
use pezpallet_staking_async_rc_runtime_constants::currency::*;
use xcm::{latest::prelude::*, VersionedLocation, VersionedXcm};
use xcm_executor::traits::TransactAsset;
@@ -47,17 +47,6 @@ use pezframe_support::{
};
pub use pezframe_system::Call as SystemCall;
use pezframe_system::{EnsureRoot, EnsureSigned};
pub use pezpallet_balances::Call as BalancesCall;
use pezpallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
use pezpallet_identity::legacy::IdentityInfo;
use pezpallet_session::{
disabling::{DisablingDecision, DisablingStrategy},
historical as session_historical,
};
use pezpallet_staking_async_ah_client::{self as ah_client};
use pezpallet_staking_async_rc_client::{self as rc_client};
pub use pezpallet_timestamp::Call as TimestampCall;
use pezpallet_transaction_payment::{FeeDetails, FungibleAdapter, RuntimeDispatchInfo};
use pezkuwi_primitives::{
async_backing::Constraints, slashing, AccountId, AccountIndex, ApprovalVotingParams, Balance,
BlockNumber, CandidateEvent, CandidateHash,
@@ -94,7 +83,17 @@ use pezkuwi_runtime_teyrchains::{
scheduler as teyrchains_scheduler, session_info as teyrchains_session_info,
shared as teyrchains_shared,
};
use scale_info::TypeInfo;
pub use pezpallet_balances::Call as BalancesCall;
use pezpallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
use pezpallet_identity::legacy::IdentityInfo;
use pezpallet_session::{
disabling::{DisablingDecision, DisablingStrategy},
historical as session_historical,
};
use pezpallet_staking_async_ah_client::{self as ah_client};
use pezpallet_staking_async_rc_client::{self as rc_client};
pub use pezpallet_timestamp::Call as TimestampCall;
use pezpallet_transaction_payment::{FeeDetails, FungibleAdapter, RuntimeDispatchInfo};
use pezsp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use pezsp_consensus_beefy::{
ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature},
@@ -116,6 +115,7 @@ use pezsp_staking::{offence::OffenceSeverity, SessionIndex};
#[cfg(any(feature = "std", test))]
use pezsp_version::NativeVersion;
use pezsp_version::RuntimeVersion;
use scale_info::TypeInfo;
use xcm::{
latest::prelude::*, VersionedAsset, VersionedAssetId, VersionedAssets, VersionedLocation,
VersionedXcm,
@@ -143,7 +143,9 @@ pub mod pezpallet_reward_point_filler {
use super::*;
#[pezpallet::config]
pub trait Config: pezframe_system::Config + pezpallet_staking_async_ah_client::Config {
pub trait Config:
pezframe_system::Config + pezpallet_staking_async_ah_client::Config
{
type FillValidatorPointsTo: Get<u32>;
}
@@ -192,8 +194,8 @@ use impls::ToTeyrchainIdentityReaper;
// Governance and configurations.
pub mod governance;
use governance::{
pezpallet_custom_origins, AuctionAdmin, FellowshipAdmin, GeneralAdmin, LeaseAdmin, StakingAdmin,
Treasurer, TreasurySpender,
pezpallet_custom_origins, AuctionAdmin, FellowshipAdmin, GeneralAdmin, LeaseAdmin,
StakingAdmin, Treasurer, TreasurySpender,
};
#[cfg(test)]
@@ -236,10 +238,10 @@ pub fn native_version() -> NativeVersion {
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
}
/// A type to identify calls to the Identity pezpallet. These will be filtered to prevent invocation,
/// locking the state of the pezpallet and preventing further updates to identities and sub-identities.
/// The locked state will be the genesis state of a new system chain and then removed from the Relay
/// Chain.
/// A type to identify calls to the Identity pezpallet. These will be filtered to prevent
/// invocation, locking the state of the pezpallet and preventing further updates to identities and
/// sub-identities. The locked state will be the genesis state of a new system chain and then
/// removed from the Relay Chain.
pub struct IsIdentityCall;
impl Contains<RuntimeCall> for IsIdentityCall {
fn contains(c: &RuntimeCall) -> bool {
@@ -1743,8 +1745,8 @@ parameter_types! {
impl pezpallet_migrations::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
// For this test runtime, always use MockedMigrations to satisfy both regular and benchmark
// builds. When runtime-benchmarks is enabled on pezframe-support (via --benches), the Migrations
// type must implement MockedMigrations, but LazyMigrationV1ToV2 doesn't.
// builds. When runtime-benchmarks is enabled on pezframe-support (via --benches), the
// Migrations type must implement MockedMigrations, but LazyMigrationV1ToV2 doesn't.
type Migrations = pezpallet_migrations::mock_helpers::MockedMigrations;
type CursorMaxLen = ConstU32<65_536>;
type IdentifierMaxLen = ConstU32<256>;
@@ -17,6 +17,22 @@
pub mod pezframe_system;
pub mod pezframe_system_extensions;
pub mod pezkuwi_runtime_common_assigned_slots;
pub mod pezkuwi_runtime_common_auctions;
pub mod pezkuwi_runtime_common_crowdloan;
pub mod pezkuwi_runtime_common_identity_migrator;
pub mod pezkuwi_runtime_common_paras_registrar;
pub mod pezkuwi_runtime_common_slots;
pub mod pezkuwi_runtime_teyrchains_configuration;
pub mod pezkuwi_runtime_teyrchains_coretime;
pub mod pezkuwi_runtime_teyrchains_disputes;
pub mod pezkuwi_runtime_teyrchains_disputes_slashing;
pub mod pezkuwi_runtime_teyrchains_hrmp;
pub mod pezkuwi_runtime_teyrchains_inclusion;
pub mod pezkuwi_runtime_teyrchains_initializer;
pub mod pezkuwi_runtime_teyrchains_on_demand;
pub mod pezkuwi_runtime_teyrchains_paras;
pub mod pezkuwi_runtime_teyrchains_paras_inherent;
pub mod pezpallet_asset_rate;
pub mod pezpallet_balances;
pub mod pezpallet_beefy_mmr;
@@ -41,20 +57,4 @@ pub mod pezpallet_utility;
pub mod pezpallet_vesting;
pub mod pezpallet_whitelist;
pub mod pezpallet_xcm;
pub mod pezkuwi_runtime_common_assigned_slots;
pub mod pezkuwi_runtime_common_auctions;
pub mod pezkuwi_runtime_common_crowdloan;
pub mod pezkuwi_runtime_common_identity_migrator;
pub mod pezkuwi_runtime_common_paras_registrar;
pub mod pezkuwi_runtime_common_slots;
pub mod pezkuwi_runtime_teyrchains_configuration;
pub mod pezkuwi_runtime_teyrchains_coretime;
pub mod pezkuwi_runtime_teyrchains_disputes;
pub mod pezkuwi_runtime_teyrchains_disputes_slashing;
pub mod pezkuwi_runtime_teyrchains_hrmp;
pub mod pezkuwi_runtime_teyrchains_inclusion;
pub mod pezkuwi_runtime_teyrchains_initializer;
pub mod pezkuwi_runtime_teyrchains_on_demand;
pub mod pezkuwi_runtime_teyrchains_paras;
pub mod pezkuwi_runtime_teyrchains_paras_inherent;
pub mod xcm;
@@ -29,14 +29,14 @@ use pezframe_support::{
},
};
use pezframe_system::EnsureRoot;
use pezpallet_staking_async_rc_runtime_constants::{
currency::CENTS, system_teyrchain::*, xcm::body::FELLOWSHIP_ADMIN_INDEX,
};
use pezpallet_xcm::XcmPassthrough;
use pezkuwi_runtime_common::{
xcm_sender::{ChildTeyrchainRouter, ExponentialPrice},
ToAuthor,
};
use pezpallet_staking_async_rc_runtime_constants::{
currency::CENTS, system_teyrchain::*, xcm::body::FELLOWSHIP_ADMIN_INDEX,
};
use pezpallet_xcm::XcmPassthrough;
use pezsp_core::ConstU32;
use xcm::latest::{prelude::*, ZAGROS_GENESIS_HASH};
use xcm_builder::{
@@ -27,10 +27,10 @@ use pezframe_support::{
},
};
use pezframe_system::EnsureRootWithSuccess;
use pezpallet_xcm::{EnsureXcm, IsVoiceOfBody};
use pezkuwi_runtime_common::impls::{
ContainsParts, LocatableAssetConverter, VersionedLocatableAsset, VersionedLocationConverter,
};
use pezpallet_xcm::{EnsureXcm, IsVoiceOfBody};
use pezsp_runtime::{traits::IdentityLookup, Percent};
use xcm::latest::{
prelude::{InteriorLocation, PalletInstance},
@@ -44,7 +44,12 @@ use assets_common::{
AssetIdForPoolAssets, AssetIdForPoolAssetsConvert, AssetIdForTrustBackedAssetsConvert,
};
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
use pezcumulus_pezpallet_teyrchain_system::{RelayNumberMonotonicallyIncreases, RelaychainDataProvider};
use governance::{
pezpallet_custom_origins, FellowshipAdmin, GeneralAdmin, StakingAdmin, Treasurer,
};
use pezcumulus_pezpallet_teyrchain_system::{
RelayNumberMonotonicallyIncreases, RelaychainDataProvider,
};
use pezcumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use pezframe_support::{
construct_runtime, derive_impl,
@@ -66,12 +71,11 @@ use pezframe_system::{
limits::{BlockLength, BlockWeights},
EnsureRoot, EnsureSigned, EnsureSignedBy,
};
use governance::{pezpallet_custom_origins, FellowshipAdmin, GeneralAdmin, StakingAdmin, Treasurer};
use pezkuwi_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
use pezpallet_asset_conversion_tx_payment::SwapAssetAdapter;
use pezpallet_nfts::PalletFeatures;
use pezpallet_nomination_pools::PoolId;
use pezpallet_xcm::EnsureXcm;
use pezkuwi_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
use pezsp_api::impl_runtime_apis;
use pezsp_core::{crypto::KeyTypeId, OpaqueMetadata};
#[cfg(any(feature = "std", test))]
@@ -721,8 +725,9 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
RuntimeCall::Uniques(pezpallet_uniques::Call::set_collection_metadata { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::clear_metadata { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::clear_attribute { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::clear_collection_metadata { .. }) |
RuntimeCall::Uniques(pezpallet_uniques::Call::set_collection_max_supply { .. }) |
RuntimeCall::Uniques(
pezpallet_uniques::Call::clear_collection_metadata { .. }
) | RuntimeCall::Uniques(pezpallet_uniques::Call::set_collection_max_supply { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
),
@@ -20,10 +20,10 @@ use super::*;
use pezcumulus_primitives_core::relay_chain::SessionIndex;
use pezframe_election_provider_support::{ElectionDataProvider, SequentialPhragmen};
use pezframe_support::traits::{ConstU128, EitherOf};
use pezkuwi_runtime_common::{prod_or_fast, BalanceToU256, U256ToBalance};
use pezpallet_election_provider_multi_block::{self as multi_block, SolutionAccuracyOf};
use pezpallet_staking_async::UseValidatorsMap;
use pezpallet_staking_async_rc_client as rc_client;
use pezkuwi_runtime_common::{prod_or_fast, BalanceToU256, U256ToBalance};
use pezsp_core::Get;
use pezsp_npos_elections::BalancingConfig;
use pezsp_runtime::{
@@ -444,7 +444,8 @@ impl pezpallet_staking_async::Config for Runtime {
type VoterList = VoterList;
type TargetList = UseValidatorsMap<Self>;
type MaxValidatorSet = MaxValidatorSet;
type NominationsQuota = pezpallet_staking_async::FixedNominationsQuota<{ MaxNominations::get() }>;
type NominationsQuota =
pezpallet_staking_async::FixedNominationsQuota<{ MaxNominations::get() }>;
type MaxUnlockingChunks = pezframe_support::traits::ConstU32<32>;
type HistoryDepth = ConstU32<1>;
type MaxControllersInDeprecationBatch = MaxControllersInDeprecationBatch;
@@ -659,7 +660,9 @@ where
mod tests {
use super::*;
use pezframe_election_provider_support::ElectionProvider;
use pezframe_support::weights::constants::{WEIGHT_PROOF_SIZE_PER_KB, WEIGHT_REF_TIME_PER_MILLIS};
use pezframe_support::weights::constants::{
WEIGHT_PROOF_SIZE_PER_KB, WEIGHT_REF_TIME_PER_MILLIS,
};
use pezpallet_election_provider_multi_block::{
self as mb, signed::WeightInfo as _, unsigned::WeightInfo as _,
};
@@ -16,10 +16,11 @@
// limitations under the License.
pub mod block_weights;
pub mod extrinsic_weights;
pub mod paritydb_weights;
pub mod pezcumulus_pezpallet_teyrchain_system;
pub mod pezcumulus_pezpallet_weight_reclaim;
pub mod pezcumulus_pezpallet_xcmp_queue;
pub mod extrinsic_weights;
pub mod pezframe_system;
pub mod pezframe_system_extensions;
pub mod pezpallet_asset_conversion;
@@ -56,7 +57,6 @@ pub mod pezpallet_vesting;
pub mod pezpallet_whitelist;
pub mod pezpallet_xcm;
pub mod pezpallet_xcm_bridge_hub_router;
pub mod paritydb_weights;
pub mod rocksdb_weights;
pub mod xcm;
@@ -35,9 +35,9 @@ use pezframe_support::{
},
};
use pezframe_system::EnsureRoot;
use pezpallet_xcm::XcmPassthrough;
use pezkuwi_runtime_common::xcm_sender::ExponentialPrice;
use pezkuwi_teyrchain_primitives::primitives::Sibling;
use pezpallet_xcm::XcmPassthrough;
use pezsp_runtime::traits::{AccountIdConversion, ConvertInto, TryConvertInto};
use teyrchains_common::{
xcm_config::{
@@ -300,8 +300,8 @@ pub type Barrier = TrailingSetTopicAsId<
// If the message is one that immediately attempts to pay for execution, then
// allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent, its pluralities (i.e. governance bodies), relay treasury pezpallet and
// sibling teyrchains get free execution.
// Parent, its pluralities (i.e. governance bodies), relay treasury pezpallet
// and sibling teyrchains get free execution.
AllowExplicitUnpaidExecutionFrom<(
ParentOrParentsPlurality,
Equals<RelayTreasuryLocation>,
@@ -321,15 +321,20 @@ pub type Barrier = TrailingSetTopicAsId<
>,
>;
// TODO: This calls into the Assets pezpallet's default `BalanceToAssetBalance` implementation, which
// uses the ratio of minimum balances and requires asset sufficiency. This means that purchasing
// weight within XCM programs will still use the old way, and paying fees via asset conversion will
// only be possible when transacting locally. We should add an impl of this trait that does asset
// conversion.
// TODO: This calls into the Assets pezpallet's default `BalanceToAssetBalance` implementation,
// which uses the ratio of minimum balances and requires asset sufficiency. This means that
// purchasing weight within XCM programs will still use the old way, and paying fees via asset
// conversion will only be possible when transacting locally. We should add an impl of this trait
// that does asset conversion.
pub type AssetFeeAsExistentialDepositMultiplierFeeCharger = AssetFeeAsExistentialDepositMultiplier<
Runtime,
WeightToFee,
pezpallet_assets::BalanceToAssetBalance<Balances, Runtime, ConvertInto, TrustBackedAssetsInstance>,
pezpallet_assets::BalanceToAssetBalance<
Balances,
Runtime,
ConvertInto,
TrustBackedAssetsInstance,
>,
TrustBackedAssetsInstance,
>;
@@ -338,7 +343,12 @@ pub type ForeignAssetFeeAsExistentialDepositMultiplierFeeCharger =
AssetFeeAsExistentialDepositMultiplier<
Runtime,
WeightToFee,
pezpallet_assets::BalanceToAssetBalance<Balances, Runtime, ConvertInto, ForeignAssetsInstance>,
pezpallet_assets::BalanceToAssetBalance<
Balances,
Runtime,
ConvertInto,
ForeignAssetsInstance,
>,
ForeignAssetsInstance,
>;
@@ -32,7 +32,7 @@
//! state consistency.
use crate::{
asset, log, BalanceOf, Bonded, Config, DecodeWithMemTracking, Error, Ledger, Pezpallet, Payee,
asset, log, BalanceOf, Bonded, Config, DecodeWithMemTracking, Error, Ledger, Payee, Pezpallet,
RewardDestination, Vec, VirtualStakers,
};
use alloc::{collections::BTreeMap, fmt::Debug};
@@ -42,9 +42,9 @@ use pezframe_support::{
traits::{Defensive, DefensiveSaturating, Get},
BoundedVec, CloneNoBound, DebugNoBound, EqNoBound, PartialEqNoBound,
};
use scale_info::TypeInfo;
use pezsp_runtime::{traits::Zero, DispatchResult, Perquintill, Rounding, Saturating};
use pezsp_staking::{EraIndex, OnStakingUpdate, StakingAccount, StakingInterface};
use scale_info::TypeInfo;
/// Just a Balance/BlockNumber tuple to encode when a chunk of funds will be unlocked.
#[derive(
+8 -7
View File
@@ -26,8 +26,8 @@
//! * It is capable of working with a multi-page `ElectionProvider``, aka.
//! `pezpallet-election-provider-multi-block`.
//!
//! While `pezpallet-staking` was somewhat general-purpose, this pezpallet is absolutely NOT right from
//! the get-go: It is designed to be used ONLY in Pezkuwi/Kusama AssetHub system teyrchains.
//! While `pezpallet-staking` was somewhat general-purpose, this pezpallet is absolutely NOT right
//! from the get-go: It is designed to be used ONLY in Pezkuwi/Kusama AssetHub system teyrchains.
//!
//! The workings of this pezpallet can be divided into a number of subsystems, as follows.
//!
@@ -198,6 +198,7 @@ pub mod weights;
extern crate alloc;
use alloc::{vec, vec::Vec};
use codec::{Decode, DecodeWithMemTracking, Encode, HasCompact, MaxEncodedLen};
use ledger::LedgerIntegrityState;
use pezframe_election_provider_support::ElectionProvider;
use pezframe_support::{
traits::{
@@ -208,14 +209,13 @@ use pezframe_support::{
WeakBoundedVec,
};
use pezframe_system::pezpallet_prelude::BlockNumberFor;
use ledger::LedgerIntegrityState;
use scale_info::TypeInfo;
use pezsp_runtime::{
traits::{AtLeast32BitUnsigned, One, StaticLookup, UniqueSaturatedInto},
BoundedBTreeMap, Perbill, RuntimeDebug, Saturating,
};
use pezsp_staking::{EraIndex, ExposurePage, PagedExposureMetadata, SessionIndex};
pub use pezsp_staking::{Exposure, IndividualExposure, StakerStatus};
use scale_info::TypeInfo;
pub use weights::WeightInfo;
// public exports
@@ -246,8 +246,8 @@ pub type BoundedExposuresOf<T> = BoundedVec<
MaxWinnersPerPageOf<<T as Config>::ElectionProvider>,
>;
/// 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.
@@ -263,7 +263,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>;
@@ -624,7 +624,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 mut maybe_stakers = vec![];
@@ -1582,8 +1582,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,
@@ -25,6 +25,7 @@ use crate::{
};
use alloc::{format, vec::Vec};
use codec::Codec;
pub use impls::*;
use pezframe_election_provider_support::{ElectionProvider, SortedListProvider, VoteWeight};
use pezframe_support::{
assert_ok,
@@ -41,12 +42,6 @@ use pezframe_support::{
BoundedBTreeSet, BoundedVec,
};
use pezframe_system::{ensure_root, ensure_signed, pezpallet_prelude::*};
pub use impls::*;
use rand::seq::SliceRandom;
use rand_chacha::{
rand_core::{RngCore, SeedableRng},
ChaChaRng,
};
use pezsp_core::{sr25519::Pair as SrPair, Pair};
use pezsp_runtime::{
traits::{StaticLookup, Zero},
@@ -57,6 +52,11 @@ use pezsp_staking::{
StakingAccount::{self, Controller, Stash},
StakingInterface,
};
use rand::seq::SliceRandom;
use rand_chacha::{
rand_core::{RngCore, SeedableRng},
ChaChaRng,
};
mod impls;
@@ -148,8 +148,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]
@@ -502,10 +502,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, ()>;
@@ -575,8 +575,8 @@ pub mod pezpallet {
/// A bounded wrapper for [`pezsp_staking::ExposurePage`].
///
/// It has `Deref` and `DerefMut` impls that map it back [`pezsp_staking::ExposurePage`] for all
/// purposes. This is done in such a way because we prefer to keep the types in [`pezsp_staking`]
/// pure, and not polluted by pezpallet-specific bounding logic.
/// purposes. This is done in such a way because we prefer to keep the types in
/// [`pezsp_staking`] pure, and not polluted by pezpallet-specific bounding logic.
///
/// It encoded and decodes exactly the same as [`pezsp_staking::ExposurePage`], and provides a
/// manual `MaxEncodedLen` implementation, to be used in benchmarking
@@ -2084,7 +2084,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,
@@ -2420,7 +2422,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,
@@ -2626,8 +2630,8 @@ pub mod pezpallet {
/// Manually and permissionlessly applies a deferred slash for a given era.
///
/// Normally, slashes are automatically applied shortly after the start of the `slash_era`.
/// The automatic application of slashes is handled by the pezpallet's internal logic, and it
/// tries to apply one slash page per block of the era.
/// The automatic application of slashes is handled by the pezpallet's internal logic, and
/// it tries to apply one slash page per block of the era.
/// If for some reason, one era is not enough for applying all slash pages, the remaining
/// slashes need to be manually (permissionlessly) applied.
///
@@ -437,7 +437,9 @@ impl<T: Config> Eras<T> {
}
/// Ensure the given era is either absent or currently being pruned.
pub(crate) fn era_absent_or_pruning(era: EraIndex) -> Result<(), pezsp_runtime::TryRuntimeError> {
pub(crate) fn era_absent_or_pruning(
era: EraIndex,
) -> Result<(), pezsp_runtime::TryRuntimeError> {
if Self::era_pruning_in_progress(era) {
Ok(())
} else {
@@ -774,7 +776,9 @@ impl<T: Config> Rotator<T> {
// if the cap is zero (not set), we don't cap the era duration.
uncapped_era_duration
} else if uncapped_era_duration > cap {
Pezpallet::<T>::deposit_event(Event::Unexpected(UnexpectedKind::EraDurationBoundExceeded));
Pezpallet::<T>::deposit_event(Event::Unexpected(
UnexpectedKind::EraDurationBoundExceeded,
));
// if the cap is set, and era duration exceeds the cap, we cap the era duration to the
// maximum allowed.
@@ -990,7 +994,10 @@ impl<T: Config> EraElectionPlanner<T> {
},
Err(e) => {
log!(warn, "election provider page failed due to {:?} (page: {})", e, page);
Pezpallet::<T>::deposit_event(Event::PagedElectionProceeded { page, result: Err(0) });
Pezpallet::<T>::deposit_event(Event::PagedElectionProceeded {
page,
result: Err(0),
});
},
}
}
@@ -42,18 +42,18 @@
use crate::{
asset, log, session_rotation::Eras, BalanceOf, Config, NegativeImbalanceOf, OffenceQueue,
OffenceQueueEras, PagedExposure, Pezpallet, Perbill, ProcessingOffence, SlashRewardFraction,
OffenceQueueEras, PagedExposure, Perbill, Pezpallet, ProcessingOffence, SlashRewardFraction,
UnappliedSlash, UnappliedSlashes, ValidatorSlashInEra, WeightInfo,
};
use alloc::vec::Vec;
use codec::{Decode, Encode, MaxEncodedLen};
use pezframe_support::traits::{Defensive, DefensiveSaturating, Get, Imbalance, OnUnbalanced};
use scale_info::TypeInfo;
use pezsp_runtime::{
traits::{Saturating, Zero},
RuntimeDebug, WeakBoundedVec, Weight,
};
use pezsp_staking::{EraIndex, StakingInterface};
use scale_info::TypeInfo;
/// Parameters for performing a slash.
#[derive(Clone)]
@@ -398,7 +398,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.
};
@@ -425,7 +427,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::*;
@@ -17,9 +17,9 @@
use super::*;
use crate::session_rotation::{EraElectionPlanner, Eras};
use bizinikiwi_test_utils::assert_eq_uvec;
use pezframe_support::assert_ok;
use pezsp_npos_elections::Support;
use bizinikiwi_test_utils::assert_eq_uvec;
use crate::tests::session_mock::ReceivedValidatorSets;
@@ -19,6 +19,8 @@
use super::*;
use crate::{asset, ledger::StakingLedgerInspect, mock::Session};
use bizinikiwi_test_utils::assert_eq_uvec;
use mock::*;
use pezframe_election_provider_support::{
bounds::{DataProviderBounds, ElectionBoundsBuilder},
SortedListProvider,
@@ -28,12 +30,10 @@ use pezframe_support::{
pezpallet_prelude::*,
traits::{InspectLockableCurrency, ReservableCurrency},
};
use mock::*;
use pezsp_runtime::{
assert_eq_error_rate, bounded_vec, traits::BadOrigin, Perbill, Percent, TokenError,
};
use pezsp_staking::{Stake, StakingAccount, StakingInterface};
use bizinikiwi_test_utils::assert_eq_uvec;
mod bonding;
mod configs;