Second migration fix (#5178)

* Second migration fix

* Fix check-runtime script

* Another fix to the CI

* Revert changes.

* Bump runtime
This commit is contained in:
Gavin Wood
2020-03-06 23:46:38 +01:00
committed by GitHub
parent 1290ae3e92
commit 1c94a03780
2 changed files with 9 additions and 4 deletions
+1 -1
View File
@@ -82,7 +82,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to 0. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 232,
spec_version: 233,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
};
+8 -3
View File
@@ -68,15 +68,20 @@ fn upgrade_v1_to_v2<T: Trait<I>, I: Instance>() {
put_storage_value(b"Balances", b"Account", &hash, account);
}
let prefix = {
let encoded_prefix_key_hash = b":session:keys".to_vec().encode();
let mut h = twox_64(&encoded_prefix_key_hash[..]).to_vec();
h.extend(&encoded_prefix_key_hash[..]);
h
};
for (hash, balances) in StorageIterator::<AccountData<T::Balance>>::new(b"Balances", b"Account").drain() {
let nonce = take_storage_value::<T::Index>(b"System", b"AccountNonce", &hash).unwrap_or_default();
let mut refs: system::RefCount = 0;
// The items in Kusama that would result in a ref count being incremented.
if have_storage_value(b"Democracy", b"Proxy", &hash) { refs += 1 }
// We skip Recovered since it's being replaced anyway.
let k = b":session:keys".encode();
let mut prefixed_hash = twox_64(&k[..]).to_vec();
prefixed_hash.extend(&k[..]);
let mut prefixed_hash = prefix.clone();
prefixed_hash.extend(&hash[..]);
if have_storage_value(b"Session", b"NextKeys", &prefixed_hash) { refs += 1 }
if have_storage_value(b"Staking", b"Bonded", &hash) { refs += 1 }