contracts: Add test to verify unique trie ids (#10914)

* Add test to verify unique trie ids

* Rename trie_seed to nonce

* Rename AccountCounter -> Nonce

* fmt
This commit is contained in:
Alexander Theißen
2022-03-10 12:28:00 +01:00
committed by GitHub
parent 18aef02e87
commit bef9b79d7b
6 changed files with 162 additions and 56 deletions
@@ -19,6 +19,7 @@ use crate::{BalanceOf, CodeHash, Config, Pallet, TrieId, Weight};
use codec::{Decode, Encode};
use frame_support::{
codec, generate_storage_alias,
pallet_prelude::*,
storage::migration,
traits::{Get, PalletInfoAccess},
Identity, Twox64Concat,
@@ -47,6 +48,11 @@ pub fn migrate<T: Config>() -> Weight {
StorageVersion::new(6).put::<Pallet<T>>();
}
if version < 7 {
weight = weight.saturating_add(v7::migrate::<T>());
StorageVersion::new(7).put::<Pallet<T>>();
}
weight
}
@@ -249,3 +255,21 @@ mod v6 {
weight
}
}
/// Rename `AccountCounter` to `Nonce`.
mod v7 {
use super::*;
pub fn migrate<T: Config>() -> Weight {
generate_storage_alias!(
Contracts,
AccountCounter => Value<u64, ValueQuery>
);
generate_storage_alias!(
Contracts,
Nonce => Value<u64, ValueQuery>
);
Nonce::set(AccountCounter::take());
T::DbWeight::get().reads_writes(1, 2)
}
}