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 1 commit
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
1 change: 1 addition & 0 deletions parachains/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#![cfg_attr(not(feature = "std"), no_std)]

pub mod impls;
pub mod prod_or_fast;
pub mod xcm_config;
pub use constants::*;
pub use opaque::*;
Expand Down
47 changes: 47 additions & 0 deletions parachains/common/src/prod_or_fast.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2021 Parity Technologies (UK) Ltd.
// This file is part of Cumulus.

// Cumulus is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Cumulus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.

//! "fast-runtime" feature utils.

/// Macro to set a value (e.g. when using the `parameter_types` macro) to either a production value
/// or to an environment variable or testing value (in case the `fast-runtime` feature is selected).
/// Note that the environment variable is evaluated _at compile time_.
///
/// Usage:
/// ```Rust
/// parameter_types! {
/// // Note that the env variable version parameter cannot be const.
/// pub LaunchPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1, "KSM_LAUNCH_PERIOD");
/// pub const VotingPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES);
/// }
/// ```
#[macro_export]
macro_rules! prod_or_fast {
($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
}
};
}
11 changes: 10 additions & 1 deletion parachains/runtimes/assets/statemint/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ match_types! {
MultiLocation { parents: 1, interior: Here } |
MultiLocation { parents: 1, interior: X1(_) }
};
pub type FellowsPlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 1, interior: X2(Parachain(1001), Plurality { id: BodyId::Technical, ..}) }
};
}

/// A call filter for the XCM Transact instruction. This is a temporary measure until we properly
Expand Down Expand Up @@ -177,7 +180,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_collator_selection::Call::set_desired_candidates { .. } |
pallet_collator_selection::Call::set_candidacy_bond { .. } |
pallet_collator_selection::Call::register_as_candidate { .. } |
pallet_collator_selection::Call::leave_intent { .. },
pallet_collator_selection::Call::leave_intent { .. } |
pallet_collator_selection::Call::set_invulnerables { .. },
) |
RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
RuntimeCall::XcmpQueue(..) |
Expand Down Expand Up @@ -237,6 +241,9 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_uniques::Call::set_collection_max_supply { .. } |
pallet_uniques::Call::set_price { .. } |
pallet_uniques::Call::buy_item { .. },
) |
RuntimeCall::PolkadotXcm(
pallet_xcm::Call::force_xcm_version { .. } | pallet_xcm::Call::send { .. },
) => true,
_ => false,
}
Expand All @@ -258,6 +265,8 @@ pub type Barrier = DenyThenTry<
AllowExplicitUnpaidExecutionFrom<ParentOrParentsPlurality>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<ParentOrSiblings>,
// Fellows plurality gets free execution.
AllowExplicitUnpaidExecutionFrom<FellowsPlurality>,
),
UniversalLocation,
ConstU32<8>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,5 @@ std = [
"pallet-referenda/std",
"pallet-ranked-collective/std",
]
# Set timing constants (e.g. session period) to faster versions to speed up testing.
fast-runtime = []
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//! Track configurations for Fellowship.

use crate::{Balance, BlockNumber, RuntimeOrigin, DAYS, DOLLARS, MINUTES};
use parachains_common::prod_or_fast;
use sp_runtime::Perbill;

/// Referendum `TrackId` type.
Expand Down Expand Up @@ -117,10 +118,10 @@ impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
name: "fellows",
max_deciding: 10,
decision_deposit: 10 * DOLLARS,
prepare_period: 30 * MINUTES,
decision_period: 7 * DAYS,
confirm_period: 30 * MINUTES,
min_enactment_period: 1 * MINUTES,
prepare_period: prod_or_fast!(30 * MINUTES, 2),
decision_period: prod_or_fast!(7 * DAYS, 1),
confirm_period: prod_or_fast!(30 * MINUTES, 1),
min_enactment_period: prod_or_fast!(1 * MINUTES, 1),
min_approval: pallet_referenda::Curve::LinearDecreasing {
length: Perbill::from_percent(100),
floor: Perbill::from_percent(50),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,16 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_collective::Call::disapprove_proposal { .. } |
pallet_collective::Call::close { .. },
) |
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) => true,
RuntimeCall::PolkadotXcm(
pallet_xcm::Call::force_xcm_version { .. } | pallet_xcm::Call::send { .. },
) |
RuntimeCall::FellowshipCollective(
pallet_ranked_collective::Call::add_member { .. } |
pallet_ranked_collective::Call::promote_member { .. } |
pallet_ranked_collective::Call::demote_member { .. } |
pallet_ranked_collective::Call::remove_member { .. },
) => true,

_ => false,
}
}
Expand Down