Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Replace simple parameter_types #11254

Merged
merged 24 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e95c523
update bin/node-template/runtime/src/lib.rs
bizzyvinci Apr 20, 2022
fb3d60a
update frame/contracts/src/tests.rs
bizzyvinci Apr 20, 2022
3534a60
update frame/executive/src/lib.rs
bizzyvinci Apr 20, 2022
2becd1e
update frame/grandpa/src/mock.rs
bizzyvinci Apr 20, 2022
c76b8ed
update frame/im-online/src/mock.rs
bizzyvinci Apr 20, 2022
f974d1c
update frame/offences/benchmarking/src/mock.rs
bizzyvinci Apr 20, 2022
8b0fa6e
update frame/recovery/src/mock.rs
bizzyvinci Apr 20, 2022
2f58878
update frame/referenda/src/mock.rs
bizzyvinci Apr 20, 2022
db6d8ea
update frame/session/benchmarking/src/mock.rs
bizzyvinci Apr 20, 2022
e0b39fc
update frame/staking/src/mock.rs
bizzyvinci Apr 20, 2022
cdc7c3b
update frame/state-trie-migration/src/lib.rs
bizzyvinci Apr 20, 2022
9be9885
update frame/support/test/compile_pass/src/lib.rs
bizzyvinci Apr 20, 2022
08703f9
frame/treasury/src/tests.rs
bizzyvinci Apr 20, 2022
a609114
update frame/whitelist/src/mock.rs
bizzyvinci Apr 20, 2022
fd100fd
update frame/vesting/src/mock.rs
bizzyvinci Apr 20, 2022
7c146de
update test-utils/runtime/src/lib.rs
bizzyvinci Apr 20, 2022
247bcac
update bin/node-template/runtime/src/lib.rs
bizzyvinci Apr 21, 2022
2f7eb78
Update frame/grandpa/src/mock.rs
shawntabrizi Apr 23, 2022
c54dcfd
resolve failed checks 1518659 & 1518669
bizzyvinci Apr 23, 2022
c93976d
resolve format check
bizzyvinci Apr 23, 2022
11eea86
backtrack to resolve compile error
bizzyvinci Apr 23, 2022
4b3d89d
check --all --tests ✅
bizzyvinci Apr 25, 2022
9d221d7
cargo +nightly fmt ✅
bizzyvinci Apr 25, 2022
b448eb3
Merge branch 'master' into parameter_types
KiChjang Apr 28, 2022
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
12 changes: 5 additions & 7 deletions bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 = ();
}

Expand Down
6 changes: 1 addition & 5 deletions frame/contracts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,13 @@ 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<Test> = {
let mut schedule = <Schedule<Test>>::default();
// We want stack height to be always enabled for tests so that this
// instrumentation path is always tested implicitly.
schedule.limits.stack_height = Some(512);
schedule
};
pub const TransactionByteFee: u64 = 0;
pub static DepositPerByte: BalanceOf<Test> = 1;
pub const DepositPerItem: BalanceOf<Test> = 2;
}
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions frame/executive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ();
Expand Down
6 changes: 1 addition & 5 deletions frame/grandpa/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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<Self::AccountId>;
type SessionInterface = Self;
type UnixTime = pallet_timestamp::Pallet<Test>;
Expand Down
6 changes: 1 addition & 5 deletions frame/im-online/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,13 @@ impl frame_support::traits::EstimateNextSessionRotation<u64> 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>;
Expand Down
6 changes: 2 additions & 4 deletions frame/offences/benchmarking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,15 @@ 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 = ();
type ReserveIdentifier = [u8; 8];
type Balance = Balance;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<10>;
type AccountStore = System;
type WeightInfo = ();
}
Expand Down
26 changes: 7 additions & 19 deletions frame/referenda/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,7 +61,6 @@ impl Contains<Call> for BaseFilter {
}

parameter_types! {
pub const BlockHashCount: u64 = 250;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1_000_000);
}
Expand All @@ -81,7 +79,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 @@ -101,42 +99,32 @@ 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<u64>;
type MaxScheduledPerBlock = ConstU32<100>;
type WeightInfo = ();
type OriginPrivilegeCmp = EqualPrivilegeOnly;
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;
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 2 additions & 4 deletions frame/session/benchmarking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,15 @@ 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 = ();
type ReserveIdentifier = [u8; 8];
type Balance = Balance;
type Event = Event;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type ExistentialDeposit = ConstU64<10>;
type AccountStore = System;
type WeightInfo = ();
}
Expand Down
14 changes: 7 additions & 7 deletions frame/state-trie-migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -1008,7 +1011,6 @@ mod mock {
);

parameter_types! {
pub const BlockHashCount: u32 = 250;
pub const SS58Prefix: u8 = 42;
}

Expand All @@ -1026,7 +1028,7 @@ mod mock {
type Lookup = IdentityLookup<Self::AccountId>;
type Header = sp_runtime::generic::Header<Self::BlockNumber, BlakeTwo256>;
type Event = Event;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU32<250>;
type DbWeight = ();
type Version = ();
type PalletInfo = PalletInfo;
Expand All @@ -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;
}
Expand All @@ -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 = ();
Expand Down
5 changes: 2 additions & 3 deletions frame/support/test/compile_pass/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -50,7 +50,6 @@ pub type BlockNumber = u64;
pub type Index = u64;

parameter_types! {
pub const BlockHashCount: BlockNumber = 2400;
pub const Version: RuntimeVersion = VERSION;
}

Expand All @@ -63,7 +62,7 @@ impl frame_system::Config for Runtime {
type Hashing = BlakeTwo256;
type Header = Header;
type Lookup = IdentityLookup<Self::AccountId>;
type BlockHashCount = BlockHashCount;
type BlockHashCount = ConstU64<2400>;
type Version = Version;
type AccountData = ();
type Origin = Origin;
Expand Down
5 changes: 1 addition & 4 deletions frame/treasury/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
13 changes: 4 additions & 9 deletions frame/whitelist/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,7 +36,7 @@ use sp_runtime::{
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;

frame_support::construct_runtime!(
construct_runtime!(
pub enum Test where
Block = Block,
NodeBlock = Block,
Expand All @@ -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);
}
Expand Down Expand Up @@ -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<Self::AccountId>;
type MaxSize = PreimageMaxSize;
type MaxSize = ConstU32<{ 4096 * 1024 }>; // PreimageMaxSize Taken from Polkadot as reference.
type BaseDeposit = ConstU64<1>;
type ByteDeposit = ConstU64<1>;
type WeightInfo = ();
Expand Down
Loading