diff --git a/substrate/bin/node-template/pallets/template/src/mock.rs b/substrate/bin/node-template/pallets/template/src/mock.rs index 733ac79d65..8721fe6c78 100644 --- a/substrate/bin/node-template/pallets/template/src/mock.rs +++ b/substrate/bin/node-template/pallets/template/src/mock.rs @@ -1,5 +1,5 @@ use crate as pallet_template; -use frame_support::parameter_types; +use frame_support::traits::{ConstU16, ConstU64}; use frame_system as system; use sp_core::H256; use sp_runtime::{ @@ -22,11 +22,6 @@ frame_support::construct_runtime!( } ); -parameter_types! { - pub const BlockHashCount: u64 = 250; - pub const SS58Prefix: u8 = 42; -} - impl system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = (); @@ -42,14 +37,14 @@ impl system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); - type SS58Prefix = SS58Prefix; + type SS58Prefix = ConstU16<42>; type OnSetCode = (); type MaxConsumers = frame_support::traits::ConstU32<16>; } diff --git a/substrate/bin/node-template/runtime/src/lib.rs b/substrate/bin/node-template/runtime/src/lib.rs index 335b36fe2f..5c277a1bb7 100644 --- a/substrate/bin/node-template/runtime/src/lib.rs +++ b/substrate/bin/node-template/runtime/src/lib.rs @@ -26,7 +26,7 @@ use sp_version::RuntimeVersion; // A few exports that help ease life for downstream crates. pub use frame_support::{ construct_runtime, parameter_types, - traits::{ConstU32, KeyOwnerProofSystem, Randomness, StorageInfo}, + traits::{ConstU128, ConstU32, ConstU8, KeyOwnerProofSystem, Randomness, StorageInfo}, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, IdentityFee, Weight, @@ -196,14 +196,10 @@ impl frame_system::Config for Runtime { impl pallet_randomness_collective_flip::Config for Runtime {} -parameter_types! { - pub const MaxAuthorities: u32 = 32; -} - impl pallet_aura::Config for Runtime { type AuthorityId = AuraId; type DisabledValidators = (); - type MaxAuthorities = MaxAuthorities; + type MaxAuthorities = ConstU32<32>; } impl pallet_grandpa::Config for Runtime { @@ -223,7 +219,7 @@ impl pallet_grandpa::Config for Runtime { type HandleEquivocation = (); type WeightInfo = (); - type MaxAuthorities = MaxAuthorities; + type MaxAuthorities = ConstU32<32>; } parameter_types! { @@ -238,13 +234,8 @@ impl pallet_timestamp::Config for Runtime { type WeightInfo = (); } -parameter_types! { - pub const ExistentialDeposit: u128 = 500; - pub const MaxLocks: u32 = 50; -} - impl pallet_balances::Config for Runtime { - type MaxLocks = MaxLocks; + type MaxLocks = ConstU32<50>; type MaxReserves = (); type ReserveIdentifier = [u8; 8]; /// The type for recording an account's balance. @@ -252,20 +243,19 @@ impl pallet_balances::Config for Runtime { /// The ubiquitous event type. type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU128<500>; type AccountStore = System; type WeightInfo = pallet_balances::weights::SubstrateWeight; } parameter_types! { pub const TransactionByteFee: Balance = 1; - pub OperationalFeeMultiplier: u8 = 5; } impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = CurrencyAdapter; type TransactionByteFee = TransactionByteFee; - type OperationalFeeMultiplier = OperationalFeeMultiplier; + type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = IdentityFee; type FeeMultiplierUpdate = (); } diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index e61a46abeb..97de54fc21 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -26,8 +26,8 @@ use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ construct_runtime, parameter_types, traits::{ - ConstU128, ConstU32, Currency, EnsureOneOf, EqualPrivilegeOnly, Everything, Imbalance, - InstanceFilter, KeyOwnerProofSystem, LockIdentifier, Nothing, OnUnbalanced, + ConstU128, ConstU16, ConstU32, Currency, EnsureOneOf, EqualPrivilegeOnly, Everything, + Imbalance, InstanceFilter, KeyOwnerProofSystem, LockIdentifier, Nothing, OnUnbalanced, U128CurrencyToVote, }, weights::{ @@ -191,7 +191,6 @@ parameter_types! { }) .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) .build_or_panic(); - pub const SS58Prefix: u16 = 42; } const_assert!(NORMAL_DISPATCH_RATIO.deconstruct() >= AVERAGE_ON_INITIALIZE_RATIO.deconstruct()); @@ -218,7 +217,7 @@ impl frame_system::Config for Runtime { type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = frame_system::weights::SubstrateWeight; - type SS58Prefix = SS58Prefix; + type SS58Prefix = ConstU16<42>; type OnSetCode = (); type MaxConsumers = frame_support::traits::ConstU32<16>; } @@ -237,7 +236,6 @@ parameter_types! { pub const DepositBase: Balance = deposit(1, 88); // Additional storage item size of 32 bytes. pub const DepositFactor: Balance = deposit(0, 32); - pub const MaxSignatories: u16 = 100; } impl pallet_multisig::Config for Runtime { @@ -246,7 +244,7 @@ impl pallet_multisig::Config for Runtime { type Currency = Balances; type DepositBase = DepositBase; type DepositFactor = DepositFactor; - type MaxSignatories = MaxSignatories; + type MaxSignatories = ConstU16<100>; type WeightInfo = pallet_multisig::weights::SubstrateWeight; } @@ -255,10 +253,8 @@ parameter_types! { pub const ProxyDepositBase: Balance = deposit(1, 8); // Additional storage item size of 33 bytes. pub const ProxyDepositFactor: Balance = deposit(0, 33); - pub const MaxProxies: u16 = 32; pub const AnnouncementDepositBase: Balance = deposit(1, 8); pub const AnnouncementDepositFactor: Balance = deposit(0, 66); - pub const MaxPending: u16 = 32; } /// The type used to represent the kinds of proxying allowed. @@ -325,9 +321,9 @@ impl pallet_proxy::Config for Runtime { type ProxyType = ProxyType; type ProxyDepositBase = ProxyDepositBase; type ProxyDepositFactor = ProxyDepositFactor; - type MaxProxies = MaxProxies; + type MaxProxies = ConstU32<32>; type WeightInfo = pallet_proxy::weights::SubstrateWeight; - type MaxPending = MaxPending; + type MaxPending = ConstU32<32>; type CallHasher = BlakeTwo256; type AnnouncementDepositBase = AnnouncementDepositBase; type AnnouncementDepositFactor = AnnouncementDepositFactor; @@ -336,7 +332,6 @@ impl pallet_proxy::Config for Runtime { parameter_types! { pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * RuntimeBlockWeights::get().max_block; - pub const MaxScheduledPerBlock: u32 = 50; // Retry a scheduled item every 10 blocks (1 minute) until the preimage exists. pub const NoPreimagePostponement: Option = Some(10); } @@ -348,7 +343,7 @@ impl pallet_scheduler::Config for Runtime { type Call = Call; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureRoot; - type MaxScheduledPerBlock = MaxScheduledPerBlock; + type MaxScheduledPerBlock = ConstU32<50>; type WeightInfo = pallet_scheduler::weights::SubstrateWeight; type OriginPrivilegeCmp = EqualPrivilegeOnly; type PreimageProvider = Preimage; @@ -581,7 +576,6 @@ parameter_types! { pub const UnsignedPhase: u32 = EPOCH_DURATION_IN_BLOCKS / 4; // signed config - pub const SignedMaxSubmissions: u32 = 10; pub const SignedRewardBase: Balance = 1 * DOLLARS; pub const SignedDepositBase: Balance = 1 * DOLLARS; pub const SignedDepositByte: Balance = 1 * CENTS; @@ -599,11 +593,6 @@ parameter_types! { *RuntimeBlockLength::get() .max .get(DispatchClass::Normal); - - // BagsList allows a practically unbounded count of nominators to participate in NPoS elections. - // To ensure we respect memory limits when using the BagsList this must be set to a number of - // voters we know can fit into a single vec allocation. - pub const VoterSnapshotPerBlock: u32 = 10_000; } sp_npos_elections::generate_solution_type!( @@ -668,7 +657,7 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type MinerMaxWeight = MinerMaxWeight; type MinerMaxLength = MinerMaxLength; type MinerTxPriority = MultiPhaseUnsignedPriority; - type SignedMaxSubmissions = SignedMaxSubmissions; + type SignedMaxSubmissions = ConstU32<10>; type SignedRewardBase = SignedRewardBase; type SignedDepositBase = SignedDepositBase; type SignedDepositByte = SignedDepositByte; @@ -687,7 +676,10 @@ impl pallet_election_provider_multi_phase::Config for Runtime { type WeightInfo = pallet_election_provider_multi_phase::weights::SubstrateWeight; type ForceOrigin = EnsureRootOrHalfCouncil; type BenchmarkingConfig = ElectionProviderBenchmarkConfig; - type VoterSnapshotPerBlock = VoterSnapshotPerBlock; + // BagsList allows a practically unbounded count of nominators to participate in NPoS elections. + // To ensure we respect memory limits when using the BagsList this must be set to a number of + // voters we know can fit into a single vec allocation. + type VoterSnapshotPerBlock = ConstU32<10_000>; } parameter_types! { @@ -705,11 +697,9 @@ parameter_types! { pub const LaunchPeriod: BlockNumber = 28 * 24 * 60 * MINUTES; pub const VotingPeriod: BlockNumber = 28 * 24 * 60 * MINUTES; pub const FastTrackVotingPeriod: BlockNumber = 3 * 24 * 60 * MINUTES; - pub const InstantAllowed: bool = true; pub const MinimumDeposit: Balance = 100 * DOLLARS; pub const EnactmentPeriod: BlockNumber = 30 * 24 * 60 * MINUTES; pub const CooloffPeriod: BlockNumber = 28 * 24 * 60 * MINUTES; - pub const MaxVotes: u32 = 100; pub const MaxProposals: u32 = 100; } @@ -738,7 +728,7 @@ impl pallet_democracy::Config for Runtime { pallet_collective::EnsureProportionAtLeast<_2, _3, AccountId, TechnicalCollective>; type InstantOrigin = pallet_collective::EnsureProportionAtLeast<_1, _1, AccountId, TechnicalCollective>; - type InstantAllowed = InstantAllowed; + type InstantAllowed = frame_support::traits::ConstBool; type FastTrackVotingPeriod = FastTrackVotingPeriod; // To cancel a proposal which has been passed, 2/3 of the council must agree to it. type CancellationOrigin = @@ -759,7 +749,7 @@ impl pallet_democracy::Config for Runtime { type Slash = Treasury; type Scheduler = Scheduler; type PalletsOrigin = OriginCaller; - type MaxVotes = MaxVotes; + type MaxVotes = frame_support::traits::ConstU32<100>; type WeightInfo = pallet_democracy::weights::SubstrateWeight; type MaxProposals = MaxProposals; } diff --git a/substrate/frame/atomic-swap/src/tests.rs b/substrate/frame/atomic-swap/src/tests.rs index 47e33252e0..2352e7852d 100644 --- a/substrate/frame/atomic-swap/src/tests.rs +++ b/substrate/frame/atomic-swap/src/tests.rs @@ -3,7 +3,10 @@ use super::*; use crate as pallet_atomic_swap; -use frame_support::parameter_types; +use frame_support::{ + parameter_types, + traits::{ConstU32, ConstU64}, +}; use sp_core::H256; use sp_runtime::{ testing::Header, @@ -26,7 +29,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -45,7 +47,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -56,9 +58,7 @@ impl frame_system::Config for Test { type OnSetCode = (); type MaxConsumers = frame_support::traits::ConstU32<16>; } -parameter_types! { - pub const ExistentialDeposit: u64 = 1; -} + impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); @@ -66,18 +66,15 @@ impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); type Event = Event; - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } -parameter_types! { - pub const ProofLimit: u32 = 1024; - pub const ExpireDuration: u64 = 100; -} + impl Config for Test { type Event = Event; type SwapAction = BalanceSwapAction; - type ProofLimit = ProofLimit; + type ProofLimit = ConstU32<1024>; } const A: u64 = 1; diff --git a/substrate/frame/aura/src/mock.rs b/substrate/frame/aura/src/mock.rs index 12748bd212..b9df2cfa0e 100644 --- a/substrate/frame/aura/src/mock.rs +++ b/substrate/frame/aura/src/mock.rs @@ -22,7 +22,7 @@ use crate as pallet_aura; use frame_support::{ parameter_types, - traits::{DisabledValidators, GenesisBuild}, + traits::{ConstU32, ConstU64, DisabledValidators, GenesisBuild}, }; use sp_consensus_aura::{ed25519::AuthorityId, AuthorityIndex}; use sp_core::H256; @@ -48,10 +48,8 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); - pub const MinimumPeriod: u64 = 1; } impl frame_system::Config for Test { @@ -69,7 +67,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -84,14 +82,10 @@ impl frame_system::Config for Test { impl pallet_timestamp::Config for Test { type Moment = u64; type OnTimestampSet = Aura; - type MinimumPeriod = MinimumPeriod; + type MinimumPeriod = ConstU64<1>; type WeightInfo = (); } -parameter_types! { - pub const MaxAuthorities: u32 = 10; -} - thread_local! { static DISABLED_VALIDATORS: RefCell> = RefCell::new(Default::default()); } @@ -118,7 +112,7 @@ impl DisabledValidators for MockDisabledValidators { impl pallet_aura::Config for Test { type AuthorityId = AuthorityId; type DisabledValidators = MockDisabledValidators; - type MaxAuthorities = MaxAuthorities; + type MaxAuthorities = ConstU32<10>; } pub fn new_test_ext(authorities: Vec) -> sp_io::TestExternalities { diff --git a/substrate/frame/authority-discovery/src/lib.rs b/substrate/frame/authority-discovery/src/lib.rs index c867f98af3..5f905e9256 100644 --- a/substrate/frame/authority-discovery/src/lib.rs +++ b/substrate/frame/authority-discovery/src/lib.rs @@ -173,7 +173,10 @@ impl OneSessionHandler for Pallet { mod tests { use super::*; use crate as pallet_authority_discovery; - use frame_support::{parameter_types, traits::GenesisBuild}; + use frame_support::{ + parameter_types, + traits::{ConstU32, ConstU64, GenesisBuild}, + }; use sp_application_crypto::Pair; use sp_authority_discovery::AuthorityPair; use sp_core::{crypto::key_types, H256}; @@ -201,11 +204,10 @@ mod tests { parameter_types! { pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(33); - pub const MaxAuthorities: u32 = 100; } impl Config for Test { - type MaxAuthorities = MaxAuthorities; + type MaxAuthorities = ConstU32<100>; } impl pallet_session::Config for Test { @@ -230,8 +232,6 @@ mod tests { parameter_types! { pub const Period: BlockNumber = 1; pub const Offset: BlockNumber = 0; - pub const UncleGenerations: u64 = 0; - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -251,7 +251,7 @@ mod tests { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -260,7 +260,7 @@ mod tests { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } pub struct TestSessionHandler; diff --git a/substrate/frame/authorship/src/lib.rs b/substrate/frame/authorship/src/lib.rs index 98dd8f1ce6..297f74ce8b 100644 --- a/substrate/frame/authorship/src/lib.rs +++ b/substrate/frame/authorship/src/lib.rs @@ -405,7 +405,11 @@ impl Pallet { mod tests { use super::*; use crate as pallet_authorship; - use frame_support::{parameter_types, ConsensusEngineId}; + use frame_support::{ + parameter_types, + traits::{ConstU32, ConstU64}, + ConsensusEngineId, + }; use sp_core::H256; use sp_runtime::{ generic::DigestItem, @@ -428,7 +432,6 @@ mod tests { ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -448,7 +451,7 @@ mod tests { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -457,16 +460,12 @@ mod tests { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; - } - - parameter_types! { - pub const UncleGenerations: u64 = 5; + type MaxConsumers = ConstU32<16>; } impl pallet::Config for Test { type FindAuthor = AuthorGiven; - type UncleGenerations = UncleGenerations; + type UncleGenerations = ConstU64<5>; type FilterUncle = SealVerify; type EventHandler = (); } diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index f3325d0c65..90051770b8 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -22,7 +22,7 @@ use codec::Encode; use frame_election_provider_support::onchain; use frame_support::{ parameter_types, - traits::{GenesisBuild, KeyOwnerProofSystem, OnInitialize}, + traits::{ConstU128, ConstU32, ConstU64, GenesisBuild, KeyOwnerProofSystem, OnInitialize}, }; use frame_system::InitKind; use pallet_session::historical as pallet_session_historical; @@ -67,7 +67,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -88,7 +87,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; type OnNewAccount = (); @@ -130,32 +129,20 @@ impl pallet_session::historical::Config for Test { type FullIdentificationOf = pallet_staking::ExposureOf; } -parameter_types! { - pub const UncleGenerations: u64 = 0; -} - impl pallet_authorship::Config for Test { type FindAuthor = pallet_session::FindAccountFromAuthorIndex; - type UncleGenerations = UncleGenerations; + type UncleGenerations = ConstU64<0>; type FilterUncle = (); type EventHandler = (); } -parameter_types! { - pub const MinimumPeriod: u64 = 1; -} - impl pallet_timestamp::Config for Test { type Moment = u64; type OnTimestampSet = Babe; - type MinimumPeriod = MinimumPeriod; + type MinimumPeriod = ConstU64<1>; type WeightInfo = (); } -parameter_types! { - pub const ExistentialDeposit: u128 = 1; -} - impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); @@ -163,7 +150,7 @@ impl pallet_balances::Config for Test { type Balance = u128; type DustRemoval = (); type Event = Event; - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU128<1>; type AccountStore = System; type WeightInfo = (); } @@ -183,11 +170,7 @@ parameter_types! { pub const SessionsPerEra: SessionIndex = 3; pub const BondingDuration: EraIndex = 3; 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 ElectionLookahead: u64 = 0; - pub const StakingUnsignedPriority: u64 = u64::MAX / 2; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(16); } @@ -211,7 +194,7 @@ impl pallet_staking::Config for Test { type SessionInterface = Self; type UnixTime = pallet_timestamp::Pallet; type EraPayout = pallet_staking::ConvertCurve; - type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; + type MaxNominatorRewardedPerValidator = ConstU32<64>; type OffendingValidatorsThreshold = OffendingValidatorsThreshold; type NextNewSession = Session; type ElectionProvider = onchain::OnChainSequentialPhragmen; @@ -229,15 +212,13 @@ impl pallet_offences::Config for Test { parameter_types! { pub const EpochDuration: u64 = 3; - pub const ExpectedBlockTime: u64 = 1; pub const ReportLongevity: u64 = BondingDuration::get() as u64 * SessionsPerEra::get() as u64 * EpochDuration::get(); - pub const MaxAuthorities: u32 = 10; } impl Config for Test { type EpochDuration = EpochDuration; - type ExpectedBlockTime = ExpectedBlockTime; + type ExpectedBlockTime = ConstU64<1>; type EpochChangeTrigger = crate::ExternalTrigger; type DisabledValidators = Session; @@ -255,7 +236,7 @@ impl Config for Test { super::EquivocationHandler; type WeightInfo = (); - type MaxAuthorities = MaxAuthorities; + type MaxAuthorities = ConstU32<10>; } pub fn go_to_block(n: u64, s: u64) { diff --git a/substrate/frame/balances/src/tests_composite.rs b/substrate/frame/balances/src/tests_composite.rs index b1a7f2417d..15648d7356 100644 --- a/substrate/frame/balances/src/tests_composite.rs +++ b/substrate/frame/balances/src/tests_composite.rs @@ -22,6 +22,7 @@ use crate::{self as pallet_balances, decl_tests, Config, Pallet}; use frame_support::{ parameter_types, + traits::{ConstU32, ConstU64, ConstU8}, weights::{DispatchInfo, IdentityFee, Weight}, }; use pallet_transaction_payment::CurrencyAdapter; @@ -44,7 +45,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); pub static ExistentialDeposit: u64 = 0; @@ -64,7 +64,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = super::AccountData; @@ -75,22 +75,15 @@ impl frame_system::Config for Test { type OnSetCode = (); type MaxConsumers = frame_support::traits::ConstU32<16>; } -parameter_types! { - pub const TransactionByteFee: u64 = 1; - pub const OperationalFeeMultiplier: u8 = 5; -} + impl pallet_transaction_payment::Config for Test { type OnChargeTransaction = CurrencyAdapter, ()>; - type TransactionByteFee = TransactionByteFee; - type OperationalFeeMultiplier = OperationalFeeMultiplier; + type TransactionByteFee = ConstU64<1>; + type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = IdentityFee; type FeeMultiplierUpdate = (); } -parameter_types! { - pub const MaxReserves: u32 = 2; -} - impl Config for Test { type Balance = u64; type DustRemoval = (); @@ -98,7 +91,7 @@ impl Config for Test { type ExistentialDeposit = ExistentialDeposit; type AccountStore = frame_system::Pallet; type MaxLocks = (); - type MaxReserves = MaxReserves; + type MaxReserves = ConstU32<2>; type ReserveIdentifier = [u8; 8]; type WeightInfo = (); } diff --git a/substrate/frame/balances/src/tests_local.rs b/substrate/frame/balances/src/tests_local.rs index ff08e63562..4ceaff26c4 100644 --- a/substrate/frame/balances/src/tests_local.rs +++ b/substrate/frame/balances/src/tests_local.rs @@ -22,7 +22,7 @@ use crate::{self as pallet_balances, decl_tests, Config, Pallet}; use frame_support::{ parameter_types, - traits::StorageMapShim, + traits::{ConstU32, ConstU64, ConstU8, StorageMapShim}, weights::{DispatchInfo, IdentityFee, Weight}, }; use pallet_transaction_payment::CurrencyAdapter; @@ -46,7 +46,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); pub static ExistentialDeposit: u64 = 0; @@ -66,7 +65,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -77,21 +76,15 @@ impl frame_system::Config for Test { type OnSetCode = (); type MaxConsumers = frame_support::traits::ConstU32<16>; } -parameter_types! { - pub const TransactionByteFee: u64 = 1; - pub const OperationalFeeMultiplier: u8 = 5; -} + impl pallet_transaction_payment::Config for Test { type OnChargeTransaction = CurrencyAdapter, ()>; - type TransactionByteFee = TransactionByteFee; - type OperationalFeeMultiplier = OperationalFeeMultiplier; + type TransactionByteFee = ConstU64<1>; + type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = IdentityFee; type FeeMultiplierUpdate = (); } -parameter_types! { - pub const MaxLocks: u32 = 50; - pub const MaxReserves: u32 = 2; -} + impl Config for Test { type Balance = u64; type DustRemoval = (); @@ -99,8 +92,8 @@ impl Config for Test { type ExistentialDeposit = ExistentialDeposit; type AccountStore = StorageMapShim, system::Provider, u64, super::AccountData>; - type MaxLocks = MaxLocks; - type MaxReserves = MaxReserves; + type MaxLocks = ConstU32<50>; + type MaxReserves = ConstU32<2>; type ReserveIdentifier = [u8; 8]; type WeightInfo = (); } diff --git a/substrate/frame/balances/src/tests_reentrancy.rs b/substrate/frame/balances/src/tests_reentrancy.rs index 01b0294348..8067e5974c 100644 --- a/substrate/frame/balances/src/tests_reentrancy.rs +++ b/substrate/frame/balances/src/tests_reentrancy.rs @@ -20,7 +20,11 @@ #![cfg(test)] use crate::{self as pallet_balances, Config, Pallet}; -use frame_support::{parameter_types, traits::StorageMapShim, weights::IdentityFee}; +use frame_support::{ + parameter_types, + traits::{ConstU32, ConstU64, ConstU8, StorageMapShim}, + weights::IdentityFee, +}; use pallet_transaction_payment::CurrencyAdapter; use sp_core::H256; use sp_io; @@ -48,7 +52,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); pub static ExistentialDeposit: u64 = 0; @@ -68,7 +71,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -79,14 +82,11 @@ impl frame_system::Config for Test { type OnSetCode = (); type MaxConsumers = frame_support::traits::ConstU32<16>; } -parameter_types! { - pub const TransactionByteFee: u64 = 1; - pub const OperationalFeeMultiplier: u8 = 5; -} + impl pallet_transaction_payment::Config for Test { type OnChargeTransaction = CurrencyAdapter, ()>; - type TransactionByteFee = TransactionByteFee; - type OperationalFeeMultiplier = OperationalFeeMultiplier; + type TransactionByteFee = ConstU64<1>; + type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = IdentityFee; type FeeMultiplierUpdate = (); } @@ -97,10 +97,7 @@ impl OnUnbalanced> for OnDustRemoval { assert_ok!(Balances::resolve_into_existing(&1, amount)); } } -parameter_types! { - pub const MaxLocks: u32 = 50; - pub const MaxReserves: u32 = 2; -} + impl Config for Test { type Balance = u64; type DustRemoval = OnDustRemoval; @@ -108,8 +105,8 @@ impl Config for Test { type ExistentialDeposit = ExistentialDeposit; type AccountStore = StorageMapShim, system::Provider, u64, super::AccountData>; - type MaxLocks = MaxLocks; - type MaxReserves = MaxReserves; + type MaxLocks = ConstU32<50>; + type MaxReserves = ConstU32<2>; type ReserveIdentifier = [u8; 8]; type WeightInfo = (); } diff --git a/substrate/frame/beefy-mmr/src/mock.rs b/substrate/frame/beefy-mmr/src/mock.rs index f1195dcc9c..d66385f880 100644 --- a/substrate/frame/beefy-mmr/src/mock.rs +++ b/substrate/frame/beefy-mmr/src/mock.rs @@ -19,7 +19,9 @@ use std::vec; use beefy_primitives::mmr::MmrLeafVersion; use frame_support::{ - construct_runtime, parameter_types, sp_io::TestExternalities, traits::GenesisBuild, + construct_runtime, parameter_types, + sp_io::TestExternalities, + traits::{ConstU16, ConstU32, ConstU64, GenesisBuild}, BasicExternalities, }; use sp_core::{Hasher, H256}; @@ -57,11 +59,6 @@ construct_runtime!( } ); -parameter_types! { - pub const BlockHashCount: u64 = 250; - pub const SS58Prefix: u8 = 42; -} - impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = (); @@ -77,29 +74,24 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); - type SS58Prefix = SS58Prefix; + type SS58Prefix = ConstU16<42>; type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -parameter_types! { - pub const Period: u64 = 1; - pub const Offset: u64 = 0; + type MaxConsumers = ConstU32<16>; } impl pallet_session::Config for Test { type Event = Event; type ValidatorId = u64; type ValidatorIdOf = ConvertInto; - type ShouldEndSession = pallet_session::PeriodicSessions; - type NextSessionRotation = pallet_session::PeriodicSessions; + type ShouldEndSession = pallet_session::PeriodicSessions, ConstU64<0>>; + type NextSessionRotation = pallet_session::PeriodicSessions, ConstU64<0>>; type SessionManager = MockSessionManager; type SessionHandler = ::KeyTypeIdProviders; type Keys = MockSessionKeys; diff --git a/substrate/frame/beefy/src/mock.rs b/substrate/frame/beefy/src/mock.rs index 3ce582b29d..22330b29b6 100644 --- a/substrate/frame/beefy/src/mock.rs +++ b/substrate/frame/beefy/src/mock.rs @@ -18,7 +18,9 @@ use std::vec; use frame_support::{ - construct_runtime, parameter_types, sp_io::TestExternalities, traits::GenesisBuild, + construct_runtime, parameter_types, + sp_io::TestExternalities, + traits::{ConstU16, ConstU32, ConstU64, GenesisBuild}, BasicExternalities, }; use sp_core::H256; @@ -55,11 +57,6 @@ construct_runtime!( } ); -parameter_types! { - pub const BlockHashCount: u64 = 250; - pub const SS58Prefix: u8 = 42; -} - impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = (); @@ -75,16 +72,16 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); - type SS58Prefix = SS58Prefix; + type SS58Prefix = ConstU16<42>; type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl pallet_beefy::Config for Test { @@ -92,8 +89,6 @@ impl pallet_beefy::Config for Test { } parameter_types! { - pub const Period: u64 = 1; - pub const Offset: u64 = 0; pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(33); } @@ -101,8 +96,8 @@ impl pallet_session::Config for Test { type Event = Event; type ValidatorId = u64; type ValidatorIdOf = ConvertInto; - type ShouldEndSession = pallet_session::PeriodicSessions; - type NextSessionRotation = pallet_session::PeriodicSessions; + type ShouldEndSession = pallet_session::PeriodicSessions, ConstU64<0>>; + type NextSessionRotation = pallet_session::PeriodicSessions, ConstU64<0>>; type SessionManager = MockSessionManager; type SessionHandler = ::KeyTypeIdProviders; type Keys = MockSessionKeys; diff --git a/substrate/frame/benchmarking/src/tests.rs b/substrate/frame/benchmarking/src/tests.rs index e27b3e09db..eded93c696 100644 --- a/substrate/frame/benchmarking/src/tests.rs +++ b/substrate/frame/benchmarking/src/tests.rs @@ -20,7 +20,7 @@ #![cfg(test)] use super::*; -use frame_support::parameter_types; +use frame_support::{parameter_types, traits::ConstU32}; use sp_runtime::{ testing::{Header, H256}, traits::{BlakeTwo256, IdentityLookup}, @@ -112,14 +112,12 @@ impl frame_system::Config for Test { } parameter_types! { - pub const LowerBound: u32 = 1; - pub const UpperBound: u32 = 100; pub const MaybeItem: Option = None; } impl pallet_test::Config for Test { - type LowerBound = LowerBound; - type UpperBound = UpperBound; + type LowerBound = ConstU32<1>; + type UpperBound = ConstU32<100>; type MaybeItem = MaybeItem; } diff --git a/substrate/frame/benchmarking/src/tests_instance.rs b/substrate/frame/benchmarking/src/tests_instance.rs index 09d11eb6c5..2ac01a0528 100644 --- a/substrate/frame/benchmarking/src/tests_instance.rs +++ b/substrate/frame/benchmarking/src/tests_instance.rs @@ -20,7 +20,7 @@ #![cfg(test)] use super::*; -use frame_support::parameter_types; +use frame_support::traits::ConstU32; use sp_runtime::{ testing::{Header, H256}, traits::{BlakeTwo256, IdentityLookup}, @@ -113,15 +113,10 @@ impl frame_system::Config for Test { type MaxConsumers = frame_support::traits::ConstU32<16>; } -parameter_types! { - pub const LowerBound: u32 = 1; - pub const UpperBound: u32 = 100; -} - impl pallet_test::Config for Test { type Event = Event; - type LowerBound = LowerBound; - type UpperBound = UpperBound; + type LowerBound = ConstU32<1>; + type UpperBound = ConstU32<100>; } impl pallet_test::OtherConfig for Test { diff --git a/substrate/frame/bounties/src/tests.rs b/substrate/frame/bounties/src/tests.rs index dc6cecc06f..209136dcda 100644 --- a/substrate/frame/bounties/src/tests.rs +++ b/substrate/frame/bounties/src/tests.rs @@ -24,8 +24,11 @@ use crate as pallet_bounties; use std::cell::RefCell; use frame_support::{ - assert_noop, assert_ok, pallet_prelude::GenesisBuild, parameter_types, traits::OnInitialize, - weights::Weight, PalletId, + assert_noop, assert_ok, + pallet_prelude::GenesisBuild, + parameter_types, + traits::{ConstU32, ConstU64, OnInitialize}, + PalletId, }; use sp_core::H256; @@ -54,9 +57,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: Weight = 1024; - pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } @@ -75,7 +75,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -86,9 +86,7 @@ impl frame_system::Config for Test { type OnSetCode = (); type MaxConsumers = frame_support::traits::ConstU32<16>; } -parameter_types! { - pub const ExistentialDeposit: u64 = 1; -} + impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); @@ -96,7 +94,7 @@ impl pallet_balances::Config for Test { type Balance = u64; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } @@ -105,13 +103,10 @@ thread_local! { } parameter_types! { pub const ProposalBond: Permill = Permill::from_percent(5); - pub const ProposalBondMinimum: u64 = 1; - pub const SpendPeriod: u64 = 2; pub const Burn: Permill = Permill::from_percent(50); - pub const DataDepositPerByte: u64 = 1; pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); - pub const MaxApprovals: u32 = 100; } + // impl pallet_treasury::Config for Test { impl pallet_treasury::Config for Test { type PalletId = TreasuryPalletId; @@ -121,31 +116,26 @@ impl pallet_treasury::Config for Test { type Event = Event; type OnSlash = (); type ProposalBond = ProposalBond; - type ProposalBondMinimum = ProposalBondMinimum; - type SpendPeriod = SpendPeriod; + type ProposalBondMinimum = ConstU64<1>; + type SpendPeriod = ConstU64<2>; type Burn = Burn; type BurnDestination = (); // Just gets burned. type WeightInfo = (); type SpendFunds = Bounties; - type MaxApprovals = MaxApprovals; + type MaxApprovals = ConstU32<100>; } parameter_types! { - pub const BountyDepositBase: u64 = 80; - pub const BountyDepositPayoutDelay: u64 = 3; - pub const BountyUpdatePeriod: u32 = 20; pub const BountyCuratorDeposit: Permill = Permill::from_percent(50); - pub const BountyValueMinimum: u64 = 1; - pub const MaximumReasonLength: u32 = 16384; } impl Config for Test { type Event = Event; - type BountyDepositBase = BountyDepositBase; - type BountyDepositPayoutDelay = BountyDepositPayoutDelay; - type BountyUpdatePeriod = BountyUpdatePeriod; + type BountyDepositBase = ConstU64<80>; + type BountyDepositPayoutDelay = ConstU64<3>; + type BountyUpdatePeriod = ConstU64<20>; type BountyCuratorDeposit = BountyCuratorDeposit; - type BountyValueMinimum = BountyValueMinimum; - type DataDepositPerByte = DataDepositPerByte; - type MaximumReasonLength = MaximumReasonLength; + type BountyValueMinimum = ConstU64<1>; + type DataDepositPerByte = ConstU64<1>; + type MaximumReasonLength = ConstU32<16384>; type WeightInfo = (); type ChildBountyManager = (); } diff --git a/substrate/frame/child-bounties/src/tests.rs b/substrate/frame/child-bounties/src/tests.rs index 8e2569738b..ba68d73ced 100644 --- a/substrate/frame/child-bounties/src/tests.rs +++ b/substrate/frame/child-bounties/src/tests.rs @@ -24,8 +24,12 @@ use crate as pallet_child_bounties; use std::cell::RefCell; use frame_support::{ - assert_noop, assert_ok, pallet_prelude::GenesisBuild, parameter_types, traits::OnInitialize, - weights::Weight, PalletId, + assert_noop, assert_ok, + pallet_prelude::GenesisBuild, + parameter_types, + traits::{ConstU32, ConstU64, OnInitialize}, + weights::Weight, + PalletId, }; use sp_core::H256; @@ -56,7 +60,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub const MaximumBlockWeight: Weight = 1024; pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); @@ -77,7 +80,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -86,11 +89,9 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} -parameter_types! { - pub const ExistentialDeposit: u64 = 1; + type MaxConsumers = ConstU32<16>; } + impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); @@ -98,7 +99,7 @@ impl pallet_balances::Config for Test { type Balance = u64; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } @@ -107,12 +108,8 @@ thread_local! { } parameter_types! { pub const ProposalBond: Permill = Permill::from_percent(5); - pub const ProposalBondMinimum: u64 = 1; - pub const SpendPeriod: u64 = 2; pub const Burn: Permill = Permill::from_percent(50); - pub const DataDepositPerByte: u64 = 1; pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); - pub const MaxApprovals: u32 = 100; } impl pallet_treasury::Config for Test { @@ -123,43 +120,36 @@ impl pallet_treasury::Config for Test { type Event = Event; type OnSlash = (); type ProposalBond = ProposalBond; - type ProposalBondMinimum = ProposalBondMinimum; - type SpendPeriod = SpendPeriod; + type ProposalBondMinimum = ConstU64<1>; + type SpendPeriod = ConstU64<2>; type Burn = Burn; type BurnDestination = (); type WeightInfo = (); type SpendFunds = Bounties; - type MaxApprovals = MaxApprovals; + type MaxApprovals = ConstU32<100>; } parameter_types! { - pub const BountyDepositBase: u64 = 80; - pub const BountyDepositPayoutDelay: u64 = 3; - pub const BountyUpdatePeriod: u32 = 10; pub const BountyCuratorDeposit: Permill = Permill::from_percent(50); - pub const BountyValueMinimum: u64 = 5; - pub const MaximumReasonLength: u32 = 300; } impl pallet_bounties::Config for Test { type Event = Event; - type BountyDepositBase = BountyDepositBase; - type BountyDepositPayoutDelay = BountyDepositPayoutDelay; - type BountyUpdatePeriod = BountyUpdatePeriod; + type BountyDepositBase = ConstU64<80>; + type BountyDepositPayoutDelay = ConstU64<3>; + type BountyUpdatePeriod = ConstU64<10>; type BountyCuratorDeposit = BountyCuratorDeposit; - type BountyValueMinimum = BountyValueMinimum; - type DataDepositPerByte = DataDepositPerByte; - type MaximumReasonLength = MaximumReasonLength; + type BountyValueMinimum = ConstU64<5>; + type DataDepositPerByte = ConstU64<1>; + type MaximumReasonLength = ConstU32<300>; type WeightInfo = (); type ChildBountyManager = ChildBounties; } parameter_types! { - pub const MaxActiveChildBountyCount: u32 = 2; - pub const ChildBountyValueMinimum: u64 = 1; pub const ChildBountyCuratorDepositBase: Permill = Permill::from_percent(10); } impl pallet_child_bounties::Config for Test { type Event = Event; - type MaxActiveChildBountyCount = MaxActiveChildBountyCount; - type ChildBountyValueMinimum = ChildBountyValueMinimum; + type MaxActiveChildBountyCount = ConstU32<2>; + type ChildBountyValueMinimum = ConstU64<1>; type ChildBountyCuratorDepositBase = ChildBountyCuratorDepositBase; type WeightInfo = (); } diff --git a/substrate/frame/collective/src/tests.rs b/substrate/frame/collective/src/tests.rs index 466cdb3eee..2af8b1b970 100644 --- a/substrate/frame/collective/src/tests.rs +++ b/substrate/frame/collective/src/tests.rs @@ -18,7 +18,10 @@ use super::{Event as CollectiveEvent, *}; use crate as pallet_collective; use frame_support::{ - assert_noop, assert_ok, parameter_types, traits::GenesisBuild, weights::Pays, Hashable, + assert_noop, assert_ok, parameter_types, + traits::{ConstU32, ConstU64, GenesisBuild}, + weights::Pays, + Hashable, }; use frame_system::{EventRecord, Phase}; use sp_core::{ @@ -83,11 +86,11 @@ mod mock_democracy { } } +pub type MaxMembers = ConstU32<100>; + parameter_types! { - pub const BlockHashCount: u64 = 250; pub const MotionDuration: u64 = 3; pub const MaxProposals: u32 = 100; - pub const MaxMembers: u32 = 100; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -106,7 +109,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -115,13 +118,13 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl Config for Test { type Origin = Origin; type Proposal = Call; type Event = Event; - type MotionDuration = MotionDuration; + type MotionDuration = ConstU64<3>; type MaxProposals = MaxProposals; type MaxMembers = MaxMembers; type DefaultVote = PrimeDefaultVote; @@ -131,7 +134,7 @@ impl Config for Test { type Origin = Origin; type Proposal = Call; type Event = Event; - type MotionDuration = MotionDuration; + type MotionDuration = ConstU64<3>; type MaxProposals = MaxProposals; type MaxMembers = MaxMembers; type DefaultVote = MoreThanMajorityThenPrimeDefaultVote; @@ -145,7 +148,7 @@ impl Config for Test { type Origin = Origin; type Proposal = Call; type Event = Event; - type MotionDuration = MotionDuration; + type MotionDuration = ConstU64<3>; type MaxProposals = MaxProposals; type MaxMembers = MaxMembers; type DefaultVote = PrimeDefaultVote; diff --git a/substrate/frame/contracts/src/tests.rs b/substrate/frame/contracts/src/tests.rs index e7745e1e5f..584253aeaa 100644 --- a/substrate/frame/contracts/src/tests.rs +++ b/substrate/frame/contracts/src/tests.rs @@ -33,7 +33,9 @@ use frame_support::{ dispatch::DispatchErrorWithPostInfo, parameter_types, storage::child, - traits::{BalanceStatus, Contains, Currency, OnInitialize, ReservableCurrency}, + traits::{ + BalanceStatus, ConstU32, ConstU64, Contains, Currency, OnInitialize, ReservableCurrency, + }, weights::{constants::WEIGHT_PER_SECOND, DispatchClass, PostDispatchInfo, Weight}, }; use frame_system::{self as system, EventRecord, Phase}; @@ -177,7 +179,6 @@ impl ChainExtension for TestExtension { } parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(2 * WEIGHT_PER_SECOND); pub static ExistentialDeposit: u64 = 1; @@ -197,7 +198,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -220,13 +221,11 @@ impl pallet_balances::Config for Test { type AccountStore = System; type WeightInfo = (); } -parameter_types! { - pub const MinimumPeriod: u64 = 1; -} + impl pallet_timestamp::Config for Test { type Moment = u64; type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; + type MinimumPeriod = ConstU64<1>; type WeightInfo = (); } impl pallet_utility::Config for Test { @@ -237,7 +236,6 @@ impl pallet_utility::Config for Test { } parameter_types! { pub const MaxValueSize: u32 = 16_384; - pub const DeletionQueueDepth: u32 = 1024; pub const DeletionWeightLimit: Weight = 500_000_000_000; pub const MaxCodeSize: u32 = 2 * 1024; pub MySchedule: Schedule = >::default(); @@ -282,7 +280,7 @@ impl Config for Test { type WeightPrice = Self; type WeightInfo = (); type ChainExtension = TestExtension; - type DeletionQueueDepth = DeletionQueueDepth; + type DeletionQueueDepth = ConstU32<1024>; type DeletionWeightLimit = DeletionWeightLimit; type Schedule = MySchedule; type DepositPerByte = DepositPerByte; diff --git a/substrate/frame/democracy/src/tests.rs b/substrate/frame/democracy/src/tests.rs index 839478a5b8..1e36313122 100644 --- a/substrate/frame/democracy/src/tests.rs +++ b/substrate/frame/democracy/src/tests.rs @@ -22,7 +22,9 @@ use crate as pallet_democracy; use codec::Encode; use frame_support::{ assert_noop, assert_ok, ord_parameter_types, parameter_types, - traits::{Contains, EqualPrivilegeOnly, GenesisBuild, OnInitialize, SortedMembers}, + traits::{ + ConstU32, ConstU64, Contains, EqualPrivilegeOnly, GenesisBuild, OnInitialize, SortedMembers, + }, weights::Weight, }; use frame_system::{EnsureRoot, EnsureSignedBy}; @@ -50,8 +52,6 @@ const NAY: Vote = Vote { aye: false, conviction: Conviction::None }; const BIG_AYE: Vote = Vote { aye: true, conviction: Conviction::Locked1x }; const BIG_NAY: Vote = Vote { aye: false, conviction: Conviction::Locked1x }; -const MAX_PROPOSALS: u32 = 100; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -77,7 +77,6 @@ impl Contains for BaseFilter { } parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1_000_000); } @@ -96,7 +95,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -123,31 +122,19 @@ impl pallet_scheduler::Config for Test { type PreimageProvider = (); type NoPreimagePostponement = (); } -parameter_types! { - pub const ExistentialDeposit: u64 = 1; - pub const MaxLocks: u32 = 10; -} + impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; - type MaxLocks = MaxLocks; + type MaxLocks = ConstU32<10>; type Balance = u64; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } parameter_types! { - pub const LaunchPeriod: u64 = 2; - pub const VotingPeriod: u64 = 2; - pub const FastTrackVotingPeriod: u64 = 2; - pub const MinimumDeposit: u64 = 1; - pub const EnactmentPeriod: u64 = 2; - pub const VoteLockingPeriod: u64 = 3; - pub const CooloffPeriod: u64 = 2; - pub const MaxVotes: u32 = 100; - pub const MaxProposals: u32 = MAX_PROPOSALS; pub static PreimageByteDeposit: u64 = 0; pub static InstantAllowed: bool = false; } @@ -172,12 +159,12 @@ impl Config for Test { type Proposal = Call; type Event = Event; type Currency = pallet_balances::Pallet; - type EnactmentPeriod = EnactmentPeriod; - type LaunchPeriod = LaunchPeriod; - type VotingPeriod = VotingPeriod; - type VoteLockingPeriod = VoteLockingPeriod; - type FastTrackVotingPeriod = FastTrackVotingPeriod; - type MinimumDeposit = MinimumDeposit; + type EnactmentPeriod = ConstU64<2>; + type LaunchPeriod = ConstU64<2>; + type VotingPeriod = ConstU64<2>; + type VoteLockingPeriod = ConstU64<3>; + type FastTrackVotingPeriod = ConstU64<2>; + type MinimumDeposit = ConstU64<1>; type ExternalOrigin = EnsureSignedBy; type ExternalMajorityOrigin = EnsureSignedBy; type ExternalDefaultOrigin = EnsureSignedBy; @@ -186,17 +173,17 @@ impl Config for Test { type BlacklistOrigin = EnsureRoot; type CancelProposalOrigin = EnsureRoot; type VetoOrigin = EnsureSignedBy; - type CooloffPeriod = CooloffPeriod; + type CooloffPeriod = ConstU64<2>; type PreimageByteDeposit = PreimageByteDeposit; type Slash = (); type InstantOrigin = EnsureSignedBy; type InstantAllowed = InstantAllowed; type Scheduler = Scheduler; - type MaxVotes = MaxVotes; + type MaxVotes = ConstU32<100>; type OperationalPreimageOrigin = EnsureSignedBy; type PalletsOrigin = OriginCaller; type WeightInfo = (); - type MaxProposals = MaxProposals; + type MaxProposals = ConstU32<100>; } pub fn new_test_ext() -> sp_io::TestExternalities { diff --git a/substrate/frame/election-provider-multi-phase/src/mock.rs b/substrate/frame/election-provider-multi-phase/src/mock.rs index 3ac14b89e7..d686df2a72 100644 --- a/substrate/frame/election-provider-multi-phase/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/src/mock.rs @@ -21,7 +21,11 @@ use frame_election_provider_support::{ data_provider, onchain, ElectionDataProvider, SequentialPhragmen, }; pub use frame_support::{assert_noop, assert_ok}; -use frame_support::{parameter_types, traits::Hooks, weights::Weight}; +use frame_support::{ + parameter_types, + traits::{ConstU32, Hooks}, + weights::Weight, +}; use multi_phase::unsigned::{IndexAssignmentOf, Voter}; use parking_lot::RwLock; use sp_core::{ @@ -218,7 +222,7 @@ impl frame_system::Config for Runtime { type OnKilledAccount = (); type SystemWeightInfo = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); diff --git a/substrate/frame/elections-phragmen/src/lib.rs b/substrate/frame/elections-phragmen/src/lib.rs index c0b6fdfce6..3a6c657a6f 100644 --- a/substrate/frame/elections-phragmen/src/lib.rs +++ b/substrate/frame/elections-phragmen/src/lib.rs @@ -1121,8 +1121,10 @@ mod tests { use super::*; use crate as elections_phragmen; use frame_support::{ - assert_noop, assert_ok, dispatch::DispatchResultWithPostInfo, parameter_types, - traits::OnInitialize, + assert_noop, assert_ok, + dispatch::DispatchResultWithPostInfo, + parameter_types, + traits::{ConstU32, ConstU64, OnInitialize}, }; use frame_system::ensure_signed; use sp_core::H256; @@ -1134,7 +1136,6 @@ mod tests { use substrate_test_utils::assert_eq_uvec; parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -1154,7 +1155,7 @@ mod tests { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -1163,18 +1164,14 @@ mod tests { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; - } - - parameter_types! { - pub const ExistentialDeposit: u64 = 1; + type MaxConsumers = ConstU32<16>; } impl pallet_balances::Config for Test { type Balance = u64; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = frame_system::Pallet; type MaxLocks = (); type MaxReserves = (); diff --git a/substrate/frame/examples/basic/src/tests.rs b/substrate/frame/examples/basic/src/tests.rs index b97083f27d..9f93c90531 100644 --- a/substrate/frame/examples/basic/src/tests.rs +++ b/substrate/frame/examples/basic/src/tests.rs @@ -20,7 +20,7 @@ use crate::*; use frame_support::{ assert_ok, parameter_types, - traits::OnInitialize, + traits::{ConstU64, OnInitialize}, weights::{DispatchInfo, GetDispatchInfo}, }; use sp_core::H256; @@ -51,7 +51,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -70,7 +69,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -81,9 +80,7 @@ impl frame_system::Config for Test { type OnSetCode = (); type MaxConsumers = frame_support::traits::ConstU32<16>; } -parameter_types! { - pub const ExistentialDeposit: u64 = 1; -} + impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); @@ -91,16 +88,13 @@ impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); type Event = Event; - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } -parameter_types! { - pub const MagicNumber: u64 = 1_000_000_000; -} impl Config for Test { - type MagicNumber = MagicNumber; + type MagicNumber = ConstU64<1_000_000_000>; type Event = Event; type WeightInfo = (); } diff --git a/substrate/frame/examples/offchain-worker/src/tests.rs b/substrate/frame/examples/offchain-worker/src/tests.rs index d83c3c6df9..2c3e623e9c 100644 --- a/substrate/frame/examples/offchain-worker/src/tests.rs +++ b/substrate/frame/examples/offchain-worker/src/tests.rs @@ -18,7 +18,10 @@ use crate as example_offchain_worker; use crate::*; use codec::Decode; -use frame_support::{assert_ok, parameter_types}; +use frame_support::{ + assert_ok, parameter_types, + traits::{ConstU32, ConstU64}, +}; use sp_core::{ offchain::{testing, OffchainWorkerExt, TransactionPoolExt}, sr25519::Signature, @@ -49,7 +52,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -68,7 +70,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -77,7 +79,7 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } type Extrinsic = TestXt; @@ -111,8 +113,6 @@ where } parameter_types! { - pub const GracePeriod: u64 = 5; - pub const UnsignedInterval: u64 = 128; pub const UnsignedPriority: u64 = 1 << 20; } @@ -120,8 +120,8 @@ impl Config for Test { type Event = Event; type AuthorityId = crypto::TestAuthId; type Call = Call; - type GracePeriod = GracePeriod; - type UnsignedInterval = UnsignedInterval; + type GracePeriod = ConstU64<5>; + type UnsignedInterval = ConstU64<128>; type UnsignedPriority = UnsignedPriority; } diff --git a/substrate/frame/examples/parallel/src/tests.rs b/substrate/frame/examples/parallel/src/tests.rs index 1a841ca681..82ce95d7a8 100644 --- a/substrate/frame/examples/parallel/src/tests.rs +++ b/substrate/frame/examples/parallel/src/tests.rs @@ -40,7 +40,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub const AvailableBlockRatio: Perbill = Perbill::one(); } @@ -57,7 +56,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = frame_support::traits::ConstU64<250>; type DbWeight = (); type BlockWeights = (); type BlockLength = (); @@ -71,12 +70,6 @@ impl frame_system::Config for Test { type MaxConsumers = frame_support::traits::ConstU32<16>; } -parameter_types! { - pub const GracePeriod: u64 = 5; - pub const UnsignedInterval: u64 = 128; - pub const UnsignedPriority: u64 = 1 << 20; -} - impl Config for Test { type Call = Call; } diff --git a/substrate/frame/executive/src/lib.rs b/substrate/frame/executive/src/lib.rs index 7ff5584879..cc013d4c33 100644 --- a/substrate/frame/executive/src/lib.rs +++ b/substrate/frame/executive/src/lib.rs @@ -578,7 +578,10 @@ mod tests { use frame_support::{ assert_err, parameter_types, - traits::{Currency, LockIdentifier, LockableCurrency, WithdrawReasons}, + traits::{ + ConstU32, ConstU64, ConstU8, Currency, LockIdentifier, LockableCurrency, + WithdrawReasons, + }, weights::{IdentityFee, RuntimeDbWeight, Weight, WeightToFeePolynomial}, }; use frame_system::{Call as SystemCall, ChainContext, LastRuntimeUpgradeInfo}; @@ -731,7 +734,6 @@ mod tests { ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::builder() .base_block(10) @@ -758,7 +760,7 @@ mod tests { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = RuntimeVersion; type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -767,7 +769,7 @@ mod tests { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } type Balance = u64; @@ -788,12 +790,11 @@ mod tests { parameter_types! { pub const TransactionByteFee: Balance = 0; - pub const OperationalFeeMultiplier: u8 = 5; } impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = CurrencyAdapter; type TransactionByteFee = TransactionByteFee; - type OperationalFeeMultiplier = OperationalFeeMultiplier; + type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = IdentityFee; type FeeMultiplierUpdate = (); } diff --git a/substrate/frame/gilt/src/mock.rs b/substrate/frame/gilt/src/mock.rs index 9ea33a6d6b..6299f7c320 100644 --- a/substrate/frame/gilt/src/mock.rs +++ b/substrate/frame/gilt/src/mock.rs @@ -21,7 +21,7 @@ use crate as pallet_gilt; use frame_support::{ ord_parameter_types, parameter_types, - traits::{Currency, GenesisBuild, OnFinalize, OnInitialize}, + traits::{ConstU16, ConstU32, ConstU64, Currency, GenesisBuild, OnFinalize, OnInitialize}, }; use sp_core::H256; use sp_runtime::{ @@ -45,11 +45,6 @@ frame_support::construct_runtime!( } ); -parameter_types! { - pub const BlockHashCount: u64 = 250; - pub const SS58Prefix: u8 = 42; -} - impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = (); @@ -64,7 +59,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; @@ -72,20 +67,16 @@ impl frame_system::Config for Test { type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); - type SS58Prefix = SS58Prefix; + type SS58Prefix = ConstU16<42>; type OnSetCode = (); type MaxConsumers = frame_support::traits::ConstU32<16>; } -parameter_types! { - pub const ExistentialDeposit: u64 = 1; -} - impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); type Event = Event; - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = frame_support::traits::ConstU64<1>; type AccountStore = System; type WeightInfo = (); type MaxLocks = (); @@ -95,13 +86,6 @@ impl pallet_balances::Config for Test { parameter_types! { pub IgnoredIssuance: u64 = Balances::total_balance(&0); // Account zero is ignored. - pub const QueueCount: u32 = 3; - pub const MaxQueueLen: u32 = 3; - pub const FifoQueueLen: u32 = 1; - pub const Period: u64 = 3; - pub const MinFreeze: u64 = 2; - pub const IntakePeriod: u64 = 2; - pub const MaxIntakeBids: u32 = 2; } ord_parameter_types! { pub const One: u64 = 1; @@ -115,13 +99,13 @@ impl pallet_gilt::Config for Test { type Deficit = (); type Surplus = (); type IgnoredIssuance = IgnoredIssuance; - type QueueCount = QueueCount; - type MaxQueueLen = MaxQueueLen; - type FifoQueueLen = FifoQueueLen; - type Period = Period; - type MinFreeze = MinFreeze; - type IntakePeriod = IntakePeriod; - type MaxIntakeBids = MaxIntakeBids; + type QueueCount = ConstU32<3>; + type MaxQueueLen = ConstU32<3>; + type FifoQueueLen = ConstU32<1>; + type Period = ConstU64<3>; + type MinFreeze = ConstU64<2>; + type IntakePeriod = ConstU64<2>; + type MaxIntakeBids = ConstU32<2>; type WeightInfo = (); } diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index aed13ec371..6f7c57cad0 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -25,7 +25,9 @@ use codec::Encode; use frame_election_provider_support::onchain; use frame_support::{ parameter_types, - traits::{GenesisBuild, KeyOwnerProofSystem, OnFinalize, OnInitialize}, + traits::{ + ConstU128, ConstU32, ConstU64, GenesisBuild, KeyOwnerProofSystem, OnFinalize, OnInitialize, + }, }; use pallet_session::historical as pallet_session_historical; use pallet_staking::EraIndex; @@ -69,7 +71,6 @@ impl_opaque_keys! { } parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -89,7 +90,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -119,8 +120,8 @@ impl pallet_session::Config for Test { type Event = Event; type ValidatorId = u64; type ValidatorIdOf = pallet_staking::StashOf; - type ShouldEndSession = pallet_session::PeriodicSessions; - type NextSessionRotation = pallet_session::PeriodicSessions; + type ShouldEndSession = pallet_session::PeriodicSessions, ConstU64<0>>; + type NextSessionRotation = pallet_session::PeriodicSessions, ConstU64<0>>; type SessionManager = pallet_session::historical::NoteHistoricalRoot; type SessionHandler = ::KeyTypeIdProviders; type Keys = TestSessionKeys; @@ -132,21 +133,13 @@ impl pallet_session::historical::Config for Test { type FullIdentificationOf = pallet_staking::ExposureOf; } -parameter_types! { - pub const UncleGenerations: u64 = 0; -} - impl pallet_authorship::Config for Test { type FindAuthor = (); - type UncleGenerations = UncleGenerations; + type UncleGenerations = ConstU64<0>; type FilterUncle = (); type EventHandler = (); } -parameter_types! { - pub const ExistentialDeposit: u128 = 1; -} - impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); @@ -154,19 +147,15 @@ impl pallet_balances::Config for Test { type Balance = u128; type DustRemoval = (); type Event = Event; - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU128<1>; type AccountStore = System; type WeightInfo = (); } -parameter_types! { - pub const MinimumPeriod: u64 = 3; -} - impl pallet_timestamp::Config for Test { type Moment = u64; type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; + type MinimumPeriod = ConstU64<3>; type WeightInfo = (); } @@ -187,7 +176,6 @@ 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 ElectionLookahead: u64 = 0; pub const StakingUnsignedPriority: u64 = u64::MAX / 2; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); @@ -213,7 +201,7 @@ impl pallet_staking::Config for Test { type SessionInterface = Self; type UnixTime = pallet_timestamp::Pallet; type EraPayout = pallet_staking::ConvertCurve; - type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; + type MaxNominatorRewardedPerValidator = ConstU32<64>; type OffendingValidatorsThreshold = OffendingValidatorsThreshold; type NextNewSession = Session; type ElectionProvider = onchain::OnChainSequentialPhragmen; @@ -232,7 +220,6 @@ impl pallet_offences::Config for Test { parameter_types! { pub const ReportLongevity: u64 = BondingDuration::get() as u64 * SessionsPerEra::get() as u64 * Period::get(); - pub const MaxAuthorities: u32 = 100; } impl Config for Test { @@ -253,7 +240,7 @@ impl Config for Test { super::EquivocationHandler; type WeightInfo = (); - type MaxAuthorities = MaxAuthorities; + type MaxAuthorities = ConstU32<100>; } pub fn grandpa_log(log: ConsensusLog) -> DigestItem { diff --git a/substrate/frame/identity/src/tests.rs b/substrate/frame/identity/src/tests.rs index 2faf65f560..efbd1d984f 100644 --- a/substrate/frame/identity/src/tests.rs +++ b/substrate/frame/identity/src/tests.rs @@ -22,7 +22,9 @@ use crate as pallet_identity; use codec::{Decode, Encode}; use frame_support::{ - assert_noop, assert_ok, ord_parameter_types, parameter_types, traits::EnsureOneOf, BoundedVec, + assert_noop, assert_ok, ord_parameter_types, parameter_types, + traits::{ConstU32, ConstU64, EnsureOneOf}, + BoundedVec, }; use frame_system::{EnsureRoot, EnsureSignedBy}; use sp_core::H256; @@ -47,7 +49,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -65,7 +66,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; @@ -75,30 +76,26 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} -parameter_types! { - pub const ExistentialDeposit: u64 = 1; + type MaxConsumers = ConstU32<16>; } + impl pallet_balances::Config for Test { type Balance = u64; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type MaxLocks = (); type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type WeightInfo = (); } + parameter_types! { - pub const BasicDeposit: u64 = 10; - pub const FieldDeposit: u64 = 10; - pub const SubAccountDeposit: u64 = 10; - pub const MaxSubAccounts: u32 = 2; pub const MaxAdditionalFields: u32 = 2; pub const MaxRegistrars: u32 = 20; } + ord_parameter_types! { pub const One: u64 = 1; pub const Two: u64 = 2; @@ -109,10 +106,10 @@ impl pallet_identity::Config for Test { type Event = Event; type Currency = Balances; type Slashed = (); - type BasicDeposit = BasicDeposit; - type FieldDeposit = FieldDeposit; - type SubAccountDeposit = SubAccountDeposit; - type MaxSubAccounts = MaxSubAccounts; + type BasicDeposit = ConstU64<10>; + type FieldDeposit = ConstU64<10>; + type SubAccountDeposit = ConstU64<10>; + type MaxSubAccounts = ConstU32<2>; type MaxAdditionalFields = MaxAdditionalFields; type MaxRegistrars = MaxRegistrars; type RegistrarOrigin = EnsureOneOrRoot; diff --git a/substrate/frame/im-online/src/mock.rs b/substrate/frame/im-online/src/mock.rs index 3168f60ce0..8166bfc911 100644 --- a/substrate/frame/im-online/src/mock.rs +++ b/substrate/frame/im-online/src/mock.rs @@ -21,7 +21,11 @@ use std::cell::RefCell; -use frame_support::{parameter_types, weights::Weight}; +use frame_support::{ + parameter_types, + traits::{ConstU32, ConstU64}, + weights::Weight, +}; use pallet_session::historical as pallet_session_historical; use sp_core::H256; use sp_runtime::{ @@ -118,7 +122,6 @@ pub fn new_test_ext() -> sp_io::TestExternalities { } parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -138,7 +141,7 @@ impl frame_system::Config for Runtime { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -147,7 +150,7 @@ impl frame_system::Config for Runtime { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } parameter_types! { @@ -173,13 +176,9 @@ impl pallet_session::historical::Config for Runtime { type FullIdentificationOf = ConvertInto; } -parameter_types! { - pub const UncleGenerations: u32 = 5; -} - impl pallet_authorship::Config for Runtime { type FindAuthor = (); - type UncleGenerations = UncleGenerations; + type UncleGenerations = ConstU64<5>; type FilterUncle = (); type EventHandler = ImOnline; } @@ -221,9 +220,6 @@ impl frame_support::traits::EstimateNextSessionRotation for TestNextSession parameter_types! { pub const UnsignedPriority: u64 = 1 << 20; - pub const MaxKeys: u32 = 10_000; - pub const MaxPeerInHeartbeats: u32 = 10_000; - pub const MaxPeerDataEncodingSize: u32 = 1_000; } impl Config for Runtime { @@ -234,9 +230,9 @@ impl Config for Runtime { type ReportUnresponsiveness = OffenceHandler; type UnsignedPriority = UnsignedPriority; type WeightInfo = (); - type MaxKeys = MaxKeys; - type MaxPeerInHeartbeats = MaxPeerInHeartbeats; - type MaxPeerDataEncodingSize = MaxPeerDataEncodingSize; + type MaxKeys = ConstU32<10_000>; + type MaxPeerInHeartbeats = ConstU32<10_000>; + type MaxPeerDataEncodingSize = ConstU32<1_000>; } impl frame_system::offchain::SendTransactionTypes for Runtime diff --git a/substrate/frame/indices/src/mock.rs b/substrate/frame/indices/src/mock.rs index 3e3aed2986..ef654833c3 100644 --- a/substrate/frame/indices/src/mock.rs +++ b/substrate/frame/indices/src/mock.rs @@ -20,7 +20,10 @@ #![cfg(test)] use crate::{self as pallet_indices, Config}; -use frame_support::parameter_types; +use frame_support::{ + parameter_types, + traits::{ConstU32, ConstU64}, +}; use sp_core::H256; use sp_runtime::testing::Header; @@ -40,7 +43,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -60,7 +62,7 @@ impl frame_system::Config for Test { type Lookup = Indices; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -69,11 +71,7 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -parameter_types! { - pub const ExistentialDeposit: u64 = 1; + type MaxConsumers = ConstU32<16>; } impl pallet_balances::Config for Test { @@ -83,19 +81,15 @@ impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); type Event = Event; - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } -parameter_types! { - pub const Deposit: u64 = 1; -} - impl Config for Test { type AccountIndex = u64; type Currency = Balances; - type Deposit = Deposit; + type Deposit = ConstU64<1>; type Event = Event; type WeightInfo = (); } diff --git a/substrate/frame/lottery/src/mock.rs b/substrate/frame/lottery/src/mock.rs index df86e063c4..36b847d48d 100644 --- a/substrate/frame/lottery/src/mock.rs +++ b/substrate/frame/lottery/src/mock.rs @@ -22,7 +22,7 @@ use crate as pallet_lottery; use frame_support::{ parameter_types, - traits::{OnFinalize, OnInitialize}, + traits::{ConstU32, ConstU64, OnFinalize, OnInitialize}, }; use frame_support_test::TestRandomness; use frame_system::EnsureRoot; @@ -49,9 +49,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: u32 = 1024; - pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } @@ -70,7 +67,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -79,11 +76,7 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -parameter_types! { - pub const ExistentialDeposit: u64 = 1; + type MaxConsumers = ConstU32<16>; } impl pallet_balances::Config for Test { @@ -93,15 +86,13 @@ impl pallet_balances::Config for Test { type Balance = u64; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } parameter_types! { pub const LotteryPalletId: PalletId = PalletId(*b"py/lotto"); - pub const MaxCalls: u32 = 2; - pub const MaxGenerateRandom: u32 = 10; } impl Config for Test { @@ -111,9 +102,9 @@ impl Config for Test { type Randomness = TestRandomness; type Event = Event; type ManagerOrigin = EnsureRoot; - type MaxCalls = MaxCalls; + type MaxCalls = ConstU32<2>; type ValidateCall = Lottery; - type MaxGenerateRandom = MaxGenerateRandom; + type MaxGenerateRandom = ConstU32<10>; type WeightInfo = (); } diff --git a/substrate/frame/membership/src/lib.rs b/substrate/frame/membership/src/lib.rs index 4bcc28c0ef..b34051731f 100644 --- a/substrate/frame/membership/src/lib.rs +++ b/substrate/frame/membership/src/lib.rs @@ -509,7 +509,8 @@ mod tests { }; use frame_support::{ - assert_noop, assert_ok, ord_parameter_types, parameter_types, traits::GenesisBuild, + assert_noop, assert_ok, ord_parameter_types, parameter_types, + traits::{ConstU32, ConstU64, GenesisBuild}, }; use frame_system::EnsureSignedBy; @@ -528,8 +529,6 @@ mod tests { ); parameter_types! { - pub const BlockHashCount: u64 = 250; - pub const MaxMembers: u32 = 10; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); pub static Members: Vec = vec![]; @@ -551,7 +550,7 @@ mod tests { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -560,7 +559,7 @@ mod tests { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } ord_parameter_types! { pub const One: u64 = 1; @@ -607,7 +606,7 @@ mod tests { type PrimeOrigin = EnsureSignedBy; type MembershipInitialized = TestChangeMembers; type MembershipChanged = TestChangeMembers; - type MaxMembers = MaxMembers; + type MaxMembers = ConstU32<10>; type WeightInfo = (); } diff --git a/substrate/frame/merkle-mountain-range/src/mock.rs b/substrate/frame/merkle-mountain-range/src/mock.rs index 392ae5050a..2adea420f0 100644 --- a/substrate/frame/merkle-mountain-range/src/mock.rs +++ b/substrate/frame/merkle-mountain-range/src/mock.rs @@ -19,7 +19,7 @@ use crate as pallet_mmr; use crate::*; use codec::{Decode, Encode}; -use frame_support::parameter_types; +use frame_support::traits::{ConstU32, ConstU64}; use pallet_mmr_primitives::{Compact, LeafDataProvider}; use sp_core::H256; use sp_runtime::{ @@ -42,9 +42,6 @@ frame_support::construct_runtime!( } ); -parameter_types! { - pub const BlockHashCount: u64 = 250; -} impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type Origin = Origin; @@ -57,7 +54,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type DbWeight = (); type BlockWeights = (); type BlockLength = (); @@ -69,7 +66,7 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl Config for Test { diff --git a/substrate/frame/multisig/src/tests.rs b/substrate/frame/multisig/src/tests.rs index f050ac9d72..2d6c02c559 100644 --- a/substrate/frame/multisig/src/tests.rs +++ b/substrate/frame/multisig/src/tests.rs @@ -22,7 +22,10 @@ use super::*; use crate as pallet_multisig; -use frame_support::{assert_noop, assert_ok, parameter_types, traits::Contains}; +use frame_support::{ + assert_noop, assert_ok, parameter_types, + traits::{ConstU16, ConstU32, ConstU64, Contains}, +}; use sp_core::H256; use sp_runtime::{ testing::Header, @@ -46,7 +49,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -65,7 +67,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -74,11 +76,9 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} -parameter_types! { - pub const ExistentialDeposit: u64 = 1; + type MaxConsumers = ConstU32<16>; } + impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); @@ -86,15 +86,11 @@ impl pallet_balances::Config for Test { type Balance = u64; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } -parameter_types! { - pub const DepositBase: u64 = 1; - pub const DepositFactor: u64 = 1; - pub const MaxSignatories: u16 = 3; -} + pub struct TestBaseCallFilter; impl Contains for TestBaseCallFilter { fn contains(c: &Call) -> bool { @@ -110,9 +106,9 @@ impl Config for Test { type Event = Event; type Call = Call; type Currency = Balances; - type DepositBase = DepositBase; - type DepositFactor = DepositFactor; - type MaxSignatories = MaxSignatories; + type DepositBase = ConstU64<1>; + type DepositFactor = ConstU64<1>; + type MaxSignatories = ConstU16<3>; type WeightInfo = (); } diff --git a/substrate/frame/nicks/src/lib.rs b/substrate/frame/nicks/src/lib.rs index ea58ea693d..91918ce846 100644 --- a/substrate/frame/nicks/src/lib.rs +++ b/substrate/frame/nicks/src/lib.rs @@ -245,7 +245,10 @@ mod tests { use super::*; use crate as pallet_nicks; - use frame_support::{assert_noop, assert_ok, ord_parameter_types, parameter_types}; + use frame_support::{ + assert_noop, assert_ok, ord_parameter_types, parameter_types, + traits::{ConstU32, ConstU64}, + }; use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ @@ -269,7 +272,6 @@ mod tests { ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -288,7 +290,7 @@ mod tests { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -297,11 +299,9 @@ mod tests { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; - } - parameter_types! { - pub const ExistentialDeposit: u64 = 1; + type MaxConsumers = ConstU32<16>; } + impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); @@ -309,26 +309,22 @@ mod tests { type Balance = u64; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } - parameter_types! { - pub const ReservationFee: u64 = 2; - pub const MinLength: u32 = 3; - pub const MaxLength: u32 = 16; - } + ord_parameter_types! { pub const One: u64 = 1; } impl Config for Test { type Event = Event; type Currency = Balances; - type ReservationFee = ReservationFee; + type ReservationFee = ConstU64<2>; type Slashed = (); type ForceOrigin = EnsureSignedBy; - type MinLength = MinLength; - type MaxLength = MaxLength; + type MinLength = ConstU32<3>; + type MaxLength = ConstU32<16>; } fn new_test_ext() -> sp_io::TestExternalities { diff --git a/substrate/frame/node-authorization/src/mock.rs b/substrate/frame/node-authorization/src/mock.rs index 8e2bc7cfd2..bb882c62ab 100644 --- a/substrate/frame/node-authorization/src/mock.rs +++ b/substrate/frame/node-authorization/src/mock.rs @@ -20,7 +20,10 @@ use super::*; use crate as pallet_node_authorization; -use frame_support::{ord_parameter_types, parameter_types, traits::GenesisBuild}; +use frame_support::{ + ord_parameter_types, + traits::{ConstU32, ConstU64, GenesisBuild}, +}; use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ @@ -44,9 +47,6 @@ frame_support::construct_runtime!( } ); -parameter_types! { - pub const BlockHashCount: u64 = 250; -} impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type DbWeight = (); @@ -62,7 +62,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -71,7 +71,7 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } ord_parameter_types! { @@ -80,14 +80,11 @@ ord_parameter_types! { pub const Three: u64 = 3; pub const Four: u64 = 4; } -parameter_types! { - pub const MaxWellKnownNodes: u32 = 4; - pub const MaxPeerIdLength: u32 = 2; -} + impl Config for Test { type Event = Event; - type MaxWellKnownNodes = MaxWellKnownNodes; - type MaxPeerIdLength = MaxPeerIdLength; + type MaxWellKnownNodes = ConstU32<4>; + type MaxPeerIdLength = ConstU32<2>; type AddOrigin = EnsureSignedBy; type RemoveOrigin = EnsureSignedBy; type SwapOrigin = EnsureSignedBy; diff --git a/substrate/frame/offences/benchmarking/src/mock.rs b/substrate/frame/offences/benchmarking/src/mock.rs index ab2b356922..1a5fdcd61b 100644 --- a/substrate/frame/offences/benchmarking/src/mock.rs +++ b/substrate/frame/offences/benchmarking/src/mock.rs @@ -21,7 +21,11 @@ use super::*; use frame_election_provider_support::onchain; -use frame_support::{parameter_types, weights::constants::WEIGHT_PER_SECOND}; +use frame_support::{ + parameter_types, + traits::{ConstU32, ConstU64}, + weights::constants::WEIGHT_PER_SECOND, +}; use frame_system as system; use pallet_session::historical as pallet_session_historical; use sp_runtime::{ @@ -80,13 +84,10 @@ impl pallet_balances::Config for Test { type WeightInfo = (); } -parameter_types! { - pub const MinimumPeriod: u64 = 5; -} impl pallet_timestamp::Config for Test { type Moment = u64; type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; + type MinimumPeriod = ConstU64<5>; type WeightInfo = (); } impl pallet_session::historical::Config for Test { @@ -145,10 +146,6 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub const MaxNominatorRewardedPerValidator: u32 = 64; - pub const MaxKeys: u32 = 10_000; - pub const MaxPeerInHeartbeats: u32 = 10_000; - pub const MaxPeerDataEncodingSize: u32 = 1_000; } pub type Extrinsic = sp_runtime::testing::TestXt; @@ -174,7 +171,7 @@ impl pallet_staking::Config for Test { type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; type NextNewSession = Session; - type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; + type MaxNominatorRewardedPerValidator = ConstU32<64>; type OffendingValidatorsThreshold = (); type ElectionProvider = onchain::OnChainSequentialPhragmen; type GenesisElectionProvider = Self::ElectionProvider; @@ -191,9 +188,9 @@ impl pallet_im_online::Config for Test { type ReportUnresponsiveness = Offences; type UnsignedPriority = (); type WeightInfo = (); - type MaxKeys = MaxKeys; - type MaxPeerInHeartbeats = MaxPeerInHeartbeats; - type MaxPeerDataEncodingSize = MaxPeerDataEncodingSize; + type MaxKeys = ConstU32<10_000>; + type MaxPeerInHeartbeats = ConstU32<10_000>; + type MaxPeerDataEncodingSize = ConstU32<1_000>; } impl pallet_offences::Config for Test { diff --git a/substrate/frame/offences/src/mock.rs b/substrate/frame/offences/src/mock.rs index c2db42ec72..17d34d46e3 100644 --- a/substrate/frame/offences/src/mock.rs +++ b/substrate/frame/offences/src/mock.rs @@ -24,6 +24,7 @@ use crate::Config; use codec::Encode; use frame_support::{ parameter_types, + traits::{ConstU32, ConstU64}, weights::{ constants::{RocksDbWeight, WEIGHT_PER_SECOND}, Weight, @@ -84,7 +85,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(2 * WEIGHT_PER_SECOND); } @@ -103,7 +103,7 @@ impl frame_system::Config for Runtime { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -112,7 +112,7 @@ impl frame_system::Config for Runtime { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl Config for Runtime { diff --git a/substrate/frame/preimage/src/mock.rs b/substrate/frame/preimage/src/mock.rs index 601f725472..3996d84256 100644 --- a/substrate/frame/preimage/src/mock.rs +++ b/substrate/frame/preimage/src/mock.rs @@ -21,7 +21,9 @@ use super::*; use crate as pallet_preimage; use frame_support::{ - ord_parameter_types, parameter_types, traits::Everything, weights::constants::RocksDbWeight, + ord_parameter_types, parameter_types, + traits::{ConstU32, ConstU64, Everything}, + weights::constants::RocksDbWeight, }; use frame_system::EnsureSignedBy; use sp_core::H256; @@ -47,7 +49,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(2_000_000_000_000); } @@ -66,7 +67,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -75,32 +76,24 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -parameter_types! { - pub const ExistentialDeposit: u64 = 5; - pub const MaxReserves: u32 = 50; + type MaxConsumers = ConstU32<16>; } impl pallet_balances::Config for Test { type Balance = u64; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<5>; type AccountStore = System; type WeightInfo = (); type MaxLocks = (); - type MaxReserves = MaxReserves; + type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; } parameter_types! { pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block; pub const MaxScheduledPerBlock: u32 = 10; - pub const MaxSize: u32 = 1024; - pub const BaseDeposit: u64 = 2; - pub const ByteDeposit: u64 = 1; } ord_parameter_types! { @@ -112,9 +105,9 @@ impl Config for Test { type Event = Event; type Currency = Balances; type ManagerOrigin = EnsureSignedBy; - type MaxSize = MaxSize; - type BaseDeposit = BaseDeposit; - type ByteDeposit = ByteDeposit; + type MaxSize = ConstU32<1024>; + type BaseDeposit = ConstU64<2>; + type ByteDeposit = ConstU64<1>; } pub fn new_test_ext() -> sp_io::TestExternalities { diff --git a/substrate/frame/proxy/src/tests.rs b/substrate/frame/proxy/src/tests.rs index 538527d47e..902eae8fc3 100644 --- a/substrate/frame/proxy/src/tests.rs +++ b/substrate/frame/proxy/src/tests.rs @@ -24,7 +24,10 @@ use super::*; use crate as proxy; use codec::{Decode, Encode}; use frame_support::{ - assert_noop, assert_ok, dispatch::DispatchError, parameter_types, traits::Contains, + assert_noop, assert_ok, + dispatch::DispatchError, + parameter_types, + traits::{ConstU32, ConstU64, Contains}, RuntimeDebug, }; use sp_core::H256; @@ -50,7 +53,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -69,7 +71,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -78,11 +80,9 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} -parameter_types! { - pub const ExistentialDeposit: u64 = 1; + type MaxConsumers = ConstU32<16>; } + impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); @@ -90,7 +90,7 @@ impl pallet_balances::Config for Test { type Balance = u64; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } @@ -100,14 +100,7 @@ impl pallet_utility::Config for Test { type PalletsOrigin = OriginCaller; type WeightInfo = (); } -parameter_types! { - pub const ProxyDepositBase: u64 = 1; - pub const ProxyDepositFactor: u64 = 1; - pub const MaxProxies: u16 = 4; - pub const MaxPending: u32 = 2; - pub const AnnouncementDepositBase: u64 = 1; - pub const AnnouncementDepositFactor: u64 = 1; -} + #[derive( Copy, Clone, @@ -161,14 +154,14 @@ impl Config for Test { type Call = Call; type Currency = Balances; type ProxyType = ProxyType; - type ProxyDepositBase = ProxyDepositBase; - type ProxyDepositFactor = ProxyDepositFactor; - type MaxProxies = MaxProxies; + type ProxyDepositBase = ConstU64<1>; + type ProxyDepositFactor = ConstU64<1>; + type MaxProxies = ConstU32<4>; type WeightInfo = (); type CallHasher = BlakeTwo256; - type MaxPending = MaxPending; - type AnnouncementDepositBase = AnnouncementDepositBase; - type AnnouncementDepositFactor = AnnouncementDepositFactor; + type MaxPending = ConstU32<2>; + type AnnouncementDepositBase = ConstU64<1>; + type AnnouncementDepositFactor = ConstU64<1>; } use super::{Call as ProxyCall, Event as ProxyEvent}; diff --git a/substrate/frame/randomness-collective-flip/src/lib.rs b/substrate/frame/randomness-collective-flip/src/lib.rs index eee70984f2..bf5920acff 100644 --- a/substrate/frame/randomness-collective-flip/src/lib.rs +++ b/substrate/frame/randomness-collective-flip/src/lib.rs @@ -169,7 +169,7 @@ mod tests { use frame_support::{ parameter_types, - traits::{OnInitialize, Randomness}, + traits::{ConstU32, ConstU64, OnInitialize, Randomness}, }; use frame_system::limits; @@ -188,7 +188,6 @@ mod tests { ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: limits::BlockWeights = limits::BlockWeights ::simple_max(1024); pub BlockLength: limits::BlockLength = limits::BlockLength @@ -210,7 +209,7 @@ mod tests { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -219,7 +218,7 @@ mod tests { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl pallet_randomness_collective_flip::Config for Test {} diff --git a/substrate/frame/recovery/src/mock.rs b/substrate/frame/recovery/src/mock.rs index 1bd7507436..778b966c76 100644 --- a/substrate/frame/recovery/src/mock.rs +++ b/substrate/frame/recovery/src/mock.rs @@ -22,7 +22,7 @@ use super::*; use crate as recovery; use frame_support::{ parameter_types, - traits::{OnFinalize, OnInitialize}, + traits::{ConstU16, ConstU32, ConstU64, OnFinalize, OnInitialize}, }; use sp_core::H256; use sp_runtime::{ @@ -46,7 +46,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -66,7 +65,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -75,7 +74,7 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } parameter_types! { @@ -97,7 +96,6 @@ impl pallet_balances::Config for Test { parameter_types! { pub const ConfigDepositBase: u64 = 10; pub const FriendDepositFactor: u64 = 1; - pub const MaxFriends: u16 = 3; pub const RecoveryDeposit: u64 = 10; } @@ -107,7 +105,7 @@ impl Config for Test { type Currency = Balances; type ConfigDepositBase = ConfigDepositBase; type FriendDepositFactor = FriendDepositFactor; - type MaxFriends = MaxFriends; + type MaxFriends = ConstU16<3>; type RecoveryDeposit = RecoveryDeposit; } diff --git a/substrate/frame/scheduler/src/mock.rs b/substrate/frame/scheduler/src/mock.rs index 535e91937e..014f473302 100644 --- a/substrate/frame/scheduler/src/mock.rs +++ b/substrate/frame/scheduler/src/mock.rs @@ -22,7 +22,9 @@ use super::*; use crate as scheduler; use frame_support::{ ord_parameter_types, parameter_types, - traits::{Contains, EnsureOneOf, EqualPrivilegeOnly, OnFinalize, OnInitialize}, + traits::{ + ConstU32, ConstU64, Contains, EnsureOneOf, EqualPrivilegeOnly, OnFinalize, OnInitialize, + }, weights::constants::RocksDbWeight, }; use frame_system::{EnsureRoot, EnsureSignedBy}; @@ -116,7 +118,6 @@ impl Contains for BaseFilter { } parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(2_000_000_000_000); } @@ -135,7 +136,7 @@ impl system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -144,15 +145,13 @@ impl system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl logger::Config for Test { type Event = Event; } parameter_types! { pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block; - pub const MaxScheduledPerBlock: u32 = 10; - pub const MaxSize: u32 = 1024; pub const NoPreimagePostponement: Option = Some(2); } ord_parameter_types! { @@ -164,7 +163,7 @@ impl pallet_preimage::Config for Test { type WeightInfo = (); type Currency = (); type ManagerOrigin = EnsureRoot; - type MaxSize = MaxSize; + type MaxSize = ConstU32<1024>; type BaseDeposit = (); type ByteDeposit = (); } @@ -176,7 +175,7 @@ impl Config for Test { type Call = Call; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureOneOf, EnsureSignedBy>; - type MaxScheduledPerBlock = MaxScheduledPerBlock; + type MaxScheduledPerBlock = ConstU32<10>; type WeightInfo = (); type OriginPrivilegeCmp = EqualPrivilegeOnly; type PreimageProvider = Preimage; diff --git a/substrate/frame/scored-pool/src/mock.rs b/substrate/frame/scored-pool/src/mock.rs index 992aecba38..d5b3814fd9 100644 --- a/substrate/frame/scored-pool/src/mock.rs +++ b/substrate/frame/scored-pool/src/mock.rs @@ -20,7 +20,10 @@ use super::*; use crate as pallet_scored_pool; -use frame_support::{ord_parameter_types, parameter_types, traits::GenesisBuild}; +use frame_support::{ + ord_parameter_types, parameter_types, + traits::{ConstU32, ConstU64, GenesisBuild}, +}; use frame_system::EnsureSignedBy; use sp_core::H256; use sp_runtime::{ @@ -46,9 +49,6 @@ frame_support::construct_runtime!( parameter_types! { pub const CandidateDeposit: u64 = 25; - pub const Period: u64 = 4; - pub const BlockHashCount: u64 = 250; - pub const ExistentialDeposit: u64 = 1; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -72,7 +72,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -81,7 +81,7 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl pallet_balances::Config for Test { @@ -91,7 +91,7 @@ impl pallet_balances::Config for Test { type Balance = u64; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } @@ -130,7 +130,7 @@ impl Config for Test { type MembershipChanged = TestChangeMembers; type Currency = Balances; type CandidateDeposit = CandidateDeposit; - type Period = Period; + type Period = ConstU64<4>; type Score = u64; type ScoreOrigin = EnsureSignedBy; } diff --git a/substrate/frame/session/benchmarking/src/mock.rs b/substrate/frame/session/benchmarking/src/mock.rs index 3f3b103905..2560563511 100644 --- a/substrate/frame/session/benchmarking/src/mock.rs +++ b/substrate/frame/session/benchmarking/src/mock.rs @@ -20,7 +20,10 @@ #![cfg(test)] use frame_election_provider_support::onchain; -use frame_support::parameter_types; +use frame_support::{ + parameter_types, + traits::{ConstU32, ConstU64}, +}; use sp_runtime::traits::IdentityLookup; type AccountId = u64; @@ -68,7 +71,7 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } parameter_types! { pub const ExistentialDeposit: Balance = 10; @@ -85,13 +88,10 @@ impl pallet_balances::Config for Test { type WeightInfo = (); } -parameter_types! { - pub const MinimumPeriod: u64 = 5; -} impl pallet_timestamp::Config for Test { type Moment = u64; type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; + type MinimumPeriod = ConstU64<5>; type WeightInfo = (); } impl pallet_session::historical::Config for Test { @@ -144,8 +144,6 @@ pallet_staking_reward_curve::build! { } parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; - pub const MaxNominatorRewardedPerValidator: u32 = 64; - pub const UnsignedPriority: u64 = 1 << 20; } pub type Extrinsic = sp_runtime::testing::TestXt; @@ -179,7 +177,7 @@ impl pallet_staking::Config for Test { type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; type NextNewSession = Session; - type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; + type MaxNominatorRewardedPerValidator = ConstU32<64>; type OffendingValidatorsThreshold = (); type ElectionProvider = onchain::OnChainSequentialPhragmen; type GenesisElectionProvider = Self::ElectionProvider; diff --git a/substrate/frame/session/src/mock.rs b/substrate/frame/session/src/mock.rs index d0511d3936..ec1f841f50 100644 --- a/substrate/frame/session/src/mock.rs +++ b/substrate/frame/session/src/mock.rs @@ -32,7 +32,11 @@ use sp_runtime::{ }; use sp_staking::SessionIndex; -use frame_support::{parameter_types, traits::GenesisBuild, BasicExternalities}; +use frame_support::{ + parameter_types, + traits::{ConstU32, ConstU64, GenesisBuild}, + BasicExternalities, +}; impl_opaque_keys! { pub struct MockSessionKeys { @@ -234,8 +238,6 @@ pub fn new_test_ext() -> sp_io::TestExternalities { } parameter_types! { - pub const MinimumPeriod: u64 = 5; - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -255,7 +257,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -264,13 +266,13 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl pallet_timestamp::Config for Test { type Moment = u64; type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; + type MinimumPeriod = ConstU64<5>; type WeightInfo = (); } diff --git a/substrate/frame/session/src/tests.rs b/substrate/frame/session/src/tests.rs index cc0606edf4..199076c882 100644 --- a/substrate/frame/session/src/tests.rs +++ b/substrate/frame/session/src/tests.rs @@ -29,7 +29,10 @@ use codec::Decode; use sp_core::crypto::key_types::DUMMY; use sp_runtime::testing::UintAuthorityId; -use frame_support::{assert_noop, assert_ok, traits::OnInitialize}; +use frame_support::{ + assert_noop, assert_ok, + traits::{ConstU64, OnInitialize}, +}; fn initialize_block(block: u64) { SESSION_CHANGED.with(|l| *l.borrow_mut() = false); @@ -291,12 +294,7 @@ fn session_changed_flag_works() { #[test] fn periodic_session_works() { - frame_support::parameter_types! { - const Period: u64 = 10; - const Offset: u64 = 3; - } - - type P = PeriodicSessions; + type P = PeriodicSessions, ConstU64<3>>; // make sure that offset phase behaves correctly for i in 0u64..3 { diff --git a/substrate/frame/society/src/mock.rs b/substrate/frame/society/src/mock.rs index 4348f2378c..fbf3b2fd75 100644 --- a/substrate/frame/society/src/mock.rs +++ b/substrate/frame/society/src/mock.rs @@ -20,7 +20,10 @@ use super::*; use crate as pallet_society; -use frame_support::{ord_parameter_types, parameter_types}; +use frame_support::{ + ord_parameter_types, parameter_types, + traits::{ConstU32, ConstU64}, +}; use frame_support_test::TestRandomness; use frame_system::EnsureSignedBy; use sp_core::H256; @@ -45,16 +48,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const CandidateDeposit: u64 = 25; - pub const WrongSideDeduction: u64 = 2; - pub const MaxStrikes: u32 = 2; - pub const RotationPeriod: u64 = 4; - pub const PeriodSpend: u64 = 1000; - pub const MaxLockDuration: u64 = 100; - pub const ChallengePeriod: u64 = 8; - pub const BlockHashCount: u64 = 250; - pub const ExistentialDeposit: u64 = 1; - pub const MaxCandidateIntake: u32 = 10; pub const SocietyPalletId: PalletId = PalletId(*b"py/socie"); pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); @@ -80,7 +73,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type OnNewAccount = (); @@ -89,7 +82,7 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl pallet_balances::Config for Test { @@ -99,7 +92,7 @@ impl pallet_balances::Config for Test { type Balance = u64; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } @@ -108,17 +101,17 @@ impl Config for Test { type Event = Event; type Currency = pallet_balances::Pallet; type Randomness = TestRandomness; - type CandidateDeposit = CandidateDeposit; - type WrongSideDeduction = WrongSideDeduction; - type MaxStrikes = MaxStrikes; - type PeriodSpend = PeriodSpend; + type CandidateDeposit = ConstU64<25>; + type WrongSideDeduction = ConstU64<2>; + type MaxStrikes = ConstU32<2>; + type PeriodSpend = ConstU64<1000>; type MembershipChanged = (); - type RotationPeriod = RotationPeriod; - type MaxLockDuration = MaxLockDuration; + type RotationPeriod = ConstU64<4>; + type MaxLockDuration = ConstU64<100>; type FounderSetOrigin = EnsureSignedBy; type SuspensionJudgementOrigin = EnsureSignedBy; - type ChallengePeriod = ChallengePeriod; - type MaxCandidateIntake = MaxCandidateIntake; + type ChallengePeriod = ConstU64<8>; + type MaxCandidateIntake = ConstU32<10>; type PalletId = SocietyPalletId; } diff --git a/substrate/frame/staking/src/benchmarking.rs b/substrate/frame/staking/src/benchmarking.rs index f96b7fd2f3..cd9755366b 100644 --- a/substrate/frame/staking/src/benchmarking.rs +++ b/substrate/frame/staking/src/benchmarking.rs @@ -947,7 +947,7 @@ mod tests { let (validator_stash, nominators) = create_validator_with_nominators::( n, - ::MaxNominatorRewardedPerValidator::get() as u32, + ::MaxNominatorRewardedPerValidator::get(), false, RewardDestination::Staked, ) @@ -972,7 +972,7 @@ mod tests { let (validator_stash, _nominators) = create_validator_with_nominators::( n, - ::MaxNominatorRewardedPerValidator::get() as u32, + ::MaxNominatorRewardedPerValidator::get(), false, RewardDestination::Staked, ) diff --git a/substrate/frame/staking/src/mock.rs b/substrate/frame/staking/src/mock.rs index f6e2ce0e4b..ea9b9f05f1 100644 --- a/substrate/frame/staking/src/mock.rs +++ b/substrate/frame/staking/src/mock.rs @@ -22,7 +22,8 @@ use frame_election_provider_support::{onchain, SortedListProvider}; use frame_support::{ assert_ok, parameter_types, traits::{ - Currency, FindAuthor, GenesisBuild, Get, Hooks, Imbalance, OnUnbalanced, OneSessionHandler, + ConstU32, ConstU64, Currency, FindAuthor, GenesisBuild, Get, Hooks, Imbalance, + OnUnbalanced, OneSessionHandler, }, weights::constants::RocksDbWeight, }; @@ -113,12 +114,10 @@ impl FindAuthor for Author11 { } parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max( frame_support::weights::constants::WEIGHT_PER_SECOND * 2 ); - pub const MaxLocks: u32 = 1024; pub static SessionsPerEra: SessionIndex = 3; pub static ExistentialDeposit: Balance = 1; pub static SlashDeferDuration: EraIndex = 0; @@ -141,7 +140,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = frame_support::traits::ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -153,7 +152,7 @@ impl frame_system::Config for Test { type MaxConsumers = frame_support::traits::ConstU32<16>; } impl pallet_balances::Config for Test { - type MaxLocks = MaxLocks; + type MaxLocks = frame_support::traits::ConstU32<1024>; type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; @@ -163,9 +162,7 @@ impl pallet_balances::Config for Test { type AccountStore = System; type WeightInfo = (); } -parameter_types! { - pub const UncleGenerations: u64 = 0; -} + sp_runtime::impl_opaque_keys! { pub struct SessionKeys { pub other: OtherSessionHandler, @@ -189,19 +186,18 @@ impl pallet_session::historical::Config for Test { } impl pallet_authorship::Config for Test { type FindAuthor = Author11; - type UncleGenerations = UncleGenerations; + type UncleGenerations = ConstU64<0>; type FilterUncle = (); type EventHandler = Pallet; } -parameter_types! { - pub const MinimumPeriod: u64 = 5; -} + impl pallet_timestamp::Config for Test { type Moment = u64; type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; + type MinimumPeriod = ConstU64<5>; type WeightInfo = (); } + pallet_staking_reward_curve::build! { const I_NPOS: PiecewiseLinear<'static> = curve!( min_inflation: 0_025_000, @@ -215,7 +211,6 @@ pallet_staking_reward_curve::build! { parameter_types! { pub const BondingDuration: EraIndex = 3; pub const RewardCurve: &'static PiecewiseLinear<'static> = &I_NPOS; - pub const MaxNominatorRewardedPerValidator: u32 = 64; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(75); } @@ -269,7 +264,7 @@ impl crate::pallet::pallet::Config for Test { type SessionInterface = Self; type EraPayout = ConvertCurve; type NextNewSession = Session; - type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator; + type MaxNominatorRewardedPerValidator = ConstU32<64>; type OffendingValidatorsThreshold = OffendingValidatorsThreshold; type ElectionProvider = onchain::OnChainSequentialPhragmen; type GenesisElectionProvider = Self::ElectionProvider; diff --git a/substrate/frame/sudo/src/mock.rs b/substrate/frame/sudo/src/mock.rs index 408cccc7de..baea68788a 100644 --- a/substrate/frame/sudo/src/mock.rs +++ b/substrate/frame/sudo/src/mock.rs @@ -21,7 +21,7 @@ use super::*; use crate as sudo; use frame_support::{ parameter_types, - traits::{Contains, GenesisBuild}, + traits::{ConstU32, ConstU64, Contains, GenesisBuild}, }; use frame_system::limits; use sp_core::H256; @@ -109,7 +109,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: limits::BlockWeights = limits::BlockWeights::simple_max(1024); } @@ -135,7 +134,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -144,7 +143,7 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } // Implement the logger module's `Config` on the Test runtime. diff --git a/substrate/frame/support/src/storage/bounded_btree_map.rs b/substrate/frame/support/src/storage/bounded_btree_map.rs index 7a59206aeb..224ff496a9 100644 --- a/substrate/frame/support/src/storage/bounded_btree_map.rs +++ b/substrate/frame/support/src/storage/bounded_btree_map.rs @@ -306,18 +306,14 @@ impl codec::EncodeLike> for BoundedBTreeMap whe pub mod test { use super::*; use crate::Twox128; + use frame_support::traits::ConstU32; use sp_io::TestExternalities; - crate::parameter_types! { - pub const Seven: u32 = 7; - pub const Four: u32 = 4; - } - - crate::generate_storage_alias! { Prefix, Foo => Value> } - crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), BoundedBTreeMap> } + crate::generate_storage_alias! { Prefix, Foo => Value>> } + crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), BoundedBTreeMap>> } crate::generate_storage_alias! { Prefix, - FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), BoundedBTreeMap> + FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), BoundedBTreeMap>> } fn map_from_keys(keys: &[K]) -> BTreeMap @@ -338,13 +334,13 @@ pub mod test { #[test] fn decode_len_works() { TestExternalities::default().execute_with(|| { - let bounded = boundedmap_from_keys::(&[1, 2, 3]); + let bounded = boundedmap_from_keys::>(&[1, 2, 3]); Foo::put(bounded); assert_eq!(Foo::decode_len().unwrap(), 3); }); TestExternalities::default().execute_with(|| { - let bounded = boundedmap_from_keys::(&[1, 2, 3]); + let bounded = boundedmap_from_keys::>(&[1, 2, 3]); FooMap::insert(1, bounded); assert_eq!(FooMap::decode_len(1).unwrap(), 3); assert!(FooMap::decode_len(0).is_none()); @@ -352,7 +348,7 @@ pub mod test { }); TestExternalities::default().execute_with(|| { - let bounded = boundedmap_from_keys::(&[1, 2, 3]); + let bounded = boundedmap_from_keys::>(&[1, 2, 3]); FooDoubleMap::insert(1, 1, bounded); assert_eq!(FooDoubleMap::decode_len(1, 1).unwrap(), 3); assert!(FooDoubleMap::decode_len(2, 1).is_none()); @@ -363,7 +359,7 @@ pub mod test { #[test] fn try_insert_works() { - let mut bounded = boundedmap_from_keys::(&[1, 2, 3]); + let mut bounded = boundedmap_from_keys::>(&[1, 2, 3]); bounded.try_insert(0, ()).unwrap(); assert_eq!(*bounded, map_from_keys(&[1, 0, 2, 3])); @@ -373,7 +369,7 @@ pub mod test { #[test] fn deref_coercion_works() { - let bounded = boundedmap_from_keys::(&[1, 2, 3]); + let bounded = boundedmap_from_keys::>(&[1, 2, 3]); // these methods come from deref-ed vec. assert_eq!(bounded.len(), 3); assert!(bounded.iter().next().is_some()); @@ -382,7 +378,7 @@ pub mod test { #[test] fn try_mutate_works() { - let bounded = boundedmap_from_keys::(&[1, 2, 3, 4, 5, 6]); + let bounded = boundedmap_from_keys::>(&[1, 2, 3, 4, 5, 6]); let bounded = bounded .try_mutate(|v| { v.insert(7, ()); @@ -398,7 +394,7 @@ pub mod test { #[test] fn btree_map_eq_works() { - let bounded = boundedmap_from_keys::(&[1, 2, 3, 4, 5, 6]); + let bounded = boundedmap_from_keys::>(&[1, 2, 3, 4, 5, 6]); assert_eq!(bounded, map_from_keys(&[1, 2, 3, 4, 5, 6])); } @@ -406,7 +402,7 @@ pub mod test { fn too_big_fail_to_decode() { let v: Vec<(u32, u32)> = vec![(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]; assert_eq!( - BoundedBTreeMap::::decode(&mut &v.encode()[..]), + BoundedBTreeMap::>::decode(&mut &v.encode()[..]), Err("BoundedBTreeMap exceeds its limit".into()), ); } @@ -436,7 +432,7 @@ pub mod test { } } - let mut map = BoundedBTreeMap::::new(); + let mut map = BoundedBTreeMap::>::new(); // when the set is full diff --git a/substrate/frame/support/src/storage/bounded_btree_set.rs b/substrate/frame/support/src/storage/bounded_btree_set.rs index ecfb0bdbd2..af292aa1c8 100644 --- a/substrate/frame/support/src/storage/bounded_btree_set.rs +++ b/substrate/frame/support/src/storage/bounded_btree_set.rs @@ -287,19 +287,15 @@ impl codec::EncodeLike> for BoundedBTreeSet where BTreeS pub mod test { use super::*; use crate::Twox128; + use frame_support::traits::ConstU32; use sp_io::TestExternalities; use sp_std::convert::TryInto; - crate::parameter_types! { - pub const Seven: u32 = 7; - pub const Four: u32 = 4; - } - - crate::generate_storage_alias! { Prefix, Foo => Value> } - crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), BoundedBTreeSet> } + crate::generate_storage_alias! { Prefix, Foo => Value>> } + crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), BoundedBTreeSet>> } crate::generate_storage_alias! { Prefix, - FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), BoundedBTreeSet> + FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), BoundedBTreeSet>> } fn map_from_keys(keys: &[T]) -> BTreeSet @@ -320,13 +316,13 @@ pub mod test { #[test] fn decode_len_works() { TestExternalities::default().execute_with(|| { - let bounded = boundedmap_from_keys::(&[1, 2, 3]); + let bounded = boundedmap_from_keys::>(&[1, 2, 3]); Foo::put(bounded); assert_eq!(Foo::decode_len().unwrap(), 3); }); TestExternalities::default().execute_with(|| { - let bounded = boundedmap_from_keys::(&[1, 2, 3]); + let bounded = boundedmap_from_keys::>(&[1, 2, 3]); FooMap::insert(1, bounded); assert_eq!(FooMap::decode_len(1).unwrap(), 3); assert!(FooMap::decode_len(0).is_none()); @@ -334,7 +330,7 @@ pub mod test { }); TestExternalities::default().execute_with(|| { - let bounded = boundedmap_from_keys::(&[1, 2, 3]); + let bounded = boundedmap_from_keys::>(&[1, 2, 3]); FooDoubleMap::insert(1, 1, bounded); assert_eq!(FooDoubleMap::decode_len(1, 1).unwrap(), 3); assert!(FooDoubleMap::decode_len(2, 1).is_none()); @@ -345,7 +341,7 @@ pub mod test { #[test] fn try_insert_works() { - let mut bounded = boundedmap_from_keys::(&[1, 2, 3]); + let mut bounded = boundedmap_from_keys::>(&[1, 2, 3]); bounded.try_insert(0).unwrap(); assert_eq!(*bounded, map_from_keys(&[1, 0, 2, 3])); @@ -355,7 +351,7 @@ pub mod test { #[test] fn deref_coercion_works() { - let bounded = boundedmap_from_keys::(&[1, 2, 3]); + let bounded = boundedmap_from_keys::>(&[1, 2, 3]); // these methods come from deref-ed vec. assert_eq!(bounded.len(), 3); assert!(bounded.iter().next().is_some()); @@ -364,7 +360,7 @@ pub mod test { #[test] fn try_mutate_works() { - let bounded = boundedmap_from_keys::(&[1, 2, 3, 4, 5, 6]); + let bounded = boundedmap_from_keys::>(&[1, 2, 3, 4, 5, 6]); let bounded = bounded .try_mutate(|v| { v.insert(7); @@ -380,7 +376,7 @@ pub mod test { #[test] fn btree_map_eq_works() { - let bounded = boundedmap_from_keys::(&[1, 2, 3, 4, 5, 6]); + let bounded = boundedmap_from_keys::>(&[1, 2, 3, 4, 5, 6]); assert_eq!(bounded, map_from_keys(&[1, 2, 3, 4, 5, 6])); } @@ -388,7 +384,7 @@ pub mod test { fn too_big_fail_to_decode() { let v: Vec = vec![1, 2, 3, 4, 5]; assert_eq!( - BoundedBTreeSet::::decode(&mut &v.encode()[..]), + BoundedBTreeSet::>::decode(&mut &v.encode()[..]), Err("BoundedBTreeSet exceeds its limit".into()), ); } @@ -418,7 +414,7 @@ pub mod test { } } - let mut set = BoundedBTreeSet::::new(); + let mut set = BoundedBTreeSet::>::new(); // when the set is full diff --git a/substrate/frame/support/src/storage/bounded_vec.rs b/substrate/frame/support/src/storage/bounded_vec.rs index b9ece89bff..decf2cb341 100644 --- a/substrate/frame/support/src/storage/bounded_vec.rs +++ b/substrate/frame/support/src/storage/bounded_vec.rs @@ -348,35 +348,31 @@ where pub mod test { use super::*; use crate::Twox128; + use frame_support::traits::ConstU32; use sp_io::TestExternalities; - crate::parameter_types! { - pub const Seven: u32 = 7; - pub const Four: u32 = 4; - } - - crate::generate_storage_alias! { Prefix, Foo => Value> } - crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), BoundedVec> } + crate::generate_storage_alias! { Prefix, Foo => Value>> } + crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), BoundedVec>> } crate::generate_storage_alias! { Prefix, - FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), BoundedVec> + FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), BoundedVec>> } #[test] fn try_append_is_correct() { - assert_eq!(BoundedVec::::bound(), 7); + assert_eq!(BoundedVec::>::bound(), 7); } #[test] fn decode_len_works() { TestExternalities::default().execute_with(|| { - let bounded: BoundedVec = vec![1, 2, 3].try_into().unwrap(); + let bounded: BoundedVec> = vec![1, 2, 3].try_into().unwrap(); Foo::put(bounded); assert_eq!(Foo::decode_len().unwrap(), 3); }); TestExternalities::default().execute_with(|| { - let bounded: BoundedVec = vec![1, 2, 3].try_into().unwrap(); + let bounded: BoundedVec> = vec![1, 2, 3].try_into().unwrap(); FooMap::insert(1, bounded); assert_eq!(FooMap::decode_len(1).unwrap(), 3); assert!(FooMap::decode_len(0).is_none()); @@ -384,7 +380,7 @@ pub mod test { }); TestExternalities::default().execute_with(|| { - let bounded: BoundedVec = vec![1, 2, 3].try_into().unwrap(); + let bounded: BoundedVec> = vec![1, 2, 3].try_into().unwrap(); FooDoubleMap::insert(1, 1, bounded); assert_eq!(FooDoubleMap::decode_len(1, 1).unwrap(), 3); assert!(FooDoubleMap::decode_len(2, 1).is_none()); @@ -395,7 +391,7 @@ pub mod test { #[test] fn try_insert_works() { - let mut bounded: BoundedVec = vec![1, 2, 3].try_into().unwrap(); + let mut bounded: BoundedVec> = vec![1, 2, 3].try_into().unwrap(); bounded.try_insert(1, 0).unwrap(); assert_eq!(*bounded, vec![1, 0, 2, 3]); @@ -406,13 +402,13 @@ pub mod test { #[test] #[should_panic(expected = "insertion index (is 9) should be <= len (is 3)")] fn try_inert_panics_if_oob() { - let mut bounded: BoundedVec = vec![1, 2, 3].try_into().unwrap(); + let mut bounded: BoundedVec> = vec![1, 2, 3].try_into().unwrap(); bounded.try_insert(9, 0).unwrap(); } #[test] fn try_push_works() { - let mut bounded: BoundedVec = vec![1, 2, 3].try_into().unwrap(); + let mut bounded: BoundedVec> = vec![1, 2, 3].try_into().unwrap(); bounded.try_push(0).unwrap(); assert_eq!(*bounded, vec![1, 2, 3, 0]); @@ -421,7 +417,7 @@ pub mod test { #[test] fn deref_coercion_works() { - let bounded: BoundedVec = vec![1, 2, 3].try_into().unwrap(); + let bounded: BoundedVec> = vec![1, 2, 3].try_into().unwrap(); // these methods come from deref-ed vec. assert_eq!(bounded.len(), 3); assert!(bounded.iter().next().is_some()); @@ -430,7 +426,7 @@ pub mod test { #[test] fn try_mutate_works() { - let bounded: BoundedVec = vec![1, 2, 3, 4, 5, 6].try_into().unwrap(); + let bounded: BoundedVec> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap(); let bounded = bounded.try_mutate(|v| v.push(7)).unwrap(); assert_eq!(bounded.len(), 7); assert!(bounded.try_mutate(|v| v.push(8)).is_none()); @@ -438,13 +434,13 @@ pub mod test { #[test] fn slice_indexing_works() { - let bounded: BoundedVec = vec![1, 2, 3, 4, 5, 6].try_into().unwrap(); + let bounded: BoundedVec> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap(); assert_eq!(&bounded[0..=2], &[1, 2, 3]); } #[test] fn vec_eq_works() { - let bounded: BoundedVec = vec![1, 2, 3, 4, 5, 6].try_into().unwrap(); + let bounded: BoundedVec> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap(); assert_eq!(bounded, vec![1, 2, 3, 4, 5, 6]); } @@ -452,7 +448,7 @@ pub mod test { fn too_big_vec_fail_to_decode() { let v: Vec = vec![1, 2, 3, 4, 5]; assert_eq!( - BoundedVec::::decode(&mut &v.encode()[..]), + BoundedVec::>::decode(&mut &v.encode()[..]), Err("BoundedVec exceeds its limit".into()), ); } diff --git a/substrate/frame/support/src/storage/mod.rs b/substrate/frame/support/src/storage/mod.rs index 9217cf4e6d..3cfe2bfaa5 100644 --- a/substrate/frame/support/src/storage/mod.rs +++ b/substrate/frame/support/src/storage/mod.rs @@ -1404,6 +1404,7 @@ mod test { use super::*; use crate::{assert_ok, hash::Identity, Twox128}; use bounded_vec::BoundedVec; + use frame_support::traits::ConstU32; use generator::StorageValue as _; use sp_core::hashing::twox_128; use sp_io::TestExternalities; @@ -1714,22 +1715,17 @@ mod test { }); } - crate::parameter_types! { - pub const Seven: u32 = 7; - pub const Four: u32 = 4; - } - - crate::generate_storage_alias! { Prefix, Foo => Value> } - crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), BoundedVec> } + crate::generate_storage_alias! { Prefix, Foo => Value>> } + crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), BoundedVec>> } crate::generate_storage_alias! { Prefix, - FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), BoundedVec> + FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), BoundedVec>> } #[test] fn try_append_works() { TestExternalities::default().execute_with(|| { - let bounded: WeakBoundedVec = vec![1, 2, 3].try_into().unwrap(); + let bounded: WeakBoundedVec> = vec![1, 2, 3].try_into().unwrap(); Foo::put(bounded); assert_ok!(Foo::try_append(4)); assert_ok!(Foo::try_append(5)); @@ -1740,7 +1736,7 @@ mod test { }); TestExternalities::default().execute_with(|| { - let bounded: BoundedVec = vec![1, 2, 3].try_into().unwrap(); + let bounded: BoundedVec> = vec![1, 2, 3].try_into().unwrap(); FooMap::insert(1, bounded); assert_ok!(FooMap::try_append(1, 4)); @@ -1755,17 +1751,17 @@ mod test { assert_ok!(FooMap::try_append(2, 4)); assert_eq!( FooMap::get(2).unwrap(), - BoundedVec::::try_from(vec![4]).unwrap(), + BoundedVec::>::try_from(vec![4]).unwrap(), ); assert_ok!(FooMap::try_append(2, 5)); assert_eq!( FooMap::get(2).unwrap(), - BoundedVec::::try_from(vec![4, 5]).unwrap(), + BoundedVec::>::try_from(vec![4, 5]).unwrap(), ); }); TestExternalities::default().execute_with(|| { - let bounded: BoundedVec = vec![1, 2, 3].try_into().unwrap(); + let bounded: BoundedVec> = vec![1, 2, 3].try_into().unwrap(); FooDoubleMap::insert(1, 1, bounded); assert_ok!(FooDoubleMap::try_append(1, 1, 4)); @@ -1780,12 +1776,12 @@ mod test { assert_ok!(FooDoubleMap::try_append(2, 1, 4)); assert_eq!( FooDoubleMap::get(2, 1).unwrap(), - BoundedVec::::try_from(vec![4]).unwrap(), + BoundedVec::>::try_from(vec![4]).unwrap(), ); assert_ok!(FooDoubleMap::try_append(2, 1, 5)); assert_eq!( FooDoubleMap::get(2, 1).unwrap(), - BoundedVec::::try_from(vec![4, 5]).unwrap(), + BoundedVec::>::try_from(vec![4, 5]).unwrap(), ); }); } diff --git a/substrate/frame/support/src/storage/weak_bounded_vec.rs b/substrate/frame/support/src/storage/weak_bounded_vec.rs index 566889f5f1..641b623053 100644 --- a/substrate/frame/support/src/storage/weak_bounded_vec.rs +++ b/substrate/frame/support/src/storage/weak_bounded_vec.rs @@ -318,36 +318,32 @@ where pub mod test { use super::*; use crate::Twox128; + use frame_support::traits::ConstU32; use sp_io::TestExternalities; use sp_std::convert::TryInto; - crate::parameter_types! { - pub const Seven: u32 = 7; - pub const Four: u32 = 4; - } - - crate::generate_storage_alias! { Prefix, Foo => Value> } - crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), WeakBoundedVec> } + crate::generate_storage_alias! { Prefix, Foo => Value>> } + crate::generate_storage_alias! { Prefix, FooMap => Map<(u32, Twox128), WeakBoundedVec>> } crate::generate_storage_alias! { Prefix, - FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), WeakBoundedVec> + FooDoubleMap => DoubleMap<(u32, Twox128), (u32, Twox128), WeakBoundedVec>> } #[test] fn try_append_is_correct() { - assert_eq!(WeakBoundedVec::::bound(), 7); + assert_eq!(WeakBoundedVec::>::bound(), 7); } #[test] fn decode_len_works() { TestExternalities::default().execute_with(|| { - let bounded: WeakBoundedVec = vec![1, 2, 3].try_into().unwrap(); + let bounded: WeakBoundedVec> = vec![1, 2, 3].try_into().unwrap(); Foo::put(bounded); assert_eq!(Foo::decode_len().unwrap(), 3); }); TestExternalities::default().execute_with(|| { - let bounded: WeakBoundedVec = vec![1, 2, 3].try_into().unwrap(); + let bounded: WeakBoundedVec> = vec![1, 2, 3].try_into().unwrap(); FooMap::insert(1, bounded); assert_eq!(FooMap::decode_len(1).unwrap(), 3); assert!(FooMap::decode_len(0).is_none()); @@ -355,7 +351,7 @@ pub mod test { }); TestExternalities::default().execute_with(|| { - let bounded: WeakBoundedVec = vec![1, 2, 3].try_into().unwrap(); + let bounded: WeakBoundedVec> = vec![1, 2, 3].try_into().unwrap(); FooDoubleMap::insert(1, 1, bounded); assert_eq!(FooDoubleMap::decode_len(1, 1).unwrap(), 3); assert!(FooDoubleMap::decode_len(2, 1).is_none()); @@ -366,7 +362,7 @@ pub mod test { #[test] fn try_insert_works() { - let mut bounded: WeakBoundedVec = vec![1, 2, 3].try_into().unwrap(); + let mut bounded: WeakBoundedVec> = vec![1, 2, 3].try_into().unwrap(); bounded.try_insert(1, 0).unwrap(); assert_eq!(*bounded, vec![1, 0, 2, 3]); @@ -377,13 +373,13 @@ pub mod test { #[test] #[should_panic(expected = "insertion index (is 9) should be <= len (is 3)")] fn try_inert_panics_if_oob() { - let mut bounded: WeakBoundedVec = vec![1, 2, 3].try_into().unwrap(); + let mut bounded: WeakBoundedVec> = vec![1, 2, 3].try_into().unwrap(); bounded.try_insert(9, 0).unwrap(); } #[test] fn try_push_works() { - let mut bounded: WeakBoundedVec = vec![1, 2, 3].try_into().unwrap(); + let mut bounded: WeakBoundedVec> = vec![1, 2, 3].try_into().unwrap(); bounded.try_push(0).unwrap(); assert_eq!(*bounded, vec![1, 2, 3, 0]); @@ -392,7 +388,7 @@ pub mod test { #[test] fn deref_coercion_works() { - let bounded: WeakBoundedVec = vec![1, 2, 3].try_into().unwrap(); + let bounded: WeakBoundedVec> = vec![1, 2, 3].try_into().unwrap(); // these methods come from deref-ed vec. assert_eq!(bounded.len(), 3); assert!(bounded.iter().next().is_some()); @@ -401,7 +397,7 @@ pub mod test { #[test] fn try_mutate_works() { - let bounded: WeakBoundedVec = vec![1, 2, 3, 4, 5, 6].try_into().unwrap(); + let bounded: WeakBoundedVec> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap(); let bounded = bounded.try_mutate(|v| v.push(7)).unwrap(); assert_eq!(bounded.len(), 7); assert!(bounded.try_mutate(|v| v.push(8)).is_none()); @@ -409,20 +405,20 @@ pub mod test { #[test] fn slice_indexing_works() { - let bounded: WeakBoundedVec = vec![1, 2, 3, 4, 5, 6].try_into().unwrap(); + let bounded: WeakBoundedVec> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap(); assert_eq!(&bounded[0..=2], &[1, 2, 3]); } #[test] fn vec_eq_works() { - let bounded: WeakBoundedVec = vec![1, 2, 3, 4, 5, 6].try_into().unwrap(); + let bounded: WeakBoundedVec> = vec![1, 2, 3, 4, 5, 6].try_into().unwrap(); assert_eq!(bounded, vec![1, 2, 3, 4, 5, 6]); } #[test] fn too_big_succeed_to_decode() { let v: Vec = vec![1, 2, 3, 4, 5]; - let w = WeakBoundedVec::::decode(&mut &v.encode()[..]).unwrap(); + let w = WeakBoundedVec::>::decode(&mut &v.encode()[..]).unwrap(); assert_eq!(v, *w); } } diff --git a/substrate/frame/support/test/compile_pass/src/lib.rs b/substrate/frame/support/test/compile_pass/src/lib.rs index 06fb6345d3..a558699621 100644 --- a/substrate/frame/support/test/compile_pass/src/lib.rs +++ b/substrate/frame/support/test/compile_pass/src/lib.rs @@ -22,7 +22,10 @@ //! This crate tests that `construct_runtime!` expands the pallet parts //! correctly even when frame-support is renamed in Cargo.toml -use frame_support::{construct_runtime, parameter_types}; +use frame_support::{ + construct_runtime, parameter_types, + traits::{ConstU16, ConstU32}, +}; use sp_core::{sr25519, H256}; use sp_runtime::{ create_runtime_str, generic, @@ -48,7 +51,6 @@ pub type Index = u64; parameter_types! { pub const BlockHashCount: BlockNumber = 2400; pub const Version: RuntimeVersion = VERSION; - pub const SS58Prefix: u8 = 0; } impl frame_system::Config for Runtime { @@ -73,9 +75,9 @@ impl frame_system::Config for Runtime { type OnNewAccount = (); type OnKilledAccount = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; type SystemWeightInfo = (); - type SS58Prefix = SS58Prefix; + type SS58Prefix = ConstU16<0>; } pub type Header = generic::Header; diff --git a/substrate/frame/support/test/tests/instance.rs b/substrate/frame/support/test/tests/instance.rs index 809edae14f..5677b9ac14 100644 --- a/substrate/frame/support/test/tests/instance.rs +++ b/substrate/frame/support/test/tests/instance.rs @@ -24,8 +24,7 @@ use frame_support::{ PalletStorageMetadata, StorageEntryMetadata, StorageEntryModifier, StorageEntryType, StorageHasher, }, - parameter_types, - traits::Get, + traits::{ConstU32, Get}, Parameter, StorageDoubleMap, StorageMap, StorageValue, }; use scale_info::TypeInfo; @@ -229,20 +228,16 @@ mod module3 { } } -parameter_types! { - pub const SomeValue: u32 = 100; -} - impl module1::Config for Runtime { type Event = Event; type Origin = Origin; - type SomeParameter = SomeValue; + type SomeParameter = ConstU32<100>; type GenericType = u32; } impl module1::Config for Runtime { type Event = Event; type Origin = Origin; - type SomeParameter = SomeValue; + type SomeParameter = ConstU32<100>; type GenericType = u32; } impl module2::Config for Runtime { diff --git a/substrate/frame/support/test/tests/pallet.rs b/substrate/frame/support/test/tests/pallet.rs index e9c6fe8be5..e57c3466e7 100644 --- a/substrate/frame/support/test/tests/pallet.rs +++ b/substrate/frame/support/test/tests/pallet.rs @@ -19,8 +19,8 @@ use frame_support::{ dispatch::{Parameter, UnfilteredDispatchable}, storage::unhashed, traits::{ - GetCallName, GetStorageVersion, OnFinalize, OnGenesis, OnInitialize, OnRuntimeUpgrade, - PalletInfoAccess, StorageVersion, + ConstU32, GetCallName, GetStorageVersion, OnFinalize, OnGenesis, OnInitialize, + OnRuntimeUpgrade, PalletInfoAccess, StorageVersion, }, weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays, RuntimeDbWeight}, }; @@ -536,10 +536,7 @@ pub mod pallet4 { } frame_support::parameter_types!( - pub const MyGetParam: u32 = 10; - pub const MyGetParam2: u32 = 11; pub const MyGetParam3: u32 = 12; - pub const BlockHashCount: u32 = 250; ); impl frame_system::Config for Runtime { @@ -554,7 +551,7 @@ impl frame_system::Config for Runtime { type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU32<250>; type BlockWeights = (); type BlockLength = (); type DbWeight = (); @@ -566,12 +563,12 @@ impl frame_system::Config for Runtime { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl pallet::Config for Runtime { type Event = Event; - type MyGetParam = MyGetParam; - type MyGetParam2 = MyGetParam2; + type MyGetParam = ConstU32<10>; + type MyGetParam2 = ConstU32<11>; type MyGetParam3 = MyGetParam3; type Balance = u64; } diff --git a/substrate/frame/support/test/tests/pallet_compatibility.rs b/substrate/frame/support/test/tests/pallet_compatibility.rs index 0cd6a6e59c..b1ed08051f 100644 --- a/substrate/frame/support/test/tests/pallet_compatibility.rs +++ b/substrate/frame/support/test/tests/pallet_compatibility.rs @@ -15,6 +15,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +use frame_support::traits::{ConstU32, ConstU64}; + pub trait SomeAssociation { type A: frame_support::dispatch::Parameter + Default; } @@ -217,11 +219,6 @@ pub mod pallet { } } -frame_support::parameter_types!( - pub const SomeConst: u64 = 10; - pub const BlockHashCount: u32 = 250; -); - impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type Origin = Origin; @@ -234,7 +231,7 @@ impl frame_system::Config for Runtime { type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU32<250>; type BlockWeights = (); type BlockLength = (); type DbWeight = (); @@ -246,16 +243,16 @@ impl frame_system::Config for Runtime { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl pallet::Config for Runtime { type Event = Event; - type SomeConst = SomeConst; + type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet_old::Config for Runtime { type Event = Event; - type SomeConst = SomeConst; + type SomeConst = ConstU64<10>; type Balance = u64; } diff --git a/substrate/frame/support/test/tests/pallet_compatibility_instance.rs b/substrate/frame/support/test/tests/pallet_compatibility_instance.rs index 16f5e16cb8..81e16ee362 100644 --- a/substrate/frame/support/test/tests/pallet_compatibility_instance.rs +++ b/substrate/frame/support/test/tests/pallet_compatibility_instance.rs @@ -15,6 +15,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +use frame_support::traits::{ConstU32, ConstU64}; + mod pallet_old { use frame_support::{ decl_error, decl_event, decl_module, decl_storage, traits::Get, weights::Weight, Parameter, @@ -197,11 +199,6 @@ pub mod pallet { } } -frame_support::parameter_types!( - pub const SomeConst: u64 = 10; - pub const BlockHashCount: u32 = 250; -); - impl frame_system::Config for Runtime { type BlockWeights = (); type BlockLength = (); @@ -217,7 +214,7 @@ impl frame_system::Config for Runtime { type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU32<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -226,36 +223,36 @@ impl frame_system::Config for Runtime { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl pallet::Config for Runtime { type Event = Event; - type SomeConst = SomeConst; + type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet::Config for Runtime { type Event = Event; - type SomeConst = SomeConst; + type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet::Config for Runtime { type Event = Event; - type SomeConst = SomeConst; + type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet_old::Config for Runtime { type Event = Event; - type SomeConst = SomeConst; + type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet_old::Config for Runtime { type Event = Event; - type SomeConst = SomeConst; + type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet_old::Config for Runtime { type Event = Event; - type SomeConst = SomeConst; + type SomeConst = ConstU64<10>; type Balance = u64; } diff --git a/substrate/frame/support/test/tests/pallet_instance.rs b/substrate/frame/support/test/tests/pallet_instance.rs index 9fd748eb33..740bfe51d4 100644 --- a/substrate/frame/support/test/tests/pallet_instance.rs +++ b/substrate/frame/support/test/tests/pallet_instance.rs @@ -18,7 +18,7 @@ use frame_support::{ dispatch::UnfilteredDispatchable, storage::unhashed, - traits::{GetCallName, OnFinalize, OnGenesis, OnInitialize, OnRuntimeUpgrade}, + traits::{ConstU32, GetCallName, OnFinalize, OnGenesis, OnInitialize, OnRuntimeUpgrade}, weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Pays}, }; use sp_io::{ @@ -245,11 +245,6 @@ pub mod pallet2 { } } -frame_support::parameter_types!( - pub const MyGetParam: u32 = 10; - pub const BlockHashCount: u32 = 250; -); - impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type Origin = Origin; @@ -262,7 +257,7 @@ impl frame_system::Config for Runtime { type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU32<250>; type BlockWeights = (); type BlockLength = (); type DbWeight = (); @@ -274,16 +269,16 @@ impl frame_system::Config for Runtime { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl pallet::Config for Runtime { type Event = Event; - type MyGetParam = MyGetParam; + type MyGetParam = ConstU32<10>; type Balance = u64; } impl pallet::Config for Runtime { type Event = Event; - type MyGetParam = MyGetParam; + type MyGetParam = ConstU32<10>; type Balance = u64; } impl pallet2::Config for Runtime { diff --git a/substrate/frame/support/test/tests/pallet_with_name_trait_is_valid.rs b/substrate/frame/support/test/tests/pallet_with_name_trait_is_valid.rs index 170e515740..128960fdb1 100644 --- a/substrate/frame/support/test/tests/pallet_with_name_trait_is_valid.rs +++ b/substrate/frame/support/test/tests/pallet_with_name_trait_is_valid.rs @@ -97,7 +97,7 @@ impl frame_support::inherent::ProvideInherent for Module { mod tests { use crate as pallet_test; - use frame_support::parameter_types; + use frame_support::traits::ConstU64; type SignedExtra = ( frame_system::CheckEra, @@ -124,10 +124,6 @@ mod tests { } ); - parameter_types! { - pub const BlockHashCount: u64 = 250; - } - impl frame_system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; type Origin = Origin; @@ -140,7 +136,7 @@ mod tests { type Lookup = sp_runtime::traits::IdentityLookup; type Header = TestHeader; type Event = (); - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type DbWeight = (); type BlockWeights = (); type BlockLength = (); diff --git a/substrate/frame/system/benches/bench.rs b/substrate/frame/system/benches/bench.rs index 0d513ff599..f1d819cb65 100644 --- a/substrate/frame/system/benches/bench.rs +++ b/substrate/frame/system/benches/bench.rs @@ -16,6 +16,7 @@ // limitations under the License. use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use frame_support::traits::{ConstU32, ConstU64}; use sp_core::H256; use sp_runtime::{ testing::Header, @@ -58,7 +59,6 @@ frame_support::construct_runtime!( ); frame_support::parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::with_sensible_defaults( 4 * 1024 * 1024, Perbill::from_percent(75), @@ -83,7 +83,7 @@ impl frame_system::Config for Runtime { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -92,7 +92,7 @@ impl frame_system::Config for Runtime { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl module::Config for Runtime { diff --git a/substrate/frame/system/src/mock.rs b/substrate/frame/system/src/mock.rs index de89324ec9..d8d9e7323a 100644 --- a/substrate/frame/system/src/mock.rs +++ b/substrate/frame/system/src/mock.rs @@ -16,7 +16,10 @@ // limitations under the License. use crate::{self as frame_system, *}; -use frame_support::parameter_types; +use frame_support::{ + parameter_types, + traits::{ConstU32, ConstU64}, +}; use sp_core::H256; use sp_runtime::{ testing::Header, @@ -42,7 +45,6 @@ const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); const MAX_BLOCK_WEIGHT: Weight = 1024; parameter_types! { - pub const BlockHashCount: u64 = 10; pub Version: RuntimeVersion = RuntimeVersion { spec_name: sp_version::create_runtime_str!("test"), impl_name: sp_version::create_runtime_str!("system-test"), @@ -101,7 +103,7 @@ impl Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<10>; type DbWeight = DbWeight; type Version = Version; type PalletInfo = PalletInfo; @@ -111,7 +113,7 @@ impl Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } pub type SysEvent = frame_system::Event; diff --git a/substrate/frame/timestamp/src/lib.rs b/substrate/frame/timestamp/src/lib.rs index ae9a3b5f69..0d2c3f385d 100644 --- a/substrate/frame/timestamp/src/lib.rs +++ b/substrate/frame/timestamp/src/lib.rs @@ -316,7 +316,10 @@ mod tests { use super::*; use crate as pallet_timestamp; - use frame_support::{assert_ok, parameter_types}; + use frame_support::{ + assert_ok, parameter_types, + traits::{ConstU32, ConstU64}, + }; use sp_core::H256; use sp_io::TestExternalities; use sp_runtime::{ @@ -344,7 +347,6 @@ mod tests { ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -363,7 +365,7 @@ mod tests { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); @@ -372,15 +374,13 @@ mod tests { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; - } - parameter_types! { - pub const MinimumPeriod: u64 = 5; + type MaxConsumers = ConstU32<16>; } + impl Config for Test { type Moment = u64; type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; + type MinimumPeriod = ConstU64<5>; type WeightInfo = (); } diff --git a/substrate/frame/tips/src/tests.rs b/substrate/frame/tips/src/tests.rs index 7d6a717347..5bab523b03 100644 --- a/substrate/frame/tips/src/tests.rs +++ b/substrate/frame/tips/src/tests.rs @@ -30,8 +30,12 @@ use sp_runtime::{ use sp_storage::Storage; use frame_support::{ - assert_noop, assert_ok, pallet_prelude::GenesisBuild, parameter_types, - storage::StoragePrefixedMap, traits::SortedMembers, weights::Weight, PalletId, + assert_noop, assert_ok, + pallet_prelude::GenesisBuild, + parameter_types, + storage::StoragePrefixedMap, + traits::{ConstU32, ConstU64, SortedMembers}, + PalletId, }; use super::*; @@ -54,9 +58,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; - pub const MaximumBlockWeight: Weight = 1024; - pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); } impl frame_system::Config for Test { @@ -74,7 +75,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -83,11 +84,9 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} -parameter_types! { - pub const ExistentialDeposit: u64 = 1; + type MaxConsumers = ConstU32<16>; } + impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); @@ -95,7 +94,7 @@ impl pallet_balances::Config for Test { type Balance = u64; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } @@ -126,13 +125,8 @@ impl ContainsLengthBound for TenToFourteen { } parameter_types! { pub const ProposalBond: Permill = Permill::from_percent(5); - pub const ProposalBondMinimum: u64 = 1; - pub const SpendPeriod: u64 = 2; pub const Burn: Permill = Permill::from_percent(50); - pub const DataDepositPerByte: u64 = 1; pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); - pub const MaximumReasonLength: u32 = 16384; - pub const MaxApprovals: u32 = 100; } impl pallet_treasury::Config for Test { type PalletId = TreasuryPalletId; @@ -142,26 +136,24 @@ impl pallet_treasury::Config for Test { type Event = Event; type OnSlash = (); type ProposalBond = ProposalBond; - type ProposalBondMinimum = ProposalBondMinimum; - type SpendPeriod = SpendPeriod; + type ProposalBondMinimum = ConstU64<1>; + type SpendPeriod = ConstU64<2>; type Burn = Burn; type BurnDestination = (); // Just gets burned. type WeightInfo = (); type SpendFunds = (); - type MaxApprovals = MaxApprovals; + type MaxApprovals = ConstU32<100>; } parameter_types! { - pub const TipCountdown: u64 = 1; pub const TipFindersFee: Percent = Percent::from_percent(20); - pub const TipReportDepositBase: u64 = 1; } impl Config for Test { - type MaximumReasonLength = MaximumReasonLength; + type MaximumReasonLength = ConstU32<16384>; type Tippers = TenToFourteen; - type TipCountdown = TipCountdown; + type TipCountdown = ConstU64<1>; type TipFindersFee = TipFindersFee; - type TipReportDepositBase = TipReportDepositBase; - type DataDepositPerByte = DataDepositPerByte; + type TipReportDepositBase = ConstU64<1>; + type DataDepositPerByte = ConstU64<1>; type Event = Event; type WeightInfo = (); } diff --git a/substrate/frame/transaction-payment/asset-tx-payment/src/tests.rs b/substrate/frame/transaction-payment/asset-tx-payment/src/tests.rs index c6c60cfe23..6292829d21 100644 --- a/substrate/frame/transaction-payment/asset-tx-payment/src/tests.rs +++ b/substrate/frame/transaction-payment/asset-tx-payment/src/tests.rs @@ -20,7 +20,7 @@ use frame_support::{ assert_ok, pallet_prelude::*, parameter_types, - traits::{fungibles::Mutate, FindAuthor}, + traits::{fungibles::Mutate, ConstU32, ConstU64, ConstU8, FindAuthor}, weights::{ DispatchClass, DispatchInfo, PostDispatchInfo, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, @@ -83,7 +83,6 @@ impl Get for BlockWeights { } parameter_types! { - pub const BlockHashCount: u64 = 250; pub static TransactionByteFee: u64 = 1; pub static WeightToFee: u64 = 1; } @@ -103,7 +102,7 @@ impl frame_system::Config for Runtime { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -112,23 +111,22 @@ impl frame_system::Config for Runtime { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } parameter_types! { pub const ExistentialDeposit: u64 = 10; - pub const MaxReserves: u32 = 50; } impl pallet_balances::Config for Runtime { type Balance = Balance; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<10>; type AccountStore = System; type MaxLocks = (); type WeightInfo = (); - type MaxReserves = MaxReserves; + type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; } @@ -145,22 +143,12 @@ impl WeightToFeePolynomial for WeightToFee { } } -parameter_types! { - pub const OperationalFeeMultiplier: u8 = 5; -} - impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = CurrencyAdapter; type TransactionByteFee = TransactionByteFee; type WeightToFee = WeightToFee; type FeeMultiplierUpdate = (); - type OperationalFeeMultiplier = OperationalFeeMultiplier; -} - -parameter_types! { - pub const AssetDeposit: u64 = 2; - pub const MetadataDeposit: u64 = 0; - pub const StringLimit: u32 = 20; + type OperationalFeeMultiplier = ConstU8<5>; } impl pallet_assets::Config for Runtime { @@ -169,12 +157,12 @@ impl pallet_assets::Config for Runtime { type AssetId = u32; type Currency = Balances; type ForceOrigin = EnsureRoot; - type AssetDeposit = AssetDeposit; - type AssetAccountDeposit = frame_support::traits::ConstU64<2>; - type MetadataDepositBase = MetadataDeposit; - type MetadataDepositPerByte = MetadataDeposit; - type ApprovalDeposit = MetadataDeposit; - type StringLimit = StringLimit; + type AssetDeposit = ConstU64<2>; + type AssetAccountDeposit = ConstU64<2>; + type MetadataDepositBase = ConstU64<0>; + type MetadataDepositPerByte = ConstU64<0>; + type ApprovalDeposit = ConstU64<0>; + type StringLimit = ConstU32<20>; type Freezer = (); type Extra = (); type WeightInfo = (); diff --git a/substrate/frame/transaction-payment/src/lib.rs b/substrate/frame/transaction-payment/src/lib.rs index c7ccdafc78..fa8b0e9be0 100644 --- a/substrate/frame/transaction-payment/src/lib.rs +++ b/substrate/frame/transaction-payment/src/lib.rs @@ -789,7 +789,7 @@ mod tests { use frame_support::{ assert_noop, assert_ok, parameter_types, - traits::{Currency, Imbalance, OnUnbalanced}, + traits::{ConstU32, ConstU64, Currency, Imbalance, OnUnbalanced}, weights::{ DispatchClass, DispatchInfo, GetDispatchInfo, PostDispatchInfo, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, @@ -836,7 +836,6 @@ mod tests { } parameter_types! { - pub const BlockHashCount: u64 = 250; pub static TransactionByteFee: u64 = 1; pub static WeightToFee: u64 = 1; pub static OperationalFeeMultiplier: u8 = 5; @@ -857,7 +856,7 @@ mod tests { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -866,18 +865,14 @@ mod tests { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; - } - - parameter_types! { - pub const ExistentialDeposit: u64 = 1; + type MaxConsumers = ConstU32<16>; } impl pallet_balances::Config for Runtime { type Balance = u64; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type MaxLocks = (); type MaxReserves = (); diff --git a/substrate/frame/transaction-storage/src/mock.rs b/substrate/frame/transaction-storage/src/mock.rs index 49b81348e7..6356312ca5 100644 --- a/substrate/frame/transaction-storage/src/mock.rs +++ b/substrate/frame/transaction-storage/src/mock.rs @@ -19,10 +19,7 @@ use crate as pallet_transaction_storage; use crate::TransactionStorageProof; -use frame_support::{ - parameter_types, - traits::{OnFinalize, OnInitialize}, -}; +use frame_support::traits::{ConstU16, ConstU32, ConstU64, OnFinalize, OnInitialize}; use sp_core::H256; use sp_runtime::{ testing::Header, @@ -48,11 +45,6 @@ frame_support::construct_runtime!( } ); -parameter_types! { - pub const BlockHashCount: u64 = 250; - pub const SS58Prefix: u8 = 42; -} - impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = (); @@ -67,7 +59,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; @@ -75,20 +67,16 @@ impl frame_system::Config for Test { type OnNewAccount = (); type OnKilledAccount = (); type SystemWeightInfo = (); - type SS58Prefix = SS58Prefix; + type SS58Prefix = ConstU16<42>; type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -parameter_types! { - pub const ExistentialDeposit: u64 = 1; + type MaxConsumers = ConstU32<16>; } impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); type Event = Event; - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); type MaxLocks = (); diff --git a/substrate/frame/treasury/src/tests.rs b/substrate/frame/treasury/src/tests.rs index c2b41e7165..765f71f5da 100644 --- a/substrate/frame/treasury/src/tests.rs +++ b/substrate/frame/treasury/src/tests.rs @@ -28,7 +28,10 @@ use sp_runtime::{ }; use frame_support::{ - assert_noop, assert_ok, pallet_prelude::GenesisBuild, parameter_types, traits::OnInitialize, + assert_noop, assert_ok, + pallet_prelude::GenesisBuild, + parameter_types, + traits::{ConstU32, ConstU64, OnInitialize}, PalletId, }; @@ -51,7 +54,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -70,7 +72,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -79,10 +81,7 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} -parameter_types! { - pub const ExistentialDeposit: u64 = 1; + type MaxConsumers = ConstU32<16>; } impl pallet_balances::Config for Test { type MaxLocks = (); @@ -91,7 +90,7 @@ impl pallet_balances::Config for Test { type Balance = u64; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } @@ -100,8 +99,6 @@ thread_local! { } parameter_types! { pub const ProposalBond: Permill = Permill::from_percent(5); - pub const ProposalBondMinimum: u64 = 1; - pub const SpendPeriod: u64 = 2; pub const Burn: Permill = Permill::from_percent(50); pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); pub const BountyUpdatePeriod: u32 = 20; @@ -117,8 +114,8 @@ impl Config for Test { type Event = Event; type OnSlash = (); type ProposalBond = ProposalBond; - type ProposalBondMinimum = ProposalBondMinimum; - type SpendPeriod = SpendPeriod; + type ProposalBondMinimum = ConstU64<1>; + type SpendPeriod = ConstU64<2>; type Burn = Burn; type BurnDestination = (); // Just gets burned. type WeightInfo = (); diff --git a/substrate/frame/uniques/src/mock.rs b/substrate/frame/uniques/src/mock.rs index f65f69209b..679adf0424 100644 --- a/substrate/frame/uniques/src/mock.rs +++ b/substrate/frame/uniques/src/mock.rs @@ -20,7 +20,10 @@ use super::*; use crate as pallet_uniques; -use frame_support::{construct_runtime, parameter_types}; +use frame_support::{ + construct_runtime, + traits::{ConstU32, ConstU64}, +}; use sp_core::H256; use sp_runtime::{ testing::Header, @@ -42,9 +45,6 @@ construct_runtime!( } ); -parameter_types! { - pub const BlockHashCount: u64 = 250; -} impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = (); @@ -59,7 +59,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; @@ -69,51 +69,35 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -parameter_types! { - pub const ExistentialDeposit: u64 = 1; - pub const MaxReserves: u32 = 50; + type MaxConsumers = ConstU32<16>; } impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); type Event = Event; - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); type MaxLocks = (); - type MaxReserves = MaxReserves; + type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; } -parameter_types! { - pub const ClassDeposit: u64 = 2; - pub const InstanceDeposit: u64 = 1; - pub const KeyLimit: u32 = 50; - pub const ValueLimit: u32 = 50; - pub const StringLimit: u32 = 50; - pub const MetadataDepositBase: u64 = 1; - pub const AttributeDepositBase: u64 = 1; - pub const MetadataDepositPerByte: u64 = 1; -} - impl Config for Test { type Event = Event; type ClassId = u32; type InstanceId = u32; type Currency = Balances; type ForceOrigin = frame_system::EnsureRoot; - type ClassDeposit = ClassDeposit; - type InstanceDeposit = InstanceDeposit; - type MetadataDepositBase = MetadataDepositBase; - type AttributeDepositBase = AttributeDepositBase; - type DepositPerByte = MetadataDepositPerByte; - type StringLimit = StringLimit; - type KeyLimit = KeyLimit; - type ValueLimit = ValueLimit; + type ClassDeposit = ConstU64<2>; + type InstanceDeposit = ConstU64<1>; + type MetadataDepositBase = ConstU64<1>; + type AttributeDepositBase = ConstU64<1>; + type DepositPerByte = ConstU64<1>; + type StringLimit = ConstU32<50>; + type KeyLimit = ConstU32<50>; + type ValueLimit = ConstU32<50>; type WeightInfo = (); } diff --git a/substrate/frame/utility/src/tests.rs b/substrate/frame/utility/src/tests.rs index 169ac6cfff..11b63254eb 100644 --- a/substrate/frame/utility/src/tests.rs +++ b/substrate/frame/utility/src/tests.rs @@ -26,7 +26,7 @@ use frame_support::{ assert_err_ignore_postinfo, assert_noop, assert_ok, dispatch::{DispatchError, DispatchErrorWithPostInfo, Dispatchable}, parameter_types, storage, - traits::Contains, + traits::{ConstU32, ConstU64, Contains}, weights::{Pays, Weight}, }; use sp_core::H256; @@ -99,7 +99,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(Weight::max_value()); } @@ -118,7 +117,7 @@ impl frame_system::Config for Test { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -127,11 +126,9 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} -parameter_types! { - pub const ExistentialDeposit: u64 = 1; + type MaxConsumers = ConstU32<16>; } + impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); @@ -139,7 +136,7 @@ impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); type Event = Event; - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } diff --git a/substrate/frame/vesting/src/mock.rs b/substrate/frame/vesting/src/mock.rs index 1e04875a7e..2176716bf3 100644 --- a/substrate/frame/vesting/src/mock.rs +++ b/substrate/frame/vesting/src/mock.rs @@ -15,7 +15,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -use frame_support::parameter_types; +use frame_support::{ + parameter_types, + traits::{ConstU32, ConstU64}, +}; use sp_core::H256; use sp_runtime::{ testing::Header, @@ -41,7 +44,6 @@ frame_support::construct_runtime!( ); parameter_types! { - pub const BlockHashCount: u64 = 250; pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -49,7 +51,7 @@ impl frame_system::Config for Test { type AccountData = pallet_balances::AccountData; type AccountId = u64; type BaseCallFilter = frame_support::traits::Everything; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type BlockLength = (); type BlockNumber = u64; type BlockWeights = (); @@ -71,16 +73,14 @@ impl frame_system::Config for Test { type SystemWeightInfo = (); type Version = (); } -parameter_types! { - pub const MaxLocks: u32 = 10; -} + impl pallet_balances::Config for Test { type AccountStore = System; type Balance = u64; type DustRemoval = (); type Event = Event; type ExistentialDeposit = ExistentialDeposit; - type MaxLocks = MaxLocks; + type MaxLocks = ConstU32<10>; type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type WeightInfo = (); diff --git a/substrate/test-utils/runtime/src/lib.rs b/substrate/test-utils/runtime/src/lib.rs index 7b78880c2c..03e39be324 100644 --- a/substrate/test-utils/runtime/src/lib.rs +++ b/substrate/test-utils/runtime/src/lib.rs @@ -38,7 +38,7 @@ use trie_db::{Trie, TrieMut}; use cfg_if::cfg_if; use frame_support::{ parameter_types, - traits::{CrateVersion, KeyOwnerProofSystem}, + traits::{ConstU32, ConstU64, CrateVersion, KeyOwnerProofSystem}, weights::RuntimeDbWeight, }; use frame_system::limits::{BlockLength, BlockWeights}; @@ -556,7 +556,6 @@ impl frame_support::traits::PalletInfo for Runtime { parameter_types! { pub const BlockHashCount: BlockNumber = 2400; - pub const MinimumPeriod: u64 = 5; pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight { read: 100, write: 1000, @@ -591,26 +590,24 @@ impl frame_system::Config for Runtime { type SystemWeightInfo = (); type SS58Prefix = (); type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } impl pallet_timestamp::Config for Runtime { /// A timestamp: milliseconds since the unix epoch. type Moment = u64; type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; + type MinimumPeriod = ConstU64<5>; type WeightInfo = (); } parameter_types! { pub const EpochDuration: u64 = 6; - pub const ExpectedBlockTime: u64 = 10_000; - pub const MaxAuthorities: u32 = 10; } impl pallet_babe::Config for Runtime { type EpochDuration = EpochDuration; - type ExpectedBlockTime = ExpectedBlockTime; + type ExpectedBlockTime = ConstU64<10_000>; // there is no actual runtime in this test-runtime, so testing crates // are manually adding the digests. normally in this situation you'd use // pallet_babe::SameAuthoritiesForever. @@ -630,7 +627,7 @@ impl pallet_babe::Config for Runtime { type HandleEquivocation = (); type WeightInfo = (); - type MaxAuthorities = MaxAuthorities; + type MaxAuthorities = ConstU32<10>; } /// Adds one to the given input and returns the final result.