From 1b8e3cab5c1e0ce7e7e9d736b559ddfddce4bffe Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Mon, 14 Oct 2024 18:37:11 +0200 Subject: [PATCH] logs --- .../ethereum-client/src/migration/mod.rs | 47 +++++++------------ .../bridge-hubs/bridge-hub-rococo/src/lib.rs | 9 ++-- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/bridges/snowbridge/pallets/ethereum-client/src/migration/mod.rs b/bridges/snowbridge/pallets/ethereum-client/src/migration/mod.rs index 90cd1a777b1e..a0776bda0184 100644 --- a/bridges/snowbridge/pallets/ethereum-client/src/migration/mod.rs +++ b/bridges/snowbridge/pallets/ethereum-client/src/migration/mod.rs @@ -81,11 +81,11 @@ pub mod v0_to_v1 { pub const PALLET_MIGRATIONS_ID: &[u8; 26] = b"ethereum-execution-headers"; - pub struct EthereumExecutionHeaderCleanup>( + pub struct ExecutionHeadersCleanup>( PhantomData<(T, W, M)>, ); impl> SteppedMigration - for EthereumExecutionHeaderCleanup + for ExecutionHeadersCleanup { type Cursor = u32; type Identifier = MigrationId<26>; // Length of the migration ID PALLET_MIGRATIONS_ID @@ -98,50 +98,39 @@ pub mod v0_to_v1 { mut cursor: Option, meter: &mut WeightMeter, ) -> Result, SteppedMigrationError> { - log::info!(target: LOG_TARGET, "Starting step iteration for Ethereum execution header cleanup."); + log::info!(target: LOG_TARGET, "ExecutionHeadersCleanup: Starting step iteration for Ethereum execution header cleanup."); let required = W::step(); if meter.remaining().any_lt(required) { return Err(SteppedMigrationError::InsufficientWeight { required }); } if let Some(last_key) = cursor { - log::info!(target: LOG_TARGET, "Last key is {}. Max value is {}", last_key, M::get()); + log::info!(target: LOG_TARGET, "ExecutionHeadersCleanup: Last key is {}. Max value is {}", last_key, M::get()); } else { - log::info!(target: LOG_TARGET, "Error getting last key"); + log::info!(target: LOG_TARGET, "ExecutionHeadersCleanup: Error getting last key"); }; // We loop here to do as much progress as possible per step. loop { if meter.try_consume(required).is_err() { - log::info!(target: LOG_TARGET, "Max weight consumed, exiting loop"); + log::info!(target: LOG_TARGET, "ExecutionHeadersCleanup: Max weight consumed, exiting loop"); break; } let index = if let Some(last_key) = cursor { last_key.saturating_add(1) } else { - log::info!(target: LOG_TARGET, "Cursor is 0, starting migration."); + log::info!(target: LOG_TARGET, "ExecutionHeadersCleanup: Cursor is 0, starting migration."); // If no cursor is provided, start iterating from the beginning. 0 }; - if index == 1 { - let execution_hash_extra1 = - crate::migration::v0::ExecutionHeaderMapping::::get(163420); - log::info!(target: LOG_TARGET, "Value at hardcoded index 163420 is {}.", execution_hash_extra1); - let execution_hash_extra2 = - crate::migration::v0::ExecutionHeaderMapping::::get(163425); - log::info!(target: LOG_TARGET, "Value at hardcoded index 163425 is {}.", execution_hash_extra2); - let execution_hash_extra3 = - crate::migration::v0::ExecutionHeaderMapping::::get(146719); - log::info!(target: LOG_TARGET, "Value at hardcoded index 146719 is {}.", execution_hash_extra3); - } let execution_hash = crate::migration::v0::ExecutionHeaderMapping::::get(index); if index >= M::get() || execution_hash == H256::zero() { - log::info!(target: LOG_TARGET, "Ethereum execution header cleanup migration is complete. Index = {}.", index); + log::info!(target: LOG_TARGET, "ExecutionHeadersCleanup: Ethereum execution header cleanup migration is complete. Index = {}.", index); crate::migration::STORAGE_VERSION.put::>(); // We are at the end of the migration, signal complete. - log::info!(target: LOG_TARGET, "SIGNAL COMPLETE"); + log::info!(target: LOG_TARGET, "ExecutionHeadersCleanup: SIGNAL COMPLETE"); cursor = None; break } else { @@ -152,9 +141,9 @@ pub mod v0_to_v1 { } if let Some(last_key) = cursor { - log::info!(target: LOG_TARGET, "Step done, index is {}.", last_key); + log::info!(target: LOG_TARGET, "ExecutionHeadersCleanup: Step done, index is {}.", last_key); } else { - log::info!(target: LOG_TARGET, "Step done, error getting last index"); + log::info!(target: LOG_TARGET, "ExecutionHeadersCleanup: Step done, error getting last index"); }; Ok(cursor) @@ -162,7 +151,7 @@ pub mod v0_to_v1 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { - log::info!(target: LOG_TARGET, "Pre-upgrade execution header at index 0 is {}.", crate::migration::v0::ExecutionHeaderMapping::::get(0)); + log::info!(target: LOG_TARGET, "ExecutionHeadersCleanup: Pre-upgrade execution header at index 0 is {}.", crate::migration::v0::ExecutionHeaderMapping::::get(0)); assert_eq!(crate::Pallet::::on_chain_storage_version(), 0); let random_indexes: alloc::vec::Vec = alloc::vec![0, 700, 340, 4000, 1501]; for i in 0..5 { @@ -179,7 +168,7 @@ pub mod v0_to_v1 { #[cfg(feature = "try-runtime")] fn post_upgrade(_: alloc::vec::Vec) -> Result<(), TryRuntimeError> { - log::info!(target: LOG_TARGET, "Post-upgrade execution header at index 0 is {}.", crate::migration::v0::ExecutionHeaderMapping::::get(0)); + log::info!(target: LOG_TARGET, "ExecutionHeadersCleanup: Post-upgrade execution header at index 0 is {}.", crate::migration::v0::ExecutionHeaderMapping::::get(0)); assert_eq!(crate::Pallet::::on_chain_storage_version(), STORAGE_VERSION); let random_indexes: alloc::vec::Vec = alloc::vec![0, 700, 340, 4000, 1501]; for i in 0..5 { @@ -193,11 +182,11 @@ pub mod v0_to_v1 { } } - pub struct ExecutionHeaderCleanup(PhantomData); + pub struct ExecutionHeaderIndexCleanup(PhantomData); - impl OnRuntimeUpgrade for ExecutionHeaderCleanup { + impl OnRuntimeUpgrade for ExecutionHeaderIndexCleanup { fn on_runtime_upgrade() -> Weight { - log::info!(target: LOG_TARGET, "Cleaning up latest execution header state and index."); + log::info!(target: LOG_TARGET, "ExecutionHeaderIndexCleanup: Cleaning up latest execution header state and index."); crate::migration::v0::LatestExecutionState::::kill(); crate::migration::v0::ExecutionHeaderIndex::::kill(); @@ -207,14 +196,14 @@ pub mod v0_to_v1 { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { let last_index = crate::migration::v0::ExecutionHeaderIndex::::get(); - log::info!(target: LOG_TARGET, "Pre-upgrade execution header index is {}.", last_index); + log::info!(target: LOG_TARGET, "ExecutionHeaderIndexCleanup: Pre-upgrade execution header index is {}.", last_index); Ok(alloc::vec![]) } #[cfg(feature = "try-runtime")] fn post_upgrade(_: alloc::vec::Vec) -> Result<(), TryRuntimeError> { let last_index = crate::migration::v0::ExecutionHeaderIndex::::get(); - log::info!(target: LOG_TARGET, "Post-upgrade execution header index is {}.", last_index); + log::info!(target: LOG_TARGET, "ExecutionHeaderIndexCleanup: Post-upgrade execution header index is {}.", last_index); frame_support::ensure!( last_index == 0, "Snowbridge execution header storage has not successfully been migrated." diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index e622b49f073f..37ccb9a231f6 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -178,7 +178,7 @@ pub type Migrations = ( RocksDbWeight, >, pallet_bridge_relayers::migration::v1::MigrationToV1, - snowbridge_pallet_ethereum_client::migration::v0_to_v1::ExecutionHeaderCleanup, + snowbridge_pallet_ethereum_client::migration::v0_to_v1::ExecutionHeaderIndexCleanup, // permanent pallet_xcm::migration::MigrateToLatestXcmVersion, ); @@ -308,7 +308,7 @@ impl frame_system::Config for Runtime { /// The action to take on a Runtime Upgrade type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; type MaxConsumers = frame_support::traits::ConstU32<16>; - type MultiBlockMigrator = pallet_migrations::Pallet; + type MultiBlockMigrator = MultiBlockMigrations; } impl pallet_timestamp::Config for Runtime { @@ -551,7 +551,7 @@ impl pallet_migrations::Config for Runtime { type RuntimeEvent = RuntimeEvent; #[cfg(not(feature = "runtime-benchmarks"))] type Migrations = - snowbridge_pallet_ethereum_client::migration::v0_to_v1::EthereumExecutionHeaderCleanup< + snowbridge_pallet_ethereum_client::migration::v0_to_v1::ExecutionHeadersCleanup< Runtime, crate::weights::snowbridge_pallet_ethereum_client::WeightInfo, ExecutionHeaderCount, @@ -575,7 +575,6 @@ construct_runtime!( ParachainSystem: cumulus_pallet_parachain_system = 1, Timestamp: pallet_timestamp = 2, ParachainInfo: parachain_info = 3, - MultiBlockMigrations: pallet_migrations = 4, // Monetary stuff. Balances: pallet_balances = 10, @@ -632,6 +631,8 @@ construct_runtime!( EthereumBeaconClient: snowbridge_pallet_ethereum_client = 82, EthereumSystem: snowbridge_pallet_system = 83, + MultiBlockMigrations: pallet_migrations = 98, + // Message Queue. Importantly, is registered last so that messages are processed after // the `on_initialize` hooks of bridging pallets. MessageQueue: pallet_message_queue = 175,