Skip to content

Commit 0a22ece

Browse files
author
Binston Sukhael Cardoza
authored
Replace const parameters types (paritytech#1691)
* Replace const parameters * fmt * missed out Maxlocks
1 parent e47a8c1 commit 0a22ece

File tree

11 files changed

+59
-95
lines changed

11 files changed

+59
-95
lines changed

bridges/bin/millau/runtime/src/lib.rs

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub use frame_support::{
6262
construct_runtime,
6363
dispatch::DispatchClass,
6464
parameter_types,
65-
traits::{Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem},
65+
traits::{ConstU32, ConstU8, Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem},
6666
weights::{
6767
constants::WEIGHT_PER_SECOND, ConstantMultiplier, IdentityFee, RuntimeDbWeight, Weight,
6868
},
@@ -215,19 +215,15 @@ impl frame_system::Config for Runtime {
215215

216216
impl pallet_randomness_collective_flip::Config for Runtime {}
217217

218-
parameter_types! {
219-
pub const MaxAuthorities: u32 = 10;
220-
}
221-
222218
impl pallet_aura::Config for Runtime {
223219
type AuthorityId = AuraId;
224-
type MaxAuthorities = MaxAuthorities;
220+
type MaxAuthorities = ConstU32<10>;
225221
type DisabledValidators = ();
226222
}
227223

228224
impl pallet_beefy::Config for Runtime {
229225
type BeefyId = BeefyId;
230-
type MaxAuthorities = MaxAuthorities;
226+
type MaxAuthorities = ConstU32<10>;
231227
type OnNewValidatorSet = MmrLeaf;
232228
}
233229

@@ -243,7 +239,7 @@ impl pallet_grandpa::Config for Runtime {
243239
type HandleEquivocation = ();
244240
// TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
245241
type WeightInfo = ();
246-
type MaxAuthorities = MaxAuthorities;
242+
type MaxAuthorities = ConstU32<10>;
247243
}
248244

249245
/// MMR helper types.
@@ -311,10 +307,6 @@ impl pallet_timestamp::Config for Runtime {
311307

312308
parameter_types! {
313309
pub const ExistentialDeposit: bp_millau::Balance = 500;
314-
// For weight estimation, we assume that the most locks on an individual account will be 50.
315-
// This number may need to be adjusted in the future if this assumption no longer holds true.
316-
pub const MaxLocks: u32 = 50;
317-
pub const MaxReserves: u32 = 50;
318310
}
319311

320312
impl pallet_balances::Config for Runtime {
@@ -327,15 +319,16 @@ impl pallet_balances::Config for Runtime {
327319
type AccountStore = System;
328320
// TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
329321
type WeightInfo = ();
330-
type MaxLocks = MaxLocks;
331-
type MaxReserves = MaxReserves;
322+
// For weight estimation, we assume that the most locks on an individual account will be 50.
323+
// This number may need to be adjusted in the future if this assumption no longer holds true.
324+
type MaxLocks = ConstU32<50>;
325+
type MaxReserves = ConstU32<50>;
332326
type ReserveIdentifier = [u8; 8];
333327
}
334328

335329
parameter_types! {
336330
pub const TransactionBaseFee: Balance = 0;
337331
pub const TransactionByteFee: Balance = 1;
338-
pub const OperationalFeeMultiplier: u8 = 5;
339332
// values for following parameters are copied from polkadot repo, but it is fine
340333
// not to sync them - we're not going to make Rialto a full copy of one of Polkadot-like chains
341334
pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25);
@@ -346,7 +339,7 @@ parameter_types! {
346339

347340
impl pallet_transaction_payment::Config for Runtime {
348341
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
349-
type OperationalFeeMultiplier = OperationalFeeMultiplier;
342+
type OperationalFeeMultiplier = ConstU8<5>;
350343
type WeightToFee = bp_millau::WeightToFee;
351344
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
352345
type FeeMultiplierUpdate = pallet_transaction_payment::TargetedFeeAdjustment<
@@ -383,14 +376,6 @@ impl pallet_session::Config for Runtime {
383376
type WeightInfo = ();
384377
}
385378

386-
parameter_types! {
387-
// This is a pretty unscientific cap.
388-
//
389-
// Note that once this is hit the pallet will essentially throttle incoming requests down to one
390-
// call per block.
391-
pub const MaxRequests: u32 = 50;
392-
}
393-
394379
impl pallet_bridge_relayers::Config for Runtime {
395380
type RuntimeEvent = RuntimeEvent;
396381
type Reward = Balance;
@@ -439,7 +424,11 @@ parameter_types! {
439424
pub type RialtoGrandpaInstance = ();
440425
impl pallet_bridge_grandpa::Config for Runtime {
441426
type BridgedChain = bp_rialto::Rialto;
442-
type MaxRequests = MaxRequests;
427+
// This is a pretty unscientific cap.
428+
//
429+
// Note that once this is hit the pallet will essentially throttle incoming requests down to one
430+
// call per block.
431+
type MaxRequests = ConstU32<50>;
443432
type HeadersToKeep = HeadersToKeep;
444433
type MaxBridgedAuthorities = MaxAuthoritiesAtRialto;
445434
type MaxBridgedHeaderSize = MaxRialtoHeaderSize;
@@ -450,7 +439,7 @@ impl pallet_bridge_grandpa::Config for Runtime {
450439
pub type WestendGrandpaInstance = pallet_bridge_grandpa::Instance1;
451440
impl pallet_bridge_grandpa::Config<WestendGrandpaInstance> for Runtime {
452441
type BridgedChain = bp_westend::Westend;
453-
type MaxRequests = MaxRequests;
442+
type MaxRequests = ConstU32<50>;
454443
type HeadersToKeep = HeadersToKeep;
455444
type MaxBridgedAuthorities = MaxAuthoritiesAtWestend;
456445
type MaxBridgedHeaderSize = MaxWestendHeaderSize;

bridges/bin/millau/runtime/src/xcm_config.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use bridge_runtime_common::{
3131
};
3232
use frame_support::{
3333
parameter_types,
34-
traits::{Everything, Nothing},
34+
traits::{ConstU32, Everything, Nothing},
3535
};
3636
use xcm::latest::prelude::*;
3737
use xcm_builder::{
@@ -112,10 +112,6 @@ pub type XcmRouter = (
112112
XcmBridgeAdapter<ToRialtoParachainBridge>,
113113
);
114114

115-
parameter_types! {
116-
pub const MaxAssetsIntoHolding: u32 = 64;
117-
}
118-
119115
/// The barriers one of which must be passed for an XCM message to be executed.
120116
pub type Barrier = (
121117
// Weight that is paid for may be consumed.
@@ -149,7 +145,7 @@ impl xcm_executor::Config for XcmConfig {
149145
type AssetClaims = XcmPallet;
150146
type SubscriptionService = XcmPallet;
151147
type PalletInstancesInfo = AllPalletsWithSystem;
152-
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
148+
type MaxAssetsIntoHolding = ConstU32<64>;
153149
type FeeManager = ();
154150
type MessageExporter = ();
155151
type UniversalAliases = Nothing;

bridges/bin/rialto-parachain/runtime/src/lib.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub use frame_support::{
5050
construct_runtime,
5151
dispatch::DispatchClass,
5252
match_types, parameter_types,
53-
traits::{Everything, IsInVec, Nothing, Randomness},
53+
traits::{ConstU32, Everything, IsInVec, Nothing, Randomness},
5454
weights::{
5555
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
5656
IdentityFee, Weight,
@@ -249,8 +249,6 @@ parameter_types! {
249249
pub const CreationFee: u128 = MILLIUNIT;
250250
pub const TransactionByteFee: u128 = MICROUNIT;
251251
pub const OperationalFeeMultiplier: u8 = 5;
252-
pub const MaxLocks: u32 = 50;
253-
pub const MaxReserves: u32 = 50;
254252
}
255253

256254
impl pallet_balances::Config for Runtime {
@@ -262,8 +260,8 @@ impl pallet_balances::Config for Runtime {
262260
type ExistentialDeposit = ExistentialDeposit;
263261
type AccountStore = System;
264262
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
265-
type MaxLocks = MaxLocks;
266-
type MaxReserves = MaxReserves;
263+
type MaxLocks = ConstU32<50>;
264+
type MaxReserves = ConstU32<50>;
267265
type ReserveIdentifier = [u8; 8];
268266
}
269267

@@ -518,12 +516,6 @@ impl pallet_bridge_relayers::Config for Runtime {
518516
}
519517

520518
parameter_types! {
521-
/// This is a pretty unscientific cap.
522-
///
523-
/// Note that once this is hit the pallet will essentially throttle incoming requests down to one
524-
/// call per block.
525-
pub const MaxRequests: u32 = 50;
526-
527519
/// Number of headers to keep.
528520
///
529521
/// Assuming the worst case of every header being finalized, we will keep headers at least for a
@@ -539,7 +531,11 @@ parameter_types! {
539531
pub type MillauGrandpaInstance = ();
540532
impl pallet_bridge_grandpa::Config for Runtime {
541533
type BridgedChain = bp_millau::Millau;
542-
type MaxRequests = MaxRequests;
534+
/// This is a pretty unscientific cap.
535+
///
536+
/// Note that once this is hit the pallet will essentially throttle incoming requests down to
537+
/// one call per block.
538+
type MaxRequests = ConstU32<50>;
543539
type HeadersToKeep = HeadersToKeep;
544540
type MaxBridgedAuthorities = MaxAuthoritiesAtMillau;
545541
type MaxBridgedHeaderSize = MaxMillauHeaderSize;

bridges/bin/rialto/runtime/src/lib.rs

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub use frame_support::{
6161
construct_runtime,
6262
dispatch::DispatchClass,
6363
parameter_types,
64-
traits::{Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem},
64+
traits::{ConstU32, ConstU8, Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem},
6565
weights::{constants::WEIGHT_PER_SECOND, IdentityFee, RuntimeDbWeight, Weight},
6666
StorageValue,
6767
};
@@ -222,13 +222,12 @@ pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration =
222222
parameter_types! {
223223
pub const EpochDuration: u64 = bp_rialto::EPOCH_DURATION_IN_SLOTS as u64;
224224
pub const ExpectedBlockTime: bp_rialto::Moment = bp_rialto::time_units::MILLISECS_PER_BLOCK;
225-
pub const MaxAuthorities: u32 = 10;
226225
}
227226

228227
impl pallet_babe::Config for Runtime {
229228
type EpochDuration = EpochDuration;
230229
type ExpectedBlockTime = ExpectedBlockTime;
231-
type MaxAuthorities = MaxAuthorities;
230+
type MaxAuthorities = ConstU32<10>;
232231

233232
// session module is the trigger
234233
type EpochChangeTrigger = pallet_babe::ExternalTrigger;
@@ -251,13 +250,13 @@ impl pallet_babe::Config for Runtime {
251250

252251
impl pallet_beefy::Config for Runtime {
253252
type BeefyId = BeefyId;
254-
type MaxAuthorities = MaxAuthorities;
253+
type MaxAuthorities = ConstU32<10>;
255254
type OnNewValidatorSet = MmrLeaf;
256255
}
257256

258257
impl pallet_grandpa::Config for Runtime {
259258
type RuntimeEvent = RuntimeEvent;
260-
type MaxAuthorities = MaxAuthorities;
259+
type MaxAuthorities = ConstU32<10>;
261260
type KeyOwnerProofSystem = ();
262261
type KeyOwnerProof =
263262
<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
@@ -327,10 +326,6 @@ impl pallet_timestamp::Config for Runtime {
327326

328327
parameter_types! {
329328
pub const ExistentialDeposit: bp_rialto::Balance = 500;
330-
// For weight estimation, we assume that the most locks on an individual account will be 50.
331-
// This number may need to be adjusted in the future if this assumption no longer holds true.
332-
pub const MaxLocks: u32 = 50;
333-
pub const MaxReserves: u32 = 50;
334329
}
335330

336331
impl pallet_balances::Config for Runtime {
@@ -343,15 +338,16 @@ impl pallet_balances::Config for Runtime {
343338
type AccountStore = System;
344339
// TODO: update me (https://github.com/paritytech/parity-bridges-common/issues/78)
345340
type WeightInfo = ();
346-
type MaxLocks = MaxLocks;
347-
type MaxReserves = MaxReserves;
341+
// For weight estimation, we assume that the most locks on an individual account will be 50.
342+
// This number may need to be adjusted in the future if this assumption no longer holds true.
343+
type MaxLocks = ConstU32<50>;
344+
type MaxReserves = ConstU32<50>;
348345
type ReserveIdentifier = [u8; 8];
349346
}
350347

351348
parameter_types! {
352349
pub const TransactionBaseFee: Balance = 0;
353350
pub const TransactionByteFee: Balance = 1;
354-
pub const OperationalFeeMultiplier: u8 = 5;
355351
// values for following parameters are copied from polkadot repo, but it is fine
356352
// not to sync them - we're not going to make Rialto a full copy of one of Polkadot-like chains
357353
pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25);
@@ -362,7 +358,7 @@ parameter_types! {
362358

363359
impl pallet_transaction_payment::Config for Runtime {
364360
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
365-
type OperationalFeeMultiplier = OperationalFeeMultiplier;
361+
type OperationalFeeMultiplier = ConstU8<5>;
366362
type WeightToFee = bp_rialto::WeightToFee;
367363
type LengthToFee = bp_rialto::WeightToFee;
368364
type FeeMultiplierUpdate = pallet_transaction_payment::TargetedFeeAdjustment<
@@ -394,7 +390,7 @@ impl pallet_session::Config for Runtime {
394390
}
395391

396392
impl pallet_authority_discovery::Config for Runtime {
397-
type MaxAuthorities = MaxAuthorities;
393+
type MaxAuthorities = ConstU32<10>;
398394
}
399395

400396
impl pallet_bridge_relayers::Config for Runtime {
@@ -405,12 +401,6 @@ impl pallet_bridge_relayers::Config for Runtime {
405401
}
406402

407403
parameter_types! {
408-
/// This is a pretty unscientific cap.
409-
///
410-
/// Note that once this is hit the pallet will essentially throttle incoming requests down to one
411-
/// call per block.
412-
pub const MaxRequests: u32 = 50;
413-
414404
/// Number of headers to keep.
415405
///
416406
/// Assuming the worst case of every header being finalized, we will keep headers at least for a
@@ -426,7 +416,11 @@ parameter_types! {
426416
pub type MillauGrandpaInstance = ();
427417
impl pallet_bridge_grandpa::Config for Runtime {
428418
type BridgedChain = bp_millau::Millau;
429-
type MaxRequests = MaxRequests;
419+
/// This is a pretty unscientific cap.
420+
///
421+
/// Note that once this is hit the pallet will essentially throttle incoming requests down to
422+
/// one call per block.
423+
type MaxRequests = ConstU32<50>;
430424
type HeadersToKeep = HeadersToKeep;
431425
type MaxBridgedAuthorities = MaxAuthoritiesAtMillau;
432426
type MaxBridgedHeaderSize = MaxMillauHeaderSize;

bridges/bin/rialto/runtime/src/parachains.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,10 @@ impl parachains_session_info::Config for Runtime {
123123

124124
impl parachains_shared::Config for Runtime {}
125125

126-
parameter_types! {
127-
pub const FirstMessageFactorPercent: u64 = 100;
128-
}
129-
130126
impl parachains_ump::Config for Runtime {
131127
type RuntimeEvent = RuntimeEvent;
132128
type UmpSink = ();
133-
type FirstMessageFactorPercent = FirstMessageFactorPercent;
129+
type FirstMessageFactorPercent = frame_support::traits::ConstU64<100>;
134130
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
135131
type WeightInfo = parachains_ump::TestWeightInfo;
136132
}

bridges/bin/rialto/runtime/src/xcm_config.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use bridge_runtime_common::{
2727
};
2828
use frame_support::{
2929
parameter_types,
30-
traits::{Everything, Nothing},
30+
traits::{ConstU32, Everything, Nothing},
3131
};
3232
use xcm::latest::prelude::*;
3333
use xcm_builder::{
@@ -104,10 +104,6 @@ pub type XcmRouter = (
104104
XcmBridgeAdapter<ToMillauBridge>,
105105
);
106106

107-
parameter_types! {
108-
pub const MaxAssetsIntoHolding: u32 = 64;
109-
}
110-
111107
/// The barriers one of which must be passed for an XCM message to be executed.
112108
pub type Barrier = (
113109
// Weight that is paid for may be consumed.
@@ -141,7 +137,7 @@ impl xcm_executor::Config for XcmConfig {
141137
type AssetClaims = XcmPallet;
142138
type SubscriptionService = XcmPallet;
143139
type PalletInstancesInfo = AllPalletsWithSystem;
144-
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
140+
type MaxAssetsIntoHolding = ConstU32<64>;
145141
type FeeManager = ();
146142
type MessageExporter = ();
147143
type UniversalAliases = Nothing;

bridges/modules/beefy/src/mock.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::{
2424
use bp_beefy::{BeefyValidatorSignatureOf, ChainWithBeefy, Commitment, MmrDataOrHash};
2525
use bp_runtime::{BasicOperatingMode, Chain};
2626
use codec::Encode;
27-
use frame_support::{construct_runtime, parameter_types, weights::Weight};
27+
use frame_support::{construct_runtime, parameter_types, traits::ConstU64, weights::Weight};
2828
use sp_core::{sr25519::Signature, Pair};
2929
use sp_runtime::{
3030
testing::{Header, H256},
@@ -72,7 +72,6 @@ construct_runtime! {
7272
}
7373

7474
parameter_types! {
75-
pub const BlockHashCount: u64 = 250;
7675
pub const MaximumBlockWeight: Weight = Weight::from_ref_time(1024);
7776
pub const MaximumBlockLength: u32 = 2 * 1024;
7877
pub const AvailableBlockRatio: Perbill = Perbill::one();
@@ -89,7 +88,7 @@ impl frame_system::Config for TestRuntime {
8988
type Lookup = IdentityLookup<Self::AccountId>;
9089
type Header = Header;
9190
type RuntimeEvent = ();
92-
type BlockHashCount = BlockHashCount;
91+
type BlockHashCount = ConstU64<250>;
9392
type Version = ();
9493
type PalletInfo = PalletInfo;
9594
type AccountData = ();

0 commit comments

Comments
 (0)