Skip to content
This repository has been 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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Adding storage_info to pallet staking
pallet compiles!
Georges Dib committed Sep 25, 2021
commit 4563cab2301f8a55e7f39ec1fac065d247aee6dd
6 changes: 3 additions & 3 deletions frame/election-provider-multi-phase/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -156,7 +156,7 @@ fn set_up_data_provider<T: Config>(v: u32, t: u32) {
info,
"setting up with voters = {} [degree = {}], targets = {}",
v,
T::DataProvider::MAXIMUM_VOTES_PER_VOTER,
T::DataProvider::MaximumVotesPerVoter::get(),
t
);

@@ -169,8 +169,8 @@ fn set_up_data_provider<T: Config>(v: u32, t: u32) {
})
.collect::<Vec<_>>();
// we should always have enough voters to fill.
assert!(targets.len() > T::DataProvider::MAXIMUM_VOTES_PER_VOTER as usize);
targets.truncate(T::DataProvider::MAXIMUM_VOTES_PER_VOTER as usize);
assert!(targets.len() > T::DataProvider::MaximumVotesPerVoter::get() as usize);
targets.truncate(T::DataProvider::MaximumVotesPerVoter::get() as usize);

// fill voters.
(0..v).for_each(|i| {
2 changes: 1 addition & 1 deletion frame/election-provider-multi-phase/src/lib.rs
Original file line number Diff line number Diff line change
@@ -807,7 +807,7 @@ pub mod pallet {
// NOTE that this pallet does not really need to enforce this in runtime. The
// solution cannot represent any voters more than `LIMIT` anyhow.
assert_eq!(
<T::DataProvider as ElectionDataProvider<T::AccountId, T::BlockNumber>>::MAXIMUM_VOTES_PER_VOTER,
<T::DataProvider as ElectionDataProvider<T::AccountId, T::BlockNumber>>::MaximumVotesPerVoter::get(),
<SolutionOf<T> as NposSolution>::LIMIT as u32,
);
}
2 changes: 1 addition & 1 deletion frame/election-provider-multi-phase/src/mock.rs
Original file line number Diff line number Diff line change
@@ -421,7 +421,7 @@ pub struct ExtBuilder {}

pub struct StakingMock;
impl ElectionDataProvider<AccountId, u64> for StakingMock {
const MAXIMUM_VOTES_PER_VOTER: u32 = <TestNposSolution as NposSolution>::LIMIT as u32;
type MaximumVotesPerVoter = ConstU32<<TestNposSolution as NposSolution>::LIMIT as u32>;
fn targets(maybe_max_len: Option<usize>) -> data_provider::Result<Vec<AccountId>> {
let targets = Targets::get();

8 changes: 4 additions & 4 deletions frame/election-provider-support/src/lib.rs
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@
//! pub struct Module<T: Config>(std::marker::PhantomData<T>);
//!
//! impl<T: Config> ElectionDataProvider<AccountId, BlockNumber> for Module<T> {
//! const MAXIMUM_VOTES_PER_VOTER: u32 = 1;
//! type MaximumVotesPerVoter = ConstU32<1>;
//! fn desired_targets() -> data_provider::Result<u32> {
//! Ok(1)
//! }
@@ -161,7 +161,7 @@
#![cfg_attr(not(feature = "std"), no_std)]

pub mod onchain;
use frame_support::traits::Get;
use frame_support::{pallet_prelude::ConstU32, traits::Get};
use sp_std::{fmt::Debug, prelude::*};

/// Re-export some type as they are used in the interface.
@@ -180,7 +180,7 @@ pub mod data_provider {
/// Something that can provide the data to an [`ElectionProvider`].
pub trait ElectionDataProvider<AccountId, BlockNumber> {
/// Maximum number of votes per voter that this data provider is providing.
const MAXIMUM_VOTES_PER_VOTER: u32;
type MaximumVotesPerVoter: Get<u32>;

/// All possible targets for the election, i.e. the candidates.
///
@@ -249,7 +249,7 @@ pub trait ElectionDataProvider<AccountId, BlockNumber> {

#[cfg(feature = "std")]
impl<AccountId, BlockNumber> ElectionDataProvider<AccountId, BlockNumber> for () {
const MAXIMUM_VOTES_PER_VOTER: u32 = 0;
type MaximumVotesPerVoter = ConstU32<0>;
fn targets(_maybe_max_len: Option<usize>) -> data_provider::Result<Vec<AccountId>> {
Ok(Default::default())
}
2 changes: 1 addition & 1 deletion frame/election-provider-support/src/onchain.rs
Original file line number Diff line number Diff line change
@@ -160,7 +160,7 @@ mod tests {

pub struct DataProvider;
impl ElectionDataProvider<AccountId, BlockNumber> for DataProvider {
const MAXIMUM_VOTES_PER_VOTER: u32 = 2;
type MaximumVotesPerVoter = ConstU32<2>;
fn voters(
_: Option<usize>,
) -> data_provider::Result<Vec<(AccountId, VoteWeight, Vec<AccountId>)>> {
12 changes: 9 additions & 3 deletions frame/staking/src/pallet/impls.rs
Original file line number Diff line number Diff line change
@@ -869,7 +869,7 @@ impl<T: Config> Pallet<T> {
}

impl<T: Config> ElectionDataProvider<T::AccountId, BlockNumberFor<T>> for Pallet<T> {
const MAXIMUM_VOTES_PER_VOTER: u32 = T::MaxNominations::get();
type MaximumVotesPerVoter = T::MaxNominations;

fn desired_targets() -> data_provider::Result<u32> {
Self::register_weight(T::DbWeight::get().reads(1));
@@ -1251,7 +1251,7 @@ where
add_db_reads_writes(rw, rw);
}
unapplied.reporters = WeakBoundedVec::<_, T::MaxNbOfReporters>::force_from(
details.reporters,
details.reporters.clone(),
Some(
"Warning: Number of reporters is bigger than expected. \
A runtime parameter adjustment may be needed.",
@@ -1271,7 +1271,13 @@ where
} else {
// Defer to end of some `slash_defer_duration` from now.
<Self as Store>::UnappliedSlashes::mutate(active_era, move |for_later| {
for_later.push(unapplied)
for_later.force_push(
unapplied,
Some(
"Warning: More unapplied stashes than expected. \
A runtime parameter adjustment may be needed.",
),
)
});
add_db_reads_writes(1, 1);
}
6 changes: 3 additions & 3 deletions frame/staking/src/pallet/mod.rs
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ pub mod pallet {

/// Maximum number of nominations per nominator.
#[pallet::constant]
type MaxNominations: Get<SessionIndex>;
type MaxNominations: Get<u32>;

/// Tokens have been minted and are unused for validator-reward.
/// See [Era payout](./index.html#era-payout).
@@ -556,7 +556,7 @@ pub mod pallet {
MinValidatorBond::<T>::put(self.min_validator_bond);

let invulnerables = BoundedVec::<_, T::MaxNbOfInvulnerables>::try_from(
self.invulnerables,
self.invulnerables.clone(),
)
.expect("Too many invulnerables passed, a runtime parameters adjustment may be needed");
Invulnerables::<T>::put(&invulnerables);
@@ -927,7 +927,7 @@ pub mod pallet {
ledger
.unlocking
.try_push(UnlockChunk { value, era })
.map_err(|_| Error::<T>::NoMoreChunks);
.map_err(|_| Error::<T>::NoMoreChunks)?;
// NOTE: ledger must be updated prior to calling `Self::weight_of`.
Self::update_ledger(&controller, &ledger);