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

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizdave97 committed Jan 25, 2022
2 parents b213cce + 9e9e4d3 commit d0846ed
Show file tree
Hide file tree
Showing 46 changed files with 1,496 additions and 1,093 deletions.
6 changes: 3 additions & 3 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use hex_literal::hex;
use node_runtime::{
constants::currency::*, wasm_binary_unwrap, AuthorityDiscoveryConfig, BabeConfig,
BalancesConfig, Block, CouncilConfig, DemocracyConfig, ElectionsConfig, GrandpaConfig,
ImOnlineConfig, IndicesConfig, SessionConfig, SessionKeys, SocietyConfig, StakerStatus,
StakingConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig, MAX_NOMINATIONS,
ImOnlineConfig, IndicesConfig, MaxNominations, SessionConfig, SessionKeys, SocietyConfig,
StakerStatus, StakingConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig,
};
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use sc_chain_spec::ChainSpecExtension;
Expand Down Expand Up @@ -278,7 +278,7 @@ pub fn testnet_genesis(
.map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator))
.chain(initial_nominators.iter().map(|x| {
use rand::{seq::SliceRandom, Rng};
let limit = (MAX_NOMINATIONS as usize).min(initial_authorities.len());
let limit = (MaxNominations::get() as usize).min(initial_authorities.len());
let count = rng.gen::<usize>() % limit;
let nominations = initial_authorities
.as_slice()
Expand Down
8 changes: 5 additions & 3 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig {
}

impl pallet_staking::Config for Runtime {
const MAX_NOMINATIONS: u32 = MAX_NOMINATIONS;
type MaxNominations = MaxNominations;
type Currency = Balances;
type UnixTime = Timestamp;
type CurrencyToVote = U128CurrencyToVote;
Expand Down Expand Up @@ -605,7 +605,9 @@ sp_npos_elections::generate_solution_type!(
>(16)
);

pub const MAX_NOMINATIONS: u32 = <NposSolution16 as sp_npos_elections::NposSolution>::LIMIT as u32;
parameter_types! {
pub MaxNominations: u32 = <NposSolution16 as sp_npos_elections::NposSolution>::LIMIT as u32;
}

/// The numbers configured here could always be more than the the maximum limits of staking pallet
/// to ensure election snapshot will not run out of memory. For now, we set them to smaller values
Expand Down Expand Up @@ -1792,7 +1794,7 @@ mod tests {
#[test]
fn perbill_as_onchain_accuracy() {
type OnChainAccuracy = <Runtime as onchain::Config>::Accuracy;
let maximum_chain_accuracy: Vec<UpperOf<OnChainAccuracy>> = (0..MAX_NOMINATIONS)
let maximum_chain_accuracy: Vec<UpperOf<OnChainAccuracy>> = (0..MaxNominations::get())
.map(|_| <UpperOf<OnChainAccuracy>>::from(OnChainAccuracy::one().deconstruct()))
.collect();
let _: UpperOf<OnChainAccuracy> =
Expand Down
2 changes: 1 addition & 1 deletion frame/babe/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl onchain::Config for Test {
}

impl pallet_staking::Config for Test {
const MAX_NOMINATIONS: u32 = 16;
type MaxNominations = ConstU32<16>;
type RewardRemainder = ();
type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote;
type Event = Event;
Expand Down
23 changes: 22 additions & 1 deletion frame/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,29 @@ pub mod pallet {
#[pallet::getter(fn total_issuance)]
pub type TotalIssuance<T: Config<I>, I: 'static = ()> = StorageValue<_, T::Balance, ValueQuery>;

/// The balance of an account.
/// The Balances pallet example of storing the balance of an account.
///
/// # Example
///
/// ```nocompile
/// impl pallet_balances::Config for Runtime {
/// type AccountStore = StorageMapShim<Self::Account<Runtime>, frame_system::Provider<Runtime>, AccountId, Self::AccountData<Balance>>
/// }
/// ```
///
/// You can also store the balance of an account in the `System` pallet.
///
/// # Example
///
/// ```nocompile
/// impl pallet_balances::Config for Runtime {
/// type AccountStore = System
/// }
/// ```
///
/// But this comes with tradeoffs, storing account balances in the system pallet stores
/// `frame_system` data alongside the account data contrary to storing account balances in the
/// `Balances` pallet, which uses a `StorageMap` to store balances data only.
/// NOTE: This is only used in the case that this pallet is used to store balances.
#[pallet::storage]
pub type Account<T: Config<I>, I: 'static = ()> = StorageMap<
Expand Down
Loading

0 comments on commit d0846ed

Please sign in to comment.