mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-05 08:37:25 +00:00
staking: Proportional ledger slashing (#10982)
* staking: Proportional ledger slashing * Some comment cleanup * Update frame/staking/src/pallet/mod.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Fix benchmarks * FMT * Try fill in all staking configs * round of feedback and imp from kian * demonstrate per_thing usage * Update some tests * FMT * Test that era offset works correctly * Update mocks * Remove unnescary docs * Remove unlock_era * Update frame/staking/src/lib.rs * Adjust tests to account for only remove when < ED * Remove stale TODOs * Remove dupe test Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: kianenigma <kian@parity.io>
This commit is contained in:
@@ -238,6 +238,7 @@ parameter_types! {
|
||||
pub static BagThresholds: &'static [sp_npos_elections::VoteWeight] = &THRESHOLDS;
|
||||
pub static MaxNominations: u32 = 16;
|
||||
pub static RewardOnUnbalanceWasCalled: bool = false;
|
||||
pub static LedgerSlashPerEra: (BalanceOf<Test>, BTreeMap<EraIndex, BalanceOf<Test>>) = (Zero::zero(), BTreeMap::new());
|
||||
}
|
||||
|
||||
impl pallet_bags_list::Config for Test {
|
||||
@@ -263,9 +264,21 @@ impl OnUnbalanced<PositiveImbalanceOf<Test>> for MockReward {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct OnStakerSlashMock<T: Config>(core::marker::PhantomData<T>);
|
||||
impl<T: Config> sp_staking::OnStakerSlash<AccountId, Balance> for OnStakerSlashMock<T> {
|
||||
fn on_slash(
|
||||
_pool_account: &AccountId,
|
||||
slashed_bonded: Balance,
|
||||
slashed_chunks: &BTreeMap<EraIndex, Balance>,
|
||||
) {
|
||||
LedgerSlashPerEra::set((slashed_bonded, slashed_chunks.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::pallet::pallet::Config for Test {
|
||||
type MaxNominations = MaxNominations;
|
||||
type Currency = Balances;
|
||||
type CurrencyBalance = <Self as pallet_balances::Config>::Balance;
|
||||
type UnixTime = Timestamp;
|
||||
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
|
||||
type RewardRemainder = RewardRemainderMock;
|
||||
@@ -286,6 +299,7 @@ impl crate::pallet::pallet::Config for Test {
|
||||
// NOTE: consider a macro and use `UseNominatorsAndValidatorsMap<Self>` as well.
|
||||
type VoterList = BagsList;
|
||||
type MaxUnlockingChunks = ConstU32<32>;
|
||||
type OnStakerSlash = OnStakerSlashMock<Test>;
|
||||
type BenchmarkingConfig = TestBenchmarkingConfig;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user