Skip to content

Commit b1dd9f7

Browse files
authored
Bump runtime and remove migrations (#3543)
* Bump runtime and remove migrations * remove unused migrations
1 parent a3a5bef commit b1dd9f7

File tree

3 files changed

+4
-152
lines changed

3 files changed

+4
-152
lines changed

parachain/runtime/heima/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
245245
impl_name: alloc::borrow::Cow::Borrowed("heima"),
246246
authoring_version: 1,
247247
// same versioning-mechanism as polkadot: use last digit for minor updates
248-
spec_version: 9244,
248+
spec_version: 9245,
249249
impl_version: 0,
250250
apis: RUNTIME_API_VERSIONS,
251251
transaction_version: 2,
@@ -473,7 +473,7 @@ parameter_types! {
473473
impl pallet_migrations::Config for Runtime {
474474
type RuntimeEvent = RuntimeEvent;
475475
#[cfg(not(feature = "runtime-benchmarks"))]
476-
type Migrations = pallet_identity::migration::v2::LazyMigrationV1ToV2<Runtime>;
476+
type Migrations = ();
477477
// Benchmarks need mocked migrations to guarantee that they succeed.
478478
#[cfg(feature = "runtime-benchmarks")]
479479
type Migrations = pallet_migrations::mock_helpers::MockedMigrations;

parachain/runtime/heima/src/migration/mod.rs

Lines changed: 0 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -13,151 +13,3 @@
1313
//
1414
// You should have received a copy of the GNU General Public License
1515
// along with Litentry. If not, see <https://www.gnu.org/licenses/>.
16-
17-
#[cfg(feature = "try-runtime")]
18-
use frame_support::ensure;
19-
#[cfg(feature = "try-runtime")]
20-
use frame_support::traits::StorageVersion;
21-
#[cfg(feature = "try-runtime")]
22-
use sp_runtime::DispatchError;
23-
#[cfg(feature = "try-runtime")]
24-
use sp_std::vec::Vec;
25-
26-
use frame_support::StorageHasher;
27-
use frame_support::{
28-
pallet_prelude::*,
29-
storage::migration::{clear_storage_prefix, put_storage_value},
30-
traits::{Get, GetStorageVersion, OnRuntimeUpgrade, PalletInfoAccess},
31-
weights::Weight,
32-
};
33-
use frame_system::pallet_prelude::BlockNumberFor;
34-
use log;
35-
use pallet_xcm::QueryStatus;
36-
use sp_std::marker::PhantomData;
37-
use xcm::v5::{Junctions, Location};
38-
use xcm::VersionedLocation;
39-
40-
pub type Migrations<Runtime> = (IdentityUpdateStorageVersion<Runtime>, RewriteXcmQueries<Runtime>);
41-
42-
const IDENTITY_LOG_TARGET: &str = "runtime::identity";
43-
const XCM_LOG_TARGET: &str = "runtime::xcm";
44-
45-
pub struct IdentityUpdateStorageVersion<T>(PhantomData<T>);
46-
impl<T> OnRuntimeUpgrade for IdentityUpdateStorageVersion<T>
47-
where
48-
T: frame_system::Config + pallet_identity::Config,
49-
{
50-
#[cfg(feature = "try-runtime")]
51-
fn pre_upgrade() -> Result<Vec<u8>, DispatchError> {
52-
ensure!(
53-
StorageVersion::get::<pallet_identity::Pallet<T>>() == 1,
54-
"Current pallet_identity StorageVersion is not 1."
55-
);
56-
Ok(Vec::<u8>::new())
57-
}
58-
59-
fn on_runtime_upgrade() -> frame_support::weights::Weight {
60-
let on_chain_version = pallet_identity::Pallet::<T>::on_chain_storage_version();
61-
let in_code_version = pallet_identity::Pallet::<T>::in_code_storage_version();
62-
63-
if on_chain_version < in_code_version {
64-
frame_support::storage::unhashed::kill(&frame_support::storage::storage_prefix(
65-
pallet_identity::Pallet::<T>::name().as_bytes(),
66-
"StorageVersion".as_bytes(),
67-
));
68-
69-
in_code_version.put::<pallet_identity::Pallet<T>>();
70-
71-
log::info!(target: IDENTITY_LOG_TARGET, "Upgrade pallet_identity StorageVersion to version 2 successfully");
72-
T::DbWeight::get().reads_writes(1, 3)
73-
} else {
74-
log::info!(
75-
target: IDENTITY_LOG_TARGET,
76-
"No migration executed. This probably should be removed."
77-
);
78-
T::DbWeight::get().reads(1)
79-
}
80-
}
81-
82-
#[cfg(feature = "try-runtime")]
83-
fn post_upgrade(_state: Vec<u8>) -> Result<(), DispatchError> {
84-
ensure!(
85-
StorageVersion::get::<pallet_identity::Pallet<T>>() == 2,
86-
"Please upgrade pallet_identity StorageVersion to 2"
87-
);
88-
Ok(())
89-
}
90-
}
91-
92-
pub struct RewriteXcmQueries<T>(PhantomData<T>);
93-
impl<T> OnRuntimeUpgrade for RewriteXcmQueries<T>
94-
where
95-
T: frame_system::Config + pallet_xcm::Config,
96-
{
97-
#[cfg(feature = "try-runtime")]
98-
fn pre_upgrade() -> Result<Vec<u8>, DispatchError> {
99-
log::info!(
100-
target: "runtime::xcm",
101-
"Starting pre-upgrade check for PolkadotXcm::Queries migration"
102-
);
103-
104-
Ok(Vec::new()) // No state needed for this simple check
105-
}
106-
107-
fn on_runtime_upgrade() -> Weight {
108-
let mut cursor = None;
109-
loop {
110-
let result =
111-
clear_storage_prefix(b"PolkadotXcm", b"Queries", &[], Some(100), cursor.as_deref());
112-
if let Some(next_cursor) = result.maybe_cursor {
113-
cursor = Some(next_cursor);
114-
} else {
115-
break;
116-
}
117-
}
118-
119-
// There is only one known entry. But it's v2, which is already removed from stable2412.
120-
// So here manually insert that entry.
121-
let known_query_id: u64 = 0;
122-
let known_new_value: QueryStatus<BlockNumberFor<T>> = QueryStatus::VersionNotifier {
123-
origin: VersionedLocation::V5(Location { parents: 0, interior: Junctions::Here }),
124-
is_active: true,
125-
};
126-
127-
// Build Blake2_128Concat key
128-
let encoded_key = known_query_id.encode();
129-
let key_hashed = Blake2_128Concat::hash(&encoded_key);
130-
131-
put_storage_value(b"PolkadotXcm", b"Queries", &key_hashed, known_new_value);
132-
133-
log::info!(
134-
target: XCM_LOG_TARGET,
135-
"Removed PolkadotXcm::Queries entries: {:?}, and inserted new known QueryId={:?}",
136-
1, known_query_id
137-
);
138-
139-
T::DbWeight::get().reads_writes(1, 1)
140-
}
141-
142-
#[cfg(feature = "try-runtime")]
143-
fn post_upgrade(_state: Vec<u8>) -> Result<(), DispatchError> {
144-
log::info!(
145-
target: "runtime::xcm",
146-
"Post-upgrade: Checking PolkadotXcm::Queries migration"
147-
);
148-
149-
let expected_query_id: u64 = 0;
150-
if let Some(status) = pallet_xcm::Pallet::<T>::query(expected_query_id) {
151-
log::info!(
152-
target: "runtime::xcm",
153-
"Post-upgrade: Query ID: {}, Status: {:?}",
154-
expected_query_id,
155-
status
156-
);
157-
} else {
158-
return Err(DispatchError::Other("Expected QueryId 0 not found in post-upgrade"));
159-
}
160-
161-
Ok(())
162-
}
163-
}

parachain/runtime/paseo/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
248248
impl_name: alloc::borrow::Cow::Borrowed("heima"),
249249
authoring_version: 1,
250250
// same versioning-mechanism as polkadot: use last digit for minor updates
251-
spec_version: 9244,
251+
spec_version: 9245,
252252
impl_version: 0,
253253
apis: RUNTIME_API_VERSIONS,
254254
transaction_version: 2,
@@ -482,7 +482,7 @@ parameter_types! {
482482
impl pallet_migrations::Config for Runtime {
483483
type RuntimeEvent = RuntimeEvent;
484484
#[cfg(not(feature = "runtime-benchmarks"))]
485-
type Migrations = pallet_identity::migration::v2::LazyMigrationV1ToV2<Runtime>;
485+
type Migrations = ();
486486
// Benchmarks need mocked migrations to guarantee that they succeed.
487487
#[cfg(feature = "runtime-benchmarks")]
488488
type Migrations = pallet_migrations::mock_helpers::MockedMigrations;

0 commit comments

Comments
 (0)