Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime Upgrade ref docs and Single Block Migration example pallet #1554

Merged
merged 110 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
a9673c7
improve metadata docs
liamaharon Sep 13, 2023
e22a2e2
improve hooks docs
liamaharon Sep 13, 2023
c6a6984
add storage_alias docs
liamaharon Sep 13, 2023
b617ce9
wip: storage migrations example pallet
liamaharon Sep 13, 2023
37e45d4
dont export unversioned migrations
liamaharon Sep 13, 2023
22fe899
patterns preventing accidental usage of unversioned migrations
liamaharon Sep 14, 2023
3ef233f
Merge branch 'master' of github.com:paritytech/polkadot-sdk into liam…
liamaharon Sep 14, 2023
76c9150
private unversioned migrations
liamaharon Sep 14, 2023
d98a0fd
docs
liamaharon Sep 14, 2023
48100f0
docs
liamaharon Sep 14, 2023
986f0bd
note about pub(crate)
liamaharon Sep 14, 2023
548316c
migration safely docs
liamaharon Sep 14, 2023
4925243
typo
liamaharon Sep 14, 2023
7d75a75
docs
liamaharon Sep 14, 2023
6858f3c
docs
liamaharon Sep 14, 2023
8446ad2
doctest false
liamaharon Sep 14, 2023
bdb1ae5
note on chopsticks
liamaharon Sep 14, 2023
35b08fd
fix society tests
liamaharon Sep 14, 2023
1fa5207
zepter
liamaharon Sep 14, 2023
ebf4cd5
fix feature propagation
liamaharon Sep 14, 2023
3f55db7
add licences
liamaharon Sep 14, 2023
ca0e4e3
format features
liamaharon Sep 14, 2023
34da4a0
fix doc visibility issue
liamaharon Sep 14, 2023
009a958
improve docs
liamaharon Sep 14, 2023
1aa3555
fix std propagataion
liamaharon Sep 14, 2023
fc08b0e
zepter
liamaharon Sep 14, 2023
01b780a
fix broken link
liamaharon Sep 14, 2023
adcfeaf
dont ref private item
liamaharon Sep 14, 2023
655b376
dont ref private doc item
liamaharon Sep 14, 2023
8335171
doc build
liamaharon Sep 14, 2023
3fff7fb
Update substrate/frame/examples/storage-migrations/src/mock.rs
liamaharon Sep 16, 2023
3bd0ef2
Update substrate/frame/examples/src/lib.rs
liamaharon Sep 17, 2023
1a54755
docify
liamaharon Sep 17, 2023
222ed3a
derive_impl
liamaharon Sep 17, 2023
4a070fd
fix derive_impl
liamaharon Sep 20, 2023
f66f9e2
improve docs
liamaharon Sep 20, 2023
70a9da4
set dbweight
liamaharon Sep 20, 2023
d915026
clean up pallet
liamaharon Sep 20, 2023
a596074
module visibility
liamaharon Sep 20, 2023
0cf19ac
fix comment
liamaharon Sep 20, 2023
fe92288
fix comment
liamaharon Sep 20, 2023
0dc8a60
fix comment
liamaharon Sep 20, 2023
e3e4940
better naming
liamaharon Sep 20, 2023
0fe21d5
better naming
liamaharon Sep 20, 2023
92e43ac
fix wasm build
liamaharon Sep 20, 2023
55f876d
cargo fmt
liamaharon Sep 20, 2023
4819209
format features
liamaharon Sep 20, 2023
59d7352
set uniques storage version
liamaharon Sep 20, 2023
f16f628
fix asset hub storage versions
liamaharon Sep 20, 2023
bbae7ef
Merge branch 'master' into liam-migrations-reference-docs
liamaharon Nov 28, 2023
7d4da68
merge
liamaharon Nov 28, 2023
eaa6aca
update cargo.lock
liamaharon Nov 28, 2023
8cafd48
reset polkadot-asset-hub-runtime
liamaharon Nov 28, 2023
a6c6781
fix merge
liamaharon Nov 28, 2023
fbdb77c
fix up merge
liamaharon Nov 28, 2023
e9aa91a
remove kusama runtime
liamaharon Nov 28, 2023
d135244
Merge branch 'master' into liam-migrations-reference-docs
liamaharon Nov 29, 2023
7a23c5f
update cargo.lock
liamaharon Nov 29, 2023
c120f47
fix build
liamaharon Nov 29, 2023
a4c2ca3
rename single block migrations
liamaharon Nov 29, 2023
4275503
runtime upgrade ref docs
liamaharon Nov 30, 2023
48605c7
Merge branch 'master' into liam-migrations-reference-docs
liamaharon Nov 30, 2023
2c014e7
version
liamaharon Nov 30, 2023
9f46c00
comment
liamaharon Nov 30, 2023
ef12e3e
note on version
liamaharon Nov 30, 2023
4881a0a
berevity
liamaharon Nov 30, 2023
e5ff5b2
brevity
liamaharon Nov 30, 2023
3f31c6b
Update substrate/frame/examples/single-block-migrations/Cargo.toml
liamaharon Dec 1, 2023
802aae3
Update substrate/frame/examples/single-block-migrations/src/lib.rs
liamaharon Dec 1, 2023
7aca6b6
Update substrate/frame/support/procedural/src/lib.rs
liamaharon Dec 1, 2023
564664e
Update substrate/frame/examples/single-block-migrations/src/runtime_u…
liamaharon Dec 1, 2023
dfa7f36
Update substrate/frame/examples/single-block-migrations/src/lib.rs
liamaharon Dec 1, 2023
b6d71a8
Update substrate/frame/examples/single-block-migrations/src/migration…
liamaharon Dec 1, 2023
4651a7e
Merge branch 'master' into liam-migrations-reference-docs
liamaharon Dec 1, 2023
eaa427a
format toml
liamaharon Dec 1, 2023
406fad7
address comment
liamaharon Dec 1, 2023
4be8f4d
address comment
liamaharon Dec 1, 2023
a8df9cd
address comment
liamaharon Dec 1, 2023
8f32ece
add benchmark note
liamaharon Dec 1, 2023
ec3ce8c
take
liamaharon Dec 1, 2023
0ae45d8
fix typo
liamaharon Dec 1, 2023
f5ac289
address comment
liamaharon Dec 1, 2023
7f21f42
current storage version -> in_code storage version
liamaharon Dec 1, 2023
050f465
try fix ci
liamaharon Dec 1, 2023
91f80eb
rename
liamaharon Dec 1, 2023
66d2745
feature propagarion
liamaharon Dec 1, 2023
1a2d834
fix unused import wanrings
liamaharon Dec 1, 2023
69e4209
fix typo
liamaharon Dec 1, 2023
6c50902
Merge branch 'master' of github.com:paritytech/polkadot-sdk into liam…
liamaharon Dec 7, 2023
52963fa
fix merge
liamaharon Dec 7, 2023
dfe32c5
move reference doc to correct place
liamaharon Dec 7, 2023
2d08759
".git/.scripts/commands/fmt/fmt.sh"
Dec 7, 2023
2fadaad
prdoc
liamaharon Dec 7, 2023
fc9d605
Merge branch 'liam-migrations-reference-docs' of github.com:paritytec…
liamaharon Dec 7, 2023
8108b8e
fix prdoc
liamaharon Dec 7, 2023
a655cd8
Merge branch 'master' into liam-migrations-reference-docs
liamaharon Dec 7, 2023
03b7735
keep current_storage_version around for 3 months
liamaharon Dec 7, 2023
27414b4
Merge branch 'liam-migrations-reference-docs' of github.com:paritytec…
liamaharon Dec 7, 2023
a6c1dc6
improve deprecation msg
liamaharon Dec 7, 2023
d8f5a38
Merge branch 'master' into liam-migrations-reference-docs
liamaharon Jan 18, 2024
319b32d
update cargo.lock
liamaharon Jan 18, 2024
85860cf
Merge branch 'master' into liam-migrations-reference-docs
liamaharon Feb 28, 2024
65082f9
update cargo.lock
liamaharon Feb 28, 2024
5b0bc65
rename
liamaharon Feb 28, 2024
d76e813
address comments
liamaharon Feb 28, 2024
26bf39f
address comments
liamaharon Feb 28, 2024
c588805
address comments and make compile
liamaharon Feb 28, 2024
3aa6ccd
Update docs/sdk/src/reference_docs/frame_runtime_upgrades_and_migrati…
liamaharon Feb 28, 2024
0f63e03
address comment
liamaharon Feb 28, 2024
a97071b
Merge branch 'liam-migrations-reference-docs' of github.com:paritytec…
liamaharon Feb 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ members = [
"substrate/frame/examples/frame-crate",
"substrate/frame/examples/kitchensink",
"substrate/frame/examples/offchain-worker",
"substrate/frame/examples/single-block-migrations",
"substrate/frame/examples/split",
"substrate/frame/examples/tasks",
"substrate/frame/executive",
Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/collator-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub mod pallet {
use sp_staking::SessionIndex;
use sp_std::vec::Vec;

/// The current storage version.
/// The in-code storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);

type BalanceOf<T> =
Expand Down
10 changes: 5 additions & 5 deletions cumulus/pallets/collator-selection/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ pub mod v1 {
pub struct MigrateToV1<T>(sp_std::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for MigrateToV1<T> {
fn on_runtime_upgrade() -> Weight {
let onchain_version = Pallet::<T>::on_chain_storage_version();
if onchain_version == 0 {
let on_chain_version = Pallet::<T>::on_chain_storage_version();
if on_chain_version == 0 {
let invulnerables_len = Invulnerables::<T>::get().to_vec().len();
<Invulnerables<T>>::mutate(|invulnerables| {
invulnerables.sort();
Expand All @@ -45,7 +45,7 @@ pub mod v1 {
invulnerables_len,
);
// Similar complexity to `set_invulnerables` (put storage value)
// Plus 1 read for length, 1 read for `onchain_version`, 1 write to put version
// Plus 1 read for length, 1 read for `on_chain_version`, 1 write to put version
T::WeightInfo::set_invulnerables(invulnerables_len as u32)
.saturating_add(T::DbWeight::get().reads_writes(2, 1))
} else {
Expand Down Expand Up @@ -83,8 +83,8 @@ pub mod v1 {
"after migration, there should be the same number of invulnerables"
);

let onchain_version = Pallet::<T>::on_chain_storage_version();
frame_support::ensure!(onchain_version >= 1, "must_upgrade");
let on_chain_version = Pallet::<T>::on_chain_storage_version();
frame_support::ensure!(on_chain_version >= 1, "must_upgrade");

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/parachain-system/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use frame_support::{
weights::Weight,
};

/// The current storage version.
/// The in-code storage version.
liamaharon marked this conversation as resolved.
Show resolved Hide resolved
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);

/// Migrates the pallet storage to the most recent version.
Expand Down
2 changes: 1 addition & 1 deletion cumulus/pallets/xcmp-queue/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use frame_support::{
weights::{constants::WEIGHT_REF_TIME_PER_MILLIS, Weight},
};

/// The current storage version.
/// The in-code storage version.
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(4);

pub const LOG: &str = "runtime::xcmp-queue-migration";
Expand Down
2 changes: 1 addition & 1 deletion cumulus/parachains/pallets/collective-content/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub mod pallet {
use frame_system::pallet_prelude::*;
use sp_runtime::{traits::BadOrigin, Saturating};

/// The current storage version.
/// The in-code storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);

#[pallet::pallet]
Expand Down
14 changes: 7 additions & 7 deletions cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -986,37 +986,37 @@ impl frame_support::traits::OnRuntimeUpgrade for InitStorageVersions {
let mut writes = 0;

if PolkadotXcm::on_chain_storage_version() == StorageVersion::new(0) {
PolkadotXcm::current_storage_version().put::<PolkadotXcm>();
PolkadotXcm::in_code_storage_version().put::<PolkadotXcm>();
writes.saturating_inc();
}

if Multisig::on_chain_storage_version() == StorageVersion::new(0) {
Multisig::current_storage_version().put::<Multisig>();
Multisig::in_code_storage_version().put::<Multisig>();
writes.saturating_inc();
}

if Assets::on_chain_storage_version() == StorageVersion::new(0) {
Assets::current_storage_version().put::<Assets>();
Assets::in_code_storage_version().put::<Assets>();
writes.saturating_inc();
}

if Uniques::on_chain_storage_version() == StorageVersion::new(0) {
Uniques::current_storage_version().put::<Uniques>();
Uniques::in_code_storage_version().put::<Uniques>();
writes.saturating_inc();
}

if Nfts::on_chain_storage_version() == StorageVersion::new(0) {
Nfts::current_storage_version().put::<Nfts>();
Nfts::in_code_storage_version().put::<Nfts>();
writes.saturating_inc();
}

if ForeignAssets::on_chain_storage_version() == StorageVersion::new(0) {
ForeignAssets::current_storage_version().put::<ForeignAssets>();
ForeignAssets::in_code_storage_version().put::<ForeignAssets>();
writes.saturating_inc();
}

if PoolAssets::on_chain_storage_version() == StorageVersion::new(0) {
PoolAssets::current_storage_version().put::<PoolAssets>();
PoolAssets::in_code_storage_version().put::<PoolAssets>();
writes.saturating_inc();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1037,17 +1037,17 @@ impl frame_support::traits::OnRuntimeUpgrade for InitStorageVersions {
let mut writes = 0;

if PolkadotXcm::on_chain_storage_version() == StorageVersion::new(0) {
PolkadotXcm::current_storage_version().put::<PolkadotXcm>();
PolkadotXcm::in_code_storage_version().put::<PolkadotXcm>();
writes.saturating_inc();
}

if ForeignAssets::on_chain_storage_version() == StorageVersion::new(0) {
ForeignAssets::current_storage_version().put::<ForeignAssets>();
ForeignAssets::in_code_storage_version().put::<ForeignAssets>();
writes.saturating_inc();
}

if PoolAssets::on_chain_storage_version() == StorageVersion::new(0) {
PoolAssets::current_storage_version().put::<PoolAssets>();
PoolAssets::in_code_storage_version().put::<PoolAssets>();
writes.saturating_inc();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ impl frame_support::traits::OnRuntimeUpgrade for InitStorageVersions {
let mut writes = 0;

if PolkadotXcm::on_chain_storage_version() == StorageVersion::new(0) {
PolkadotXcm::current_storage_version().put::<PolkadotXcm>();
PolkadotXcm::in_code_storage_version().put::<PolkadotXcm>();
writes.saturating_inc();
}

if Balances::on_chain_storage_version() == StorageVersion::new(0) {
Balances::current_storage_version().put::<Balances>();
Balances::in_code_storage_version().put::<Balances>();
writes.saturating_inc();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ impl frame_support::traits::OnRuntimeUpgrade for InitStorageVersions {
let mut writes = 0;

if PolkadotXcm::on_chain_storage_version() == StorageVersion::new(0) {
PolkadotXcm::current_storage_version().put::<PolkadotXcm>();
PolkadotXcm::in_code_storage_version().put::<PolkadotXcm>();
writes.saturating_inc();
}

if Balances::on_chain_storage_version() == StorageVersion::new(0) {
Balances::current_storage_version().put::<Balances>();
Balances::in_code_storage_version().put::<Balances>();
writes.saturating_inc();
}

Expand Down
7 changes: 6 additions & 1 deletion docs/sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ node-cli = { package = "staging-node-cli", path = "../../substrate/bin/node/cli"
kitchensink-runtime = { path = "../../substrate/bin/node/runtime" }
chain-spec-builder = { package = "staging-chain-spec-builder", path = "../../substrate/bin/utils/chain-spec-builder" }
subkey = { path = "../../substrate/bin/utils/subkey" }
frame-system = { path = "../../substrate/frame/system", default-features = false }
frame-support = { path = "../../substrate/frame/support", default-features = false }
frame-executive = { path = "../../substrate/frame/executive", default-features = false }
pallet-example-single-block-migrations = { path = "../../substrate/frame/examples/single-block-migrations" }

# Substrate
sc-network = { path = "../../substrate/client/network" }
Expand Down Expand Up @@ -66,14 +70,15 @@ pallet-proxy = { path = "../../substrate/frame/proxy" }
pallet-authorship = { path = "../../substrate/frame/authorship" }
pallet-collective = { path = "../../substrate/frame/collective" }
pallet-democracy = { path = "../../substrate/frame/democracy" }
frame-system = { path = "../../substrate/frame/system" }
pallet-scheduler = { path = "../../substrate/frame/scheduler" }

# Primitives
sp-io = { path = "../../substrate/primitives/io" }
sp-api = { path = "../../substrate/primitives/api" }
sp-core = { path = "../../substrate/primitives/core" }
sp-keyring = { path = "../../substrate/primitives/keyring" }
sp-runtime = { path = "../../substrate/primitives/runtime" }
sp-version = { path = "../../substrate/primitives/version" }

# XCM
xcm = { package = "staging-xcm", path = "../../polkadot/xcm" }
Expand Down
9 changes: 0 additions & 9 deletions docs/sdk/src/reference_docs/frame_runtime_migration.rs

This file was deleted.

Loading
Loading