mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-24 10:11:08 +00:00
Runtime Upgrade ref docs and Single Block Migration example pallet (#1554)
Closes https://github.com/paritytech/polkadot-sdk-docs/issues/55 - Changes 'current storage version' terminology to less ambiguous 'in-code storage version' (suggestion by @ggwpez) - Adds a new example pallet `pallet-example-single-block-migrations` - Adds a new reference doc to replace https://docs.substrate.io/maintain/runtime-upgrades/ (temporarily living in the pallet while we wait for developer hub PR to merge) - Adds documentation for the `storage_alias` macro - Improves `trait Hooks` docs - Improves `trait GetStorageVersion` docs - Update the suggested patterns for using `VersionedMigration`, so that version unchecked migrations are never exported - Prevents accidental usage of version unchecked migrations in runtimes https://github.com/paritytech/substrate/pull/14421#discussion_r1255467895 - Unversioned migration code is kept inside `mod version_unchecked`, versioned code is kept in `pub mod versioned` - It is necessary to use modules to limit visibility because the inner migration must be `pub`. See https://github.com/rust-lang/rust/issues/30905 and https://internals.rust-lang.org/t/lang-team-minutes-private-in-public-rules/4504/40 for more. ### todo - [x] move to reference docs to proper place within sdk-docs (now that https://github.com/paritytech/polkadot-sdk/pull/2102 is merged) - [x] prdoc --------- Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Juan <juangirini@gmail.com> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: command-bot <> Co-authored-by: gupnik <nikhilgupta.iitk@gmail.com>
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
//! Tests for the module.
|
||||
|
||||
use super::*;
|
||||
use migrations::old;
|
||||
use migrations::v0;
|
||||
use mock::*;
|
||||
|
||||
use frame_support::{assert_noop, assert_ok};
|
||||
@@ -32,41 +32,41 @@ use RuntimeOrigin as Origin;
|
||||
#[test]
|
||||
fn migration_works() {
|
||||
EnvBuilder::new().founded(false).execute(|| {
|
||||
use old::Vote::*;
|
||||
use v0::Vote::*;
|
||||
|
||||
// Initialise the old storage items.
|
||||
Founder::<Test>::put(10);
|
||||
Head::<Test>::put(30);
|
||||
old::Members::<Test, ()>::put(vec![10, 20, 30]);
|
||||
old::Vouching::<Test, ()>::insert(30, Vouching);
|
||||
old::Vouching::<Test, ()>::insert(40, Banned);
|
||||
old::Strikes::<Test, ()>::insert(20, 1);
|
||||
old::Strikes::<Test, ()>::insert(30, 2);
|
||||
old::Strikes::<Test, ()>::insert(40, 5);
|
||||
old::Payouts::<Test, ()>::insert(20, vec![(1, 1)]);
|
||||
old::Payouts::<Test, ()>::insert(
|
||||
v0::Members::<Test, ()>::put(vec![10, 20, 30]);
|
||||
v0::Vouching::<Test, ()>::insert(30, Vouching);
|
||||
v0::Vouching::<Test, ()>::insert(40, Banned);
|
||||
v0::Strikes::<Test, ()>::insert(20, 1);
|
||||
v0::Strikes::<Test, ()>::insert(30, 2);
|
||||
v0::Strikes::<Test, ()>::insert(40, 5);
|
||||
v0::Payouts::<Test, ()>::insert(20, vec![(1, 1)]);
|
||||
v0::Payouts::<Test, ()>::insert(
|
||||
30,
|
||||
(0..=<Test as Config>::MaxPayouts::get())
|
||||
.map(|i| (i as u64, i as u64))
|
||||
.collect::<Vec<_>>(),
|
||||
);
|
||||
old::SuspendedMembers::<Test, ()>::insert(40, true);
|
||||
v0::SuspendedMembers::<Test, ()>::insert(40, true);
|
||||
|
||||
old::Defender::<Test, ()>::put(20);
|
||||
old::DefenderVotes::<Test, ()>::insert(10, Approve);
|
||||
old::DefenderVotes::<Test, ()>::insert(20, Approve);
|
||||
old::DefenderVotes::<Test, ()>::insert(30, Reject);
|
||||
v0::Defender::<Test, ()>::put(20);
|
||||
v0::DefenderVotes::<Test, ()>::insert(10, Approve);
|
||||
v0::DefenderVotes::<Test, ()>::insert(20, Approve);
|
||||
v0::DefenderVotes::<Test, ()>::insert(30, Reject);
|
||||
|
||||
old::SuspendedCandidates::<Test, ()>::insert(50, (10, Deposit(100)));
|
||||
v0::SuspendedCandidates::<Test, ()>::insert(50, (10, Deposit(100)));
|
||||
|
||||
old::Candidates::<Test, ()>::put(vec![
|
||||
v0::Candidates::<Test, ()>::put(vec![
|
||||
Bid { who: 60, kind: Deposit(100), value: 200 },
|
||||
Bid { who: 70, kind: Vouch(30, 30), value: 100 },
|
||||
]);
|
||||
old::Votes::<Test, ()>::insert(60, 10, Approve);
|
||||
old::Votes::<Test, ()>::insert(70, 10, Reject);
|
||||
old::Votes::<Test, ()>::insert(70, 20, Approve);
|
||||
old::Votes::<Test, ()>::insert(70, 30, Approve);
|
||||
v0::Votes::<Test, ()>::insert(60, 10, Approve);
|
||||
v0::Votes::<Test, ()>::insert(70, 10, Reject);
|
||||
v0::Votes::<Test, ()>::insert(70, 20, Approve);
|
||||
v0::Votes::<Test, ()>::insert(70, 30, Approve);
|
||||
|
||||
let bids = (0..=<Test as Config>::MaxBids::get())
|
||||
.map(|i| Bid {
|
||||
@@ -75,7 +75,7 @@ fn migration_works() {
|
||||
value: 10u64 + i as u64,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
old::Bids::<Test, ()>::put(bids);
|
||||
v0::Bids::<Test, ()>::put(bids);
|
||||
|
||||
migrations::from_original::<Test, ()>(&mut [][..]).expect("migration failed");
|
||||
migrations::assert_internal_consistency::<Test, ()>();
|
||||
|
||||
Reference in New Issue
Block a user