Skip to content

Commit

Permalink
Various backports and alignments with polkadot-sdk (which does not …
Browse files Browse the repository at this point in the history
…depend on crates.io versions) (#45)

## Summary

This PR proposes several changes.

- The alignment of the terminology used for "common-good" and "system"
parachains in the Polkadot ecosystem, as discussed in
[PR#1406](paritytech/polkadot-sdk#1406).
- Additionally, it suggests the removal of the
`ChildSystemParachainAsSuperuser` feature from the Kusama runtime, as
mentioned in a comment on the same PR [comment
link](paritytech/polkadot-sdk#1406 (comment)).
- Relax `force_default_xcm_version` in `SafeCallFilter` for system
parachains - based on
paritytech/polkadot-sdk#2385
- Add `Storage` item to `PolkadotXcm` pallet definition for BridgeHubs
(now we cannot see storage items for `pallet_xcm` in polkadot.js) -
based on paritytech/polkadot-sdk#2385

## Explanation

A significant [change of
PR#1406](https://github.com/paritytech/polkadot-sdk/pull/1406/files#diff-0b7b4f5b962a18ce980354592b55ab2a27b5a2e9f6f8089ec803ca73853e8583L202-R224)
is the redefinition of what constitutes a "system" parachain.
Previously, a "system" parachain was identified with `para_id <= 1000`.
However, the
[PR#1406](paritytech/polkadot-sdk#1406) changed
a definition, considering a "system" parachain to have `para_id <=
1999`.

One consequence of this change is the reconsideration of the
[`ChildSystemParachainAsSuperuser`](https://github.com/paritytech/polkadot-sdk/blob/a50e6ba7af50a4be9ae78ebb90e86a61f3dd85e1/polkadot/xcm/xcm-builder/src/origin_conversion.rs#L72-L88)
feature. This feature relies on the
[`is_system`](https://github.com/paritytech/polkadot-sdk/blob/a50e6ba7af50a4be9ae78ebb90e86a61f3dd85e1/polkadot/parachain/src/primitives.rs#L216-L226)
function, which, in turn, depends on the para_id of a parachain to
determine "system" status. However, further examination has revealed
that there is no known scenario in which a system parachain would need
to call the Kusama runtime with `RuntimeOrigin::root()` privileges.
Consequently, maintaining the `ChildSystemParachainAsSuperuser` feature
in the Kusama runtime is deemed unnecessary.

## References

- [GitHub Pull Request
#1406](paritytech/polkadot-sdk#1406)
- [GitHub Pull Request
#2385](paritytech/polkadot-sdk#2385)
- Redo of #32 on main.

---------

Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
  • Loading branch information
3 people authored Dec 8, 2023
1 parent 2b30243 commit d67b905
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 60 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Remove `experimental` feature flag for `pallet-society`, `pallet-xcm`, and `runtime-common` crates imports ([polkadot-fellows/runtimes#56](https://github.com/polkadot-fellows/runtimes/pull/56))
- Election provider: use a geometric deposit base calculation for EPM signed submissions in Polkadot and Kusama ([polkadot-fellows/runtimes#56](https://github.com/polkadot-fellows/runtimes/pull/56))
- Make `IdentityInfo` generic in `pallet-identity` ([polkadot-fellows/runtimes#87](https://github.com/polkadot-fellows/runtimes/pull/87)). Context: https://github.com/paritytech/polkadot-sdk/pull/1661
- Whitelist `force_default_xcm_version` in XCM call filter ([polkadot-fellows/runtimes#45](https://github.com/polkadot-fellows/runtimes/pull/45))

### Added

Expand Down
2 changes: 1 addition & 1 deletion relay/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ impl pallet_staking::EraPayout<Balance> for EraPayout {
// all para-ids that are currently active.
let auctioned_slots = Paras::parachains()
.into_iter()
// all active para-ids that do not belong to a system or common good chain is the number
// all active para-ids that do not belong to a system chain is the number
// of parachains that we should take into account for inflation.
.filter(|i| *i >= LOWEST_PUBLIC_ID)
.count() as u64;
Expand Down
8 changes: 8 additions & 0 deletions relay/kusama/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,11 @@ fn check_whitelist() {
// XcmPallet SafeXcmVersion
assert!(whitelist.contains("1405f2411d0af5a7ff397e7c9dc68d196323ae84c43568be0d1394d5d0d522c4"));
}

#[test]
fn check_treasury_pallet_id() {
assert_eq!(
<Treasury as frame_support::traits::PalletInfoAccess>::index() as u8,
kusama_runtime_constants::TREASURY_PALLET_ID
);
}
13 changes: 6 additions & 7 deletions relay/kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, ChildParachainAsNative,
ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain, IsConcrete, MintLocation,
OriginToPluralityVoice, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId, UsingComponents,
WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeesToAccount,
ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter, IsChildSystemParachain,
IsConcrete, MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, TrailingSetTopicAsId,
UsingComponents, WeightInfoBounds, WithComputedOrigin, WithUniqueTopic, XcmFeesToAccount,
};
use xcm_executor::traits::WithOriginFilter;

Expand Down Expand Up @@ -99,8 +98,6 @@ type LocalOriginConverter = (
ChildParachainAsNative<parachains_origin::Origin, RuntimeOrigin>,
// The AccountId32 location type can be expressed natively as a `Signed` origin.
SignedAccountId32AsNative<ThisNetwork, RuntimeOrigin>,
// A system child parachain, expressed as a Superuser, converts to the `Root` origin.
ChildSystemParachainAsSuperuser<ParaId, RuntimeOrigin>,
);

parameter_types! {
Expand Down Expand Up @@ -135,6 +132,8 @@ parameter_types! {
pub const KsmForBridgeHub: (MultiAssetFilter, MultiLocation) = (Ksm::get(), BridgeHubLocation::get());
pub const MaxAssetsIntoHolding: u32 = 64;
}

/// Kusama Relay recognizes/respects AssetHub, Encointer, and BridgeHub chains as teleporters.
pub type TrustedTeleporters = (
xcm_builder::Case<KsmForAssetHub>,
xcm_builder::Case<KsmForEncointer>,
Expand Down
26 changes: 17 additions & 9 deletions relay/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ impl pallet_staking::EraPayout<Balance> for EraPayout {
// all para-ids that are not active.
let auctioned_slots = Paras::parachains()
.into_iter()
// all active para-ids that do not belong to a system or common good chain is the number
// all active para-ids that do not belong to a system chain is the number
// of parachains that we should take into account for inflation.
.filter(|i| *i >= LOWEST_PUBLIC_ID)
.count() as u64;
Expand Down Expand Up @@ -2497,6 +2497,7 @@ mod test {

use super::*;
use frame_support::traits::WhitelistedStorageKeys;
use scale_info::TypeInfo;
use sp_core::hexdisplay::HexDisplay;

#[test]
Expand Down Expand Up @@ -2540,6 +2541,21 @@ mod test {
whitelist.contains("1405f2411d0af5a7ff397e7c9dc68d196323ae84c43568be0d1394d5d0d522c4")
);
}

#[test]
fn check_treasury_pallet_id() {
assert_eq!(
<Treasury as frame_support::traits::PalletInfoAccess>::index() as u8,
polkadot_runtime_constants::TREASURY_PALLET_ID
);
}

#[test]
fn ensure_xcm_metadata_is_correct() {
let path = xcm::VersionedXcm::<()>::type_info().path;
// Ensure that the name doesn't include `staging` (from the pallet name)
assert_eq!(vec!["xcm", "VersionedXcm"], path.segments);
}
}

#[cfg(test)]
Expand All @@ -2550,7 +2566,6 @@ mod multiplier_tests {
traits::{OnFinalize, PalletInfoAccess},
};
use runtime_common::{MinimumMultiplier, TargetBlockFullness};
use scale_info::TypeInfo;
use separator::Separatable;
use sp_runtime::traits::Convert;

Expand Down Expand Up @@ -2678,13 +2693,6 @@ mod multiplier_tests {
blocks += 1;
}
}

#[test]
fn ensure_xcm_metadata_is_correct() {
let path = xcm::VersionedXcm::<()>::type_info().path;
// Ensure that the name doesn't include `staging` (from the pallet name)
assert_eq!(vec!["xcm", "VersionedXcm"], path.segments);
}
}

#[cfg(all(test, feature = "try-runtime"))]
Expand Down
4 changes: 2 additions & 2 deletions relay/polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ parameter_types! {
pub const MaxAssetsIntoHolding: u32 = 64;
}

/// Polkadot Relay recognizes/respects the asset hub chain as a teleporter.
/// Polkadot Relay recognizes/respects AssetHub, Collectives, and BridgeHub chains as teleporters.
pub type TrustedTeleporters = (
xcm_builder::Case<DotForAssetHub>,
xcm_builder::Case<DotForCollectives>,
Expand All @@ -166,7 +166,7 @@ pub type Barrier = TrailingSetTopicAsId<(
AllowKnownQueryResponses<XcmPallet>,
WithComputedOrigin<
(
// If the message is one that immediately attemps to pay for execution, then allow it.
// If the message is one that immediately attempts to pay for execution, then allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Subscriptions for version tracking are OK.
AllowSubscriptionsFrom<OnlyParachains>,
Expand Down
22 changes: 12 additions & 10 deletions system-parachains/asset-hubs/asset-hub-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub type CurrencyTransactor = CurrencyAdapter<
(),
>;

/// `AssetId`/`Balance` converter for `PoolAssets`.
/// `AssetId`/`Balance` converter for `TrustBackedAssets`.
pub type TrustBackedAssetsConvertedConcreteId =
assets_common::TrustBackedAssetsConvertedConcreteId<TrustBackedAssetsPalletLocation, Balance>;

Expand All @@ -126,7 +126,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
CheckingAccount,
>;

/// `AssetId/Balance` converter for `TrustBackedAssets`
/// `AssetId`/`Balance` converter for `ForeignAssets`
pub type ForeignAssetsConvertedConcreteId = assets_common::ForeignAssetsConvertedConcreteId<
(
// Ignore `TrustBackedAssets` explicitly
Expand Down Expand Up @@ -260,13 +260,15 @@ impl Contains<RuntimeCall> for SafeCallFilter {

matches!(
call,
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
frame_system::Call::set_code { .. } |
frame_system::Call::set_code_without_checks { .. } |
frame_system::Call::kill_prefix { .. },
) | RuntimeCall::ParachainSystem(..) |
RuntimeCall::PolkadotXcm(
pallet_xcm::Call::force_xcm_version { .. } |
pallet_xcm::Call::force_default_xcm_version { .. }
) | RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
frame_system::Call::set_code { .. } |
frame_system::Call::set_code_without_checks { .. } |
frame_system::Call::kill_prefix { .. },
) | RuntimeCall::ParachainSystem(..) |
RuntimeCall::Timestamp(..) |
RuntimeCall::Balances(..) |
RuntimeCall::CollatorSelection(
Expand Down Expand Up @@ -457,7 +459,7 @@ pub type Barrier = TrailingSetTopicAsId<
// Allow XCMs with some computed origins to pass through.
WithComputedOrigin<
(
// If the message is one that immediately attemps to pay for execution, then
// If the message is one that immediately attempts to pay for execution, then
// allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent, its pluralities (i.e. governance bodies) and parent's treasury
Expand Down
20 changes: 11 additions & 9 deletions system-parachains/asset-hubs/asset-hub-polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub type FungiblesTransactor = FungiblesAdapter<
CheckingAccount,
>;

/// `AssetId/Balance` converter for `TrustBackedAssets`
/// `AssetId`/`Balance` converter for `ForeignAssets`
pub type ForeignAssetsConvertedConcreteId = assets_common::ForeignAssetsConvertedConcreteId<
(
// Ignore `TrustBackedAssets` explicitly
Expand Down Expand Up @@ -216,13 +216,15 @@ impl Contains<RuntimeCall> for SafeCallFilter {

matches!(
call,
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
frame_system::Call::set_code { .. } |
frame_system::Call::set_code_without_checks { .. } |
frame_system::Call::kill_prefix { .. },
) | RuntimeCall::ParachainSystem(..) |
RuntimeCall::PolkadotXcm(
pallet_xcm::Call::force_xcm_version { .. } |
pallet_xcm::Call::force_default_xcm_version { .. }
) | RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
frame_system::Call::set_code { .. } |
frame_system::Call::set_code_without_checks { .. } |
frame_system::Call::kill_prefix { .. },
) | RuntimeCall::ParachainSystem(..) |
RuntimeCall::Timestamp(..) |
RuntimeCall::Balances(..) |
RuntimeCall::CollatorSelection(
Expand Down Expand Up @@ -372,7 +374,7 @@ pub type Barrier = TrailingSetTopicAsId<
// Allow XCMs with some computed origins to pass through.
WithComputedOrigin<
(
// If the message is one that immediately attemps to pay for execution, then
// If the message is one that immediately attempts to pay for execution, then
// allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// The locations listed below get free execution.
Expand Down
2 changes: 1 addition & 1 deletion system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ construct_runtime!(

// XCM helpers.
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 30,
PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin, Config<T>} = 31,
PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin, Config<T>} = 31,
CumulusXcm: cumulus_pallet_xcm::{Pallet, Event<T>, Origin} = 32,
DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 33,

Expand Down
18 changes: 10 additions & 8 deletions system-parachains/bridge-hubs/bridge-hub-kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,15 @@ impl Contains<RuntimeCall> for SafeCallFilter {

matches!(
call,
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
frame_system::Call::set_code { .. } |
frame_system::Call::set_code_without_checks { .. } |
frame_system::Call::kill_prefix { .. },
) | RuntimeCall::ParachainSystem(..) |
RuntimeCall::PolkadotXcm(
pallet_xcm::Call::force_xcm_version { .. } |
pallet_xcm::Call::force_default_xcm_version { .. }
) | RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
frame_system::Call::set_code { .. } |
frame_system::Call::set_code_without_checks { .. } |
frame_system::Call::kill_prefix { .. },
) | RuntimeCall::ParachainSystem(..) |
RuntimeCall::Timestamp(..) |
RuntimeCall::Balances(..) |
RuntimeCall::CollatorSelection(
Expand Down Expand Up @@ -172,7 +174,7 @@ pub type Barrier = TrailingSetTopicAsId<
AllowKnownQueryResponses<PolkadotXcm>,
WithComputedOrigin<
(
// If the message is one that immediately attemps to pay for execution, then
// If the message is one that immediately attempts to pay for execution, then
// allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent and its pluralities (i.e. governance bodies) and relay treasury get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ construct_runtime!(

// XCM helpers.
XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 30,
PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin, Config<T>} = 31,
PolkadotXcm: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin, Config<T>} = 31,
CumulusXcm: cumulus_pallet_xcm::{Pallet, Event<T>, Origin} = 32,
DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 33,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,15 @@ impl Contains<RuntimeCall> for SafeCallFilter {

matches!(
call,
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
frame_system::Call::set_code { .. } |
frame_system::Call::set_code_without_checks { .. } |
frame_system::Call::kill_prefix { .. },
) | RuntimeCall::ParachainSystem(..) |
RuntimeCall::PolkadotXcm(
pallet_xcm::Call::force_xcm_version { .. } |
pallet_xcm::Call::force_default_xcm_version { .. }
) | RuntimeCall::System(
frame_system::Call::set_heap_pages { .. } |
frame_system::Call::set_code { .. } |
frame_system::Call::set_code_without_checks { .. } |
frame_system::Call::kill_prefix { .. },
) | RuntimeCall::ParachainSystem(..) |
RuntimeCall::Timestamp(..) |
RuntimeCall::Balances(..) |
RuntimeCall::CollatorSelection(
Expand Down Expand Up @@ -175,7 +177,7 @@ pub type Barrier = TrailingSetTopicAsId<
AllowKnownQueryResponses<PolkadotXcm>,
WithComputedOrigin<
(
// If the message is one that immediately attemps to pay for execution, then
// If the message is one that immediately attempts to pay for execution, then
// allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent, its pluralities (i.e. governance bodies), Fellows plurality
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//!
//! ### Governance
//!
//! As a common good parachain, Collectives defers its governance (namely, its `Root` origin), to
//! As a system parachain, Collectives defers its governance (namely, its `Root` origin), to
//! its Relay Chain parent, Polkadot.
//!
//! ### Collator Selection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ impl Contains<RuntimeCall> for SafeCallFilter {
pallet_collator_selection::Call::add_invulnerable { .. } |
pallet_collator_selection::Call::remove_invulnerable { .. },
) | RuntimeCall::Session(pallet_session::Call::purge_keys { .. }) |
RuntimeCall::PolkadotXcm(pallet_xcm::Call::force_xcm_version { .. }) |
RuntimeCall::XcmpQueue(..) |
RuntimeCall::PolkadotXcm(
pallet_xcm::Call::force_xcm_version { .. } |
pallet_xcm::Call::force_default_xcm_version { .. }
) | RuntimeCall::XcmpQueue(..) |
RuntimeCall::DmpQueue(..) |
RuntimeCall::Alliance(
// `init_members` accepts unbounded vecs as arguments,
Expand Down Expand Up @@ -221,7 +223,7 @@ pub type Barrier = TrailingSetTopicAsId<
// Allow XCMs with some computed origins to pass through.
WithComputedOrigin<
(
// If the message is one that immediately attemps to pay for execution, then
// If the message is one that immediately attempts to pay for execution, then
// allow it.
AllowTopLevelPaidExecutionFrom<Everything>,
// Parent and its pluralities (i.e. governance bodies) and relay treasury get
Expand Down

0 comments on commit d67b905

Please sign in to comment.