Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Generate storage info for Pallets Offences and Session #10113

Closed
wants to merge 94 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
9cb610c
Updating broken website link
Sep 20, 2021
5fba3bb
Updating rust example to FRAME 2.0 syntax
Sep 20, 2021
6d46910
Start of the implementation of adding storage_info
Sep 20, 2021
04d55f3
Continuing adding storage_info to pallet staking
Sep 21, 2021
a55274a
Implementing `MaxEncodedLen` on `PerThing`
Sep 21, 2021
578284f
Adding `force_push` to `WeakBoundedVec`
Sep 21, 2021
6a2a06e
Continue adding storage_info to staking pallet
Sep 22, 2021
97c4c9f
Implementing `PartialOrd` on `WeakBoundedVec`
Sep 22, 2021
d6ebf74
Implementing `Ord` for `WeakBoundedVec`
Sep 22, 2021
7c60ac5
Implementing `force_insert` on `WeakBoundedVec`
Sep 22, 2021
1fc848f
Implementing `truncate` on `WeakBoundedVec`
Sep 22, 2021
06830eb
Moved const `MAX_NOMINATIONS` to be a type
Sep 23, 2021
df969c6
Add `drain` to `BoundedVec` and `WeakBoundedVec`
Sep 23, 2021
8b4392a
Implementing `sort_by` on `WeakBoundedVec`
Sep 24, 2021
fc54a66
Implement `entry` on `BoundedBTreeMap`
Sep 24, 2021
8e358e5
Implement `last_mut` on `BoundedVec`
Sep 24, 2021
6f10ad3
Implement `pop` on `BoundedVec`
Sep 24, 2021
d415c3b
Implement `iter_mut` on `BoundedVec`
Sep 25, 2021
4563cab
Adding `storage_info` to pallet `staking`
Sep 25, 2021
7d6c9b6
Radical change: moving `MaxValidatorsCount` from
Sep 25, 2021
f0201b9
Merge branch 'master' of https://github.com/paritytech/substrate into…
Sep 25, 2021
243e038
Cleanups
Sep 25, 2021
e16f995
Fixing tests and some refactoring
Sep 25, 2021
5604e90
Fixed test cases
Sep 25, 2021
7473eca
Fixing docs
Sep 25, 2021
55d9d93
Fixing other pallets' tests
Sep 25, 2021
37d5d35
Fixing README
Sep 25, 2021
2dce1f1
Fixing test benchmarks
Sep 25, 2021
68fc710
fixing benchmark tests
Sep 25, 2021
abe2d61
Changing naming from `Nb` to `Count` nomenclature
Sep 26, 2021
a8f9dcc
Stop globally importing `ConstU32` and annotate
Sep 26, 2021
f8b5e80
No need for a full description, only scope is
Sep 26, 2021
87613b8
Only scope is needed in message
Sep 26, 2021
1230145
Better documentation punctuation
Sep 26, 2021
b83cda7
Removing few `[pallet::constant]`
Sep 26, 2021
a097ab6
Making MAX_UNLOCKING_CHUNKS become a runtime
Sep 26, 2021
b8e8559
Adding punctuation to documentation.
Sep 26, 2021
98526da
Fixing tests after changes to `MaxUnlockingChunks`
Sep 26, 2021
cc6729b
Test fixes
Sep 26, 2021
0c8fa9f
Test fixes
Sep 26, 2021
a024de5
Adding `MaxIndividualExposures` replacing
Sep 26, 2021
de68fd2
Fixing tests after adding `MaxIndividualExposures`
Sep 26, 2021
d3d61da
Merge branch 'paritytech:master' into staking-storage-info
georgesdib Sep 26, 2021
531f43a
Removing trailing whitespace
Sep 26, 2021
a9eef28
Merge branch 'staking-storage-info' of https://github.com/georgesdib/…
Sep 26, 2021
84d2b13
Fixing tests post merge
Sep 26, 2021
a2f7055
fmt
Sep 26, 2021
5705c25
Renaming `MaxNominatorRewardedPerValidator` to
Sep 27, 2021
38b4554
Merge branch 'master' of https://github.com/paritytech/substrate into…
Oct 2, 2021
2577c7d
Implementing `OrdNoBound` derive trait
Oct 2, 2021
0e6455a
Adding tests for `OrdNoBound`
Oct 2, 2021
a629627
Fixing tests, I must be running a different
Oct 2, 2021
1fc1a32
Implementing bounding
Oct 12, 2021
c51b29c
* Increasing `MaxIndividualExposures`
Oct 12, 2021
f35b5d2
Merge branch 'master' into staking-storage-info
Oct 12, 2021
545a98a
Make `OffendingValidators` a `BoundedVec`
Oct 12, 2021
e8aff29
Fixing fmt
Oct 12, 2021
a53cfc9
fmt
Oct 12, 2021
9105c63
fmt
Oct 12, 2021
570f7cb
Merge branch 'paritytech:master' into staking-storage-info
georgesdib Oct 13, 2021
9cd2bd6
Fixing tests
Oct 13, 2021
d70e2e6
Merge branch 'staking-storage-info' of https://github.com/georgesdib/…
Oct 13, 2021
b54368d
Adding storage info to frame session
Oct 20, 2021
c32bc2b
Merge branch 'staking-storage-info' into session-storage-info
Oct 20, 2021
22f7915
Removing duplicate
Oct 20, 2021
ba5ad35
Merge branch 'staking-storage-info-continue' into session-storage-info
Oct 20, 2021
184a8cb
Replacing `Vec` by `BoundedVec`
Oct 21, 2021
65d9591
Fixing election-provider-support
Oct 21, 2021
538dcd7
Adding `MaxEncodedLen` to `impl_opaque_keys`
Oct 21, 2021
6f1bf5a
Some more bounding conversions
Oct 21, 2021
21d87fc
Fixing tests
Oct 21, 2021
3a67669
Fixing more tests
Oct 22, 2021
4c1c74b
Some more test fixes
Oct 22, 2021
fb1d739
Merge branch 'master' of https://github.com/paritytech/substrate into…
Oct 22, 2021
d74bee4
Merging `MaxKeys` with `MaxValidatorsCount`
Oct 22, 2021
bae9525
Merging `MaxAuthorities` and `MaxValidatorsCount`
Oct 23, 2021
6d4e1d1
Bounding `OffenceDetails` and moving
Oct 24, 2021
8390471
Fixing tests
Oct 27, 2021
c32addb
Changing `Clone` to `CloneNoBound`
Oct 27, 2021
5910f5f
Fixing test after change to `CloneNoBound`
Oct 27, 2021
daaa48f
Adding missing `MaxReportersCount`
Oct 27, 2021
a1d4b45
Merge branch 'paritytech:master' into offences-storage-info
georgesdib Oct 27, 2021
c5a3ac5
Changing `BoundedVec` to `WeakBoundedVec`
Oct 30, 2021
4c8f9f8
Merge branch 'offences-storage-info' of https://github.com/georgesdib…
Oct 30, 2021
be3564a
Fixing tests after `BoundedVec` change
Oct 30, 2021
9b8f704
running cargo +nightly fmt
Nov 1, 2021
ba25494
missed one
Nov 1, 2021
052f17f
Merge branch 'master' of https://github.com/paritytech/substrate into…
Nov 1, 2021
77d320f
Fixing benchmarks
Nov 1, 2021
451d306
Fixing benchmarks
Nov 2, 2021
423b99c
removing unneeded import
Nov 2, 2021
5c8bb91
Merge branch 'master' into offences-storage-info
Nov 11, 2021
04aed17
cargo fmt
Nov 11, 2021
d24c5fc
Add `max-encoded-len` feature to `sp-arithmetic`
Nov 11, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ impl pallet_randomness_collective_flip::Config for Runtime {}

parameter_types! {
pub const MaxAuthorities: u32 = 32;
pub const MaxReportersCount: u32 = 100;
}

impl pallet_aura::Config for Runtime {
Expand All @@ -223,6 +224,7 @@ impl pallet_grandpa::Config for Runtime {

type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
type MaxReportersCount = MaxReportersCount;
}

parameter_types! {
Expand Down
46 changes: 35 additions & 11 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ impl pallet_babe::Config for Runtime {
pallet_babe::EquivocationHandler<Self::KeyOwnerIdentification, Offences, ReportLongevity>;

type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
type MaxAuthorities = MaxValidatorsCount;
type MaxReportersCount = MaxReportersCount;
}

parameter_types! {
Expand Down Expand Up @@ -473,10 +474,12 @@ impl pallet_session::Config for Runtime {
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = SessionKeys;
type WeightInfo = pallet_session::weights::SubstrateWeight<Runtime>;
type MaxValidatorsCount = MaxValidatorsCount;
type MaxKeysEncodingSize = MaxKeysEncodingSize;
}

impl pallet_session::historical::Config for Runtime {
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
type FullIdentification = pallet_staking::Exposure<AccountId, Balance, MaxIndividualExposures>;
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
}

Expand All @@ -496,19 +499,30 @@ parameter_types! {
pub const BondingDuration: pallet_staking::EraIndex = 24 * 28;
pub const SlashDeferDuration: pallet_staking::EraIndex = 24 * 7; // 1/4 the bonding duration.
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const MaxNominatorRewardedPerValidator: u32 = 256;
pub const MaxRewardableIndividualExposures: u32 = 256;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
pub OffchainRepeat: BlockNumber = 5;
pub const MaxIndividualExposures: u32 = 10_000;
pub const MaxNominations: u32 = MAX_NOMINATIONS;
pub const MaxUnappliedSlashes: u32 = 1_000;
pub const MaxInvulnerablesCount: u32 = 10;
pub const MaxHistoryDepth: u32 = 10_000;
pub const MaxReportersCount: u32 = 1_000;
pub const MaxPriorSlashingSpans: u32 = 1_000;
pub const MaxValidatorsCount: u32 = 4_000;
pub const MaxUnlockingChunks: u32 = 32;
pub const MaxKeysEncodingSize: u32 = 1_000;
}

use frame_election_provider_support::onchain;
impl onchain::Config for Runtime {
type Accuracy = Perbill;
type DataProvider = Staking;
type MaxNominations = MaxNominations;
type MaxTargets = MaxValidatorsCount;
}

impl pallet_staking::Config for Runtime {
const MAX_NOMINATIONS: u32 = MAX_NOMINATIONS;
type Currency = Balances;
type UnixTime = Timestamp;
type CurrencyToVote = U128CurrencyToVote;
Expand All @@ -528,14 +542,23 @@ impl pallet_staking::Config for Runtime {
type SessionInterface = Self;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type NextNewSession = Session;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type MaxRewardableIndividualExposures = MaxRewardableIndividualExposures;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type ElectionProvider = ElectionProviderMultiPhase;
type GenesisElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
// Alternatively, use pallet_staking::UseNominatorsMap<Runtime> to just use the nominators map.
// Note that the aforementioned does not scale to a very large number of nominators.
type SortedListProvider = BagsList;
type WeightInfo = pallet_staking::weights::SubstrateWeight<Runtime>;
type MaxIndividualExposures = MaxIndividualExposures;
type MaxNominations = MaxNominations;
type MaxUnappliedSlashes = MaxUnappliedSlashes;
type MaxInvulnerablesCount = MaxInvulnerablesCount;
type MaxHistoryDepth = MaxHistoryDepth;
type MaxReportersCount = MaxReportersCount;
type MaxPriorSlashingSpans = MaxPriorSlashingSpans;
type MaxValidatorsCount = MaxValidatorsCount;
type MaxUnlockingChunks = MaxUnlockingChunks;
}

parameter_types! {
Expand Down Expand Up @@ -591,7 +614,6 @@ impl pallet_election_provider_multi_phase::BenchmarkingConfig for BenchmarkConfi
const DESIRED_TARGETS: [u32; 2] = [200, 400];
const SNAPSHOT_MAXIMUM_VOTERS: u32 = 1000;
const MINER_MAXIMUM_VOTERS: u32 = 1000;
const MAXIMUM_TARGETS: u32 = 300;
}

/// Maximum number of iterations for balancing that will be executed in the embedded OCW
Expand Down Expand Up @@ -651,6 +673,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type ForceOrigin = EnsureRootOrHalfCouncil;
type BenchmarkingConfig = BenchmarkConfig;
type VoterSnapshotPerBlock = VoterSnapshotPerBlock;
type MaxTargets = MaxValidatorsCount;
}

parameter_types! {
Expand Down Expand Up @@ -936,8 +959,6 @@ parameter_types! {
pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
/// We prioritize im-online heartbeats over election solution submission.
pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2;
pub const MaxAuthorities: u32 = 100;
pub const MaxKeys: u32 = 10_000;
pub const MaxPeerInHeartbeats: u32 = 10_000;
pub const MaxPeerDataEncodingSize: u32 = 1_000;
}
Expand Down Expand Up @@ -1004,19 +1025,21 @@ impl pallet_im_online::Config for Runtime {
type ReportUnresponsiveness = Offences;
type UnsignedPriority = ImOnlineUnsignedPriority;
type WeightInfo = pallet_im_online::weights::SubstrateWeight<Runtime>;
type MaxKeys = MaxKeys;
type MaxKeys = MaxValidatorsCount;
type MaxPeerInHeartbeats = MaxPeerInHeartbeats;
type MaxPeerDataEncodingSize = MaxPeerDataEncodingSize;
type MaxReportersCount = MaxReportersCount;
}

impl pallet_offences::Config for Runtime {
type Event = Event;
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
type OnOffenceHandler = Staking;
type MaxReportersCount = MaxReportersCount;
}

impl pallet_authority_discovery::Config for Runtime {
type MaxAuthorities = MaxAuthorities;
type MaxAuthorities = MaxValidatorsCount;
}

impl pallet_grandpa::Config for Runtime {
Expand All @@ -1040,7 +1063,8 @@ impl pallet_grandpa::Config for Runtime {
>;

type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
type MaxAuthorities = MaxValidatorsCount;
type MaxReportersCount = MaxReportersCount;
}

parameter_types! {
Expand Down
1 change: 1 addition & 0 deletions frame/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub mod pallet {
+ Default
+ MaybeSerializeDeserialize
+ MaxEncodedLen;

/// The maximum number of authorities that the pallet can hold.
type MaxAuthorities: Get<u32>;

Expand Down
3 changes: 3 additions & 0 deletions frame/authority-discovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ mod tests {
parameter_types! {
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(33);
pub const MaxAuthorities: u32 = 100;
pub const MaxKeysEncodingSize: u32 = 1_000;
}

impl Config for Test {
Expand All @@ -217,6 +218,8 @@ mod tests {
type ValidatorId = AuthorityId;
type ValidatorIdOf = ConvertInto;
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
type MaxValidatorsCount = MaxAuthorities;
type MaxKeysEncodingSize = MaxKeysEncodingSize;
type WeightInfo = ();
}

Expand Down
11 changes: 6 additions & 5 deletions frame/babe/src/equivocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
//! that the `ValidateUnsigned` for the BABE pallet is used in the runtime
//! definition.

use frame_support::traits::{Get, KeyOwnerProofSystem};
use frame_support::traits::{Get, KeyOwnerProofSystem, ReportOffence};
use sp_consensus_babe::{EquivocationProof, Slot};
use sp_runtime::{
transaction_validity::{
Expand All @@ -43,7 +43,7 @@ use sp_runtime::{
DispatchResult, Perbill,
};
use sp_staking::{
offence::{Kind, Offence, OffenceError, ReportOffence},
offence::{Kind, Offence, OffenceError},
SessionIndex,
};
use sp_std::prelude::*;
Expand All @@ -62,7 +62,7 @@ pub trait HandleEquivocation<T: Config> {

/// Report an offence proved by the given reporters.
fn report_offence(
reporters: Vec<T::AccountId>,
reporters: frame_support::WeakBoundedVec<T::AccountId, T::MaxReportersCount>,
offence: BabeEquivocationOffence<T::KeyOwnerIdentification>,
) -> Result<(), OffenceError>;

Expand All @@ -83,7 +83,7 @@ impl<T: Config> HandleEquivocation<T> for () {
type ReportLongevity = ();

fn report_offence(
_reporters: Vec<T::AccountId>,
_reporters: frame_support::WeakBoundedVec<T::AccountId, T::MaxReportersCount>,
_offence: BabeEquivocationOffence<T::KeyOwnerIdentification>,
) -> Result<(), OffenceError> {
Ok(())
Expand Down Expand Up @@ -131,6 +131,7 @@ where
T::AccountId,
T::KeyOwnerIdentification,
BabeEquivocationOffence<T::KeyOwnerIdentification>,
T::MaxReportersCount,
>,
// The longevity (in blocks) that the equivocation report is valid for. When using the staking
// pallet this should be the bonding duration.
Expand All @@ -139,7 +140,7 @@ where
type ReportLongevity = L;

fn report_offence(
reporters: Vec<T::AccountId>,
reporters: frame_support::WeakBoundedVec<T::AccountId, T::MaxReportersCount>,
offence: BabeEquivocationOffence<T::KeyOwnerIdentification>,
) -> Result<(), OffenceError> {
R::report_offence(reporters, offence)
Expand Down
11 changes: 9 additions & 2 deletions frame/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ pub mod pallet {
/// Max number of authorities allowed
#[pallet::constant]
type MaxAuthorities: Get<u32>;

/// Maximum number of reporters.
#[pallet::constant]
type MaxReportersCount: Get<u32>;
}

#[pallet::error]
Expand Down Expand Up @@ -814,8 +818,11 @@ impl<T: Config> Pallet<T> {
BabeEquivocationOffence { slot, validator_set_count, offender, session_index };

let reporters = match reporter {
Some(id) => vec![id],
None => vec![],
Some(id) => WeakBoundedVec::<_, _>::force_from(
vec![id],
Some("pallet_babe.do_report_equivocation"),
),
None => WeakBoundedVec::default(),
};

T::HandleEquivocation::report_offence(reporters, offence)
Expand Down
32 changes: 28 additions & 4 deletions frame/babe/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@ impl pallet_session::Config for Test {
type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, Staking>;
type SessionHandler = <MockSessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = MockSessionKeys;
type MaxValidatorsCount = MaxValidatorsCount;
type MaxKeysEncodingSize = MaxKeysEncodingSize;
type WeightInfo = ();
}

impl pallet_session::historical::Config for Test {
type FullIdentification = pallet_staking::Exposure<u64, u128>;
type FullIdentification = pallet_staking::Exposure<u64, u128, MaxIndividualExposures>;
type FullIdentificationOf = pallet_staking::ExposureOf<Self>;
}

Expand Down Expand Up @@ -184,19 +186,30 @@ parameter_types! {
pub const SlashDeferDuration: EraIndex = 0;
pub const AttestationPeriod: u64 = 100;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const MaxNominatorRewardedPerValidator: u32 = 64;
pub const MaxRewardableIndividualExposures: u32 = 64;
pub const MaxIndividualExposures: u32 = 64;
pub const ElectionLookahead: u64 = 0;
pub const StakingUnsignedPriority: u64 = u64::MAX / 2;
pub const MaxNominations: u32 = 16;
pub const MaxUnappliedSlashes: u32 = 1_000;
pub const MaxInvulnerablesCount: u32 = 10;
pub const MaxHistoryDepth: u32 = 10_000;
pub const MaxReportersCount: u32 = 1_000;
pub const MaxPriorSlashingSpans: u32 = 1_000;
pub const MaxValidatorsCount: u32 = 4_000;
pub const MaxKeysEncodingSize: u32 = 1_000;
pub const MaxUnlockingChunks: u32 = 32;
pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(16);
}

impl onchain::Config for Test {
type Accuracy = Perbill;
type DataProvider = Staking;
type MaxNominations = MaxNominations;
type MaxTargets = MaxValidatorsCount;
}

impl pallet_staking::Config for Test {
const MAX_NOMINATIONS: u32 = 16;
type RewardRemainder = ();
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
type Event = Event;
Expand All @@ -210,7 +223,16 @@ impl pallet_staking::Config for Test {
type SessionInterface = Self;
type UnixTime = pallet_timestamp::Pallet<Test>;
type EraPayout = pallet_staking::ConvertCurve<RewardCurve>;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type MaxRewardableIndividualExposures = MaxRewardableIndividualExposures;
type MaxIndividualExposures = MaxIndividualExposures;
type MaxNominations = MaxNominations;
type MaxUnappliedSlashes = MaxUnappliedSlashes;
type MaxInvulnerablesCount = MaxInvulnerablesCount;
type MaxHistoryDepth = MaxHistoryDepth;
type MaxReportersCount = MaxReportersCount;
type MaxPriorSlashingSpans = MaxPriorSlashingSpans;
type MaxValidatorsCount = MaxValidatorsCount;
type MaxUnlockingChunks = MaxUnlockingChunks;
type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
type NextNewSession = Session;
type ElectionProvider = onchain::OnChainSequentialPhragmen<Self>;
Expand All @@ -223,6 +245,7 @@ impl pallet_offences::Config for Test {
type Event = Event;
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
type OnOffenceHandler = Staking;
type MaxReportersCount = MaxReportersCount;
}

parameter_types! {
Expand Down Expand Up @@ -254,6 +277,7 @@ impl Config for Test {

type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
type MaxReportersCount = MaxReportersCount;
}

pub fn go_to_block(n: u64, s: u64) {
Expand Down
12 changes: 6 additions & 6 deletions frame/babe/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,13 @@ fn report_equivocation_current_session_works() {
let validators = Session::validators();

// make sure that all authorities have the same balance
for validator in &validators {
for validator in &validators.to_vec() {
assert_eq!(Balances::total_balance(validator), 10_000_000);
assert_eq!(Staking::slashable_balance_of(validator), 10_000);

assert_eq!(
Staking::eras_stakers(1, validator),
pallet_staking::Exposure { total: 10_000, own: 10_000, others: vec![] },
pallet_staking::Exposure { total: 10_000, own: 10_000, others: Default::default() },
);
}

Expand Down Expand Up @@ -456,11 +456,11 @@ fn report_equivocation_current_session_works() {
assert_eq!(Staking::slashable_balance_of(&offending_validator_id), 0);
assert_eq!(
Staking::eras_stakers(2, offending_validator_id),
pallet_staking::Exposure { total: 0, own: 0, others: vec![] },
pallet_staking::Exposure { total: 0, own: 0, others: Default::default() },
);

// check that the balances of all other validators are left intact.
for validator in &validators {
for validator in &validators.to_vec() {
if *validator == offending_validator_id {
continue
}
Expand All @@ -469,7 +469,7 @@ fn report_equivocation_current_session_works() {
assert_eq!(Staking::slashable_balance_of(validator), 10_000);
assert_eq!(
Staking::eras_stakers(2, validator),
pallet_staking::Exposure { total: 10_000, own: 10_000, others: vec![] },
pallet_staking::Exposure { total: 10_000, own: 10_000, others: Default::default() },
);
}
})
Expand Down Expand Up @@ -528,7 +528,7 @@ fn report_equivocation_old_session_works() {
assert_eq!(Staking::slashable_balance_of(&offending_validator_id), 0);
assert_eq!(
Staking::eras_stakers(3, offending_validator_id),
pallet_staking::Exposure { total: 0, own: 0, others: vec![] },
pallet_staking::Exposure { total: 0, own: 0, others: Default::default() },
);
})
}
Expand Down
1 change: 1 addition & 0 deletions frame/bags-list/remote-tests/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub async fn execute<Runtime: crate::RuntimeT, Block: BlockT + DeserializeOwned>
let voters = <pallet_staking::Pallet<Runtime> as ElectionDataProvider<
Runtime::AccountId,
Runtime::BlockNumber,
Runtime::MaxValidatorsCount,
>>::voters(voter_limit)
.unwrap();

Expand Down
Loading