diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 780a84572d582..a7a162bf74327 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -26,7 +26,9 @@ use sp_version::RuntimeVersion; // A few exports that help ease life for downstream crates. pub use frame_support::{ construct_runtime, parameter_types, - traits::{ConstU128, ConstU32, ConstU8, KeyOwnerProofSystem, Randomness, StorageInfo}, + traits::{ + ConstU128, ConstU32, ConstU64, ConstU8, KeyOwnerProofSystem, Randomness, StorageInfo, + }, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, IdentityFee, Weight, @@ -132,8 +134,8 @@ pub fn native_version() -> NativeVersion { const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); parameter_types! { - pub const Version: RuntimeVersion = VERSION; pub const BlockHashCount: BlockNumber = 2400; + pub const Version: RuntimeVersion = VERSION; /// We allow for 2 seconds of compute with a 6 second average block time. pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights ::with_sensible_defaults(2 * WEIGHT_PER_SECOND, NORMAL_DISPATCH_RATIO); @@ -224,15 +226,11 @@ impl pallet_grandpa::Config for Runtime { type MaxAuthorities = ConstU32<32>; } -parameter_types! { - pub const MinimumPeriod: u64 = SLOT_DURATION / 2; -} - impl pallet_timestamp::Config for Runtime { /// A timestamp: milliseconds since the unix epoch. type Moment = u64; type OnTimestampSet = Aura; - type MinimumPeriod = MinimumPeriod; + type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>; type WeightInfo = (); } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index ce59f5bb858ac..9d949eea9b948 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -234,9 +234,6 @@ impl pallet_utility::Config for Test { type WeightInfo = (); } parameter_types! { - pub const MaxValueSize: u32 = 16_384; - pub const DeletionWeightLimit: Weight = 500_000_000_000; - pub const MaxCodeSize: u32 = 2 * 1024; pub MySchedule: Schedule = { let mut schedule = >::default(); // We want stack height to be always enabled for tests so that this @@ -244,7 +241,6 @@ parameter_types! { schedule.limits.stack_height = Some(512); schedule }; - pub const TransactionByteFee: u64 = 0; pub static DepositPerByte: BalanceOf = 1; pub const DepositPerItem: BalanceOf = 2; } @@ -286,7 +282,7 @@ impl Config for Test { type WeightInfo = (); type ChainExtension = TestExtension; type DeletionQueueDepth = ConstU32<1024>; - type DeletionWeightLimit = DeletionWeightLimit; + type DeletionWeightLimit = ConstU64<500_000_000_000>; type Schedule = MySchedule; type DepositPerByte = DepositPerByte; type DepositPerItem = DepositPerItem; diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index de1cc3b916404..68b5e910ed1fc 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -769,14 +769,11 @@ mod tests { } type Balance = u64; - parameter_types! { - pub const ExistentialDeposit: Balance = 1; - } impl pallet_balances::Config for Runtime { type Balance = Balance; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type MaxLocks = (); type MaxReserves = (); diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 5700fbe3aa36e..5e6c955c441c5 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -172,11 +172,7 @@ pallet_staking_reward_curve::build! { 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 ElectionLookahead: u64 = 0; - pub const StakingUnsignedPriority: u64 = u64::MAX / 2; pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17); } @@ -199,7 +195,7 @@ impl pallet_staking::Config for Test { type Reward = (); type SessionsPerEra = SessionsPerEra; type BondingDuration = BondingDuration; - type SlashDeferDuration = SlashDeferDuration; + type SlashDeferDuration = (); type SlashCancelOrigin = frame_system::EnsureRoot; type SessionInterface = Self; type UnixTime = pallet_timestamp::Pallet; diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 86904b38d834b..2459f7e748941 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -218,17 +218,13 @@ impl frame_support::traits::EstimateNextSessionRotation for TestNextSession } } -parameter_types! { - pub const UnsignedPriority: u64 = 1 << 20; -} - impl Config for Runtime { type AuthorityId = UintAuthorityId; type Event = Event; type ValidatorSet = Historical; type NextSessionRotation = TestNextSessionRotation; type ReportUnresponsiveness = OffenceHandler; - type UnsignedPriority = UnsignedPriority; + type UnsignedPriority = ConstU64<{ 1 << 20 }>; type WeightInfo = (); type MaxKeys = ConstU32<10_000>; type MaxPeerInHeartbeats = ConstU32<10_000>; diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index fba8c567059c2..d51a81b1212c0 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -69,9 +69,7 @@ impl frame_system::Config for Test { type OnSetCode = (); type MaxConsumers = frame_support::traits::ConstU32<16>; } -parameter_types! { - pub const ExistentialDeposit: Balance = 10; -} + impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); @@ -79,7 +77,7 @@ impl pallet_balances::Config for Test { type Balance = Balance; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<10>; type AccountStore = System; type WeightInfo = (); } diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index fdd14fdadf04d..1b0bbba24bbe6 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -26,7 +26,6 @@ use frame_support::{ ConstU32, ConstU64, Contains, EqualPrivilegeOnly, OnInitialize, OriginTrait, Polling, PreimageRecipient, SortedMembers, }, - weights::Weight, }; use frame_system::{EnsureRoot, EnsureSignedBy}; use sp_core::H256; @@ -62,7 +61,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); } @@ -81,7 +79,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; @@ -101,15 +99,12 @@ impl pallet_preimage::Config for Test { type BaseDeposit = (); type ByteDeposit = (); } -parameter_types! { - pub MaximumSchedulerWeight: Weight = 2_000_000_000_000; -} impl pallet_scheduler::Config for Test { type Event = Event; type Origin = Origin; type PalletsOrigin = OriginCaller; type Call = Call; - type MaximumWeight = MaximumSchedulerWeight; + type MaximumWeight = ConstU64<2_000_000_000_000>; type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = ConstU32<100>; type WeightInfo = (); @@ -117,26 +112,19 @@ impl pallet_scheduler::Config for Test { type PreimageProvider = Preimage; type NoPreimagePostponement = ConstU64<10>; } -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 static AlarmInterval: u64 = 1; - pub const SubmissionDeposit: u64 = 2; - pub const MaxQueued: u32 = 3; - pub const UndecidingTimeout: u64 = 20; } ord_parameter_types! { pub const One: u64 = 1; @@ -228,9 +216,9 @@ impl Config for Test { type Slash = (); type Votes = u32; type Tally = Tally; - type SubmissionDeposit = SubmissionDeposit; - type MaxQueued = MaxQueued; - type UndecidingTimeout = UndecidingTimeout; + type SubmissionDeposit = ConstU64<2>; + type MaxQueued = ConstU32<3>; + type UndecidingTimeout = ConstU64<20>; type AlarmInterval = AlarmInterval; type Tracks = TestTracksInfo; } diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 6835736aa8e00..c777f2c56de3a 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -73,9 +73,7 @@ impl frame_system::Config for Test { type OnSetCode = (); type MaxConsumers = ConstU32<16>; } -parameter_types! { - pub const ExistentialDeposit: Balance = 10; -} + impl pallet_balances::Config for Test { type MaxLocks = (); type MaxReserves = (); @@ -83,7 +81,7 @@ impl pallet_balances::Config for Test { type Balance = Balance; type Event = Event; type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<10>; type AccountStore = System; type WeightInfo = (); } diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index 87be4099c89c8..3d66c6a66b8cf 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -980,7 +980,10 @@ mod benchmarks { mod mock { use super::*; use crate as pallet_state_trie_migration; - use frame_support::{parameter_types, traits::Hooks}; + use frame_support::{ + parameter_types, + traits::{ConstU32, ConstU64, Hooks}, + }; use frame_system::{EnsureRoot, EnsureSigned}; use sp_core::{ storage::{ChildInfo, StateVersion}, @@ -1008,7 +1011,6 @@ mod mock { ); parameter_types! { - pub const BlockHashCount: u32 = 250; pub const SS58Prefix: u8 = 42; } @@ -1026,7 +1028,7 @@ mod mock { type Lookup = IdentityLookup; type Header = sp_runtime::generic::Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU32<250>; type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; @@ -1036,12 +1038,10 @@ mod mock { type SystemWeightInfo = (); type SS58Prefix = SS58Prefix; type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } parameter_types! { - pub const ExistentialDeposit: u64 = 1; - pub const OffchainRepeat: u32 = 1; pub const SignedDepositPerItem: u64 = 1; pub const SignedDepositBase: u64 = 5; } @@ -1050,7 +1050,7 @@ mod mock { 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/frame/support/test/compile_pass/src/lib.rs b/frame/support/test/compile_pass/src/lib.rs index 0c955c749613c..7850726048546 100644 --- a/frame/support/test/compile_pass/src/lib.rs +++ b/frame/support/test/compile_pass/src/lib.rs @@ -24,7 +24,7 @@ use frame_support::{ construct_runtime, parameter_types, - traits::{ConstU16, ConstU32}, + traits::{ConstU16, ConstU32, ConstU64}, }; use sp_core::{sr25519, H256}; use sp_runtime::{ @@ -50,7 +50,6 @@ pub type BlockNumber = u64; pub type Index = u64; parameter_types! { - pub const BlockHashCount: BlockNumber = 2400; pub const Version: RuntimeVersion = VERSION; } @@ -63,7 +62,7 @@ impl frame_system::Config for Runtime { type Hashing = BlakeTwo256; type Header = Header; type Lookup = IdentityLookup; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<2400>; type Version = Version; type AccountData = (); type Origin = Origin; diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index a67bbe9b1d1e9..b755db29682aa 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -101,9 +101,6 @@ parameter_types! { pub const ProposalBond: Permill = Permill::from_percent(5); pub const Burn: Permill = Permill::from_percent(50); pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); - pub const BountyUpdatePeriod: u32 = 20; - pub const BountyCuratorDeposit: Permill = Permill::from_percent(50); - pub const BountyValueMinimum: u64 = 1; pub const MaxApprovals: u32 = 100; } impl Config for Test { @@ -121,7 +118,7 @@ impl Config for Test { type BurnDestination = (); // Just gets burned. type WeightInfo = (); type SpendFunds = (); - type MaxApprovals = MaxApprovals; + type MaxApprovals = ConstU32<100>; } pub fn new_test_ext() -> sp_io::TestExternalities { diff --git a/frame/whitelist/src/mock.rs b/frame/whitelist/src/mock.rs index 3009a6f6b5d58..634db53a09a4e 100644 --- a/frame/whitelist/src/mock.rs +++ b/frame/whitelist/src/mock.rs @@ -22,7 +22,7 @@ use crate as pallet_whitelist; use frame_support::{ - parameter_types, + construct_runtime, parameter_types, traits::{ConstU32, ConstU64, Nothing}, }; use frame_system::EnsureRoot; @@ -36,7 +36,7 @@ use sp_runtime::{ type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; -frame_support::construct_runtime!( +construct_runtime!( pub enum Test where Block = Block, NodeBlock = Block, @@ -49,7 +49,7 @@ frame_support::construct_runtime!( } ); -frame_support::parameter_types! { +parameter_types! { pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights::simple_max(1024); } @@ -92,16 +92,11 @@ impl pallet_balances::Config for Test { type WeightInfo = (); } -parameter_types! { - // Taken from Polkadot as reference. - pub const PreimageMaxSize: u32 = 4096 * 1024; -} - impl pallet_preimage::Config for Test { type Event = Event; type Currency = Balances; type ManagerOrigin = EnsureRoot; - type MaxSize = PreimageMaxSize; + type MaxSize = ConstU32<{ 4096 * 1024 }>; // PreimageMaxSize Taken from Polkadot as reference. type BaseDeposit = ConstU64<1>; type ByteDeposit = ConstU64<1>; type WeightInfo = (); diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 743652a0ee899..94325ae9c1ab1 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -553,7 +553,6 @@ impl frame_support::traits::PalletInfo for Runtime { } parameter_types! { - pub const BlockHashCount: BlockNumber = 2400; pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight { read: 100, write: 1000, @@ -578,7 +577,7 @@ impl frame_system::Config for Runtime { type Lookup = IdentityLookup; type Header = Header; type Event = Event; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<2400>; type DbWeight = (); type Version = (); type PalletInfo = Self;