From dc0ddab39e407a1e604fd7b2d2ba62a3d1600b9e Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Fri, 17 Nov 2023 17:40:59 +0800 Subject: [PATCH] Release `v6.5.0` (#1321) * Plan B * Add migrations * Avoid potential panic * Bump versions * Bump version * Fix compile * Fix migration * Satisfy idempotency test --- Cargo.lock | 44 +++++++++++++++---------------- Cargo.toml | 2 +- pallet/message-gadget/Cargo.toml | 2 +- pallet/staking/src/lib.rs | 35 +++++++++++++++--------- pallet/staking/src/migration.rs | 8 +++--- runtime/crab/src/lib.rs | 4 +-- runtime/darwinia/src/lib.rs | 4 +-- runtime/darwinia/src/migration.rs | 8 +++--- runtime/pangolin/src/lib.rs | 4 +-- runtime/pangoro/src/lib.rs | 4 +-- 10 files changed, 62 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index be56bf786..38adaf129 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1801,7 +1801,7 @@ dependencies = [ [[package]] name = "crab-runtime" -version = "6.4.0" +version = "6.5.0" dependencies = [ "array-bytes", "bp-darwinia-core", @@ -2842,7 +2842,7 @@ dependencies = [ [[package]] name = "darwinia" -version = "6.4.0" +version = "6.5.0" dependencies = [ "array-bytes", "async-trait", @@ -2921,7 +2921,7 @@ dependencies = [ [[package]] name = "darwinia-account-migration" -version = "6.4.0" +version = "6.5.0" dependencies = [ "array-bytes", "darwinia-deposit", @@ -2946,7 +2946,7 @@ dependencies = [ [[package]] name = "darwinia-asset-limit" -version = "6.4.0" +version = "6.5.0" dependencies = [ "frame-support", "frame-system", @@ -2957,7 +2957,7 @@ dependencies = [ [[package]] name = "darwinia-common-runtime" -version = "6.4.0" +version = "6.5.0" dependencies = [ "bp-darwinia-core", "darwinia-precompile-assets", @@ -2985,7 +2985,7 @@ dependencies = [ [[package]] name = "darwinia-deposit" -version = "6.4.0" +version = "6.5.0" dependencies = [ "darwinia-staking-traits", "dc-inflation", @@ -3006,7 +3006,7 @@ dependencies = [ [[package]] name = "darwinia-ecdsa-authority" -version = "6.4.0" +version = "6.5.0" dependencies = [ "array-bytes", "dc-primitives", @@ -3026,7 +3026,7 @@ dependencies = [ [[package]] name = "darwinia-message-gadget" -version = "6.4.0" +version = "6.5.0" dependencies = [ "array-bytes", "frame-support", @@ -3045,7 +3045,7 @@ dependencies = [ [[package]] name = "darwinia-message-transact" -version = "6.4.0" +version = "6.5.0" dependencies = [ "array-bytes", "bp-message-dispatch", @@ -3074,7 +3074,7 @@ dependencies = [ [[package]] name = "darwinia-precompile-assets" -version = "6.4.0" +version = "6.5.0" dependencies = [ "fp-evm", "frame-support", @@ -3095,7 +3095,7 @@ dependencies = [ [[package]] name = "darwinia-precompile-bls12-381" -version = "6.4.0" +version = "6.5.0" dependencies = [ "ark-bls12-381", "ark-ec", @@ -3113,7 +3113,7 @@ dependencies = [ [[package]] name = "darwinia-precompile-deposit" -version = "6.4.0" +version = "6.5.0" dependencies = [ "darwinia-deposit", "fp-evm", @@ -3133,7 +3133,7 @@ dependencies = [ [[package]] name = "darwinia-precompile-staking" -version = "6.4.0" +version = "6.5.0" dependencies = [ "darwinia-deposit", "darwinia-staking", @@ -3154,7 +3154,7 @@ dependencies = [ [[package]] name = "darwinia-precompile-state-storage" -version = "6.4.0" +version = "6.5.0" dependencies = [ "fp-evm", "frame-support", @@ -3173,7 +3173,7 @@ dependencies = [ [[package]] name = "darwinia-runtime" -version = "6.4.0" +version = "6.5.0" dependencies = [ "array-bytes", "bp-darwinia-core", @@ -3285,7 +3285,7 @@ dependencies = [ [[package]] name = "darwinia-staking" -version = "6.4.0" +version = "6.5.0" dependencies = [ "darwinia-deposit", "darwinia-staking-traits", @@ -3313,7 +3313,7 @@ dependencies = [ [[package]] name = "darwinia-staking-traits" -version = "6.4.0" +version = "6.5.0" dependencies = [ "parity-scale-codec", "scale-info", @@ -3348,7 +3348,7 @@ dependencies = [ [[package]] name = "dc-inflation" -version = "6.4.0" +version = "6.5.0" dependencies = [ "dc-types", "primitive-types", @@ -3358,7 +3358,7 @@ dependencies = [ [[package]] name = "dc-primitives" -version = "6.4.0" +version = "6.5.0" dependencies = [ "dc-types", "fp-account", @@ -3368,7 +3368,7 @@ dependencies = [ [[package]] name = "dc-types" -version = "6.4.0" +version = "6.5.0" [[package]] name = "der" @@ -9250,7 +9250,7 @@ dependencies = [ [[package]] name = "pangolin-runtime" -version = "6.4.0" +version = "6.5.0" dependencies = [ "array-bytes", "bp-darwinia-core", @@ -9364,7 +9364,7 @@ dependencies = [ [[package]] name = "pangoro-runtime" -version = "6.4.0" +version = "6.5.0" dependencies = [ "array-bytes", "bp-darwinia-core", diff --git a/Cargo.toml b/Cargo.toml index eb8d61579..95a8a2e35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ edition = "2021" homepage = "https://darwinia.network" license = "GPL-3.0" repository = "https://github.com/darwinia-network/darwinia" -version = "6.4.0" +version = "6.5.0" [workspace.dependencies] # crates.io diff --git a/pallet/message-gadget/Cargo.toml b/pallet/message-gadget/Cargo.toml index 6f9ddb500..809078456 100644 --- a/pallet/message-gadget/Cargo.toml +++ b/pallet/message-gadget/Cargo.toml @@ -57,5 +57,5 @@ try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", "pallet-evm/try-runtime", - "sp-runtime/try-runtime", + "sp-runtime?/try-runtime", ] diff --git a/pallet/staking/src/lib.rs b/pallet/staking/src/lib.rs index 037bd2f03..906c7293e 100644 --- a/pallet/staking/src/lib.rs +++ b/pallet/staking/src/lib.rs @@ -95,6 +95,9 @@ pub mod pallet { // Deposit helper for runtime benchmark. #[cfg(feature = "runtime-benchmarks")] use darwinia_deposit::Config as DepositConfig; + + const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + /// Empty trait acts as a place holder to satisfy the `#[pallet::config]` macro. #[cfg(not(feature = "runtime-benchmarks"))] pub trait DepositConfig {} @@ -344,7 +347,8 @@ pub mod pallet { } #[pallet::pallet] - pub struct Pallet(PhantomData); + #[pallet::storage_version(STORAGE_VERSION)] + pub struct Pallet(_); #[pallet::hooks] impl Hooks> for Pallet { fn on_initialize(_: BlockNumberFor) -> Weight { @@ -957,23 +961,30 @@ pub mod pallet { return None; } + let bn = >::block_number(); + log::info!( - "[pallet::staking] assembling new collators for new session {index} at #{:?}", - >::block_number(), + "[pallet::staking] assembling new collators for new session {index} at #{bn:?}", ); if let Ok(collators) = Self::elect() { - // TODO?: if we really need this event - Self::deposit_event(Event::Elected { collators: collators.clone() }); + if !collators.is_empty() { + // TODO?: if we really need this event + Self::deposit_event(Event::Elected { collators: collators.clone() }); - Some(collators) - } else { - // Impossible case. - // - // But if there is an issue, retain the old collators; do not alter the session - // collators if any error occurs to prevent the chain from stalling. - None + return Some(collators); + } } + + log::error!( + "[pallet::staking] fail to elect collators for new session {index} at #{bn:?}" + ); + + // Impossible case. + // + // But if there is an issue, retain the old collators; do not alter the session + // collators if any error occurs to prevent the chain from stalling. + None } /// Shift the exposure cache states. diff --git a/pallet/staking/src/migration.rs b/pallet/staking/src/migration.rs index 8c496d8f8..ba097a6b3 100644 --- a/pallet/staking/src/migration.rs +++ b/pallet/staking/src/migration.rs @@ -42,8 +42,6 @@ pub mod v1 { { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { - assert_eq!(StorageVersion::get::>(), 0, "Can only upgrade from version 0."); - Ok(Vec::new()) } @@ -52,7 +50,7 @@ pub mod v1 { if version != 0 { log::warn!( - "[pallet::staking] skipping v0 to v1 migration: executed on wrong storage version. Expected version 1, found {version:?}", + "[pallet::staking] skipping v0 to v1 migration: executed on wrong storage version. Expected version 0, found {version:?}", ); return T::DbWeight::get().reads(1); @@ -125,10 +123,10 @@ pub mod v1 { // Check that everything decoded fine. >::iter_keys().for_each(|k| { - assert!(>::try_get(k).is_ok(), "Can not decode V1 `Exposure`."); + assert!(>::try_get(k).is_ok(), "Can not decode V1 `Exposure`."); }); >::iter_keys().for_each(|k| { - assert!(>::try_get(k).is_ok(), "Can not decode V1 `Exposure`."); + assert!(>::try_get(k).is_ok(), "Can not decode V1 `Exposure`."); }); Ok(()) diff --git a/runtime/crab/src/lib.rs b/runtime/crab/src/lib.rs index f986c2aed..a625bc087 100644 --- a/runtime/crab/src/lib.rs +++ b/runtime/crab/src/lib.rs @@ -69,7 +69,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - migration::CustomOnRuntimeUpgrade, + (migration::CustomOnRuntimeUpgrade, darwinia_staking::migration::v1::MigrateToV1), >; /// Darwinia proposal base fee. @@ -82,7 +82,7 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { spec_name: sp_runtime::create_runtime_str!("Crab2"), impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"), authoring_version: 0, - spec_version: 6_4_0_2, + spec_version: 6_5_0_0, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 0, diff --git a/runtime/darwinia/src/lib.rs b/runtime/darwinia/src/lib.rs index f729eebff..0f79bd4bf 100644 --- a/runtime/darwinia/src/lib.rs +++ b/runtime/darwinia/src/lib.rs @@ -69,7 +69,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - migration::CustomOnRuntimeUpgrade, + (migration::CustomOnRuntimeUpgrade, darwinia_staking::migration::v1::MigrateToV1), >; /// Darwinia proposal base fee. @@ -82,7 +82,7 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { spec_name: sp_runtime::create_runtime_str!("Darwinia2"), impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"), authoring_version: 0, - spec_version: 6_4_0_2, + spec_version: 6_5_0_0, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 0, diff --git a/runtime/darwinia/src/migration.rs b/runtime/darwinia/src/migration.rs index c1d3ef74e..a58486668 100644 --- a/runtime/darwinia/src/migration.rs +++ b/runtime/darwinia/src/migration.rs @@ -48,10 +48,10 @@ fn migrate() -> frame_support::weights::Weight { const REVERT_BYTECODE: [u8; 5] = [0x60, 0x00, 0x60, 0x00, 0xFD]; const USDT_ADDRESS: &str = "0x0000000000000000000000000000000000000403"; - EVM::create_account( - H160::from_str(USDT_ADDRESS).expect("USDT_ADDRESS is not a valid address"), - REVERT_BYTECODE.to_vec(), - ); + if let Ok(a) = H160::from_str(USDT_ADDRESS) { + EVM::create_account(a, REVERT_BYTECODE.to_vec()); + } + ::DbWeight::get().reads_writes(5, 5) // frame_support::weights::Weight::zero() diff --git a/runtime/pangolin/src/lib.rs b/runtime/pangolin/src/lib.rs index eae088845..7ebf73a45 100644 --- a/runtime/pangolin/src/lib.rs +++ b/runtime/pangolin/src/lib.rs @@ -70,7 +70,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - migration::CustomOnRuntimeUpgrade, + (migration::CustomOnRuntimeUpgrade, darwinia_staking::migration::v1::MigrateToV1), >; /// Darwinia proposal base fee. @@ -83,7 +83,7 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { spec_name: sp_runtime::create_runtime_str!("Pangolin2"), impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"), authoring_version: 0, - spec_version: 6_4_0_7, + spec_version: 6_5_0_0, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 0, diff --git a/runtime/pangoro/src/lib.rs b/runtime/pangoro/src/lib.rs index 08fc2700f..3312d40ba 100644 --- a/runtime/pangoro/src/lib.rs +++ b/runtime/pangoro/src/lib.rs @@ -69,7 +69,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - migration::CustomOnRuntimeUpgrade, + (migration::CustomOnRuntimeUpgrade, darwinia_staking::migration::v1::MigrateToV1), >; /// Darwinia proposal base fee. @@ -82,7 +82,7 @@ pub const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion { spec_name: sp_runtime::create_runtime_str!("Pangoro2"), impl_name: sp_runtime::create_runtime_str!("DarwiniaOfficialRust"), authoring_version: 0, - spec_version: 6_4_0_7, + spec_version: 6_5_0_0, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 0,