This repository was 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.7k
Assign unique storage names to pallets. #5010
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
d217526
Assign unique storage names to pallets.
shawntabrizi e6cb251
Bump spec
shawntabrizi e4da049
Upgrade logic for finality tracker (untested)
shawntabrizi 48da9c8
Logic for migrating Identity (untested)
shawntabrizi a6033e9
Logic for migrating transaction-payment
shawntabrizi 24225b7
Fix tests
shawntabrizi cec4172
Fix `decl_storage` build
shawntabrizi 774bc9e
Contract -> Contracts
shawntabrizi da77c17
Merge remote-tracking branch 'upstream/master' into shawntabrizi-fix-…
shawntabrizi 92c6217
Update Cargo.lock
shawntabrizi 6f732fc
Merge branch 'master' into shawntabrizi-fix-storage-names
gavofyork 9a554f2
Merge remote-tracking branch 'upstream/master' into shawntabrizi-fix-…
shawntabrizi 58f671e
bump spec
shawntabrizi 916f0a6
update migration
shawntabrizi f6d5693
Fix merge error
shawntabrizi 7ea6bc6
Migration for contracts
shawntabrizi 93b26ce
Merge branch 'master' into shawntabrizi-fix-storage-names
shawntabrizi 0a1a848
Remove serde
shawntabrizi 8016be2
Merge remote-tracking branch 'upstream/master' into shawntabrizi-fix-…
shawntabrizi abb90d4
Merge branch 'master' into shawntabrizi-fix-storage-names
gavofyork 504389a
Remove some illegal spaces and Options
gavofyork e21c85e
Fix types in identity.
gavofyork 066f8ef
Minor variable rename
gavofyork 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
This file contains hidden or 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 hidden or 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 hidden or 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,62 @@ | ||
| // Copyright 2020 Parity Technologies (UK) Ltd. | ||
| // This file is part of Substrate. | ||
|
|
||
| // Substrate is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
|
|
||
| // Substrate is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
|
|
||
| // You should have received a copy of the GNU General Public License | ||
| // along with Substrate. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| //! Migration code to update storage. | ||
|
|
||
| use super::*; | ||
| use frame_support::storage::migration::{put_storage_value, take_storage_value, StorageIterator}; | ||
|
|
||
| pub fn on_runtime_upgrade<T: Trait>() { | ||
| change_name_contract_to_contracts::<T>() | ||
| } | ||
|
|
||
| // Change the storage name used by this pallet from `Contract` to `Contracts`. | ||
| // | ||
| // Since the format of the storage items themselves have not changed, we do not | ||
| // need to keep track of a storage version. If the runtime does not need to be | ||
| // upgraded, nothing here will happen anyway. | ||
|
|
||
| fn change_name_contract_to_contracts<T: Trait>() { | ||
| sp_runtime::print("Migrating Contracts."); | ||
|
|
||
| if let Some(gas_spent) = take_storage_value::<Gas>(b"Contract", b"GasSpent", &[]) { | ||
| put_storage_value(b"Contracts", b"GasSpent", &[], gas_spent); | ||
| } | ||
|
|
||
| if let Some(current_schedule) = take_storage_value::<Schedule>(b"Contract", b"CurrentSchedule", &[]) { | ||
| put_storage_value(b"Contracts", b"CurrentSchedule", &[], current_schedule); | ||
| } | ||
|
|
||
| for (hash, pristine_code) in StorageIterator::<Vec<u8>>::new(b"Contract", b"PristineCode").drain() { | ||
| put_storage_value(b"Contracts", b"PristineCode", &hash, pristine_code); | ||
| } | ||
|
|
||
| for (hash, code_storage) in StorageIterator::<wasm::PrefabWasmModule>::new(b"Contract", b"CodeStorage").drain() { | ||
| put_storage_value(b"Contracts", b"CodeStorage", &hash, code_storage); | ||
| } | ||
|
|
||
| if let Some(current_schedule) = take_storage_value::<u64>(b"Contract", b"AccountCounter", &[]) { | ||
| put_storage_value(b"Contracts", b"AccountCounter", &[], current_schedule); | ||
| } | ||
|
|
||
| for (hash, contract_info_of) in StorageIterator::<ContractInfo<T>>::new(b"Contract", b"ContractInfoOf").drain() { | ||
| put_storage_value(b"Contracts", b"ContractInfoOf", &hash, contract_info_of); | ||
| } | ||
|
|
||
| if let Some(get_price) = take_storage_value::<BalanceOf<T>>(b"Contract", b"GetPrice", &[]) { | ||
| put_storage_value(b"Contracts", b"GetPrice", &[], get_price); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,54 @@ | ||
| // Copyright 2020 Parity Technologies (UK) Ltd. | ||
| // This file is part of Substrate. | ||
|
|
||
| // Substrate is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
|
|
||
| // Substrate is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
|
|
||
| // You should have received a copy of the GNU General Public License | ||
| // along with Substrate. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| // Migration code to update storage. | ||
|
|
||
| use super::*; | ||
| use frame_support::storage::migration::{put_storage_value, take_storage_value}; | ||
|
|
||
| pub fn on_runtime_upgrade<T: Trait>() { | ||
| change_name_timestamp_to_finality_tracker::<T>() | ||
| } | ||
|
|
||
| // Change the storage name used by this pallet from `Timestamp` to `FinalityTracker`. | ||
| // | ||
| // Since the format of the storage items themselves have not changed, we do not | ||
| // need to keep track of a storage version. If the runtime does not need to be | ||
| // upgraded, nothing here will happen anyway. | ||
|
|
||
| fn change_name_timestamp_to_finality_tracker<T:Trait>() { | ||
| sp_runtime::print("Migrating Finality Tracker."); | ||
|
|
||
| if let Some(recent_hints) = take_storage_value::<Vec<T::BlockNumber>>(b"Timestamp", b"RecentHints", &[]) { | ||
| put_storage_value(b"FinalityTracker", b"RecentHints", &[], recent_hints); | ||
| } | ||
|
|
||
| if let Some(ordered_hints) = take_storage_value::<Vec<T::BlockNumber>>(b"Timestamp", b"OrderedHints", &[]) { | ||
| put_storage_value(b"FinalityTracker", b"OrderedHints", &[], ordered_hints); | ||
| } | ||
|
|
||
| if let Some(median) = take_storage_value::<T::BlockNumber>(b"Timestamp", b"Median", &[]) { | ||
| put_storage_value(b"FinalityTracker", b"Median", &[], median); | ||
| } | ||
|
|
||
| if let Some(update) = take_storage_value::<T::BlockNumber>(b"Timestamp", b"Update", &[]) { | ||
| put_storage_value(b"FinalityTracker", b"Update", &[], update); | ||
| } | ||
|
|
||
| if let Some(initialized) = take_storage_value::<bool>(b"Timestamp", b"Initialized", &[]) { | ||
| put_storage_value(b"FinalityTracker", b"Initialized", &[], initialized); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,52 @@ | ||
| // Copyright 2020 Parity Technologies (UK) Ltd. | ||
| // This file is part of Substrate. | ||
|
|
||
| // Substrate is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
|
|
||
| // Substrate is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
|
|
||
| // You should have received a copy of the GNU General Public License | ||
| // along with Substrate. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| //! Migration code to update storage. | ||
|
|
||
| use super::*; | ||
| use frame_support::storage::migration::{put_storage_value, take_storage_value, StorageIterator}; | ||
|
|
||
| pub fn on_runtime_upgrade<T: Trait>() { | ||
| change_name_sudo_to_identity::<T>() | ||
| } | ||
|
|
||
| // Change the storage name used by this pallet from `Sudo` to `Identity`. | ||
| // | ||
| // Since the format of the storage items themselves have not changed, we do not | ||
| // need to keep track of a storage version. If the runtime does not need to be | ||
| // upgraded, nothing here will happen anyway. | ||
|
|
||
| fn change_name_sudo_to_identity<T: Trait>() { | ||
| sp_runtime::print("Migrating Identity."); | ||
|
|
||
| for (hash, identity_of) in StorageIterator::<Registration<BalanceOf<T>>>::new(b"Sudo", b"IdentityOf").drain() { | ||
| put_storage_value(b"Identity", b"IdentityOf", &hash, identity_of); | ||
| } | ||
|
|
||
| for (hash, super_of) in StorageIterator::<(T::AccountId, Data)>::new(b"Sudo", b"SuperOf").drain() { | ||
| put_storage_value(b"Identity", b"SuperOf", &hash, super_of); | ||
| } | ||
|
|
||
| for (hash, subs_of) in StorageIterator::<(BalanceOf<T>, Vec<T::AccountId>)>::new(b"Sudo", b"SubsOf").drain() { | ||
| put_storage_value(b"Identity", b"SubsOf", &hash, subs_of); | ||
| } | ||
|
|
||
| if let Some(registrars) = take_storage_value::<Vec<Option<RegistrarInfo<BalanceOf<T>, T::AccountId>>>>(b"Sudo", b"Registrars", &[]) { | ||
| put_storage_value(b"Identity", b"Registrars", &[], registrars); | ||
| } | ||
|
|
||
| sp_runtime::print("Done Identity."); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.