Skip to content

Commit

Permalink
Adjust time
Browse files Browse the repository at this point in the history
  • Loading branch information
aurexav committed Oct 13, 2023
1 parent 9645108 commit 60a359f
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 46 deletions.
9 changes: 5 additions & 4 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -105,6 +105,7 @@ fast-runtime = [
# darwinia
"crab-runtime?/fast-runtime",
"darwinia-runtime?/fast-runtime",
"pangolin-runtime?/fast-runtime",
]

evm-tracing = [
Expand Down
6 changes: 3 additions & 3 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}

Expand Down
3 changes: 2 additions & 1 deletion runtime/crab/src/pallets/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion runtime/crab/src/pallets/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion runtime/darwinia/src/pallets/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion runtime/darwinia/src/pallets/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions runtime/pangolin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 10 additions & 4 deletions runtime/pangolin/src/pallets/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TIME_1>;
type Time2 = ConstU32<TIME_2>;

pub const COLLECTIVE_DESIRED_MEMBERS: u32 = 7;
pub const COLLECTIVE_MAX_MEMBERS: u32 = 100;
pub const COLLECTIVE_MAX_PROPOSALS: u32 = 100;
Expand All @@ -47,7 +53,7 @@ impl pallet_collective::Config<CouncilCollective> for Runtime {
type MaxMembers = ConstU32<COLLECTIVE_MAX_MEMBERS>;
type MaxProposalWeight = MaxProposalWeight;
type MaxProposals = ConstU32<100>;
type MotionDuration = ConstU32<{ 2 * MINUTES }>;
type MotionDuration = Time1;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
Expand All @@ -59,7 +65,7 @@ impl pallet_collective::Config<TechnicalCollective> for Runtime {
type MaxMembers = ConstU32<COLLECTIVE_MAX_MEMBERS>;
type MaxProposalWeight = MaxProposalWeight;
type MaxProposals = ConstU32<100>;
type MotionDuration = ConstU32<{ 2 * MINUTES }>;
type MotionDuration = Time1;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
Expand All @@ -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<Runtime>;
}
Expand All @@ -95,7 +101,7 @@ impl pallet_referenda::Config for Runtime {
type SubmitOrigin = frame_system::EnsureSigned<AccountId>;
type Tally = pallet_conviction_voting::TallyOf<Runtime>;
type Tracks = TracksInfo;
type UndecidingTimeout = ConstU32<{ 5 * MINUTES }>;
type UndecidingTimeout = Time2;
type Votes = pallet_conviction_voting::VotesOf<Runtime>;
// TODO: weight
type WeightInfo = pallet_referenda::weights::SubstrateWeight<Runtime>;
Expand Down
40 changes: 20 additions & 20 deletions runtime/pangolin/src/pallets/governance/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 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(
Expand All @@ -68,10 +68,10 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 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,
Expand All @@ -94,10 +94,10 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 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,
Expand All @@ -120,10 +120,10 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 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,
Expand All @@ -146,10 +146,10 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 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,
Expand Down
2 changes: 1 addition & 1 deletion runtime/pangolin/src/pallets/governance/treasury.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ impl pallet_treasury::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type SpendFunds = ();
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
type SpendPeriod = ConstU32<{ 2 * MINUTES }>;
type SpendPeriod = Time1;
type WeightInfo = weights::pallet_treasury::WeightInfo<Self>;
}
14 changes: 6 additions & 8 deletions runtime/pangolin/src/pallets/governance/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TechnicalCollective>;
type CancellationOrigin = RootOrAtLeastTwoThird<CouncilCollective>;
type CooloffPeriod = ConstU32<{ 2 * MINUTES }>;
type CooloffPeriod = Time1;
type Currency = Balances;
type EnactmentPeriod = ConstU32<ENACTMENT_PERIOD>;
type EnactmentPeriod = Time1;
type ExternalDefaultOrigin = RootOrAll<CouncilCollective>;
type ExternalMajorityOrigin = RootOrAtLeastHalf<CouncilCollective>;
type ExternalOrigin = RootOrAtLeastHalf<CouncilCollective>;
type FastTrackOrigin = RootOrAtLeastTwoThird<TechnicalCollective>;
type FastTrackVotingPeriod = ConstU32<{ 2 * MINUTES }>;
type FastTrackVotingPeriod = Time1;
type InstantAllowed = ConstBool<true>;
type InstantOrigin = RootOrAll<TechnicalCollective>;
type LaunchPeriod = ConstU32<{ 2 * MINUTES }>;
type LaunchPeriod = Time1;
type MaxBlacklisted = ConstU32<100>;
type MaxDeposits = ConstU32<100>;
type MaxProposals = ConstU32<100>;
Expand All @@ -48,7 +46,7 @@ impl pallet_democracy::Config for Runtime {
type Slash = Treasury;
type SubmitOrigin = frame_system::EnsureSigned<AccountId>;
type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCollective>;
type VoteLockingPeriod = ConstU32<ENACTMENT_PERIOD>;
type VotingPeriod = ConstU32<{ 2 * MINUTES }>;
type VoteLockingPeriod = Time1;
type VotingPeriod = Time1;
type WeightInfo = weights::pallet_democracy::WeightInfo<Self>;
}
3 changes: 2 additions & 1 deletion runtime/pangolin/src/pallets/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion runtime/pangoro/src/pallets/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 60a359f

Please sign in to comment.