mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 00:01:09 +00:00
Refactor away from opaque hashes (#5226)
* System.BlockHash * Fix hash * Introduce K/V iteration in all _concat maps Also move across: - System.Account (blake2_128_concat) - Balances.Locks (twox_64_concat) - ElectionsPhragmen.VotesOf (twox_64_concat) - ElectionsPhragmen.StakeOf (twox_64_concat) - Identity.IdentityOf (twox_64_concat) - Identity.SubsOf (twox_64_concat) - Society.Payouts (twox_64_concat) - Session.NextKeys (twox_64_concat) - Identity.SuperOf (blake2_128_concat) - Session.KeyOwner (blake2_128_concat) - Society.SuspendedCandidates (twox_64_concat) - Society.SuspendedMembers (twox_64_concat) - Society.Vouching (twox_64_concat) - Society.Strikes (twox_64_concat) - System.EventTopics - Balances.Account * Build fixes * Ensure migration happens in correct order * Staking.* * Vesting.* Offences.* * Democracy.* * Babe.* Collective.* * Grandpa.* * Assets.* Benchmark.* Contracts.* Elections.* Asset.* Nicks.* Also introduce real account list * ImOnline.* * Treasury.* * Recovery.* * Final bits. * Docs * Fix one test * Fix test * All passing except the UI tests * Remove linked_map part 1 * Remove linked_map * Some iterator utils for double maps. * Remove old migrations * Introduce tombstone for LinkedMap type * Migration for genesis hash * Fix build * Fix hash * Rename Map is_linked -> unused, keeping backwards compat (#5256) * Update frame/balances/src/lib.rs Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com> * Update frame/elections/src/lib.rs Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com> * Remove old migration code. * Update frame/system/src/lib.rs Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com> * Update bin/node/runtime/src/lib.rs Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com> * Fix hash * fix session migration * Fix watning Co-authored-by: Jaco Greeff <jacogr@gmail.com> Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
This commit is contained in:
@@ -98,7 +98,6 @@ mod rent;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
mod migration;
|
||||
|
||||
use crate::exec::ExecutionContext;
|
||||
use crate::account_db::{AccountDb, DirectAccountDb};
|
||||
@@ -667,10 +666,6 @@ decl_module! {
|
||||
fn on_finalize() {
|
||||
GasSpent::kill();
|
||||
}
|
||||
|
||||
fn on_runtime_upgrade() {
|
||||
migration::on_runtime_upgrade::<T>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -934,13 +929,13 @@ decl_storage! {
|
||||
/// Current cost schedule for contracts.
|
||||
CurrentSchedule get(fn current_schedule) config(): Schedule = Schedule::default();
|
||||
/// A mapping from an original code hash to the original code, untouched by instrumentation.
|
||||
pub PristineCode: map hasher(blake2_256) CodeHash<T> => Option<Vec<u8>>;
|
||||
pub PristineCode: map hasher(identity) CodeHash<T> => Option<Vec<u8>>;
|
||||
/// A mapping between an original code hash and instrumented wasm code, ready for execution.
|
||||
pub CodeStorage: map hasher(blake2_256) CodeHash<T> => Option<wasm::PrefabWasmModule>;
|
||||
pub CodeStorage: map hasher(identity) CodeHash<T> => Option<wasm::PrefabWasmModule>;
|
||||
/// The subtrie counter.
|
||||
pub AccountCounter: u64 = 0;
|
||||
/// The code associated with a given account.
|
||||
pub ContractInfoOf: map hasher(blake2_256) T::AccountId => Option<ContractInfo<T>>;
|
||||
pub ContractInfoOf: map hasher(twox_64_concat) T::AccountId => Option<ContractInfo<T>>;
|
||||
/// The price of one unit of gas.
|
||||
GasPrice get(fn gas_price) config(): BalanceOf<T> = 1.into();
|
||||
}
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ impl frame_system::Trait for Test {
|
||||
type Version = ();
|
||||
type ModuleToIndex = ();
|
||||
type AccountData = pallet_balances::AccountData<u64>;
|
||||
type OnNewAccount = ();
|
||||
type MigrateAccount = (); type OnNewAccount = ();
|
||||
type OnKilledAccount = Contracts;
|
||||
}
|
||||
impl pallet_balances::Trait for Test {
|
||||
|
||||
Reference in New Issue
Block a user