Skip to content

Commit bab3fb5

Browse files
[stable2407] Backport #6148 (#6232)
Backport #6148 into `stable2407` from bkontur. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> --------- Co-authored-by: Branislav Kontur <[email protected]>
1 parent 6d6aa61 commit bab3fb5

12 files changed

Lines changed: 613 additions & 14 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

polkadot/node/overseer/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ tikv-jemalloc-ctl = "0.5.0"
5050
[features]
5151
default = ["futures_channel"]
5252
expand = ["orchestra/expand"]
53-
futures_channel = [ "orchestra/futures_channel"]
53+
futures_channel = ["orchestra/futures_channel"]
5454
jemalloc-allocator = ["dep:tikv-jemalloc-ctl"]

polkadot/runtime/westend/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,6 +1705,8 @@ pub mod migrations {
17051705
MaxPoolsToMigrate,
17061706
>,
17071707
pallet_staking::migrations::v15::MigrateV14ToV15<Runtime>,
1708+
// permanent
1709+
pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
17081710
);
17091711
}
17101712

polkadot/xcm/docs/src/cookbook/relay_token_transactor/parachain/xcm_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl pallet_xcm::Config for Runtime {
168168
type UniversalLocation = UniversalLocation;
169169
// No version discovery needed
170170
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 0;
171-
type AdvertisedXcmVersion = frame::traits::ConstU32<3>;
171+
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
172172
type AdminOrigin = frame_system::EnsureRoot<AccountId>;
173173
// No locking
174174
type TrustedLockers = ();

polkadot/xcm/docs/src/cookbook/relay_token_transactor/relay_chain/xcm_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl pallet_xcm::Config for Runtime {
142142
type UniversalLocation = UniversalLocation;
143143
// No version discovery needed
144144
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 0;
145-
type AdvertisedXcmVersion = frame::traits::ConstU32<3>;
145+
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
146146
type AdminOrigin = frame_system::EnsureRoot<AccountId>;
147147
// No locking
148148
type TrustedLockers = ();

polkadot/xcm/pallet-xcm/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ codec = { features = ["derive"], workspace = true }
1515
scale-info = { features = ["derive"], workspace = true }
1616
serde = { optional = true, features = ["derive"], workspace = true, default-features = true }
1717
log = { workspace = true }
18+
tracing = { workspace = true }
1819
frame-support.workspace = true
1920
frame-system.workspace = true
2021
sp-core.workspace = true
@@ -47,6 +48,7 @@ std = [
4748
"sp-core/std",
4849
"sp-io/std",
4950
"sp-runtime/std",
51+
"tracing/std",
5052
"xcm-builder/std",
5153
"xcm-executor/std",
5254
"xcm-runtime-apis/std",

polkadot/xcm/pallet-xcm/src/lib.rs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,6 +2692,44 @@ impl<T: Config> Pallet<T> {
26922692
/// set.
26932693
#[cfg(any(feature = "try-runtime", test))]
26942694
pub fn do_try_state() -> Result<(), TryRuntimeError> {
2695+
use migration::data::NeedsMigration;
2696+
2697+
// Take the minimum version between `SafeXcmVersion` and `latest - 1` and ensure that the
2698+
// operational data is stored at least at that version, for example, to prevent issues when
2699+
// removing older XCM versions.
2700+
let minimal_allowed_xcm_version = if let Some(safe_xcm_version) = SafeXcmVersion::<T>::get()
2701+
{
2702+
XCM_VERSION.saturating_sub(1).min(safe_xcm_version)
2703+
} else {
2704+
XCM_VERSION.saturating_sub(1)
2705+
};
2706+
2707+
// check `Queries`
2708+
ensure!(
2709+
!Queries::<T>::iter_values()
2710+
.any(|data| data.needs_migration(minimal_allowed_xcm_version)),
2711+
TryRuntimeError::Other("`Queries` data should be migrated to the higher xcm version!")
2712+
);
2713+
2714+
// check `LockedFungibles`
2715+
ensure!(
2716+
!LockedFungibles::<T>::iter_values()
2717+
.any(|data| data.needs_migration(minimal_allowed_xcm_version)),
2718+
TryRuntimeError::Other(
2719+
"`LockedFungibles` data should be migrated to the higher xcm version!"
2720+
)
2721+
);
2722+
2723+
// check `RemoteLockedFungibles`
2724+
ensure!(
2725+
!RemoteLockedFungibles::<T>::iter()
2726+
.any(|(key, data)| key.needs_migration(minimal_allowed_xcm_version) ||
2727+
data.needs_migration(minimal_allowed_xcm_version)),
2728+
TryRuntimeError::Other(
2729+
"`RemoteLockedFungibles` data should be migrated to the higher xcm version!"
2730+
)
2731+
);
2732+
26952733
// if migration has been already scheduled, everything is ok and data will be eventually
26962734
// migrated
26972735
if CurrentMigration::<T>::exists() {
@@ -2772,7 +2810,7 @@ impl<T: Config> xcm_executor::traits::Enact for UnlockTicket<T> {
27722810
let mut maybe_remove_index = None;
27732811
let mut locked = BalanceOf::<T>::zero();
27742812
let mut found = false;
2775-
// We could just as well do with with an into_iter, filter_map and collect, however this way
2813+
// We could just as well do with an into_iter, filter_map and collect, however this way
27762814
// avoids making an allocation.
27772815
for (i, x) in locks.iter_mut().enumerate() {
27782816
if x.1.try_as::<_>().defensive() == Ok(&self.unlocker) {
@@ -3154,7 +3192,7 @@ impl<T: Config> OnResponse for Pallet<T> {
31543192
});
31553193
return Weight::zero()
31563194
}
3157-
return match maybe_notify {
3195+
match maybe_notify {
31583196
Some((pallet_index, call_index)) => {
31593197
// This is a bit horrible, but we happen to know that the `Call` will
31603198
// be built by `(pallet_index: u8, call_index: u8, QueryId, Response)`.

0 commit comments

Comments
 (0)