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

[stable2407] Backport #6148 #6232

Open
wants to merge 5 commits into
base: stable2407
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion polkadot/node/overseer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ tikv-jemalloc-ctl = "0.5.0"
[features]
default = ["futures_channel"]
expand = ["orchestra/expand"]
futures_channel = [ "orchestra/futures_channel"]
futures_channel = ["orchestra/futures_channel"]
jemalloc-allocator = ["dep:tikv-jemalloc-ctl"]
2 changes: 2 additions & 0 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,8 @@ pub mod migrations {
MaxPoolsToMigrate,
>,
pallet_staking::migrations::v15::MigrateV14ToV15<Runtime>,
// permanent
pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl pallet_xcm::Config for Runtime {
type UniversalLocation = UniversalLocation;
// No version discovery needed
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 0;
type AdvertisedXcmVersion = frame::traits::ConstU32<3>;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
type AdminOrigin = frame_system::EnsureRoot<AccountId>;
// No locking
type TrustedLockers = ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl pallet_xcm::Config for Runtime {
type UniversalLocation = UniversalLocation;
// No version discovery needed
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 0;
type AdvertisedXcmVersion = frame::traits::ConstU32<3>;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
type AdminOrigin = frame_system::EnsureRoot<AccountId>;
// No locking
type TrustedLockers = ();
Expand Down
2 changes: 2 additions & 0 deletions polkadot/xcm/pallet-xcm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ codec = { features = ["derive"], workspace = true }
scale-info = { features = ["derive"], workspace = true }
serde = { optional = true, features = ["derive"], workspace = true, default-features = true }
log = { workspace = true }
tracing = { workspace = true }
frame-support.workspace = true
frame-system.workspace = true
sp-core.workspace = true
Expand Down Expand Up @@ -47,6 +48,7 @@ std = [
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"tracing/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm-runtime-apis/std",
Expand Down
42 changes: 40 additions & 2 deletions polkadot/xcm/pallet-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2692,6 +2692,44 @@ impl<T: Config> Pallet<T> {
/// set.
#[cfg(any(feature = "try-runtime", test))]
pub fn do_try_state() -> Result<(), TryRuntimeError> {
use migration::data::NeedsMigration;

// Take the minimum version between `SafeXcmVersion` and `latest - 1` and ensure that the
// operational data is stored at least at that version, for example, to prevent issues when
// removing older XCM versions.
let minimal_allowed_xcm_version = if let Some(safe_xcm_version) = SafeXcmVersion::<T>::get()
{
XCM_VERSION.saturating_sub(1).min(safe_xcm_version)
} else {
XCM_VERSION.saturating_sub(1)
};

// check `Queries`
ensure!(
!Queries::<T>::iter_values()
.any(|data| data.needs_migration(minimal_allowed_xcm_version)),
TryRuntimeError::Other("`Queries` data should be migrated to the higher xcm version!")
);

// check `LockedFungibles`
ensure!(
!LockedFungibles::<T>::iter_values()
.any(|data| data.needs_migration(minimal_allowed_xcm_version)),
TryRuntimeError::Other(
"`LockedFungibles` data should be migrated to the higher xcm version!"
)
);

// check `RemoteLockedFungibles`
ensure!(
!RemoteLockedFungibles::<T>::iter()
.any(|(key, data)| key.needs_migration(minimal_allowed_xcm_version) ||
data.needs_migration(minimal_allowed_xcm_version)),
TryRuntimeError::Other(
"`RemoteLockedFungibles` data should be migrated to the higher xcm version!"
)
);

// if migration has been already scheduled, everything is ok and data will be eventually
// migrated
if CurrentMigration::<T>::exists() {
Expand Down Expand Up @@ -2772,7 +2810,7 @@ impl<T: Config> xcm_executor::traits::Enact for UnlockTicket<T> {
let mut maybe_remove_index = None;
let mut locked = BalanceOf::<T>::zero();
let mut found = false;
// We could just as well do with with an into_iter, filter_map and collect, however this way
// We could just as well do with an into_iter, filter_map and collect, however this way
// avoids making an allocation.
for (i, x) in locks.iter_mut().enumerate() {
if x.1.try_as::<_>().defensive() == Ok(&self.unlocker) {
Expand Down Expand Up @@ -3154,7 +3192,7 @@ impl<T: Config> OnResponse for Pallet<T> {
});
return Weight::zero()
}
return match maybe_notify {
match maybe_notify {
Some((pallet_index, call_index)) => {
// This is a bit horrible, but we happen to know that the `Call` will
// be built by `(pallet_index: u8, call_index: u8, QueryId, Response)`.
Expand Down
Loading
Loading