Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 🎸 prod_or_fast #1144

Merged
merged 2 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ kusama-runtime = { package = "staging-kusama-runtime", git = "https
kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
polkadot-runtime-constants = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
Expand Down
1 change: 1 addition & 0 deletions runtime/bifrost-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ parachain-info = { workspace = true }
pallet-xcm = { workspace = true }
polkadot-parachain-primitives = { workspace = true }
polkadot-primitives = { workspace = true }
polkadot-runtime-common = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
Expand Down
17 changes: 9 additions & 8 deletions runtime/bifrost-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ pub use bifrost_primitives::{
Ratio, RpcContributionStatus, Shortfall, TimeUnit, TokenSymbol,
};
pub use bifrost_runtime_common::{
cent, constants::time::*, dollar, micro, milli, millicent, prod_or_test, AuraId,
CouncilCollective, EnsureRootOrAllTechnicalCommittee, MoreThanHalfCouncil,
SlowAdjustingFeeUpdate, TechnicalCollective,
cent, constants::time::*, dollar, micro, milli, millicent, AuraId, CouncilCollective,
EnsureRootOrAllTechnicalCommittee, MoreThanHalfCouncil, SlowAdjustingFeeUpdate,
TechnicalCollective,
};
use bifrost_slp::QueryId;
use constants::currency::*;
Expand All @@ -95,6 +95,7 @@ use frame_system::{EnsureRoot, EnsureRootWithSuccess, EnsureSigned};
use hex_literal::hex;
use orml_oracle::{DataFeeder, DataProvider, DataProviderExtended};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use polkadot_runtime_common::prod_or_fast;

// zenlink imports
use zenlink_protocol::{
Expand Down Expand Up @@ -976,7 +977,7 @@ parameter_types! {
/// Minimum round length is 2 minutes (10 * 12 second block times)
pub const MinBlocksPerRound: u32 = 10;
/// Blocks per round
pub const DefaultBlocksPerRound: u32 = prod_or_test!(2 * HOURS, 10);
pub const DefaultBlocksPerRound: u32 = prod_or_fast!(2 * HOURS, 10);
/// Rounds before the collator leaving the candidates request can be executed
pub const LeaveCandidatesDelay: u32 = 84;
/// Rounds before the candidate bond increase/decrease can be executed
Expand All @@ -990,7 +991,7 @@ parameter_types! {
/// Rounds before the reward is paid
pub const RewardPaymentDelay: u32 = 2;
/// Minimum collators selected per round, default at genesis and minimum forever after
pub const MinSelectedCandidates: u32 = prod_or_test!(16,6);
pub const MinSelectedCandidates: u32 = prod_or_fast!(16,6);
/// Maximum top delegations per candidate
pub const MaxTopDelegationsPerCandidate: u32 = 300;
/// Maximum bottom delegations per candidate
Expand All @@ -1008,7 +1009,7 @@ parameter_types! {
/// Minimum stake required to be reserved to be a delegator
pub MinDelegatorStk: u128 = 50 * BNCS;
pub AllowInflation: bool = false;
pub ToMigrateInvulnables: Vec<AccountId> = prod_or_test!(vec![
pub ToMigrateInvulnables: Vec<AccountId> = prod_or_fast!(vec![
hex!["8cf80f0bafcd0a3d80ca61cb688e4400e275b39d3411b4299b47e712e9dab809"].into(),
hex!["40ac4effe39181731a8feb8a8ee0780e177bdd0d752b09c8fd71047e67189022"].into(),
hex!["624d6a004c72a1abcf93131e185515ebe1410e43a301fe1f25d20d8da345376e"].into(),
Expand Down Expand Up @@ -1426,7 +1427,7 @@ impl bifrost_farming::Config for Runtime {
}

parameter_types! {
pub const BlocksPerRound: u32 = prod_or_test!(1500, 50);
pub const BlocksPerRound: u32 = prod_or_fast!(1500, 50);
pub const MaxTokenLen: u32 = 500;
pub const MaxFarmingPoolIdLen: u32 = 100;
}
Expand Down Expand Up @@ -1786,7 +1787,7 @@ impl leverage_staking::Config for Runtime {
}

parameter_types! {
pub const ClearingDuration: u32 = 7 * DAYS;
pub const ClearingDuration: u32 = prod_or_fast!(7 * DAYS, 10 * MINUTES);
pub const NameLengthLimit: u32 = 20;
pub BifrostCommissionReceiver: AccountId = TreasuryPalletId::get().into_account_truncating();
}
Expand Down
1 change: 1 addition & 0 deletions runtime/bifrost-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ parachain-info = { workspace = true }
pallet-xcm = { workspace = true }
polkadot-parachain-primitives = { workspace = true }
polkadot-primitives = { workspace = true }
polkadot-runtime-common = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
Expand Down
7 changes: 4 additions & 3 deletions runtime/bifrost-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub use bifrost_primitives::{
GLMR_TOKEN_ID,
};
use bifrost_runtime_common::{
constants::time::*, dollar, micro, milli, prod_or_test, AuraId, CouncilCollective,
constants::time::*, dollar, micro, milli, AuraId, CouncilCollective,
EnsureRootOrAllTechnicalCommittee, MoreThanHalfCouncil, SlowAdjustingFeeUpdate,
TechnicalCollective,
};
Expand All @@ -103,6 +103,7 @@ use zenlink_protocol::{
pub mod xcm_config;
use orml_traits::{currency::MutationHooks, location::RelativeReserveProvider};
use pallet_xcm::{EnsureResponse, QueryStatus};
use polkadot_runtime_common::prod_or_fast;
use static_assertions::const_assert;
use xcm::v3::prelude::*;
use xcm_config::{
Expand Down Expand Up @@ -1258,7 +1259,7 @@ impl bifrost_farming::Config for Runtime {
}

parameter_types! {
pub const BlocksPerRound: u32 = prod_or_test!(1500, 50);
pub const BlocksPerRound: u32 = prod_or_fast!(1500, 50);
pub const MaxTokenLen: u32 = 500;
pub const MaxFarmingPoolIdLen: u32 = 100;
}
Expand Down Expand Up @@ -1594,7 +1595,7 @@ impl leverage_staking::Config for Runtime {
}

parameter_types! {
pub const ClearingDuration: u32 = 7 * DAYS;
pub const ClearingDuration: u32 = prod_or_fast!(7 * DAYS, 10 * MINUTES);
pub const NameLengthLimit: u32 = 20;
pub BifrostCommissionReceiver: AccountId = TreasuryPalletId::get().into_account_truncating();
}
Expand Down
18 changes: 0 additions & 18 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,3 @@ impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider
.unwrap_or_default()
}
}

#[macro_export]
macro_rules! prod_or_test {
($prod:expr, $test:expr) => {
if cfg!(feature = "fast-runtime") {
$test
} else {
$prod
}
};
($prod:expr, $test:expr, $env:expr) => {
if cfg!(feature = "fast-runtime") {
core::option_env!($env).map(|s| s.parse().ok()).flatten().unwrap_or($test)
} else {
$prod
}
};
}
Loading