Skip to content

Commit e6fc0c1

Browse files
committed
bring back some more changes
1 parent c15fb37 commit e6fc0c1

File tree

24 files changed

+164
-608
lines changed

24 files changed

+164
-608
lines changed

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

+2-2
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 = pallet_staking::Exposure<AccountId, Balance>;
327-
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
326+
type FullIdentification = ();
327+
type FullIdentificationOf = pallet_staking::NullIdentity;
328328
}
329329

330330
pallet_staking_reward_curve::build! {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,8 @@ impl pallet_session::Config for Runtime {
693693
}
694694

695695
impl pallet_session::historical::Config for Runtime {
696-
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
697-
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
696+
type FullIdentification = ();
697+
type FullIdentificationOf = pallet_staking::NullIdentity;
698698
}
699699

700700
pallet_staking_reward_curve::build! {

substrate/frame/babe/src/mock.rs

+2-2
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 = pallet_staking::Exposure<u64, u128>;
109-
type FullIdentificationOf = pallet_staking::ExposureOf<Self>;
108+
type FullIdentification = ();
109+
type FullIdentificationOf = pallet_staking::NullIdentity;
110110
}
111111

112112
impl pallet_authorship::Config for Test {

substrate/frame/beefy/src/tests.rs

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ use crate::{self as beefy, mock::*, Call, Config, Error, WeightInfoExt};
3939

4040
fn init_block(block: u64) {
4141
System::set_block_number(block);
42+
// Staking has to also be initialized, and be the first, to have the new validator set ready.
43+
Staking::on_initialize(block);
4244
Session::on_initialize(block);
4345
}
4446

substrate/frame/benchmarking/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ pub use v1::*;
381381
///
382382
/// #[extrinsic_call]
383383
/// _(RuntimeOrigin::Signed(caller), vec![0u8; l]);
384-
///
384+
///
385385
/// // Everything onwards will be treated as test.
386386
/// assert_last_event::<T>(Event::FooExecuted { result: Ok(()) }.into());
387387
/// Ok(())

substrate/frame/election-provider-multi-block/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
//!
6767
//! ## Pagination
6868
//!
69-
//! Most of the external APIs of this pallet are paginated. All pagination follow a patter where if
69+
//! Most of the external APIs of this pallet are paginated. All pagination follow a pattern where if
7070
//! `N` pages exist, the first paginated call is `function(N-1)` and the last one is `function(0)`.
7171
//! For example, with 3 pages, the `elect` of [`ElectionProvider`] is expected to be called as
7272
//! `elect(2) -> elect(1) -> elect(0)`. In essence, calling a paginated function with index 0 is

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

+3-6
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 = pallet_staking::Exposure<AccountId, Balance>;
151-
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
150+
type FullIdentification = ();
151+
type FullIdentificationOf = pallet_staking::NullIdentity;
152152
}
153153

154154
frame_election_provider_support::generate_solution_type!(
@@ -898,10 +898,7 @@ pub(crate) fn on_offence_now(
898898
// Add offence to validator, slash it.
899899
pub(crate) fn add_slash(who: &AccountId) {
900900
on_offence_now(
901-
&[OffenceDetails {
902-
offender: (*who, Staking::eras_stakers(active_era(), who)),
903-
reporters: vec![],
904-
}],
901+
&[OffenceDetails { offender: (*who, ()), reporters: vec![] }],
905902
&[Perbill::from_percent(10)],
906903
);
907904
}

substrate/frame/election-provider-support/solution-type/fuzzer/src/compact.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ use sp_arithmetic::Percent;
2121
use sp_runtime::codec::{Encode, Error};
2222

2323
fn main() {
24-
generate_solution_type!(#[compact] pub struct InnerTestSolutionCompact::<
24+
generate_solution_type!(
25+
#[compact] pub struct InnerTestSolutionCompact::<
2526
VoterIndex = u32,
2627
TargetIndex = u32,
2728
Accuracy = Percent,

substrate/frame/grandpa/src/mock.rs

+2-2
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 = pallet_staking::Exposure<u64, u128>;
113-
type FullIdentificationOf = pallet_staking::ExposureOf<Self>;
112+
type FullIdentification = ();
113+
type FullIdentificationOf = pallet_staking::NullIdentity;
114114
}
115115

116116
impl pallet_authorship::Config for Test {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ impl pallet_timestamp::Config for Test {
5454
type WeightInfo = ();
5555
}
5656
impl pallet_session::historical::Config for Test {
57-
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
58-
type FullIdentificationOf = pallet_staking::ExposureOf<Test>;
57+
type FullIdentification = ();
58+
type FullIdentificationOf = pallet_staking::NullIdentity;
5959
}
6060

6161
sp_runtime::impl_opaque_keys! {

substrate/frame/root-offences/src/lib.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extern crate alloc;
3131

3232
use alloc::vec::Vec;
3333
use pallet_session::historical::IdentificationTuple;
34-
use pallet_staking::{BalanceOf, Exposure, ExposureOf, Pallet as Staking};
34+
use pallet_staking::Pallet as Staking;
3535
use sp_runtime::Perbill;
3636
use sp_staking::offence::OnOffenceHandler;
3737

@@ -49,11 +49,8 @@ pub mod pallet {
4949
+ pallet_staking::Config
5050
+ pallet_session::Config<ValidatorId = <Self as frame_system::Config>::AccountId>
5151
+ pallet_session::historical::Config<
52-
FullIdentification = Exposure<
53-
<Self as frame_system::Config>::AccountId,
54-
BalanceOf<Self>,
55-
>,
56-
FullIdentificationOf = ExposureOf<Self>,
52+
FullIdentification = (),
53+
FullIdentificationOf = pallet_staking::NullIdentity,
5754
>
5855
{
5956
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
@@ -106,15 +103,11 @@ pub mod pallet {
106103
fn get_offence_details(
107104
offenders: Vec<(T::AccountId, Perbill)>,
108105
) -> Result<Vec<OffenceDetails<T>>, DispatchError> {
109-
let now = pallet_staking::ActiveEra::<T>::get()
110-
.map(|e| e.index)
111-
.ok_or(Error::<T>::FailedToGetActiveEra)?;
112-
113106
Ok(offenders
114107
.clone()
115108
.into_iter()
116109
.map(|(o, _)| OffenceDetails::<T> {
117-
offender: (o.clone(), Staking::<T>::eras_stakers(now, &o)),
110+
offender: (o.clone(), ()),
118111
reporters: Default::default(),
119112
})
120113
.collect())
@@ -124,7 +117,7 @@ pub mod pallet {
124117
fn submit_offence(offenders: &[OffenceDetails<T>], slash_fraction: &[Perbill]) {
125118
let session_index = <pallet_session::Pallet<T> as frame_support::traits::ValidatorSet<T::AccountId>>::session_index();
126119

127-
<pallet_staking::Pallet<T> as OnOffenceHandler<
120+
<Staking<T> as OnOffenceHandler<
128121
T::AccountId,
129122
IdentificationTuple<T>,
130123
Weight,

substrate/frame/root-offences/src/mock.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ impl pallet_staking::Config for Test {
144144
}
145145

146146
impl pallet_session::historical::Config for Test {
147-
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
148-
type FullIdentificationOf = pallet_staking::ExposureOf<Test>;
147+
type FullIdentification = ();
148+
type FullIdentificationOf = pallet_staking::NullIdentity;
149149
}
150150

151151
sp_runtime::impl_opaque_keys! {

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ impl pallet_timestamp::Config for Test {
6868
type WeightInfo = ();
6969
}
7070
impl pallet_session::historical::Config for Test {
71-
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
72-
type FullIdentificationOf = pallet_staking::ExposureOf<Test>;
71+
type FullIdentification = ();
72+
type FullIdentificationOf = pallet_staking::NullIdentity;
7373
}
7474

7575
sp_runtime::impl_opaque_keys! {

substrate/frame/session/src/lib.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,6 @@ impl<T: Config> Pallet<T> {
661661
/// punishment after a fork.
662662
pub fn rotate_session() {
663663
let session_index = CurrentIndex::<T>::get();
664-
log::trace!(target: "runtime::session", "rotating session {:?}", session_index);
665-
666664
let changed = QueuedChanged::<T>::get();
667665

668666
// Inform the session handlers that a session is going to end.
@@ -684,11 +682,17 @@ impl<T: Config> Pallet<T> {
684682
// Increment session index.
685683
let session_index = session_index + 1;
686684
CurrentIndex::<T>::put(session_index);
687-
688685
T::SessionManager::start_session(session_index);
686+
log::trace!(target: "runtime::session", "starting_session {:?}", session_index);
689687

690688
// Get next validator set.
691689
let maybe_next_validators = T::SessionManager::new_session(session_index + 1);
690+
log::trace!(
691+
target: "runtime::session",
692+
"planning_session {:?} with {:?} validators",
693+
session_index + 1,
694+
maybe_next_validators.as_ref().map(|v| v.len())
695+
);
692696
let (next_validators, next_identities_changed) =
693697
if let Some(validators) = maybe_next_validators {
694698
// NOTE: as per the documentation on `OnSessionEnding`, we consider

substrate/frame/staking/src/lib.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -933,10 +933,7 @@ pub trait SessionInterface<AccountId> {
933933
impl<T: Config> SessionInterface<<T as frame_system::Config>::AccountId> for T
934934
where
935935
T: pallet_session::Config<ValidatorId = <T as frame_system::Config>::AccountId>,
936-
T: pallet_session::historical::Config<
937-
FullIdentification = Exposure<<T as frame_system::Config>::AccountId, BalanceOf<T>>,
938-
FullIdentificationOf = ExposureOf<T>,
939-
>,
936+
T: pallet_session::historical::Config,
940937
T::SessionHandler: pallet_session::SessionHandler<<T as frame_system::Config>::AccountId>,
941938
T::SessionManager: pallet_session::SessionManager<<T as frame_system::Config>::AccountId>,
942939
T::ValidatorIdOf: Convert<
@@ -1080,6 +1077,13 @@ impl<T: Config> Convert<T::AccountId, Option<Exposure<T::AccountId, BalanceOf<T>
10801077
}
10811078
}
10821079

1080+
pub struct NullIdentity;
1081+
impl<T> Convert<T, Option<()>> for NullIdentity {
1082+
fn convert(_: T) -> Option<()> {
1083+
Some(())
1084+
}
1085+
}
1086+
10831087
/// Filter historical offences out and only allow those from the bonding period.
10841088
pub struct FilterHistoricalOffences<T, R> {
10851089
_inner: core::marker::PhantomData<(T, R)>,

0 commit comments

Comments
 (0)