diff --git a/node/Cargo.toml b/node/Cargo.toml index 8893f9d6f..3b694b662 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -48,10 +48,10 @@ fp-evm = { workspace = true, features = ["std"] } fp-rpc = { workspace = true, features = ["std"] } # moonbeam -moonbeam-primitives-ext = { workspace = true, optional = true, features = ["std"] } -moonbeam-rpc-debug = { workspace = true } -moonbeam-rpc-primitives-debug = { workspace = true, features = ["std"] } -moonbeam-rpc-trace = { workspace = true } +moonbeam-primitives-ext = { workspace = true, optional = true, features = ["std"] } +moonbeam-rpc-debug = { workspace = true } +moonbeam-rpc-primitives-debug = { workspace = true, features = ["std"] } +moonbeam-rpc-trace = { workspace = true } # polkadot polkadot-cli = { workspace = true } @@ -105,6 +105,7 @@ fast-runtime = [ # darwinia "crab-runtime?/fast-runtime", "darwinia-runtime?/fast-runtime", + "pangolin-runtime?/fast-runtime", ] evm-tracing = [ diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 186aca415..759789ae0 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -45,11 +45,11 @@ use frame_support::{ #[macro_export] macro_rules! fast_runtime_or_not { - ($name:ident, $development_type:ty, $production_type:ty) => { + ($name:ident, $type:ty, $fast:expr, $regular:expr) => { #[cfg(feature = "fast-runtime")] - type $name = $development_type; + const $name: $type = $fast; #[cfg(not(feature = "fast-runtime"))] - type $name = $production_type; + const $name: $type = $regular; }; } diff --git a/runtime/crab/src/pallets/session.rs b/runtime/crab/src/pallets/session.rs index 383efa998..303b40d03 100644 --- a/runtime/crab/src/pallets/session.rs +++ b/runtime/crab/src/pallets/session.rs @@ -25,9 +25,10 @@ sp_runtime::impl_opaque_keys! { } } -fast_runtime_or_not!(Period, ConstU32<{ 5 * MINUTES }>, ConstU32<{ 6 * HOURS }>); +fast_runtime_or_not!(PERIOD, BlockNumber, 5 * MINUTES, 6 * HOURS); type Offset = ConstU32<0>; +type Period = ConstU32<{ PERIOD }>; impl pallet_session::Config for Runtime { type Keys = SessionKeys; diff --git a/runtime/crab/src/pallets/staking.rs b/runtime/crab/src/pallets/staking.rs index 953f9d4ca..73b78050c 100644 --- a/runtime/crab/src/pallets/staking.rs +++ b/runtime/crab/src/pallets/staking.rs @@ -19,7 +19,9 @@ // darwinia use crate::*; -fast_runtime_or_not!(MinStakingDuration, ConstU32<{ 5 * MINUTES }>, ConstU32<{ 14 * DAYS }>); +fast_runtime_or_not!(DURATION, BlockNumber, 5 * MINUTES, 14 * DAYS); + +type MinStakingDuration = ConstU32<{ DURATION }>; pub enum RingStaking {} impl darwinia_staking::Stake for RingStaking { diff --git a/runtime/darwinia/src/pallets/session.rs b/runtime/darwinia/src/pallets/session.rs index 383efa998..303b40d03 100644 --- a/runtime/darwinia/src/pallets/session.rs +++ b/runtime/darwinia/src/pallets/session.rs @@ -25,9 +25,10 @@ sp_runtime::impl_opaque_keys! { } } -fast_runtime_or_not!(Period, ConstU32<{ 5 * MINUTES }>, ConstU32<{ 6 * HOURS }>); +fast_runtime_or_not!(PERIOD, BlockNumber, 5 * MINUTES, 6 * HOURS); type Offset = ConstU32<0>; +type Period = ConstU32<{ PERIOD }>; impl pallet_session::Config for Runtime { type Keys = SessionKeys; diff --git a/runtime/darwinia/src/pallets/staking.rs b/runtime/darwinia/src/pallets/staking.rs index dd0ea72eb..055228344 100644 --- a/runtime/darwinia/src/pallets/staking.rs +++ b/runtime/darwinia/src/pallets/staking.rs @@ -19,7 +19,9 @@ // darwinia use crate::*; -fast_runtime_or_not!(MinStakingDuration, ConstU32<{ 5 * MINUTES }>, ConstU32<{ 14 * DAYS }>); +fast_runtime_or_not!(DURATION, BlockNumber, 5 * MINUTES, 14 * DAYS); + +type MinStakingDuration = ConstU32<{ DURATION }>; pub enum RingStaking {} impl darwinia_staking::Stake for RingStaking { diff --git a/runtime/pangolin/Cargo.toml b/runtime/pangolin/Cargo.toml index 49a585a48..8367c0815 100644 --- a/runtime/pangolin/Cargo.toml +++ b/runtime/pangolin/Cargo.toml @@ -273,6 +273,8 @@ evm-tracing = [ "moonbeam-evm-tracer", ] +fast-runtime = [] + # A feature that should be enabled when the runtime should be build for on-chain # deployment. This will disable stuff that shouldn't be part of the on-chain wasm # to make it smaller like logging for example. diff --git a/runtime/pangolin/src/pallets/governance.rs b/runtime/pangolin/src/pallets/governance.rs index 21fa9c200..27563ff25 100644 --- a/runtime/pangolin/src/pallets/governance.rs +++ b/runtime/pangolin/src/pallets/governance.rs @@ -31,6 +31,12 @@ pub use pallet_collective::{Instance1 as CouncilCollective, Instance2 as Technic pub(super) use crate::*; +fast_runtime_or_not!(TIME_1, BlockNumber, 2 * MINUTES, 10 * MINUTES); +fast_runtime_or_not!(TIME_2, BlockNumber, 5 * MINUTES, 20 * MINUTES); + +type Time1 = ConstU32; +type Time2 = ConstU32; + pub const COLLECTIVE_DESIRED_MEMBERS: u32 = 7; pub const COLLECTIVE_MAX_MEMBERS: u32 = 100; pub const COLLECTIVE_MAX_PROPOSALS: u32 = 100; @@ -47,7 +53,7 @@ impl pallet_collective::Config for Runtime { type MaxMembers = ConstU32; type MaxProposalWeight = MaxProposalWeight; type MaxProposals = ConstU32<100>; - type MotionDuration = ConstU32<{ 2 * MINUTES }>; + type MotionDuration = Time1; type Proposal = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; @@ -59,7 +65,7 @@ impl pallet_collective::Config for Runtime { type MaxMembers = ConstU32; type MaxProposalWeight = MaxProposalWeight; type MaxProposals = ConstU32<100>; - type MotionDuration = ConstU32<{ 2 * MINUTES }>; + type MotionDuration = Time1; type Proposal = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; @@ -73,7 +79,7 @@ impl pallet_conviction_voting::Config for Runtime { type MaxVotes = ConstU32<512>; type Polls = Referenda; type RuntimeEvent = RuntimeEvent; - type VoteLockingPeriod = ConstU32<{ 5 * MINUTES }>; + type VoteLockingPeriod = Time2; // TODO: weight type WeightInfo = pallet_conviction_voting::weights::SubstrateWeight; } @@ -95,7 +101,7 @@ impl pallet_referenda::Config for Runtime { type SubmitOrigin = frame_system::EnsureSigned; type Tally = pallet_conviction_voting::TallyOf; type Tracks = TracksInfo; - type UndecidingTimeout = ConstU32<{ 5 * MINUTES }>; + type UndecidingTimeout = Time2; type Votes = pallet_conviction_voting::VotesOf; // TODO: weight type WeightInfo = pallet_referenda::weights::SubstrateWeight; diff --git a/runtime/pangolin/src/pallets/governance/track.rs b/runtime/pangolin/src/pallets/governance/track.rs index 781a4a95c..e474c180d 100644 --- a/runtime/pangolin/src/pallets/governance/track.rs +++ b/runtime/pangolin/src/pallets/governance/track.rs @@ -41,13 +41,13 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo); 5] // Amount that must be placed on deposit before a decision can be made. decision_deposit: DARWINIA_PROPOSAL_REQUIREMENT, // Amount of time this must be submitted for before a decision can be made. - prepare_period: 2 * MINUTES, + prepare_period: TIME_1, // Amount of time that a decision may take to be approved prior to cancellation. - decision_period: 2 * MINUTES, + decision_period: TIME_1, // Amount of time that the approval criteria must hold before it can be approved. - confirm_period: 2 * MINUTES, + confirm_period: TIME_1, // Minimum amount of time that an approved proposal must be in the dispatch queue. - min_enactment_period: 2 * MINUTES, + min_enactment_period: TIME_1, // Minimum aye votes as percentage of overall conviction-weighted votes needed for // approval as a function of time into decision period. min_approval: pallet_referenda::Curve::make_reciprocal( @@ -68,10 +68,10 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo); 5] name: "whitelisted_caller", max_deciding: 100, decision_deposit: DARWINIA_PROPOSAL_REQUIREMENT, - prepare_period: 2 * MINUTES, - decision_period: 2 * MINUTES, - confirm_period: 2 * MINUTES, - min_enactment_period: 2 * MINUTES, + prepare_period: TIME_1, + decision_period: TIME_1, + confirm_period: TIME_1, + min_enactment_period: TIME_1, min_approval: pallet_referenda::Curve::make_reciprocal( 1, 2, @@ -94,10 +94,10 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo); 5] name: "general_admin", max_deciding: 10, decision_deposit: DARWINIA_PROPOSAL_REQUIREMENT, - prepare_period: 2 * MINUTES, - decision_period: 2 * MINUTES, - confirm_period: 2 * MINUTES, - min_enactment_period: 2 * MINUTES, + prepare_period: TIME_1, + decision_period: TIME_1, + confirm_period: TIME_1, + min_enactment_period: TIME_1, min_approval: pallet_referenda::Curve::make_reciprocal( 1, 2, @@ -120,10 +120,10 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo); 5] name: "referendum_canceller", max_deciding: 20, decision_deposit: DARWINIA_PROPOSAL_REQUIREMENT, - prepare_period: 2 * MINUTES, - decision_period: 2 * MINUTES, - confirm_period: 2 * MINUTES, - min_enactment_period: 2 * MINUTES, + prepare_period: TIME_1, + decision_period: TIME_1, + confirm_period: TIME_1, + min_enactment_period: TIME_1, min_approval: pallet_referenda::Curve::make_reciprocal( 1, 2, @@ -146,10 +146,10 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo); 5] name: "referendum_killer", max_deciding: 100, decision_deposit: DARWINIA_PROPOSAL_REQUIREMENT, - prepare_period: 2 * MINUTES, - decision_period: 2 * MINUTES, - confirm_period: 2 * MINUTES, - min_enactment_period: 2 * MINUTES, + prepare_period: TIME_1, + decision_period: TIME_1, + confirm_period: TIME_1, + min_enactment_period: TIME_1, min_approval: pallet_referenda::Curve::make_reciprocal( 1, 2, diff --git a/runtime/pangolin/src/pallets/governance/treasury.rs b/runtime/pangolin/src/pallets/governance/treasury.rs index 6e9ff1080..167a9cbc9 100644 --- a/runtime/pangolin/src/pallets/governance/treasury.rs +++ b/runtime/pangolin/src/pallets/governance/treasury.rs @@ -41,6 +41,6 @@ impl pallet_treasury::Config for Runtime { type RuntimeEvent = RuntimeEvent; type SpendFunds = (); type SpendOrigin = frame_support::traits::NeverEnsureOrigin; - type SpendPeriod = ConstU32<{ 2 * MINUTES }>; + type SpendPeriod = Time1; type WeightInfo = weights::pallet_treasury::WeightInfo; } diff --git a/runtime/pangolin/src/pallets/governance/v1.rs b/runtime/pangolin/src/pallets/governance/v1.rs index e937cfebb..478e5b4ed 100644 --- a/runtime/pangolin/src/pallets/governance/v1.rs +++ b/runtime/pangolin/src/pallets/governance/v1.rs @@ -19,23 +19,21 @@ // darwinia use super::*; -const ENACTMENT_PERIOD: u32 = 2 * MINUTES; - impl pallet_democracy::Config for Runtime { type BlacklistOrigin = Root; type CancelProposalOrigin = RootOrAtLeastTwoThird; type CancellationOrigin = RootOrAtLeastTwoThird; - type CooloffPeriod = ConstU32<{ 2 * MINUTES }>; + type CooloffPeriod = Time1; type Currency = Balances; - type EnactmentPeriod = ConstU32; + type EnactmentPeriod = Time1; type ExternalDefaultOrigin = RootOrAll; type ExternalMajorityOrigin = RootOrAtLeastHalf; type ExternalOrigin = RootOrAtLeastHalf; type FastTrackOrigin = RootOrAtLeastTwoThird; - type FastTrackVotingPeriod = ConstU32<{ 2 * MINUTES }>; + type FastTrackVotingPeriod = Time1; type InstantAllowed = ConstBool; type InstantOrigin = RootOrAll; - type LaunchPeriod = ConstU32<{ 2 * MINUTES }>; + type LaunchPeriod = Time1; type MaxBlacklisted = ConstU32<100>; type MaxDeposits = ConstU32<100>; type MaxProposals = ConstU32<100>; @@ -48,7 +46,7 @@ impl pallet_democracy::Config for Runtime { type Slash = Treasury; type SubmitOrigin = frame_system::EnsureSigned; type VetoOrigin = pallet_collective::EnsureMember; - type VoteLockingPeriod = ConstU32; - type VotingPeriod = ConstU32<{ 2 * MINUTES }>; + type VoteLockingPeriod = Time1; + type VotingPeriod = Time1; type WeightInfo = weights::pallet_democracy::WeightInfo; } diff --git a/runtime/pangolin/src/pallets/session.rs b/runtime/pangolin/src/pallets/session.rs index 383efa998..303b40d03 100644 --- a/runtime/pangolin/src/pallets/session.rs +++ b/runtime/pangolin/src/pallets/session.rs @@ -25,9 +25,10 @@ sp_runtime::impl_opaque_keys! { } } -fast_runtime_or_not!(Period, ConstU32<{ 5 * MINUTES }>, ConstU32<{ 6 * HOURS }>); +fast_runtime_or_not!(PERIOD, BlockNumber, 5 * MINUTES, 6 * HOURS); type Offset = ConstU32<0>; +type Period = ConstU32<{ PERIOD }>; impl pallet_session::Config for Runtime { type Keys = SessionKeys; diff --git a/runtime/pangoro/src/pallets/session.rs b/runtime/pangoro/src/pallets/session.rs index 383efa998..303b40d03 100644 --- a/runtime/pangoro/src/pallets/session.rs +++ b/runtime/pangoro/src/pallets/session.rs @@ -25,9 +25,10 @@ sp_runtime::impl_opaque_keys! { } } -fast_runtime_or_not!(Period, ConstU32<{ 5 * MINUTES }>, ConstU32<{ 6 * HOURS }>); +fast_runtime_or_not!(PERIOD, BlockNumber, 5 * MINUTES, 6 * HOURS); type Offset = ConstU32<0>; +type Period = ConstU32<{ PERIOD }>; impl pallet_session::Config for Runtime { type Keys = SessionKeys;