Skip to content

Commit 82513b0

Browse files
committed
Revert "[Staking] Bounded Slashing: Paginated Offence Processing & Slash Application (#7424)"
This reverts commit dda2cb5.
1 parent e1629e7 commit 82513b0

File tree

23 files changed

+1257
-1838
lines changed

23 files changed

+1257
-1838
lines changed

polkadot/runtime/test-runtime/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ impl pallet_session::Config for Runtime {
323323
}
324324

325325
impl pallet_session::historical::Config for Runtime {
326-
type FullIdentification = ();
327-
type FullIdentificationOf = pallet_staking::NullIdentity;
326+
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
327+
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
328328
}
329329

330330
pallet_staking_reward_curve::build! {

polkadot/runtime/westend/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1874,7 +1874,6 @@ pub mod migrations {
18741874
parachains_shared::migration::MigrateToV1<Runtime>,
18751875
parachains_scheduler::migration::MigrateV2ToV3<Runtime>,
18761876
pallet_staking::migrations::v16::MigrateV15ToV16<Runtime>,
1877-
pallet_staking::migrations::v17::MigrateV16ToV17<Runtime>,
18781877
pallet_session::migrations::v1::MigrateV0ToV1<
18791878
Runtime,
18801879
pallet_staking::migrations::v17::MigrateDisabledToSession<Runtime>,

prdoc/pr_7424.prdoc

Lines changed: 0 additions & 37 deletions
This file was deleted.

substrate/bin/node/runtime/src/lib.rs

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,8 @@ impl_opaque_keys! {
680680

681681
#[cfg(feature = "staking-playground")]
682682
pub mod staking_playground {
683+
use pallet_staking::Exposure;
684+
683685
use super::*;
684686

685687
/// An adapter to make the chain work with --dev only, even though it is running a large staking
@@ -714,43 +716,61 @@ pub mod staking_playground {
714716
}
715717
}
716718

717-
impl pallet_session::historical::SessionManager<AccountId, ()> for AliceAsOnlyValidator {
719+
impl pallet_session::historical::SessionManager<AccountId, Exposure<AccountId, Balance>>
720+
for AliceAsOnlyValidator
721+
{
718722
fn end_session(end_index: sp_staking::SessionIndex) {
719-
<Staking as pallet_session::historical::SessionManager<AccountId, ()>>::end_session(
720-
end_index,
721-
)
723+
<Staking as pallet_session::historical::SessionManager<
724+
AccountId,
725+
Exposure<AccountId, Balance>,
726+
>>::end_session(end_index)
722727
}
723728

724-
fn new_session(new_index: sp_staking::SessionIndex) -> Option<Vec<(AccountId, ())>> {
725-
<Staking as pallet_session::historical::SessionManager<AccountId, ()>>::new_session(
726-
new_index,
727-
)
729+
fn new_session(
730+
new_index: sp_staking::SessionIndex,
731+
) -> Option<Vec<(AccountId, Exposure<AccountId, Balance>)>> {
732+
<Staking as pallet_session::historical::SessionManager<
733+
AccountId,
734+
Exposure<AccountId, Balance>,
735+
>>::new_session(new_index)
728736
.map(|_ignored| {
729737
// construct a fake exposure for alice.
730-
vec![(sp_keyring::Sr25519Keyring::AliceStash.to_account_id().into(), ())]
738+
vec![(
739+
sp_keyring::Sr25519Keyring::AliceStash.to_account_id().into(),
740+
pallet_staking::Exposure {
741+
total: 1_000_000_000,
742+
own: 1_000_000_000,
743+
others: vec![],
744+
},
745+
)]
731746
})
732747
}
733748

734749
fn new_session_genesis(
735750
new_index: sp_staking::SessionIndex,
736-
) -> Option<Vec<(AccountId, ())>> {
751+
) -> Option<Vec<(AccountId, Exposure<AccountId, Balance>)>> {
737752
<Staking as pallet_session::historical::SessionManager<
738753
AccountId,
739-
(),
754+
Exposure<AccountId, Balance>,
740755
>>::new_session_genesis(new_index)
741756
.map(|_ignored| {
742757
// construct a fake exposure for alice.
743758
vec![(
744759
sp_keyring::Sr25519Keyring::AliceStash.to_account_id().into(),
745-
(),
760+
pallet_staking::Exposure {
761+
total: 1_000_000_000,
762+
own: 1_000_000_000,
763+
others: vec![],
764+
},
746765
)]
747766
})
748767
}
749768

750769
fn start_session(start_index: sp_staking::SessionIndex) {
751-
<Staking as pallet_session::historical::SessionManager<AccountId, ()>>::start_session(
752-
start_index,
753-
)
770+
<Staking as pallet_session::historical::SessionManager<
771+
AccountId,
772+
Exposure<AccountId, Balance>,
773+
>>::start_session(start_index)
754774
}
755775
}
756776
}
@@ -776,8 +796,8 @@ impl pallet_session::Config for Runtime {
776796
}
777797

778798
impl pallet_session::historical::Config for Runtime {
779-
type FullIdentification = ();
780-
type FullIdentificationOf = pallet_staking::NullIdentity;
799+
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
800+
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
781801
}
782802

783803
pallet_staking_reward_curve::build! {

substrate/frame/babe/src/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ impl pallet_session::Config for Test {
105105
}
106106

107107
impl pallet_session::historical::Config for Test {
108-
type FullIdentification = ();
109-
type FullIdentificationOf = pallet_staking::NullIdentity;
108+
type FullIdentification = pallet_staking::Exposure<u64, u128>;
109+
type FullIdentificationOf = pallet_staking::ExposureOf<Self>;
110110
}
111111

112112
impl pallet_authorship::Config for Test {

substrate/frame/beefy/src/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ impl pallet_session::Config for Test {
189189
}
190190

191191
impl pallet_session::historical::Config for Test {
192-
type FullIdentification = ();
193-
type FullIdentificationOf = pallet_staking::NullIdentity;
192+
type FullIdentification = pallet_staking::Exposure<u64, u128>;
193+
type FullIdentificationOf = pallet_staking::ExposureOf<Self>;
194194
}
195195

196196
impl pallet_authorship::Config for Test {

substrate/frame/election-provider-multi-phase/test-staking-e2e/src/mock.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ impl pallet_session::Config for Runtime {
147147
type WeightInfo = ();
148148
}
149149
impl pallet_session::historical::Config for Runtime {
150-
type FullIdentification = ();
151-
type FullIdentificationOf = pallet_staking::NullIdentity;
150+
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
151+
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
152152
}
153153

154154
frame_election_provider_support::generate_solution_type!(
@@ -909,7 +909,10 @@ pub(crate) fn on_offence_now(
909909
// Add offence to validator, slash it.
910910
pub(crate) fn add_slash(who: &AccountId) {
911911
on_offence_now(
912-
&[OffenceDetails { offender: (*who, ()), reporters: vec![] }],
912+
&[OffenceDetails {
913+
offender: (*who, Staking::eras_stakers(active_era(), who)),
914+
reporters: vec![],
915+
}],
913916
&[Perbill::from_percent(10)],
914917
);
915918
}

substrate/frame/grandpa/src/mock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ impl pallet_session::Config for Test {
109109
}
110110

111111
impl pallet_session::historical::Config for Test {
112-
type FullIdentification = ();
113-
type FullIdentificationOf = pallet_staking::NullIdentity;
112+
type FullIdentification = pallet_staking::Exposure<u64, u128>;
113+
type FullIdentificationOf = pallet_staking::ExposureOf<Self>;
114114
}
115115

116116
impl pallet_authorship::Config for Test {

substrate/frame/offences/benchmarking/src/inner.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,6 @@ fn make_offenders<T: Config>(
170170
Ok(id_tuples)
171171
}
172172

173-
#[cfg(test)]
174-
fn run_staking_next_block<T: Config>() {
175-
use frame_support::traits::Hooks;
176-
System::<T>::set_block_number(System::<T>::block_number().saturating_add(1u32.into()));
177-
Staking::<T>::on_initialize(System::<T>::block_number());
178-
}
179-
180173
#[cfg(test)]
181174
fn assert_all_slashes_applied<T>(offender_count: usize)
182175
where
@@ -189,10 +182,10 @@ where
189182
// make sure that all slashes have been applied
190183
// deposit to reporter + reporter account endowed.
191184
assert_eq!(System::<T>::read_events_for_pallet::<pallet_balances::Event<T>>().len(), 2);
192-
// (n nominators + one validator) * slashed + Slash Reported + Slash Computed
185+
// (n nominators + one validator) * slashed + Slash Reported
193186
assert_eq!(
194187
System::<T>::read_events_for_pallet::<pallet_staking::Event<T>>().len(),
195-
1 * (offender_count + 1) as usize + 2
188+
1 * (offender_count + 1) as usize + 1
196189
);
197190
// offence
198191
assert_eq!(System::<T>::read_events_for_pallet::<pallet_offences::Event>().len(), 1);
@@ -239,8 +232,6 @@ mod benchmarks {
239232

240233
#[cfg(test)]
241234
{
242-
// slashes applied at the next block.
243-
run_staking_next_block::<T>();
244235
assert_all_slashes_applied::<T>(n as usize);
245236
}
246237

@@ -275,8 +266,6 @@ mod benchmarks {
275266
}
276267
#[cfg(test)]
277268
{
278-
// slashes applied at the next block.
279-
run_staking_next_block::<T>();
280269
assert_all_slashes_applied::<T>(n as usize);
281270
}
282271

substrate/frame/offences/benchmarking/src/mock.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use sp_runtime::{
3333
};
3434

3535
type AccountId = u64;
36+
type Balance = u64;
3637

3738
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
3839
impl frame_system::Config for Test {
@@ -53,8 +54,8 @@ impl pallet_timestamp::Config for Test {
5354
type WeightInfo = ();
5455
}
5556
impl pallet_session::historical::Config for Test {
56-
type FullIdentification = ();
57-
type FullIdentificationOf = pallet_staking::NullIdentity;
57+
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
58+
type FullIdentificationOf = pallet_staking::ExposureOf<Test>;
5859
}
5960

6061
sp_runtime::impl_opaque_keys! {

0 commit comments

Comments
 (0)