Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
coverage ahm_dry_run_repo="../ahm-dryrun":
#!/usr/bin/env bash

runtimes=$(pwd)
cd {{ahm_dry_run_repo}}
just coverage update $runtimes
7 changes: 6 additions & 1 deletion integration-tests/ahm/src/proxy_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,16 @@ impl AhMigrationCheck for ProxiesStillWork {
type AhPrePayload = ();

fn pre_check(_: Self::RcPrePayload) -> Self::AhPrePayload {
() // No OP
// Not empty in this case
assert!(
!pallet_proxy::Proxies::<AssetHubRuntime>::iter().next().is_none(),
"Assert storage 'Proxy::Proxies::ah_pre::empty'"
);
}

fn post_check(rc_pre_payload: Self::RcPrePayload, _: Self::AhPrePayload) {
for ((delegatee, delegator), permissions) in rc_pre_payload.iter() {
// Assert storage "Proxy::Proxies::ah_post::correct"
let (entry, _) = pallet_proxy::Proxies::<AssetHubRuntime>::get(&delegator);
if entry.is_empty() {
// FIXME possibly bug
Expand Down
6 changes: 4 additions & 2 deletions pallets/ah-migrator/src/conviction_voting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ impl<T: Config> crate::types::AhMigrationCheck for ConvictionVotingMigrator<T> {
fn pre_check(_: Self::RcPrePayload) -> Self::AhPrePayload {
assert!(
alias::VotingFor::<T>::iter().next().is_none(),
"VotingFor should be empty before migration starts"
"Assert storage 'ConvictionVoting::VotingFor::ah_pre::empty'"
);
assert!(
pallet_conviction_voting::ClassLocksFor::<T>::iter().next().is_none(),
"ClassLocksFor should be empty before migration starts"
"Assert storage 'ConvictionVoting::ClassLocksFor::ah_pre::empty'"
);
}

Expand All @@ -108,6 +108,8 @@ impl<T: Config> crate::types::AhMigrationCheck for ConvictionVotingMigrator<T> {
.push(RcConvictionVotingMessage::ClassLocksFor(account_id, balance_per_class));
}

// Assert storage "ConvictionVoting::VotingFor::ah_post::correct"
// Assert storage "ConvictionVoting::ClassLocksFor::ah_post::correct"
assert_eq!(
rc_pre_payload, ah_messages,
"Conviction voting data mismatch: Asset Hub data differs from original Relay Chain data"
Expand Down
10 changes: 8 additions & 2 deletions pallets/ah-migrator/src/indices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ impl<T: Config> crate::types::AhMigrationCheck for IndicesMigrator<T> {
type AhPrePayload = Vec<RcIndicesIndexOf<T>>;

fn pre_check(_: Self::RcPrePayload) -> Self::AhPrePayload {
pallet_indices::Accounts::<T>::iter()
let indices = pallet_indices::Accounts::<T>::iter()
.map(|(index, (who, deposit, frozen))| RcIndicesIndex { index, who, deposit, frozen })
.collect()
.collect::<Vec<_>>();

assert!(indices.is_empty(), "Assert storage 'Indices::Accounts::ah_pre::empty'");

indices
}

fn post_check(rc_pre_payload: Self::RcPrePayload, ah_pre_payload: Self::AhPrePayload) {
Expand All @@ -69,6 +73,8 @@ impl<T: Config> crate::types::AhMigrationCheck for IndicesMigrator<T> {

// Note that by using BTreeMaps, we implicitly check the case that an AH entry is not
// overwritten by a RC entry since we iterate over the RC entries first before the collect.
// Assert storage "Indices::Accounts::ah_post::correct"
// Assert storage "Indices::Accounts::ah_post::length"
assert_eq!(all_pre, all_post, "RC and AH indices are present");
}
}
13 changes: 11 additions & 2 deletions pallets/ah-migrator/src/preimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,13 @@ impl<T: Config> crate::types::AhMigrationCheck for PreimageChunkMigrator<T> {
// AH does not have a preimage pallet, therefore must be empty.
assert!(
alias::PreimageFor::<T>::iter_keys().next().is_none(),
"Preimage::PreimageFor is not empty"
"Assert storage 'Preimage::PreimageFor::ah_pre::empty'"
);
}

// The payload should come from the relay chain pre-check method on the same pallet
fn post_check(rc_pre_payload: Self::RcPrePayload, _ah_pre_payload: Self::AhPrePayload) {
// Check that the PreimageFor entries are sane.
// Assert storage "Preimage::PreimageFor::ah_post::consistent"
for (key, preimage) in alias::PreimageFor::<T>::iter() {
assert!(preimage.len() > 0, "Preimage::PreimageFor is empty");
assert!(preimage.len() <= 4 * 1024 * 1024_usize, "Preimage::PreimageFor is too big");
Expand All @@ -255,6 +255,7 @@ impl<T: Config> crate::types::AhMigrationCheck for PreimageChunkMigrator<T> {
<T as frame_system::Config>::Hashing::hash(&preimage) == key.0,
"Preimage::PreimageFor hash mismatch"
);
// Assert storage "Preimage::RequestStatusFor::ah_post::consistent"
assert!(
alias::RequestStatusFor::<T>::contains_key(key.0),
"Preimage::RequestStatusFor is missing"
Expand All @@ -273,6 +274,7 @@ impl<T: Config> crate::types::AhMigrationCheck for PreimageChunkMigrator<T> {
}

// All items have been successfully migrated from the relay chain
// Assert storage "Preimage::PreimageFor::ah_post::correct"
for (hash, len) in rc_pre_payload.iter() {
// Pallet scheduler currently unrequests and deletes preimage with hash
// 0x7ee7ea7b28e3e17353781b6d9bff255b8d00beffe8d1ed259baafe1de0c2cc2e and len 42
Expand All @@ -286,6 +288,7 @@ impl<T: Config> crate::types::AhMigrationCheck for PreimageChunkMigrator<T> {
}

// All AssetHub items came from the relay chain
// Assert storage "Preimage::PreimageFor::ah_post::correct"
for (hash, len) in alias::PreimageFor::<T>::iter_keys() {
// Preimages for referendums that did not pass on the relay chain can be noted when
// migrating to Asset Hub.
Expand All @@ -295,6 +298,7 @@ impl<T: Config> crate::types::AhMigrationCheck for PreimageChunkMigrator<T> {
}

// Integrity check that all preimages have the correct hash and length
// Assert storage "Preimage::PreimageFor::ah_post::consistent"
for (hash, len) in alias::PreimageFor::<T>::iter_keys() {
let preimage = alias::PreimageFor::<T>::get((hash, len)).expect("Storage corrupted");

Expand All @@ -311,6 +315,7 @@ impl<T: Config> crate::types::AhMigrationCheck for PreimageRequestStatusMigrator

fn pre_check(_rc_pre_payload: Self::RcPrePayload) -> Self::AhPrePayload {
// AH does not have a preimage pallet, therefore must be empty.
// Assert storage "Preimage::RequestStatusFor::ah_pre::empty"
assert!(
alias::RequestStatusFor::<T>::iter_keys().next().is_none(),
"Preimage::RequestStatusFor is not empty"
Expand All @@ -333,6 +338,7 @@ impl<T: Config> crate::types::AhMigrationCheck for PreimageRequestStatusMigrator
for (hash, requested) in rc_pre_payload.iter() {
// Pallet scheduler currently unrequests and deletes preimage with hash
// 0x7ee7ea7b28e3e17353781b6d9bff255b8d00beffe8d1ed259baafe1de0c2cc2e and len 42
// Assert storage "Preimage::RequestStatusFor::ah_post::correct"
if !alias::RequestStatusFor::<T>::contains_key(hash) {
log::warn!(
"Relay chain Preimage::RequestStatusFor storage item with key {:?} is not found on assethub",
Expand Down Expand Up @@ -376,6 +382,7 @@ impl<T: Config> crate::types::AhMigrationCheck for PreimageRequestStatusMigrator
}
}

// Assert storage "Preimage::PreimageFor::ah_post::consistent"
assert_eq!(
alias::PreimageFor::<T>::iter_keys().count(),
alias::RequestStatusFor::<T>::iter_keys().count(),
Expand All @@ -391,6 +398,7 @@ impl<T: Config> crate::types::AhMigrationCheck for PreimageLegacyRequestStatusMi

fn pre_check(_rc_pre_payload: Self::RcPrePayload) -> Self::AhPrePayload {
// AH does not have a preimage pallet, therefore must be empty.
// Assert storage "Preimage::StatusFor::ah_pre::empty"
assert!(
alias::StatusFor::<T>::iter_keys().next().is_none(),
"Preimage::StatusFor is not empty on the relay chain"
Expand All @@ -399,6 +407,7 @@ impl<T: Config> crate::types::AhMigrationCheck for PreimageLegacyRequestStatusMi

fn post_check(_rc_pre_payload: Self::RcPrePayload, _ah_pre_payload: Self::AhPrePayload) {
// All items have been deleted
// Assert storage "Preimage::StatusFor::ah_post::correct"
assert!(
alias::StatusFor::<T>::iter_keys().next().is_none(),
"Preimage::StatusFor is not empty on assetHub"
Expand Down
1 change: 1 addition & 0 deletions pallets/ah-migrator/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ impl<T: Config> crate::types::AhMigrationCheck for ProxyProxiesMigrator<T> {

log::info!(target: LOG_TARGET, "Total number of proxies: {}", count);
// TODO: This is not necessarily correct, since some proxy types are not migrated.
// Assert storage "Proxy::Proxies::ah_post::length"
if count < rc_pre_payload {
panic!(
"Some proxies were not migrated. Expected at least {} proxies, got {}",
Expand Down
5 changes: 5 additions & 0 deletions pallets/ah-migrator/src/staking/bags_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ impl<T: Config> crate::types::AhMigrationCheck for BagsListMigrator<T> {
type AhPrePayload = ();

fn pre_check(_: Self::RcPrePayload) -> Self::AhPrePayload {
// Assert storage "VoterList::ListNodes::ah_pre::empty"
assert!(
alias::ListNodes::<T>::iter().next().is_none(),
"ListNodes should be empty before migration starts"
);

// Assert storage "VoterList::ListBags::ah_pre::empty"
assert!(
alias::ListBags::<T>::iter().next().is_none(),
"ListBags should be empty before migration starts"
Expand Down Expand Up @@ -112,6 +115,8 @@ impl<T: Config> crate::types::AhMigrationCheck for BagsListMigrator<T> {
});
}

// Assert storage "VoterList::ListNodes::ah_post::correct"
// Assert storage "VoterList::ListBags::ah_post::correct"
assert_eq!(
rc_pre_payload, ah_messages,
"Bags list data mismatch: Asset Hub data differs from original Relay Chain data"
Expand Down
7 changes: 3 additions & 4 deletions pallets/ah-migrator/src/vesting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ impl<T: Config> crate::types::AhMigrationCheck for VestingMigrator<T> {

fn pre_check(_: Self::RcPrePayload) -> Self::AhPrePayload {
let vesting_schedules: Vec<_> = pallet_vesting::Vesting::<T>::iter().collect();
assert!(
vesting_schedules.is_empty(),
"Vesting schedules should be empty before migration starts"
);
assert!(vesting_schedules.is_empty(), "Assert storage 'Vesting::Vesting::ah_pre::empty'");
}

fn post_check(rc_pre_payload: Self::RcPrePayload, _: Self::AhPrePayload) {
Expand Down Expand Up @@ -137,6 +134,8 @@ impl<T: Config> crate::types::AhMigrationCheck for VestingMigrator<T> {
})
.collect();

// Assert storage "Vesting::Vesting::ah_post::correct"
// Assert storage "Vesting::Vesting::ah_post::length"
assert_eq!(
rc_pre,
all_post,
Expand Down
2 changes: 1 addition & 1 deletion pallets/rc-migrator/src/indices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ impl<T: Config> crate::types::RcMigrationCheck for IndicesMigrator<T> {

fn post_check(_: Self::RcPrePayload) {
let index = pallet_indices::Accounts::<T>::iter().collect::<Vec<_>>();
assert_eq!(index, vec![], "All indices should be removed from the Relay");
assert_eq!(index, vec![], "Assert storage 'Indices::Accounts::rc_post::empty'");
}
}
2 changes: 1 addition & 1 deletion pallets/rc-migrator/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,6 @@ impl<T: Config> RcMigrationCheck for ProxyProxiesMigrator<T> {

fn post_check(_: Self::RcPrePayload) {
let count = pallet_proxy::Proxies::<T>::iter_keys().count();
assert_eq!(count, 0, "All proxies are removed from the relay");
assert_eq!(count, 0, "Assert storage 'Proxy::Proxies::rc_post::empty'");
}
}
1 change: 1 addition & 0 deletions pallets/rc-migrator/src/vesting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ impl<T: Config> crate::types::RcMigrationCheck for VestingMigrator<T> {
}

fn post_check(_: Self::RcPrePayload) {
// Assert storage "Vesting::Vesting::rc_post::empty"
assert!(
pallet_vesting::Vesting::<T>::iter().next().is_none(),
"Vesting storage should be empty after migration"
Expand Down
Loading