diff --git a/bin/millau/runtime/src/lib.rs b/bin/millau/runtime/src/lib.rs index b1f1e33d18a47..d6e99afb2d8bb 100644 --- a/bin/millau/runtime/src/lib.rs +++ b/bin/millau/runtime/src/lib.rs @@ -62,7 +62,7 @@ pub use frame_support::{ construct_runtime, dispatch::DispatchClass, parameter_types, - traits::{Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem}, + traits::{ConstU32, ConstU8, Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem}, weights::{ constants::WEIGHT_PER_SECOND, ConstantMultiplier, IdentityFee, RuntimeDbWeight, Weight, }, @@ -215,19 +215,15 @@ impl frame_system::Config for Runtime { impl pallet_randomness_collective_flip::Config for Runtime {} -parameter_types! { - pub const MaxAuthorities: u32 = 10; -} - impl pallet_aura::Config for Runtime { type AuthorityId = AuraId; - type MaxAuthorities = MaxAuthorities; + type MaxAuthorities = ConstU32<10>; type DisabledValidators = (); } impl pallet_beefy::Config for Runtime { type BeefyId = BeefyId; - type MaxAuthorities = MaxAuthorities; + type MaxAuthorities = ConstU32<10>; type OnNewValidatorSet = MmrLeaf; } @@ -243,7 +239,7 @@ impl pallet_grandpa::Config for Runtime { type HandleEquivocation = (); // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) type WeightInfo = (); - type MaxAuthorities = MaxAuthorities; + type MaxAuthorities = ConstU32<10>; } /// MMR helper types. @@ -311,10 +307,6 @@ impl pallet_timestamp::Config for Runtime { parameter_types! { pub const ExistentialDeposit: bp_millau::Balance = 500; - // For weight estimation, we assume that the most locks on an individual account will be 50. - // This number may need to be adjusted in the future if this assumption no longer holds true. - pub const MaxLocks: u32 = 50; - pub const MaxReserves: u32 = 50; } impl pallet_balances::Config for Runtime { @@ -327,15 +319,16 @@ impl pallet_balances::Config for Runtime { type AccountStore = System; // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) type WeightInfo = (); - type MaxLocks = MaxLocks; - type MaxReserves = MaxReserves; + // For weight estimation, we assume that the most locks on an individual account will be 50. + // This number may need to be adjusted in the future if this assumption no longer holds true. + type MaxLocks = ConstU32<50>; + type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; } parameter_types! { pub const TransactionBaseFee: Balance = 0; pub const TransactionByteFee: Balance = 1; - pub const OperationalFeeMultiplier: u8 = 5; // values for following parameters are copied from polkadot repo, but it is fine // not to sync them - we're not going to make Rialto a full copy of one of Polkadot-like chains pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); @@ -346,7 +339,7 @@ parameter_types! { impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; - type OperationalFeeMultiplier = OperationalFeeMultiplier; + type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = bp_millau::WeightToFee; type LengthToFee = ConstantMultiplier; type FeeMultiplierUpdate = pallet_transaction_payment::TargetedFeeAdjustment< @@ -383,14 +376,6 @@ impl pallet_session::Config for Runtime { type WeightInfo = (); } -parameter_types! { - // This is a pretty unscientific cap. - // - // Note that once this is hit the pallet will essentially throttle incoming requests down to one - // call per block. - pub const MaxRequests: u32 = 50; -} - impl pallet_bridge_relayers::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Reward = Balance; @@ -439,7 +424,11 @@ parameter_types! { pub type RialtoGrandpaInstance = (); impl pallet_bridge_grandpa::Config for Runtime { type BridgedChain = bp_rialto::Rialto; - type MaxRequests = MaxRequests; + // This is a pretty unscientific cap. + // + // Note that once this is hit the pallet will essentially throttle incoming requests down to one + // call per block. + type MaxRequests = ConstU32<50>; type HeadersToKeep = HeadersToKeep; type MaxBridgedAuthorities = MaxAuthoritiesAtRialto; type MaxBridgedHeaderSize = MaxRialtoHeaderSize; @@ -450,7 +439,7 @@ impl pallet_bridge_grandpa::Config for Runtime { pub type WestendGrandpaInstance = pallet_bridge_grandpa::Instance1; impl pallet_bridge_grandpa::Config for Runtime { type BridgedChain = bp_westend::Westend; - type MaxRequests = MaxRequests; + type MaxRequests = ConstU32<50>; type HeadersToKeep = HeadersToKeep; type MaxBridgedAuthorities = MaxAuthoritiesAtWestend; type MaxBridgedHeaderSize = MaxWestendHeaderSize; diff --git a/bin/millau/runtime/src/xcm_config.rs b/bin/millau/runtime/src/xcm_config.rs index b5be117ac7732..a3a59e626e572 100644 --- a/bin/millau/runtime/src/xcm_config.rs +++ b/bin/millau/runtime/src/xcm_config.rs @@ -31,7 +31,7 @@ use bridge_runtime_common::{ }; use frame_support::{ parameter_types, - traits::{Everything, Nothing}, + traits::{ConstU32, Everything, Nothing}, }; use xcm::latest::prelude::*; use xcm_builder::{ @@ -112,10 +112,6 @@ pub type XcmRouter = ( XcmBridgeAdapter, ); -parameter_types! { - pub const MaxAssetsIntoHolding: u32 = 64; -} - /// The barriers one of which must be passed for an XCM message to be executed. pub type Barrier = ( // Weight that is paid for may be consumed. @@ -149,7 +145,7 @@ impl xcm_executor::Config for XcmConfig { type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; - type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type MaxAssetsIntoHolding = ConstU32<64>; type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; diff --git a/bin/rialto-parachain/runtime/src/lib.rs b/bin/rialto-parachain/runtime/src/lib.rs index f946abf4c1da9..2d0be49a07f46 100644 --- a/bin/rialto-parachain/runtime/src/lib.rs +++ b/bin/rialto-parachain/runtime/src/lib.rs @@ -50,7 +50,7 @@ pub use frame_support::{ construct_runtime, dispatch::DispatchClass, match_types, parameter_types, - traits::{Everything, IsInVec, Nothing, Randomness}, + traits::{ConstU32, Everything, IsInVec, Nothing, Randomness}, weights::{ constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, IdentityFee, Weight, @@ -249,8 +249,6 @@ parameter_types! { pub const CreationFee: u128 = MILLIUNIT; pub const TransactionByteFee: u128 = MICROUNIT; pub const OperationalFeeMultiplier: u8 = 5; - pub const MaxLocks: u32 = 50; - pub const MaxReserves: u32 = 50; } impl pallet_balances::Config for Runtime { @@ -262,8 +260,8 @@ impl pallet_balances::Config for Runtime { type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = pallet_balances::weights::SubstrateWeight; - type MaxLocks = MaxLocks; - type MaxReserves = MaxReserves; + type MaxLocks = ConstU32<50>; + type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; } @@ -518,12 +516,6 @@ impl pallet_bridge_relayers::Config for Runtime { } parameter_types! { - /// This is a pretty unscientific cap. - /// - /// Note that once this is hit the pallet will essentially throttle incoming requests down to one - /// call per block. - pub const MaxRequests: u32 = 50; - /// Number of headers to keep. /// /// Assuming the worst case of every header being finalized, we will keep headers at least for a @@ -539,7 +531,11 @@ parameter_types! { pub type MillauGrandpaInstance = (); impl pallet_bridge_grandpa::Config for Runtime { type BridgedChain = bp_millau::Millau; - type MaxRequests = MaxRequests; + /// This is a pretty unscientific cap. + /// + /// Note that once this is hit the pallet will essentially throttle incoming requests down to + /// one call per block. + type MaxRequests = ConstU32<50>; type HeadersToKeep = HeadersToKeep; type MaxBridgedAuthorities = MaxAuthoritiesAtMillau; type MaxBridgedHeaderSize = MaxMillauHeaderSize; diff --git a/bin/rialto/runtime/src/lib.rs b/bin/rialto/runtime/src/lib.rs index 25778705e5ef5..59284df910a26 100644 --- a/bin/rialto/runtime/src/lib.rs +++ b/bin/rialto/runtime/src/lib.rs @@ -61,7 +61,7 @@ pub use frame_support::{ construct_runtime, dispatch::DispatchClass, parameter_types, - traits::{Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem}, + traits::{ConstU32, ConstU8, Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem}, weights::{constants::WEIGHT_PER_SECOND, IdentityFee, RuntimeDbWeight, Weight}, StorageValue, }; @@ -222,13 +222,12 @@ pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration = parameter_types! { pub const EpochDuration: u64 = bp_rialto::EPOCH_DURATION_IN_SLOTS as u64; pub const ExpectedBlockTime: bp_rialto::Moment = bp_rialto::time_units::MILLISECS_PER_BLOCK; - pub const MaxAuthorities: u32 = 10; } impl pallet_babe::Config for Runtime { type EpochDuration = EpochDuration; type ExpectedBlockTime = ExpectedBlockTime; - type MaxAuthorities = MaxAuthorities; + type MaxAuthorities = ConstU32<10>; // session module is the trigger type EpochChangeTrigger = pallet_babe::ExternalTrigger; @@ -251,13 +250,13 @@ impl pallet_babe::Config for Runtime { impl pallet_beefy::Config for Runtime { type BeefyId = BeefyId; - type MaxAuthorities = MaxAuthorities; + type MaxAuthorities = ConstU32<10>; type OnNewValidatorSet = MmrLeaf; } impl pallet_grandpa::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type MaxAuthorities = MaxAuthorities; + type MaxAuthorities = ConstU32<10>; type KeyOwnerProofSystem = (); type KeyOwnerProof = >::Proof; @@ -327,10 +326,6 @@ impl pallet_timestamp::Config for Runtime { parameter_types! { pub const ExistentialDeposit: bp_rialto::Balance = 500; - // For weight estimation, we assume that the most locks on an individual account will be 50. - // This number may need to be adjusted in the future if this assumption no longer holds true. - pub const MaxLocks: u32 = 50; - pub const MaxReserves: u32 = 50; } impl pallet_balances::Config for Runtime { @@ -343,15 +338,16 @@ impl pallet_balances::Config for Runtime { type AccountStore = System; // TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78) type WeightInfo = (); - type MaxLocks = MaxLocks; - type MaxReserves = MaxReserves; + // For weight estimation, we assume that the most locks on an individual account will be 50. + // This number may need to be adjusted in the future if this assumption no longer holds true. + type MaxLocks = ConstU32<50>; + type MaxReserves = ConstU32<50>; type ReserveIdentifier = [u8; 8]; } parameter_types! { pub const TransactionBaseFee: Balance = 0; pub const TransactionByteFee: Balance = 1; - pub const OperationalFeeMultiplier: u8 = 5; // values for following parameters are copied from polkadot repo, but it is fine // not to sync them - we're not going to make Rialto a full copy of one of Polkadot-like chains pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25); @@ -362,7 +358,7 @@ parameter_types! { impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; - type OperationalFeeMultiplier = OperationalFeeMultiplier; + type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = bp_rialto::WeightToFee; type LengthToFee = bp_rialto::WeightToFee; type FeeMultiplierUpdate = pallet_transaction_payment::TargetedFeeAdjustment< @@ -394,7 +390,7 @@ impl pallet_session::Config for Runtime { } impl pallet_authority_discovery::Config for Runtime { - type MaxAuthorities = MaxAuthorities; + type MaxAuthorities = ConstU32<10>; } impl pallet_bridge_relayers::Config for Runtime { @@ -405,12 +401,6 @@ impl pallet_bridge_relayers::Config for Runtime { } parameter_types! { - /// This is a pretty unscientific cap. - /// - /// Note that once this is hit the pallet will essentially throttle incoming requests down to one - /// call per block. - pub const MaxRequests: u32 = 50; - /// Number of headers to keep. /// /// Assuming the worst case of every header being finalized, we will keep headers at least for a @@ -426,7 +416,11 @@ parameter_types! { pub type MillauGrandpaInstance = (); impl pallet_bridge_grandpa::Config for Runtime { type BridgedChain = bp_millau::Millau; - type MaxRequests = MaxRequests; + /// This is a pretty unscientific cap. + /// + /// Note that once this is hit the pallet will essentially throttle incoming requests down to + /// one call per block. + type MaxRequests = ConstU32<50>; type HeadersToKeep = HeadersToKeep; type MaxBridgedAuthorities = MaxAuthoritiesAtMillau; type MaxBridgedHeaderSize = MaxMillauHeaderSize; diff --git a/bin/rialto/runtime/src/parachains.rs b/bin/rialto/runtime/src/parachains.rs index 960931a0b3cee..1c7280198a421 100644 --- a/bin/rialto/runtime/src/parachains.rs +++ b/bin/rialto/runtime/src/parachains.rs @@ -123,14 +123,10 @@ impl parachains_session_info::Config for Runtime { impl parachains_shared::Config for Runtime {} -parameter_types! { - pub const FirstMessageFactorPercent: u64 = 100; -} - impl parachains_ump::Config for Runtime { type RuntimeEvent = RuntimeEvent; type UmpSink = (); - type FirstMessageFactorPercent = FirstMessageFactorPercent; + type FirstMessageFactorPercent = frame_support::traits::ConstU64<100>; type ExecuteOverweightOrigin = EnsureRoot; type WeightInfo = parachains_ump::TestWeightInfo; } diff --git a/bin/rialto/runtime/src/xcm_config.rs b/bin/rialto/runtime/src/xcm_config.rs index 892c1ed747b19..419a55489307c 100644 --- a/bin/rialto/runtime/src/xcm_config.rs +++ b/bin/rialto/runtime/src/xcm_config.rs @@ -27,7 +27,7 @@ use bridge_runtime_common::{ }; use frame_support::{ parameter_types, - traits::{Everything, Nothing}, + traits::{ConstU32, Everything, Nothing}, }; use xcm::latest::prelude::*; use xcm_builder::{ @@ -104,10 +104,6 @@ pub type XcmRouter = ( XcmBridgeAdapter, ); -parameter_types! { - pub const MaxAssetsIntoHolding: u32 = 64; -} - /// The barriers one of which must be passed for an XCM message to be executed. pub type Barrier = ( // Weight that is paid for may be consumed. @@ -141,7 +137,7 @@ impl xcm_executor::Config for XcmConfig { type AssetClaims = XcmPallet; type SubscriptionService = XcmPallet; type PalletInstancesInfo = AllPalletsWithSystem; - type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type MaxAssetsIntoHolding = ConstU32<64>; type FeeManager = (); type MessageExporter = (); type UniversalAliases = Nothing; diff --git a/modules/beefy/src/mock.rs b/modules/beefy/src/mock.rs index 927c39ff9aad4..a07f7962a44d8 100644 --- a/modules/beefy/src/mock.rs +++ b/modules/beefy/src/mock.rs @@ -24,7 +24,7 @@ use crate::{ use bp_beefy::{BeefyValidatorSignatureOf, ChainWithBeefy, Commitment, MmrDataOrHash}; use bp_runtime::{BasicOperatingMode, Chain}; use codec::Encode; -use frame_support::{construct_runtime, parameter_types, weights::Weight}; +use frame_support::{construct_runtime, parameter_types, traits::ConstU64, weights::Weight}; use sp_core::{sr25519::Signature, Pair}; use sp_runtime::{ testing::{Header, H256}, @@ -72,7 +72,6 @@ construct_runtime! { } parameter_types! { - pub const BlockHashCount: u64 = 250; pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); @@ -89,7 +88,7 @@ impl frame_system::Config for TestRuntime { type Lookup = IdentityLookup; type Header = Header; type RuntimeEvent = (); - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); diff --git a/modules/grandpa/src/mock.rs b/modules/grandpa/src/mock.rs index 0f83bd528d68e..12a40a688f6aa 100644 --- a/modules/grandpa/src/mock.rs +++ b/modules/grandpa/src/mock.rs @@ -18,7 +18,7 @@ #![allow(clippy::from_over_into)] use bp_runtime::Chain; -use frame_support::{construct_runtime, parameter_types, weights::Weight}; +use frame_support::{construct_runtime, parameter_types, traits::ConstU64, weights::Weight}; use sp_core::sr25519::Signature; use sp_runtime::{ testing::{Header, H256}, @@ -50,7 +50,6 @@ construct_runtime! { } parameter_types! { - pub const BlockHashCount: u64 = 250; pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); @@ -67,7 +66,7 @@ impl frame_system::Config for TestRuntime { type Lookup = IdentityLookup; type Header = Header; type RuntimeEvent = (); - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = (); diff --git a/modules/messages/src/mock.rs b/modules/messages/src/mock.rs index 36c38677e5373..da2d1c6a4da4e 100644 --- a/modules/messages/src/mock.rs +++ b/modules/messages/src/mock.rs @@ -32,6 +32,7 @@ use bp_runtime::{messages::MessageDispatchResult, Size}; use codec::{Decode, Encode}; use frame_support::{ parameter_types, + traits::ConstU64, weights::{RuntimeDbWeight, Weight}, }; use scale_info::TypeInfo; @@ -104,7 +105,7 @@ impl frame_system::Config for TestRuntime { type Lookup = IdentityLookup; type Header = SubstrateHeader; type RuntimeEvent = RuntimeEvent; - type BlockHashCount = BlockHashCount; + type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -120,16 +121,12 @@ impl frame_system::Config for TestRuntime { type MaxConsumers = frame_support::traits::ConstU32<16>; } -parameter_types! { - pub const ExistentialDeposit: u64 = 1; -} - impl pallet_balances::Config for TestRuntime { type MaxLocks = (); type Balance = Balance; type DustRemoval = (); type RuntimeEvent = RuntimeEvent; - type ExistentialDeposit = ExistentialDeposit; + type ExistentialDeposit = ConstU64<1>; type AccountStore = frame_system::Pallet; type WeightInfo = (); type MaxReserves = (); diff --git a/modules/parachains/src/mock.rs b/modules/parachains/src/mock.rs index 9638472aa985f..4e17a71bcdc5e 100644 --- a/modules/parachains/src/mock.rs +++ b/modules/parachains/src/mock.rs @@ -16,7 +16,11 @@ use bp_polkadot_core::parachains::ParaId; use bp_runtime::Chain; -use frame_support::{construct_runtime, parameter_types, traits::IsInVec, weights::Weight}; +use frame_support::{ + construct_runtime, parameter_types, + traits::{ConstU32, IsInVec}, + weights::Weight, +}; use sp_runtime::{ testing::{Header, H256}, traits::{BlakeTwo256, Header as HeaderT, IdentityLookup}, @@ -86,15 +90,14 @@ impl frame_system::Config for TestRuntime { } parameter_types! { - pub const MaxRequests: u32 = 2; - pub const HeadersToKeep: u32 = 5; pub const SessionLength: u64 = 5; pub const NumValidators: u32 = 5; + pub const HeadersToKeep: u32 = 5; } impl pallet_bridge_grandpa::Config for TestRuntime { type BridgedChain = TestBridgedChain; - type MaxRequests = MaxRequests; + type MaxRequests = ConstU32<2>; type HeadersToKeep = HeadersToKeep; type MaxBridgedAuthorities = frame_support::traits::ConstU32<5>; type MaxBridgedHeaderSize = frame_support::traits::ConstU32<512>; @@ -103,7 +106,7 @@ impl pallet_bridge_grandpa::Config for TestRun impl pallet_bridge_grandpa::Config for TestRuntime { type BridgedChain = TestBridgedChain; - type MaxRequests = MaxRequests; + type MaxRequests = ConstU32<2>; type HeadersToKeep = HeadersToKeep; type MaxBridgedAuthorities = frame_support::traits::ConstU32<5>; type MaxBridgedHeaderSize = frame_support::traits::ConstU32<512>; diff --git a/modules/shift-session-manager/src/lib.rs b/modules/shift-session-manager/src/lib.rs index 073013d92d030..dce6005ab549d 100644 --- a/modules/shift-session-manager/src/lib.rs +++ b/modules/shift-session-manager/src/lib.rs @@ -152,7 +152,6 @@ mod tests { } parameter_types! { - pub const BlockHashCount: u64 = 250; pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024); pub const MaximumBlockLength: u32 = 2 * 1024; pub const AvailableBlockRatio: Perbill = Perbill::one(); @@ -169,7 +168,7 @@ mod tests { type Lookup = IdentityLookup; type Header = Header; type RuntimeEvent = (); - type BlockHashCount = BlockHashCount; + type BlockHashCount = frame_support::traits::ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; type AccountData = ();