Skip to content

Commit 9497c32

Browse files
authored
⬆️ 0.7.5 Release Polimec/Politest (#315)
## What? - New runtime for Politest and Polimec ## Why? - WAP calculation changed - Evaluator rewards fixed ## How? - Bump version and write migration for ProjectDetails ## Testing? Try-runtime output for polimec: ```sh polimec-node on  06-03-new-release [!] via 🦀 v1.76.0-nightly ❯ try-runtime --runtime ./target/release/wbuild/polimec-runtime/polimec_runtime.compact.compressed.wasm on-runtime-upgrade live --uri wss://rpc.polimec.org:443 [2024-06-03T15:07:18Z INFO remote-ext] replacing wss:// in uri with https://: "https://rpc.polimec.org:443" (ws is currently unstable for fetching remote storage, for more see paritytech/jsonrpsee#1086) [2024-06-03T15:07:18Z INFO remote-ext] since no at is provided, setting it to latest finalized head, 0xd014d5b26ca93fab61eb751f501e7c3dd8261294312177d192863dbe09b457a6 [2024-06-03T15:07:18Z INFO remote-ext] since no prefix is filtered, the data for all pallets will be downloaded [2024-06-03T15:07:18Z INFO remote-ext] scraping key-pairs from remote at block height 0xd014d5b26ca93fab61eb751f501e7c3dd8261294312177d192863dbe09b457a6 ✅ Found 7323 keys (0.40s) [00:00:01] ✅ Downloaded key values 5,262.6345/s [=======================================================================================================] 7323/7323 (0s) ✅ Inserted keys into DB (0.03s) [2024-06-03T15:07:20Z INFO remote-ext] adding data for hashed prefix: , took 1.90s [2024-06-03T15:07:20Z INFO remote-ext] adding data for hashed key: 3a636f6465 [2024-06-03T15:07:20Z INFO remote-ext] adding data for hashed key: 26aa394eea5630e07c48ae0c9558cef7f9cce9c888469bb1a0dceaa129672ef8 [2024-06-03T15:07:20Z INFO remote-ext] adding data for hashed key: 26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac [2024-06-03T15:07:20Z INFO remote-ext] 👩‍👦 no child roots found to scrape [2024-06-03T15:07:20Z INFO remote-ext] initialized state externalities with storage root 0xef346e03d62a4c25945962c2172acdd1cb25ddf239c984e5a9144f5ae057b13b and state_version V1 [2024-06-03T15:07:20Z INFO try-runtime::cli] Original runtime [Name: RuntimeString::Owned("polimec-mainnet")] [Version: 7001] [Code hash: 0xb7f5...fa01] [2024-06-03T15:07:20Z INFO try-runtime::cli] New runtime [Name: RuntimeString::Owned("polimec-mainnet")] [Version: 8000] [Code hash: 0x9b0e...e800] [2024-06-03T15:07:20Z INFO try-runtime::cli] 🚀 Speed up your workflow by using snapshots instead of live state. See `try-runtime create-snapshot --help`. [2024-06-03T15:07:20Z INFO try_runtime_core::misc] ------------------------------------------------------------------ [2024-06-03T15:07:20Z INFO try_runtime_core::misc] 🔬 Running TryRuntime_on_runtime_upgrade with checks: PreAndPost [2024-06-03T15:07:20Z INFO try_runtime_core::misc] ------------------------------------------------------------------ [2024-06-03T15:07:21Z INFO frame_support::migrations] 🚚 Pallet "Funding" VersionedMigration migrating storage version from 2 to 3. [2024-06-03T15:07:21Z INFO runtime::executive] ✅ Entire runtime state decodes without error. 430868 bytes total. [2024-06-03T15:07:21Z INFO try_runtime_core::misc] ------------------------------------------------------------------------------------------------------ [2024-06-03T15:07:21Z INFO try_runtime_core::misc] 🔬 TryRuntime_on_runtime_upgrade succeeded! Running it again without checks for weight measurements. [2024-06-03T15:07:21Z INFO try_runtime_core::misc] ------------------------------------------------------------------------------------------------------ [2024-06-03T15:07:21Z INFO frame_support::migrations] 🚚 Pallet "Funding" VersionedMigration migrating storage version from 2 to 3. [2024-06-03T15:07:21Z INFO try_runtime_core::misc] --------------------------------------------------------------------------------- [2024-06-03T15:07:21Z INFO try_runtime_core::misc] 🔬 Running TryRuntime_on_runtime_upgrade again to check idempotency: PreAndPost [2024-06-03T15:07:21Z INFO try_runtime_core::misc] --------------------------------------------------------------------------------- [2024-06-03T15:07:21Z WARN frame_support::migrations] 🚚 Pallet "Funding" VersionedMigration migration 2->3 can be removed; on-chain is already at StorageVersion(3). [2024-06-03T15:07:21Z INFO runtime::executive] ✅ Entire runtime state decodes without error. 430868 bytes total. [2024-06-03T15:07:21Z INFO try-runtime::cli] PoV size (zstd-compressed compact proof): 7.1 KB. For parachains, it's your responsibility to verify that a PoV of this size fits within any relaychain constraints. [2024-06-03T15:07:21Z INFO try-runtime::cli] Consumed ref_time: 0.001175s (0.23% of max 0.5s) [2024-06-03T15:07:21Z INFO try-runtime::cli] ✅ No weight safety issues detected. Please note this does not guarantee a successful runtime upgrade. Always test your runtime upgrade with recent state, and ensure that the weight usage of your migrations will not drastically differ between testing and actual on-chain execution. ``` Politest output: ```sh polimec-node on  06-03-new-release [!] via 🦀 v1.76.0-nightly ❯ try-runtime --runtime ./target/release/wbuild/politest-runtime/politest_runtime.compact.compressed.wasm on-runtime-upgrade live --uri wss://beta.rolimec.org:443 [2024-06-03T15:08:58Z INFO remote-ext] replacing wss:// in uri with https://: "https://beta.rolimec.org:443" (ws is currently unstable for fetching remote storage, for more see paritytech/jsonrpsee#1086) [2024-06-03T15:08:58Z INFO remote-ext] since no at is provided, setting it to latest finalized head, 0x8bcc13d328c028a0a6c5d40b07b27c14b13fc64c8325397ad0b20e49594c2f23 [2024-06-03T15:08:58Z INFO remote-ext] since no prefix is filtered, the data for all pallets will be downloaded [2024-06-03T15:08:58Z INFO remote-ext] scraping key-pairs from remote at block height 0x8bcc13d328c028a0a6c5d40b07b27c14b13fc64c8325397ad0b20e49594c2f23 ✅ Found 4901 keys (0.24s) [00:00:01] ✅ Downloaded key values 4,507.4666/s [=======================================================================================================] 4901/4901 (0s) ✅ Inserted keys into DB (0.02s) [2024-06-03T15:08:59Z INFO remote-ext] adding data for hashed prefix: , took 1.43s [2024-06-03T15:08:59Z INFO remote-ext] adding data for hashed key: 3a636f6465 [2024-06-03T15:08:59Z INFO remote-ext] adding data for hashed key: 26aa394eea5630e07c48ae0c9558cef7f9cce9c888469bb1a0dceaa129672ef8 [2024-06-03T15:08:59Z INFO remote-ext] adding data for hashed key: 26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac [2024-06-03T15:09:00Z INFO remote-ext] 👩‍👦 no child roots found to scrape [2024-06-03T15:09:00Z INFO remote-ext] initialized state externalities with storage root 0x72b4d17b9898800f58b7e65186a4d3a04517f8a86554fdc9cf097e5d8090b935 and state_version V1 [2024-06-03T15:09:00Z INFO try-runtime::cli] Original runtime [Name: RuntimeString::Owned("politest")] [Version: 7005] [Code hash: 0xd45f...b7e5] [2024-06-03T15:09:00Z INFO try-runtime::cli] New runtime [Name: RuntimeString::Owned("politest")] [Version: 8000] [Code hash: 0x9897...cbae] [2024-06-03T15:09:00Z INFO try-runtime::cli] 🚀 Speed up your workflow by using snapshots instead of live state. See `try-runtime create-snapshot --help`. [2024-06-03T15:09:00Z INFO try_runtime_core::misc] ------------------------------------------------------------------ [2024-06-03T15:09:00Z INFO try_runtime_core::misc] 🔬 Running TryRuntime_on_runtime_upgrade with checks: PreAndPost [2024-06-03T15:09:00Z INFO try_runtime_core::misc] ------------------------------------------------------------------ [2024-06-03T15:09:00Z INFO frame_support::migrations] 🚚 Pallet "Funding" VersionedMigration migrating storage version from 2 to 3. [2024-06-03T15:09:00Z INFO runtime::executive] ✅ Entire runtime state decodes without error. 212814 bytes total. [2024-06-03T15:09:00Z INFO try_runtime_core::misc] ------------------------------------------------------------------------------------------------------ [2024-06-03T15:09:00Z INFO try_runtime_core::misc] 🔬 TryRuntime_on_runtime_upgrade succeeded! Running it again without checks for weight measurements. [2024-06-03T15:09:00Z INFO try_runtime_core::misc] ------------------------------------------------------------------------------------------------------ [2024-06-03T15:09:00Z INFO frame_support::migrations] 🚚 Pallet "Funding" VersionedMigration migrating storage version from 2 to 3. [2024-06-03T15:09:00Z INFO try_runtime_core::misc] --------------------------------------------------------------------------------- [2024-06-03T15:09:00Z INFO try_runtime_core::misc] 🔬 Running TryRuntime_on_runtime_upgrade again to check idempotency: PreAndPost [2024-06-03T15:09:00Z INFO try_runtime_core::misc] --------------------------------------------------------------------------------- [2024-06-03T15:09:00Z WARN frame_support::migrations] 🚚 Pallet "Funding" VersionedMigration migration 2->3 can be removed; on-chain is already at StorageVersion(3). [2024-06-03T15:09:00Z INFO runtime::executive] ✅ Entire runtime state decodes without error. 212814 bytes total. [2024-06-03T15:09:00Z INFO try-runtime::cli] PoV size (zstd-compressed compact proof): 9.6 KB. For parachains, it's your responsibility to verify that a PoV of this size fits within any relaychain constraints. [2024-06-03T15:09:00Z INFO try-runtime::cli] Consumed ref_time: 0.007325s (1.47% of max 0.5s) [2024-06-03T15:09:00Z INFO try-runtime::cli] ✅ No weight safety issues detected. Please note this does not guarantee a successful runtime upgrade. Always test your runtime upgrade with recent state, and ensure that the weight usage of your migrations will not drastically differ between testing and actual on-chain execution. ``` ## Anything else? Srtool output: ```sh ✨ Your Substrate WASM Runtime is ready! ✨ ✨ WASM : runtimes/polimec/target/srtool/production/wbuild/polimec-runtime/polimec_runtime.compact.wasm ✨ Z_WASM: runtimes/polimec/target/srtool/production/wbuild/polimec-runtime/polimec_runtime.compact.compressed.wasm Summary generated with srtool v0.15.0 using the docker image paritytech/srtool:1.77.0: Package : polimec-runtime v0.7.0 GIT commit : 70a2e82 GIT tag : v0.7.1 GIT branch : 06-03-new-release Rustc : rustc 1.77.0 (aedd173a2 2024-03-17) Time : 2024-06-03T16:00:02Z == Compact Version : polimec-mainnet-8000 (polimec-mainnet-0.tx2.au1) Metadata : V14 Size : 5.06 MB (5310465 bytes) setCode : 0x06af567b18b0cf38fe65ab3d343a7d273ae62c845ee92f07d59507563e193642 authorizeUpgrade : 0xc0e16c491677d5288a41fdc23899b9d31d1baf6ba6a10776270d1aff36361a3a IPFS : QmQaspjJBhC3NXZcqUwivwbdnnV1vuafbK216uat6vcBme BLAKE2_256 : 0x4ce5d816233409c0b4fa87ac0a52a2e4dea8159d09f757b2e1cfc1e01defaba5 Wasm : runtimes/polimec/target/srtool/production/wbuild/polimec-runtime/polimec_runtime.compact.wasm == Compressed Version : polimec-mainnet-8000 (polimec-mainnet-0.tx2.au1) Metadata : V14 Size : 1.26 MB (1320120 bytes) Compression : 75.15% setCode : 0x9ddad8e071d1f5fdbb422e2519c2748b3ab71b6c700a79f04d53ed5543488e33 authorizeUpgrade : 0xf50fa40ec27e04f9059669d1e48b057e43474ddcede4e289aba63529cbb519f4 IPFS : QmQ8GTsFbstKtaPnoHntvmEk2o5Lg6tV4vVbsNDS6dCw2m BLAKE2_256 : 0x6014bb2c081c70360f5d3ef5c18f6930a6ec1ed0670f8f761fc17551194b9bb4 Wasm : runtimes/polimec/target/srtool/production/wbuild/polimec-runtime/polimec_runtime.compact.compressed.wasm ``
1 parent 079940c commit 9497c32

File tree

3 files changed

+105
-6
lines changed

3 files changed

+105
-6
lines changed

pallets/funding/src/storage_migrations.rs

+97-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use frame_support::traits::StorageVersion;
33

44
/// The current storage version
5-
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);
5+
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(3);
66
pub const LOG: &str = "runtime::funding::migration";
77

88
pub mod v2 {
@@ -152,3 +152,99 @@ pub mod v2 {
152152
<T as frame_system::Config>::DbWeight,
153153
>;
154154
}
155+
156+
pub mod v3 {
157+
use crate::{
158+
AccountIdOf, BalanceOf, Config, EvaluationRoundInfoOf, HRMPChannelStatus, MigrationReadinessCheck,
159+
PhaseTransitionPoints, PriceOf, ProjectDetailsOf, ProjectStatus,
160+
};
161+
use frame_support::{
162+
pallet_prelude::Get,
163+
traits::{tokens::Balance as BalanceT, OnRuntimeUpgrade},
164+
};
165+
use frame_system::pallet_prelude::BlockNumberFor;
166+
use polimec_common::credentials::Did;
167+
use polkadot_parachain_primitives::primitives::Id as ParaId;
168+
use scale_info::TypeInfo;
169+
use sp_arithmetic::FixedPointNumber;
170+
use sp_core::{Decode, Encode, MaxEncodedLen, RuntimeDebug};
171+
use sp_std::marker::PhantomData;
172+
173+
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
174+
pub struct OldProjectDetails<
175+
AccountId,
176+
Did,
177+
BlockNumber,
178+
Price: FixedPointNumber,
179+
Balance: BalanceT,
180+
EvaluationRoundInfo,
181+
> {
182+
pub issuer_account: AccountId,
183+
pub issuer_did: Did,
184+
/// Whether the project is frozen, so no `metadata` changes are allowed.
185+
pub is_frozen: bool,
186+
/// The price in USD per token decided after the Auction Round
187+
pub weighted_average_price: Option<Price>,
188+
/// The current status of the project
189+
pub status: ProjectStatus,
190+
/// When the different project phases start and end
191+
pub phase_transition_points: PhaseTransitionPoints<BlockNumber>,
192+
/// Fundraising target amount in USD (6 decimals)
193+
pub fundraising_target_usd: Balance,
194+
/// The amount of Contribution Tokens that have not yet been sold
195+
pub remaining_contribution_tokens: Balance,
196+
/// Funding reached amount in USD (6 decimals)
197+
pub funding_amount_reached_usd: Balance,
198+
/// Information about the total amount bonded, and the outcome in regards to reward/slash/nothing
199+
pub evaluation_round_info: EvaluationRoundInfo,
200+
/// When the Funding Round ends
201+
pub funding_end_block: Option<BlockNumber>,
202+
/// ParaId of project
203+
pub parachain_id: Option<ParaId>,
204+
/// Migration readiness check
205+
pub migration_readiness_check: Option<MigrationReadinessCheck>,
206+
/// HRMP Channel status
207+
pub hrmp_channel_status: HRMPChannelStatus,
208+
}
209+
type OldProjectDetailsOf<T> =
210+
OldProjectDetails<AccountIdOf<T>, Did, BlockNumberFor<T>, PriceOf<T>, BalanceOf<T>, EvaluationRoundInfoOf<T>>;
211+
212+
pub struct UncheckedMigrationToV3<T: Config>(PhantomData<T>);
213+
impl<T: Config> OnRuntimeUpgrade for UncheckedMigrationToV3<T> {
214+
fn on_runtime_upgrade() -> frame_support::weights::Weight {
215+
let mut items = 0;
216+
let mut translate = |_key, item: OldProjectDetailsOf<T>| -> Option<ProjectDetailsOf<T>> {
217+
items += 1;
218+
Some(ProjectDetailsOf::<T> {
219+
issuer_account: item.issuer_account,
220+
issuer_did: item.issuer_did,
221+
is_frozen: item.is_frozen,
222+
weighted_average_price: item.weighted_average_price,
223+
status: item.status,
224+
phase_transition_points: item.phase_transition_points,
225+
fundraising_target_usd: item.fundraising_target_usd,
226+
remaining_contribution_tokens: item.remaining_contribution_tokens,
227+
funding_amount_reached_usd: item.funding_amount_reached_usd,
228+
evaluation_round_info: item.evaluation_round_info,
229+
usd_bid_on_oversubscription: None,
230+
funding_end_block: item.funding_end_block,
231+
parachain_id: item.parachain_id,
232+
migration_readiness_check: item.migration_readiness_check,
233+
hrmp_channel_status: item.hrmp_channel_status,
234+
})
235+
};
236+
237+
crate::ProjectsDetails::<T>::translate(|key, object: OldProjectDetailsOf<T>| translate(key, object));
238+
239+
T::DbWeight::get().reads_writes(items, items)
240+
}
241+
}
242+
243+
pub type MigrationToV3<T> = frame_support::migrations::VersionedMigration<
244+
2,
245+
3,
246+
UncheckedMigrationToV3<T>,
247+
crate::Pallet<T>,
248+
<T as frame_system::Config>::DbWeight,
249+
>;
250+
}

runtimes/polimec/src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,11 @@ pub type Migrations = migrations::Unreleased;
157157
/// The runtime migrations per release.
158158
#[allow(missing_docs)]
159159
pub mod migrations {
160-
use crate::{custom_migrations::init_pallet::InitializePallet, DmpQueue};
160+
use crate::Runtime;
161+
161162
/// Unreleased migrations. Add new ones here:
162163
#[allow(unused_parens)]
163-
pub type Unreleased = (InitializePallet<DmpQueue>);
164+
pub type Unreleased = (pallet_funding::storage_migrations::v3::MigrationToV3<Runtime>);
164165
}
165166

166167
/// Executive: handles dispatch to the various modules.
@@ -206,7 +207,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
206207
spec_name: create_runtime_str!("polimec-mainnet"),
207208
impl_name: create_runtime_str!("polimec-mainnet"),
208209
authoring_version: 1,
209-
spec_version: 0_007_001,
210+
spec_version: 0_007_002,
210211
impl_version: 0,
211212
apis: RUNTIME_API_VERSIONS,
212213
transaction_version: 2,

runtimes/politest/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,10 @@ pub type Migrations = migrations::Unreleased;
166166
/// The runtime migrations per release.
167167
#[allow(missing_docs)]
168168
pub mod migrations {
169+
use crate::Runtime;
170+
169171
/// Unreleased migrations. Add new ones here:
170-
pub type Unreleased = ();
172+
pub type Unreleased = (pallet_funding::storage_migrations::v3::MigrationToV3<Runtime>);
171173
}
172174

173175
/// Executive: handles dispatch to the various modules.
@@ -213,7 +215,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
213215
spec_name: create_runtime_str!("politest"),
214216
impl_name: create_runtime_str!("politest"),
215217
authoring_version: 1,
216-
spec_version: 0_007_004,
218+
spec_version: 0_007_005,
217219
impl_version: 0,
218220
apis: RUNTIME_API_VERSIONS,
219221
transaction_version: 2,

0 commit comments

Comments
 (0)