Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: extend v1.7.2 transfer location migration #1858

Conversation

wischli
Copy link
Contributor

@wischli wischli commented Jun 4, 2024

Description

Extends #1853 by

  • Adding pre- and post-hooks
  • Adding a migration for Dev and Demo
  • Moving from hardcoded account id migration to account list per runtime
    • Dev has no storage entries which need to be migrated
    • Demo has 2 storage entries for the same account id which need to be migrated but since we don't use XCM messages on Demo, we can just purge them IMO

To be discussed

This PR is more aggressive with storage removal than the base one: It removes any old storage entry which cannot be decoded versus only removing, if it can be decoded and a new v4 location can be created.

My argument is that undecodable storage keys are always a pain to clean up. If new storage entries pop up in between proposing the RU and executing it, we can either push a hotfix PR afterwards migrating those keys or communicating that these users need to re-do their transfer allowlist call manually.

Another option would be exposing a migrate extrinsic in the pallet-transfer-allowlist for undecodable keys and keeping them in storage.

Checklist:

  • I have added Rust doc comments to structs, enums, traits and functions
  • I have made corresponding changes to the documentation
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works

@wischli wischli added the D8-migration Pull request touches storage and needs migration code. label Jun 4, 2024
@wischli wischli self-assigned this Jun 4, 2024
@wischli wischli requested a review from lemunozm June 4, 2024 14:45
Copy link

codecov bot commented Jun 4, 2024

Codecov Report

Attention: Patch coverage is 0% with 60 lines in your changes missing coverage. Please review.

Project coverage is 46.55%. Comparing base (b95b098) to head (995887e).
Report is 2 commits behind head on polkadot-v1.7.2-transfer-location.

Files Patch % Lines
...ntime/common/src/migrations/restricted_location.rs 0.00% 60 Missing ⚠️
Additional details and impacted files
@@                          Coverage Diff                          @@
##           polkadot-v1.7.2-transfer-location    #1858      +/-   ##
=====================================================================
- Coverage                              46.74%   46.55%   -0.20%     
=====================================================================
  Files                                    166      167       +1     
  Lines                                  13044    13076      +32     
=====================================================================
- Hits                                    6097     6087      -10     
- Misses                                  6947     6989      +42     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lemunozm
Copy link
Contributor

lemunozm commented Jun 5, 2024

My argument is that undecodable storage keys are always a pain to clean up. If new storage entries pop up in between proposing the RU and executing it, we can either push a hotfix PR afterwards migrating those keys or communicating that these users need to re-do their transfer allowlist call manually.

But how can we know we need to migrate them or re-do them if we remove all of them? Just because the transfer filter is not filtering as expected?

Copy link
Contributor

@lemunozm lemunozm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great improvement over the base migration @wischli! All cases are well tied 💯

Self::migrate_location_key(transfer_address.clone(), hash),
)),
(None, old::RestrictedTransferLocation::Xcm(_)) => {
log::warn!("{LOG_PREFIX} Account {account_id:?} missing in AccountMap despite old XCM location storage");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great check!

currency_id,
old_restricted_location,
// Leads to storage entry removal
// TODO: Discuss whether we are fine with removing such storage entries or whether we want to keep the old undecodable ones or maybe just use same account id per default instead of removing?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. removing such storage entries
  2. keep the old undecodable ones
  3. use same account id per default instead of removing

I would vote for 1. and 2.

// 4dTeMxuPJCK7zQGhFcgCivSJqBs9Wo2SuMSQeYCCuVJ9xrE2 --> 5Fc9NzKzJZwZvgjQBmSKtvZmJ5oP6B49DFC5dXZhTETjrSzo
pub AccountMap: Vec<(AccountId, AccountId)> = vec![
(
AccountId::new(hex_literal::hex!("5dbb2cec05b6bda775f7945827b887b0e7b5245eae8b4ef266c60820c9377185")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This account is 4dTeMxuPJCK7zQGhFcgCivSJqBs9Wo2SuMSQeYCCuVJ9xrE2 in hex, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

❯ subkey inspect 4dTeMxuPJCK7zQGhFcgCivSJqBs9Wo2SuMSQeYCCuVJ9xrE2
Public Key URI `4dTeMxuPJCK7zQGhFcgCivSJqBs9Wo2SuMSQeYCCuVJ9xrE2` is account:
  Network ID/Version: centrifuge
  Public key (hex):   0x5dbb2cec05b6bda775f7945827b887b0e7b5245eae8b4ef266c60820c9377185
  Account ID:         0x5dbb2cec05b6bda775f7945827b887b0e7b5245eae8b4ef266c60820c9377185
  Public key (SS58):  4dTeMxuPJCK7zQGhFcgCivSJqBs9Wo2SuMSQeYCCuVJ9xrE2

@lemunozm lemunozm mentioned this pull request Jun 5, 2024
52 tasks
@wischli
Copy link
Contributor Author

wischli commented Jun 5, 2024

But how can we know we need to migrate them or re-do them if we remove all of them? Just because the transfer filter is not filtering as expected?

I would say by looking at the logs at the time of the migration which I always do for runtime upgrades and we have access to historic storage by querying it for an older block hash in which it still existed.

The only upside for keeping it is that it is easier to reconstruct and check against on the runtime level.

@lemunozm
Copy link
Contributor

lemunozm commented Jun 5, 2024

Ok, then we can remove them. I think the probability to have new entries is low

@lemunozm
Copy link
Contributor

lemunozm commented Jun 5, 2024

You can merge it when you want 💯

@wischli wischli merged commit f457f22 into polkadot-v1.7.2-transfer-location Jun 5, 2024
9 of 15 checks passed
@wischli wischli added this to the Centrifuge 1029 milestone Jun 6, 2024
lemunozm added a commit that referenced this pull request Jun 6, 2024
* migration for restricted transfer location

* add correct location for centrifuge

* minor changes

* fix benchmarks

* fix IT compilation

* chore: extend v1.7.2 transfer location migration (#1858)

* feat: add pre + post-upgrade

* feat: add nuking migration for dev and demo

* fix: remove account list for demo

* refactor: Use `VersionedLocation` in `RestrictedTransferLocation` (#1861)

* feat: add pre + post-upgrade

* feat: add nuking migration for dev and demo

* fix: remove account list for demo

* refactor: use VersionedLocation

* fix: transfer allowlist benchmarks + tests

* fix: clippy

* fix: benchmark cli

* fix: revert tight coupling

* fmt

* fix IT compilation

---------

Co-authored-by: William Freudenberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
D8-migration Pull request touches storage and needs migration code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants