This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add ClassAccount storage to unique pallet #9940
Merged
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b45b6dc
add ClassAccount to uniques storage
hamidra e9d0e08
add tests for Class and ClassAccount storage
hamidra 01e91da
fix format
hamidra 24b5b36
fix description
hamidra 958bcdf
Merge branch 'master' into hamidra/class-account-storage
hamidra 4efe073
Merge branch 'master' into hamidra/class-account-storage
hamidra c8233a9
add migration
hamidra afe267a
remove extra iteration
hamidra e3f8c26
Update frame/uniques/src/migration.rs
hamidra 4105836
Merge branch 'master' of https://github.com/paritytech/substrate into…
dcf2714
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
fe16078
Merge branch 'master' into hamidra/class-account-storage
hamidra a76c927
Merge branch 'master' into hamidra/class-account-storage
hamidra 62dee5c
Merge branch 'master' into hamidra/class-account-storage
hamidra f33efca
fix format
hamidra eb1735b
Merge branch 'master' into hamidra/class-account-storage
shawntabrizi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// This file is part of Substrate. | ||
|
||
// Copyright (C) 2021 Parity Technologies (UK) Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//! Various pieces of common functionality. | ||
use super::*; | ||
use frame_support::{ | ||
traits::{Get, GetStorageVersion, PalletInfoAccess, StorageVersion}, | ||
weights::Weight, | ||
}; | ||
|
||
pub fn migrate_to_v1<T: Config<I>, I: 'static, P: GetStorageVersion + PalletInfoAccess>( | ||
) -> frame_support::weights::Weight { | ||
let on_chain_storage_version = <P as GetStorageVersion>::on_chain_storage_version(); | ||
log::info!( | ||
target: "runtime::uniques", | ||
"Running migration storage v1 for uniques with storage version {:?}", | ||
on_chain_storage_version, | ||
); | ||
|
||
if on_chain_storage_version < 1 { | ||
let mut count = 0; | ||
for (class, detail) in Class::<T, I>::iter() { | ||
ClassAccount::<T, I>::insert(&detail.owner, &class, ()); | ||
count += 1; | ||
} | ||
StorageVersion::new(1).put::<P>(); | ||
log::info!( | ||
target: "runtime::uniques", | ||
"Running migration storage v1 for uniques with storage version {:?} was complete", | ||
on_chain_storage_version, | ||
); | ||
// calculate and return migration weights | ||
T::DbWeight::get().reads_writes(count as Weight + 1, count as Weight + 1) | ||
} else { | ||
log::warn!( | ||
target: "runtime::uniques", | ||
"Attempted to apply migration to v1 but failed because storage version is {:?}", | ||
on_chain_storage_version, | ||
); | ||
T::DbWeight::get().reads(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this migration might be very big and cause issues on a parachain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the best practice to bound the migrations. do we just set an upper limit?! Currently there are only 5-6 classes on statemine that this will run for. I assume any other parachain which launches after this will start from storage version 1, hence won't run this migration.