diff --git a/pallets/crowdloans/src/migrations.rs b/pallets/crowdloans/src/migrations.rs index 22dca14d0..053db7077 100644 --- a/pallets/crowdloans/src/migrations.rs +++ b/pallets/crowdloans/src/migrations.rs @@ -382,3 +382,86 @@ pub mod v3 { Ok(()) } } + +pub mod v4 { + use super::*; + use frame_support::{log, traits::Get}; + use primitives::ParaId; + use sp_std::{vec, vec::Vec}; + use types::*; + + pub fn pre_migrate() -> Result, &'static str> { + frame_support::ensure!( + StorageVersion::::get() == Releases::V3_0_0, + "must be V3_0_0" + ); + frame_support::ensure!(NextTrieIndex::::get() == 31, "must be 31"); + Ok(Vec::new()) + } + + pub fn migrate() -> frame_support::weights::Weight { + if StorageVersion::::get() == Releases::V3_0_0 { + log::info!( + target: "crowdloans::migrate", + "migrating crowdloan storage" + ); + // paraId, ctoken, contributed, cap, end_block, trie_index, lease_start, lease_end + let batch: Vec<(u32, u32, u128, u128, u32, u32, u32, u32)> = vec![ + // 2040,8-15,3000000000000000,150000000000000000,10881401 + ( + 2040, + 200080015, + 3000000000000000, + 150_000_000_000_000_000, + 10881401, + 25, + 8, + 15, + ), + ]; + let length = batch.len() as u64; + for (para_id, _, raised, _, _, _, lease_start, lease_end) in batch.into_iter() { + match Vaults::::get((&ParaId::from(para_id), &lease_start, &lease_end)) { + Some(vault) if vault.phase == VaultPhase::Expired => { + Vaults::::insert( + (&ParaId::from(para_id), &lease_start, &lease_end), + Vault { + contributed: raised, + ..vault + }, + ); + } + Some(_) => { + log::error!("Vault for para_id {} is not in Expired phase", para_id); + } + None => { + log::error!( + "No vault found for para_id {} ({}, {})", + para_id, + lease_start, + lease_end + ); + } + } + } + log::info!( + target: "crowdloans::migrate", + "completed crowdloans storage migration" + ); + ::DbWeight::get().writes(length * 3 + 1u64) + } else { + T::DbWeight::get().reads(1) + } + } + + pub fn post_migrate() -> Result<(), &'static str> { + frame_support::ensure!( + StorageVersion::::get() == Releases::V3_0_0, + "must be V3_0_0" + ); + frame_support::ensure!(NextTrieIndex::::get() == 31, "must be 31"); + log::info!("👜 crowdloan migration passes POST migrate checks ✅",); + + Ok(()) + } +} diff --git a/runtime/heiko/src/lib.rs b/runtime/heiko/src/lib.rs index 645bc636d..6f7ca8592 100644 --- a/runtime/heiko/src/lib.rs +++ b/runtime/heiko/src/lib.rs @@ -180,7 +180,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("heiko"), impl_name: create_runtime_str!("heiko"), authoring_version: 1, - spec_version: 206, + spec_version: 207, impl_version: 33, apis: RUNTIME_API_VERSIONS, transaction_version: 17, diff --git a/runtime/kerria/src/lib.rs b/runtime/kerria/src/lib.rs index 0df60c323..528f1ced6 100644 --- a/runtime/kerria/src/lib.rs +++ b/runtime/kerria/src/lib.rs @@ -180,7 +180,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("kerria"), impl_name: create_runtime_str!("kerria"), authoring_version: 1, - spec_version: 206, + spec_version: 207, impl_version: 33, apis: RUNTIME_API_VERSIONS, transaction_version: 17, diff --git a/runtime/parallel/src/lib.rs b/runtime/parallel/src/lib.rs index 9f7333f49..42a82d956 100644 --- a/runtime/parallel/src/lib.rs +++ b/runtime/parallel/src/lib.rs @@ -185,7 +185,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("parallel"), impl_name: create_runtime_str!("parallel"), authoring_version: 1, - spec_version: 206, + spec_version: 207, impl_version: 33, apis: RUNTIME_API_VERSIONS, transaction_version: 17, @@ -2073,7 +2073,7 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - CrowdloansMigrationV3, + CrowdloansMigrationV4, >; impl fp_self_contained::SelfContainedCall for RuntimeCall { @@ -2134,20 +2134,20 @@ impl fp_self_contained::SelfContainedCall for RuntimeCall { } } -pub struct CrowdloansMigrationV3; -impl OnRuntimeUpgrade for CrowdloansMigrationV3 { +pub struct CrowdloansMigrationV4; +impl OnRuntimeUpgrade for CrowdloansMigrationV4 { fn on_runtime_upgrade() -> frame_support::weights::Weight { - pallet_crowdloans::migrations::v3::migrate::() + pallet_crowdloans::migrations::v4::migrate::() } #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, &'static str> { - pallet_crowdloans::migrations::v3::pre_migrate::() + pallet_crowdloans::migrations::v4::pre_migrate::() } #[cfg(feature = "try-runtime")] fn post_upgrade(_: Vec) -> Result<(), &'static str> { - pallet_crowdloans::migrations::v3::post_migrate::() + pallet_crowdloans::migrations::v4::post_migrate::() } } diff --git a/runtime/vanilla/src/lib.rs b/runtime/vanilla/src/lib.rs index da78c4c01..fd4836115 100644 --- a/runtime/vanilla/src/lib.rs +++ b/runtime/vanilla/src/lib.rs @@ -180,7 +180,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("vanilla"), impl_name: create_runtime_str!("vanilla"), authoring_version: 1, - spec_version: 206, + spec_version: 207, impl_version: 33, apis: RUNTIME_API_VERSIONS, transaction_version: 17, diff --git a/scripts/collator.sh b/scripts/collator.sh index 2c07503c1..5390e2b2d 100755 --- a/scripts/collator.sh +++ b/scripts/collator.sh @@ -20,7 +20,7 @@ VOLUME="chains" NODE_KEY="$1" KEYSTORE_PATH="$2" NODE_NAME="$3" -DOCKER_IMAGE="parallelfinance/parallel:v2.0.6" +DOCKER_IMAGE="parallelfinance/parallel:v2.0.7" BASE_PATH="/data" if [ $# -lt 3 ]; then