Skip to content

Commit ea17097

Browse files
Developed system pallet verifier migration. Added system pallet verifier migration to the runtimeupgrades struct.
1 parent 728f8f5 commit ea17097

File tree

4 files changed

+63
-127
lines changed

4 files changed

+63
-127
lines changed

runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ parameter_types! {
129129
pub TestAccount: AccountId = hex_literal::hex!["d8033c4d04a502901d24a789da32940085c62eba881c4701a73411288445cc46"].into();
130130
}
131131
pub type RuntimeUpgrades = (
132-
migrations::system::v0::Migrate,
133132
migrations::parachain_system::v1::Migrate,
134133
cumulus_pallet_parachain_system::migration::Migration<Runtime>,
135134
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
@@ -146,6 +145,7 @@ pub type RuntimeUpgrades = (
146145
migrations::authorship::v0::Migrate,
147146
pallet_fruniques::migration::v0::MigrateToV1<Runtime>,
148147
migrations::general::GeneralMigration,
148+
migrations::system_verifier::Migrate,
149149
migrations::identity_verifier::Migrate,
150150
migrations::aura_verifier::Migrate,
151151
migrations::balances_verifier::Migrate,

runtime/src/migrations/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pub mod balances_verifier;
44
pub mod identity_verifier;
55
pub mod aura_verifier;
66
pub mod parachain_system;
7-
pub mod system;
7+
pub mod system_verifier;
88
pub mod transaction_payment;
99
pub mod vesting;
1010
pub mod collator_selection_verifier;

runtime/src/migrations/system.rs

Lines changed: 0 additions & 125 deletions
This file was deleted.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
use crate::*;
2+
use frame_support::{pallet_prelude::*, traits::OnRuntimeUpgrade};
3+
use frame_system::{ConsumedWeight, EventRecord};
4+
#[cfg(feature = "try-runtime")]
5+
use sp_runtime::TryRuntimeError;
6+
7+
/// The log target.
8+
const TARGET: &'static str = "runtime::system::migration";
9+
10+
#[frame_support::storage_alias]
11+
pub(super) type Events<T: frame_system::Config> = StorageValue<
12+
frame_system::Pallet<T>,
13+
Vec<
14+
Box<
15+
EventRecord<
16+
<T as frame_system::Config>::RuntimeEvent,
17+
<T as frame_system::Config>::Hash,
18+
>,
19+
>,
20+
>,
21+
ValueQuery,
22+
>;
23+
24+
#[frame_support::storage_alias]
25+
pub(super) type BlockWeight<T: frame_system::Config> =
26+
StorageValue<frame_system::Pallet<T>, ConsumedWeight, ValueQuery>;
27+
28+
#[frame_support::storage_alias]
29+
pub(super) type Digest<T: frame_system::Config> =
30+
StorageValue<frame_system::Pallet<T>, generic::Digest, ValueQuery>;
31+
32+
pub struct Migrate;
33+
34+
impl OnRuntimeUpgrade for Migrate {
35+
fn on_runtime_upgrade() -> Weight {
36+
Weight::zero()
37+
}
38+
39+
#[cfg(feature = "try-runtime")]
40+
fn post_upgrade(_state: Vec<u8>) -> Result<(), TryRuntimeError> {
41+
log::info!(target: TARGET, "In post upgrade");
42+
let num_account_keys = frame_system::Account::<Runtime>::iter_keys().count() as u32;
43+
let num_accounts = frame_system::Account::<Runtime>::iter_values().count() as u32;
44+
log::info!(target: TARGET, "account keys: {}, decodable accounts: {}", num_account_keys, num_accounts);
45+
frame_system::Account::<Runtime>::iter().take(10).for_each(|(k, v)| {
46+
let account_bytes: [u8; 32] = k.clone().into();
47+
log::info!(target: TARGET, " ");
48+
log::info!(target: TARGET, " ");
49+
log::info!(target: TARGET, "key account bytes: {:?} ", account_bytes);
50+
log::info!(target: TARGET, "Nonce: {:?}", v.nonce);
51+
log::info!(target: TARGET, "Consumers: {:?}", v.consumers);
52+
log::info!(target: TARGET, "Providers: {:?}", v.providers);
53+
log::info!(target: TARGET, "Sufficients: {:?}", v.sufficients);
54+
log::info!(target: TARGET, "Data: {:?}", v.data);
55+
});
56+
log::info!(target: TARGET, "block weight: {:?}", BlockWeight::<Runtime>::get());
57+
log::info!(target: TARGET, "digest: {:?}", Digest::<Runtime>::get());
58+
log::info!(target: TARGET, "last runtime upgrade: {:?}", frame_system::LastRuntimeUpgrade::<Runtime>::get());
59+
Ok(())
60+
}
61+
}

0 commit comments

Comments
 (0)