|
| 1 | +use crate::*; |
| 2 | +use frame_support::{ |
| 3 | + pallet_prelude::*, |
| 4 | + traits::{Currency, OnRuntimeUpgrade}, |
| 5 | +}; |
| 6 | +use frame_system::pallet_prelude::BlockNumberFor; |
| 7 | +use cumulus_pallet_xcmp_queue::{QueueConfigData, OverweightIndex}; |
| 8 | +use cumulus_primitives_core::relay_chain::BlockNumber as RelayBlockNumber; |
| 9 | +use crate::ParaId; |
| 10 | +use super::*; |
| 11 | + |
| 12 | +#[cfg(feature = "try-runtime")] |
| 13 | +use sp_runtime::TryRuntimeError; |
| 14 | + |
| 15 | +/// The log target. |
| 16 | +const TARGET: &'static str = "runtime::xcmp_queue_verifier::migration"; |
| 17 | + |
| 18 | + |
| 19 | +#[frame_support::storage_alias] |
| 20 | +pub(super) type Overweight<T: cumulus_pallet_xcmp_queue::Config> = |
| 21 | + CountedStorageMap<cumulus_pallet_xcmp_queue::Pallet<T>, Twox64Concat, OverweightIndex, (ParaId, RelayBlockNumber, Vec<u8>)>; |
| 22 | + |
| 23 | +#[frame_support::storage_alias] |
| 24 | +pub(super) type QueueConfig<T: cumulus_pallet_xcmp_queue::Config> = StorageValue<cumulus_pallet_xcmp_queue::Pallet<T>, QueueConfigData, ValueQuery>; |
| 25 | + |
| 26 | +pub struct Migrate; |
| 27 | + |
| 28 | +impl OnRuntimeUpgrade for Migrate { |
| 29 | + |
| 30 | + fn on_runtime_upgrade() -> Weight { |
| 31 | + return Weight::zero() |
| 32 | + } |
| 33 | + |
| 34 | + #[cfg(feature = "try-runtime")] |
| 35 | + fn post_upgrade(state: Vec<u8>) -> Result<(), TryRuntimeError> { |
| 36 | + log::info!(target: TARGET, "In post upgrade"); |
| 37 | + let overweight_tracked_count = Overweight::<Runtime>::count(); |
| 38 | + let overweight_count = Overweight::<Runtime>::iter_keys().count() as u32; |
| 39 | + let decodable_overweight_count = Overweight::<Runtime>::iter_values().count() as u32; |
| 40 | + log::info!(target: TARGET, "Num overweight: {}, decodable: {}, tracked: {}", overweight_count, decodable_overweight_count, overweight_tracked_count); |
| 41 | + Overweight::<Runtime>::iter().for_each(|(k, v)| { |
| 42 | + log::info!(" "); |
| 43 | + log::info!(" "); |
| 44 | + log::info!("overweight index: {} ", k); |
| 45 | + log::info!("overweight: {:?}", v); |
| 46 | + }); |
| 47 | + |
| 48 | + log::info!("config data: {:?} ", QueueConfig::<Runtime>::get()); |
| 49 | + Ok(()) |
| 50 | + } |
| 51 | +} |
0 commit comments