Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
949cf3a
remove parameter types and use const type
Dec 2, 2021
e0a6de6
remove parameter types and use const type
Dec 3, 2021
eb685a2
fix merge conflict
Dec 3, 2021
c65bd09
Delete {
gui1117 Dec 7, 2021
691c8a0
Delete count,
gui1117 Dec 7, 2021
367dfe1
Merge branch 'master' of https://github.com/paritytech/substrate into…
Dec 11, 2021
a7ec5ed
Merge branch 'dharjeezy/change-parameter-types' of https://github.com…
Dec 11, 2021
97c6827
refractor for beefy, benchmarking, child bounties, and collective pal…
Dec 11, 2021
d4cb6cd
refractor for pallet contracts
Dec 11, 2021
79803af
refractor for elections
Dec 11, 2021
fe5fc30
refractor for more pallets
Dec 13, 2021
049330b
fix CI issues
Dec 13, 2021
0891184
fix CI issues
Dec 13, 2021
28ef4ab
fix CI issues
Dec 13, 2021
f884936
fix CI issues
Dec 13, 2021
2f06a51
Merge branch 'master' of https://github.com/paritytech/substrate into…
Dec 14, 2021
afeb9d1
remove warning to fix CI issue
Dec 14, 2021
fed71ad
remove warning to fix CI issue
Dec 14, 2021
ff2b679
remove warning to fix CI issue
Dec 14, 2021
578c606
remove warning to fix CI issue
Dec 14, 2021
c26c0c7
remove warning to fix CI issue
Dec 14, 2021
73fd9eb
remove warning to fix CI issue
Dec 14, 2021
1a4ddd8
remove warning to fix CI issue
Dec 15, 2021
7f031c1
remove warning to fix CI issue
Dec 15, 2021
9db0013
cargo +nightly fmt
Dec 15, 2021
ee86965
CI fix
Dec 15, 2021
7db185e
more param refractor on beefy-mmr
Dec 15, 2021
96a70a1
refractor for beefy
Dec 15, 2021
68edde0
Update frame/babe/src/mock.rs
gui1117 Dec 16, 2021
760ada2
Update frame/babe/src/mock.rs
gui1117 Dec 16, 2021
3215584
Update frame/bounties/src/tests.rs
gui1117 Dec 16, 2021
8fcedb7
Update frame/tips/src/tests.rs
gui1117 Dec 16, 2021
8452705
Delete mock.rs
gui1117 Dec 16, 2021
1934f96
Update frame/examples/basic/src/tests.rs
gui1117 Dec 16, 2021
1dacf5f
Apply suggestions from code review
gui1117 Dec 16, 2021
7b761ec
Update frame/im-online/src/mock.rs
gui1117 Dec 16, 2021
84e1f50
Update frame/im-online/src/mock.rs
gui1117 Dec 16, 2021
01d7b53
Update frame/offences/benchmarking/src/mock.rs
gui1117 Dec 16, 2021
d58eb39
Update frame/session/benchmarking/src/mock.rs
gui1117 Dec 16, 2021
a128b97
Update frame/support/test/tests/pallet_compatibility.rs
gui1117 Dec 16, 2021
cc389e7
Update frame/support/test/tests/pallet_compatibility_instance.rs
gui1117 Dec 16, 2021
f32ffdb
Update frame/treasury/src/tests.rs
gui1117 Dec 16, 2021
9feb374
Update test-utils/runtime/src/lib.rs
gui1117 Dec 16, 2021
7e65680
some cleanup
gui1117 Dec 16, 2021
1aca17d
fmt
gui1117 Dec 16, 2021
c67bc24
remove unused
gui1117 Dec 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions bin/node-template/pallets/template/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate as pallet_template;
use frame_support::parameter_types;
use frame_support::{parameter_types, traits::{ConstU16, ConstU64}};
use frame_system as system;
use sp_core::H256;
use sp_runtime::{
Expand All @@ -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 = ();
Expand All @@ -42,14 +37,14 @@ impl system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
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 = ();
}

Expand Down
22 changes: 6 additions & 16 deletions bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{KeyOwnerProofSystem, Randomness, StorageInfo},
traits::{KeyOwnerProofSystem, Randomness, StorageInfo, ConstU8, ConstU32, ConstU128},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
IdentityFee, Weight,
Expand Down Expand Up @@ -195,14 +195,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 {
Expand All @@ -222,7 +218,7 @@ impl pallet_grandpa::Config for Runtime {
type HandleEquivocation = ();

type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
type MaxAuthorities = ConstU32<32>;
}

parameter_types! {
Expand All @@ -237,34 +233,28 @@ 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.
type Balance = Balance;
/// 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<Runtime>;
}

parameter_types! {
pub const TransactionByteFee: Balance = 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could also remove this with a ConstU128 actually

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still to do

pub OperationalFeeMultiplier: u8 = 5;
}

impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = CurrencyAdapter<Balances, ()>;
type TransactionByteFee = TransactionByteFee;
type OperationalFeeMultiplier = OperationalFeeMultiplier;
type OperationalFeeMultiplier = ConstU8<5>;
type WeightToFee = IdentityFee<Balance>;
type FeeMultiplierUpdate = ();
}
Expand Down
35 changes: 13 additions & 22 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{
construct_runtime, parameter_types,
traits::{
ConstU32, Currency, EnsureOneOf, EqualPrivilegeOnly, Everything, Imbalance, InstanceFilter,
ConstU16, ConstU32, Currency, EnsureOneOf, EqualPrivilegeOnly, Everything, Imbalance, InstanceFilter,
KeyOwnerProofSystem, LockIdentifier, Nothing, OnUnbalanced, U128CurrencyToVote,
},
weights::{
Expand Down Expand Up @@ -190,7 +190,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());
Expand All @@ -217,7 +216,7 @@ impl frame_system::Config for Runtime {
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = frame_system::weights::SubstrateWeight<Runtime>;
type SS58Prefix = SS58Prefix;
type SS58Prefix = ConstU16<42>;
type OnSetCode = ();
}

Expand All @@ -235,7 +234,6 @@ parameter_types! {
pub const DepositBase: Balance = deposit(1, 88);
// Additional storage item size of 32 bytes.
pub const DepositFactor: Balance = deposit(0, 32);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't is possible to use ConstU128<{ deposit(0, 32) } instead of this ?
I think we should also get rid of them then.

pub const MaxSignatories: u16 = 100;
}

impl pallet_multisig::Config for Runtime {
Expand All @@ -244,7 +242,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<Runtime>;
}

Expand All @@ -253,10 +251,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.
Expand Down Expand Up @@ -323,9 +319,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<Runtime>;
type MaxPending = MaxPending;
type MaxPending = ConstU32<32>;
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
Expand All @@ -334,7 +330,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;
}

impl pallet_scheduler::Config for Runtime {
Expand All @@ -344,7 +339,7 @@ impl pallet_scheduler::Config for Runtime {
type Call = Call;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type MaxScheduledPerBlock = ConstU32<50>;
type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
type OriginPrivilegeCmp = EqualPrivilegeOnly;
}
Expand Down Expand Up @@ -558,7 +553,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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same we can probably use ConstU128<{ 1 * DOLLATS }>

pub const SignedDepositBase: Balance = 1 * DOLLARS;
pub const SignedDepositByte: Balance = 1 * CENTS;
Expand All @@ -576,11 +570,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!(
Expand Down Expand Up @@ -645,7 +634,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;
Expand All @@ -664,7 +653,10 @@ impl pallet_election_provider_multi_phase::Config for Runtime {
type WeightInfo = pallet_election_provider_multi_phase::weights::SubstrateWeight<Self>;
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! {
Expand All @@ -682,7 +674,6 @@ 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;
Expand Down Expand Up @@ -717,7 +708,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<true>;
type FastTrackVotingPeriod = FastTrackVotingPeriod;
// To cancel a proposal which has been passed, 2/3 of the council must agree to it.
type CancellationOrigin =
Expand All @@ -738,7 +729,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>;
Comment thread
gui1117 marked this conversation as resolved.
type WeightInfo = pallet_democracy::weights::SubstrateWeight<Runtime>;
type MaxProposals = MaxProposals;
}
Expand Down
Empty file added count,
Empty file.
27 changes: 8 additions & 19 deletions frame/assets/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use super::*;
use crate as pallet_assets;

use frame_support::{construct_runtime, parameter_types, traits::GenesisBuild};
use frame_support::{construct_runtime, parameter_types, traits::{GenesisBuild, ConstU32, ConstU64}};
use sp_core::H256;
use sp_runtime::{
testing::Header,
Expand All @@ -42,9 +42,6 @@ construct_runtime!(
}
);

parameter_types! {
pub const BlockHashCount: u64 = 250;
}
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
Expand All @@ -59,7 +56,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type DbWeight = ();
type Version = ();
type PalletInfo = PalletInfo;
Expand All @@ -71,15 +68,11 @@ impl frame_system::Config for Test {
type OnSetCode = ();
}

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 = ConstU64<1>;
type AccountStore = System;
type WeightInfo = ();
type MaxLocks = ();
Expand All @@ -88,11 +81,7 @@ impl pallet_balances::Config for Test {
}

parameter_types! {
pub const AssetDeposit: u64 = 1;
pub const ApprovalDeposit: u64 = 1;
pub const StringLimit: u32 = 50;
Comment thread
gui1117 marked this conversation as resolved.
Outdated
pub const MetadataDepositBase: u64 = 1;
pub const MetadataDepositPerByte: u64 = 1;
}

impl Config for Test {
Expand All @@ -101,11 +90,11 @@ impl Config for Test {
type AssetId = u32;
type Currency = Balances;
type ForceOrigin = frame_system::EnsureRoot<u64>;
type AssetDeposit = AssetDeposit;
type MetadataDepositBase = MetadataDepositBase;
type MetadataDepositPerByte = MetadataDepositPerByte;
type ApprovalDeposit = ApprovalDeposit;
type StringLimit = StringLimit;
type AssetDeposit = ConstU64<1>;
type MetadataDepositBase = ConstU64<1>;
type MetadataDepositPerByte = ConstU64<1>;
type ApprovalDeposit = ConstU64<1>;
type StringLimit = ConstU32<50>;
type Freezer = TestFreezer;
type WeightInfo = ();
type Extra = ();
Expand Down
18 changes: 6 additions & 12 deletions frame/atomic-swap/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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,
Expand All @@ -26,7 +26,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);
}
Expand All @@ -45,7 +44,7 @@ impl frame_system::Config for Test {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<250>;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
Expand All @@ -55,28 +54,23 @@ impl frame_system::Config for Test {
type SS58Prefix = ();
type OnSetCode = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
}

impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
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<u64, Balances>;
type ProofLimit = ProofLimit;
type ProofLimit = ConstU32<1024>;
}

const A: u64 = 1;
Expand Down
Loading