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
Next Next commit
pass xcm origin, allow unpaid form Collectives and Fellows, whitelist…
… call
  • Loading branch information
muharem committed Mar 10, 2023
commit 4883335bc054ad2971d308193288d22713d0b5e4
8 changes: 8 additions & 0 deletions runtime/polkadot/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ pub mod xcm {
}
}

/// Parachains.
pub mod parachains {
/// Statemint parachain id.
pub const STATEMINT_ID: u32 = 1000;
/// Collectives parachain id.
pub const COLLECTIVES_ID: u32 = 1001;
}

#[cfg(test)]
mod tests {
use super::{
Expand Down
16 changes: 8 additions & 8 deletions runtime/polkadot/src/governance/tracks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 15
name: "staking_admin",
max_deciding: 10,
decision_deposit: 5 * GRAND,
prepare_period: 2 * HOURS,
decision_period: 28 * DAYS,
confirm_period: 3 * HOURS,
min_enactment_period: 10 * MINUTES,
prepare_period: prod_or_fast!(2 * HOURS, 2),
decision_period: prod_or_fast!(28 * DAYS, 1),
confirm_period: prod_or_fast!(3 * HOURS, 1),
min_enactment_period: prod_or_fast!(10 * MINUTES, 1),
min_approval: APP_STAKING_ADMIN,
min_support: SUP_STAKING_ADMIN,
},
Expand Down Expand Up @@ -142,10 +142,10 @@ const TRACKS_DATA: [(u16, pallet_referenda::TrackInfo<Balance, BlockNumber>); 15
name: "fellowship_admin",
max_deciding: 10,
decision_deposit: 5 * GRAND,
prepare_period: 2 * HOURS,
decision_period: 28 * DAYS,
confirm_period: 3 * HOURS,
min_enactment_period: 10 * MINUTES,
prepare_period: prod_or_fast!(2 * HOURS, 2),
decision_period: prod_or_fast!(28 * DAYS, 1),
confirm_period: prod_or_fast!(3 * HOURS, 1),
min_enactment_period: prod_or_fast!(10 * MINUTES, 1),
min_approval: APP_FELLOWSHIP_ADMIN,
min_support: SUP_FELLOWSHIP_ADMIN,
},
Expand Down
26 changes: 18 additions & 8 deletions runtime/polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ use frame_support::{
traits::{Contains, Everything, Nothing},
weights::Weight,
};
use polkadot_runtime_constants::xcm::body::FELLOWSHIP_ADMIN_INDEX;
use pallet_xcm::XcmPassthrough;
use polkadot_runtime_constants::{parachains::*, xcm::body::FELLOWSHIP_ADMIN_INDEX};
use runtime_common::{paras_registrar, xcm_sender, ToAuthor};
use sp_core::ConstU32;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
AllowTopLevelPaidExecutionFrom, BackingToPlurality, ChildParachainAsNative,
ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds,
IsConcrete, MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative,
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, BackingToPlurality,
ChildParachainAsNative, ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter,
FixedWeightBounds, IsConcrete, MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
WithComputedOrigin,
};
Expand Down Expand Up @@ -94,6 +95,8 @@ type LocalOriginConverter = (
// If the origin kind is `Native` and the XCM origin is the `AccountId32` location, then it can
// be expressed using the `Signed` origin variant.
SignedAccountId32AsNative<ThisNetwork, RuntimeOrigin>,
// Xcm origins can be represented natively under the Xcm pallet's Xcm origin.
XcmPassthrough<RuntimeOrigin>,
);

parameter_types! {
Expand All @@ -113,8 +116,8 @@ pub type XcmRouter = (

parameter_types! {
pub const Dot: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) });
pub const DotForStatemint: (MultiAssetFilter, MultiLocation) = (Dot::get(), Parachain(1000).into_location());
pub const CollectivesLocation: MultiLocation = Parachain(1001).into_location();
pub const DotForStatemint: (MultiAssetFilter, MultiLocation) = (Dot::get(), Parachain(STATEMINT_ID).into_location());
pub const CollectivesLocation: MultiLocation = Parachain(COLLECTIVES_ID).into_location();
pub const DotForCollectives: (MultiAssetFilter, MultiLocation) = (Dot::get(), CollectivesLocation::get());
pub const MaxAssetsIntoHolding: u32 = 64;
}
Expand All @@ -127,6 +130,10 @@ match_types! {
pub type OnlyParachains: impl Contains<MultiLocation> = {
MultiLocation { parents: 0, interior: X1(Parachain(_)) }
};
pub type CollectivesOrCollectivesPlurality: impl Contains<MultiLocation> = {
MultiLocation { parents: 0, interior: X1(Parachain(COLLECTIVES_ID)) } |
MultiLocation { parents: 0, interior: X2(Parachain(COLLECTIVES_ID), Plurality { .. }) }
};
}

/// The barriers one of which must be passed for an XCM message to be executed.
Expand All @@ -141,6 +148,8 @@ pub type Barrier = (
AllowTopLevelPaidExecutionFrom<Everything>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<OnlyParachains>,
// Collectives and its pluralities get free execution.
AllowExplicitUnpaidExecutionFrom<CollectivesOrCollectivesPlurality>,
),
UniversalLocation,
ConstU32<8>,
Expand Down Expand Up @@ -304,7 +313,8 @@ impl Contains<RuntimeCall> for SafeCallFilter {
) |
RuntimeCall::XcmPallet(pallet_xcm::Call::limited_reserve_transfer_assets {
..
}) => true,
}) |
RuntimeCall::Whitelist(pallet_whitelist::Call::whitelist_call { .. }) => true,
_ => false,
}
}
Expand Down