-
Notifications
You must be signed in to change notification settings - Fork 139
[AHM] Do not pause inherents 🙈 #609
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Oliver Tale-Yazdi <[email protected]>
acatangiu
approved these changes
Feb 27, 2025
x3c41a
approved these changes
Feb 27, 2025
1 task
fellowship-merge-bot bot
added a commit
that referenced
this pull request
Sep 24, 2025
A high-level look of the migration is this: <img width="1204" height="745" alt="Screenshot 2025-09-17 at 18 23 57" src="https://github.com/user-attachments/assets/1fb39ef8-5efa-4db2-81db-6dd775af3a39" /> You can see the main components being the `pallet_rc_migrator` and `pallet_ah_migrator`. The RC migrator pallet takes data out of the RC storage and enqueues it for AH through XCM::Transact calls to the AH migrator pallet. Each pallet on the RC side has a migrator module that handles the removal of the old data and creation of the messages for AH. AH then processes these messages through the MQ pallet and acknowledges back to RC that they were processed (not shown in the graphic). There is rate-limiting code in place to prevent it from overloading the DMP queue or Asset Hub. ## For Reviewers The review comments are being addressed in #915. We need eyes on the Core part that is described below. ## Core STM The main stage transitions look like this. The only manual part is the scheduling call by the fellowship that kicks off the procedure: * `Pending` wait for Fellowship to call `schedule_migration(when)` -> Scheduled * `Scheduled` waiting for scheduled block -> `WaitingForAH` * `WaitingForAH` AH replies that it is ready -> `WarmUp` * `WarmUp` waiting for warm-up end -> `Starting` * `Starting` doing some startup initialization -> `DataMigration` * `DataMigration` MAIN PART **all pallet migrations finish** -> `CoolOff` * `CoolOff` waiting for cool-off to end -> `SignalMigrationFinish` * `SignalMigrationFinish` send signal to AH that we are done -> `MigrationDone` * `MigrationDone` finished, unlock all Pallets. ### State Machine The core State Machine lives in the `RcMigrator` pallet in its `on_initialize`: https://github.com/polkadot-fellows/runtimes/blob/8ef1cc739d756b109dc93eaf3b9da00e3dcf1383/pallets/rc-migrator/src/lib.rs#L1338-L1342 On each block the Rc Migrator checks the current state and possibly progresses to the next one. It will only do a single state transition per block to reduce complexity of the code. Generally, there are three states per pallet (called [*stages*](https://github.com/polkadot-fellows/runtimes/blob/8ef1cc739d756b109dc93eaf3b9da00e3dcf1383/pallets/rc-migrator/src/lib.rs#L190-L389) in the code). Some pallets have more then three, but it is generally still a multiple of three and always follows the pattern of `PalletInit`, `PalletOngoing { cursor }`, `PalletDone`: https://github.com/polkadot-fellows/runtimes/blob/8ef1cc739d756b109dc93eaf3b9da00e3dcf1383/pallets/rc-migrator/src/lib.rs#L239-L244 Each pallet then has one migrator struct (eg. `MultisigMigrator<T>`) that migrates the storage items from the Relay side. It lives in the module of its name `rc-migrator/src/multisig.rs` respectively. Taking Multisigs as an example; you can find two functions in the migrator struct: `migrate_many` and `migrate_single`. The former one is from the [`PalletMigration` trait](https://github.com/polkadot-fellows/runtimes/blob/715dbb4455a127066d0118ce7a096c72200e1126/pallets/rc-migrator/src/types.rs#L209-L221). The `migrate_single` function is done by convention to keep the code readable. The `migrate_many` does the following: - Weight accounting for the RC side: Normal weight tracking to not have overtime RC blocks - Weight accounting for the AH side: Ensuring to not send messages that would take up too much weight on AH processing - Ensure that DMP messages are sensibly sized by using the `XcmBatchAndMeter` - Taking the data out from the Relay chain (deleting it) - Including the data into a DMP message and sending it towards AH ### AH Side The main logic on Asset Hub lives in the `AhMigrator` pallet. It contains at least one extrinsic per pallet to receive the incoming data from the RC. We are using extrinsics since RC is wrapping the data into XCM::Transacts: https://github.com/polkadot-fellows/runtimes/blob/9a20b12e22b019c1c0b15b9af897567a559e424c/pallets/ah-migrator/src/lib.rs#L650-L653 This calls into the [`multisig` module](https://github.com/polkadot-fellows/runtimes/blob/6b603ca47e5c49b3a898be3f8f6b078c424f42a0/pallets/ah-migrator/src/multisig.rs#L37) to integrate the data into the storage. Per convention we are emitting events for each item and the whole batch. The main task of the AH side is to integrate the data. In the example of the multisig it is special since we do not migrate the multisig, but only the reserved account which will be unreserved on AH. ## Messaging Logic The messaging is ACK based. The Relay sends message to Asset Hub up to a specified limit (50). The limit can be adjusted on the fly through a dedicated dispatchable call, restricted to Admin and Manager roles. The limit may be overstepped by the configured batch-size (10), so in total there should never be more than 60 DMPs queued. Each DMP is set to at most [50KB](https://github.com/polkadot-fellows/runtimes/blob/8ef1cc739d756b109dc93eaf3b9da00e3dcf1383/pallets/rc-migrator/src/lib.rs#L131). The Relay Chain migrator creates a query for each XCM data message using the XCM query–response primitives and attaches a response status request from Asset Hub to the message. The XCM executor on Asset Hub then sends back the response status for every message with such a request. The Relay migrator stores each data message sent to Asset Hub until it receives confirmation of successful processing. It also provides a dispatchable call, available only to Admin and Manager roles, to resend any unconfirmed messages. A bug that prevented certain messages from being accounted for during a particulat pallet migration caused the Westend AHM stall. The system was queuing too many DMPs, which forced WAH to author an overweight block while attempting to process them all at once. ## Call Filtering Pallet calls are filtered during the migration for three reasons: - prevent malicious users from spamming the chain with cheap TX and slowing down the migration - prevent users from sending many UMPs out of AH to clog up the UMP queue - prevent interference with pallets that are being migrated to avoid messing up their storage invariants Both RC and AH provide call filters for `Before`, `During` and `After` the migration. As you can see, most things are disabled during the migration on both chains. After the migration, Relay chain keeps pretty much everything disabled since it was now enabled on AH: - Before: RC everything enabled, AH all new pallets disabled (staking, gov etc) - During: RC mostly everything disabled, AH mostly everything disabled - After: RC mostly everything disabled (staking, gov etc), AH everything enabled (staking, gov etc) This is implemented by returning three bools, one for each phase: https://github.com/polkadot-fellows/runtimes/blob/88f4aaf62236fbee9cfb9183e44333bac45b1371/system-parachains/asset-hubs/asset-hub-polkadot/src/ah_migration/call_filter.rs#L81-L83 ## Testing and Dry-Runs https://github.com/paritytech/ahm-dryrun is the repository for testing infrastructure for AHM. As of now, the following is being tested there (as a part of "[AHM Flow (all steps)](https://github.com/paritytech/ahm-dryrun/actions/workflows/zombie-bite.yml)" nightly action): * Dry-running a migration on a fork of Kusama * Re-running the rust unit tests introduced in this branch * Re-running a subset of the same tests, re-written in TS * Re-running PET tests. Each action produces a table with the summary of the test results: <img width="682" height="357" alt="Screenshot 2025-09-19 at 09 03 20" src="https://github.com/user-attachments/assets/69c1e37d-6f8f-4b57-b97f-75781a1e1a3a" /> And 4 snapshot files (2 real databases, 2 try-runtime snapshots) which can be used to re-run any of the tests, or run the pre/post migration chain, locally. <img width="1347" height="476" alt="Screenshot 2025-09-19 at 09 03 40" src="https://github.com/user-attachments/assets/127cbf76-b2fb-467f-8fef-3e93a9a709f6" /> <details><summary>Full Changelog</summary> <p> - **[AHM] OpenGov for Kusama AH (#877)** - **Relay Chain Accounts to Asset Hub Migration (#515)** - **Test Relay<->AH migration through DMP messages (#528)** - **[AHM] Improve account migration (#532)** - **[AHM] Add multisig migration (#534)** - **[AHM] Proxy migration (#542)** - **[AHM] Cleanup and add Preimage doc (#543)** - **[AHM] Improve accounts migration (#550)** - **[AHM] Preimage migration (#545)** - **[AHM] Add Polkadot call filtering (#559)** - **[AHM] Nomination pools (#562)** - **[AHM] referenda pallet (#558)** - **[AHM] Cleanup (#565)** - **[AHM] Scheduler Pallet (#569)** - **[AHM] Fast unstake and Bags list (#563)** - **[AHM] Pallet claims (#570)** - **[AHM] Conviction Voting Pallet (#578)** - **[AHM] Pallet Indices (#577)** - **[AHM] pause scheduler during migration (#580)** - **[AHM] Asset rate pallet migration (#581)** - **[AHM] Bounties data migration (#585)** - **[AHM] Vesting (#575)** - **[AHM] fix the rc-migrator call filter (#598)** - **[AHM] Sovereign Account Translation (#594)** - **[AHM] Crowdloans (#592)** - **[AHM] Set up AH migration testing framework for single pallets (#597)** - **[AHM] Stage management (#584)** - **[AHM] Do not pause inherents 🙈 (#609)** - **[AHM] Relay Chain accounts' reserves (#602)** - **[AHM] Benchmarks (#589)** - **[AHM] Pallet testing framework (#612)** - **[AHM] fix xcm weight at most (#617)** - **[AHM] Improve weight accounting for accounts migration (#618)** - **[AHM] AH acks messages from RC (#620)** - **[AHM] Pure Proxy Investigation (#621)** - **[AHM] Remove migrated items for pallet preimage and improve testing (#619)** - **[AHM] Referenda metadata (#633)** - **[AHM] Fix accounts migration failures (#628)** - **[AHM] refactor events and enable scheduled migration start (#634)** - **[AHM] Migrating DOT total issuance tracking from RC to AH (#607)** - **[AHM] Comment faulty checks out (#640)** - **Account migrator refactor (#639)** - **[AHM] Rebase (#641)** - **[AHM] Run AHM test in CI (#642)** - **[AHM] Vesting test (#615)** - **[AHM] bags_list and conviction_voting tests (#632)** - **[AHM] Treasury pallet migration (#624)** - **[AHM] Fix tests for pallet preimage (#643)** - **[AHM] Test Coverage Report (#650)** - **[AHM] deactivate/reactivate total issuance & weights (#648)** - **[AHM] add sudo behind feature flag (#657)** - **[AHM] fast_unstake tests (#658)** - **[AHM] asset_rate test (#660)** - **[AHM] Pallet treasury tests (#664)** - **[AHM] Improve account balances integration tests (#655)** - **[AHM] Integrate AH migrator weights to RC (#665)** - **Testing for bounties migration (#669)** - **[AHM] Westend port adapters (#652)** - **[AHM] fix checking account and total issuance migration (#636)** - **[AHM] Bump polkadot relay and AH versions (#667)** - **[AHM] Fix tests for pallet treasury (#671)** - **[AHM] Claims and Crowdloan tests (#622)** - **[AHM] Benchmarks (#663)** - **[AHM] Add Asset Hub CallFilter (#670)** - **[AHM] Westend staking migration (#689)** - **[AHM] Referenda migration storage checks (#672)** - **[AHM] AH benchmarks cleanup (#690)** - **[AHM] Westend Async Staking Migration (#691)** - **[AHM] Relay Chain migrator benchmarks (#692)** - **[AHM] Asset Hub ops pallet benchmarks (#693)** - **[AHM] Xcm send weights and Batch helper types (#694)** - **Finish staking Westend (#695)** - **[AHM] Account provider/consumer references (#702)** - **[AHM] Fix westend builds (#704)** - **[AHM] Generate weights (#706)** - **[AHM] Proxy fixes and more tests (#707)** - **[AHM] Docs and simpler events (#699)** - **[AHM] Test call decoding (#710)** - **[AHM] Emulated test for migration with async backing (#717)** - **[AHM] Increase test coverage (#720)** - **[AHM] Add referenda checks to Westend migration (#713)** - **[AHM] Nom_pools test (#677)** - **[AHM] Scheduler storage item checks (#680)** - **[AHM] Update Polkadot Snapshot (#725)** - **[AHM] Pallet multisig tests (#666)** - **[AHM] Adapt XCM configuration to account for changes before and after migration (#722)** - **[AHM] document checking account migration (#716)** - **[AHM] Dependency fixes for integration tests and the Polkadot runtime (#751)** - **[AHM] Remove empty conviction voting filter (#750)** - **[AHM] Missing TODOs and `AccountState` type update (#742)** - **[AHM] DMP prioritization on AH (#772)** - **[AHM] Disable #[pallet::hooks] for migrating pallets during migration (#784)** - **[AHM] AH messages prioritization on RC (#787)** - **[AHM] Cache test snapshots and include more tests into CI job (#788)** - **[AHM] Cleanup Westend feature (#789)** - **[AHM] Introducing the Cool-Off stage (#786)** - **[AHM] Flow Control System (#780)** - **[AHM] Migrate pallet delegated-staking to AH (#791)** - **[AHM] Merge master into dev branch (#793)** - **[AHM] Disable indirect XCMs from RC to AH and vice versa during migration (#774)** - **Rebase** - **bring back RelayTreasuryLocation to make old tests compiole** - **[AHM] Missing `RootLocation` for WaivedLocation for AHP (#798)** - **[AHM] Missing `SecretaryEntities` for AHP (#797)** - **[AHM] Migration idempotency (#808)** - **[AHM] Block number providers for migrating pallets (#809)** - **[AHM] Copy latest ah-ops pallet from the SDK (#810)** - **[AHM / ah-migrator]: Implement RC->AH account translation `mocked` migration across all involved pallets (#807)** - **[AHM] Complete account balances tests (#674)** - **[AHM] Address TODOs (#815)** - **[AHM] Async staking config (#812)** - **[AHM] Optional migration manager account id (#818)** - **[AHM] Type safe Hold and Freeze-Reason translation (#819)** - **[AHM] Create new response query on resend and tests (#816)** - **PolkadotAssetHub: Enable Async Backing (#763)** - **Ensure no era planned when migration starts (#728)** - **[AHM] with async backing (#822)** - **[AHM] Staking migration (#821)** - **identify with only validator account** - **[AHM] Tests work for Paseo (#827)** - **[AHM] Child bounties (#613)** - **[AHM] Cleanup and linter fixes (#828)** - **[AHM] Fix snowbridge test - wrong import of `RelayTreasuryPalletAccount` (instead of AH, it should be BH) (#831)** - **[AHM] Account Translation mapping (#829)** - **Fast unstake: remove alias** - **fmt** - **[AHM] Max migrated items per block (#834)** - **[AHM] Record migration timings (#835)** - **[AHM] Remove storage aliases and cleanup (#832)** - **[AHM] fix Kusama bags list pallet benchmarks (#836)** - **[AHM] Unprocessed msg buffer size 50 (#839)** - **[AHM] Post migration cool off stage (#841)** - **[AHM] Multisig test and storage_alias cleanup (#842)** - **[AHM] Remove fast-unstake and test fixes (#846)** - **Run try-state check for all pallets post AHM rust tests (#833)** - **[AHM] Preserve on RC manager' account (#843)** - **[AHM] Filter staking calls before migration starts (#847)** - **[AHM] State Decode Tests (#848)** - **[AHM] Send xcm extrinsic within migrator pallets (#851)** - **Merge and cleanup merge commit** - #845 - #852 - #862 - #875 - #872 - #877 - #626 - #879 - #885 - #886 - #882 - #883 - #854 - #888 - #895 - #892 - #896 - #889 </p> </details> // only to let all CIs to execute for now - [ ] Does not require a CHANGELOG entry --------- Signed-off-by: Oliver Tale-Yazdi <[email protected]> Signed-off-by: Adrian Catangiu <[email protected]> Signed-off-by: Andrei Sandu <[email protected]> Signed-off-by: Alexandru Vasile <[email protected]> Co-authored-by: Muharem <[email protected]> Co-authored-by: Dónal Murray <[email protected]> Co-authored-by: Adrian Catangiu <[email protected]> Co-authored-by: Giuseppe Re <[email protected]> Co-authored-by: Andrii <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Yuri Volkov <[email protected]> Co-authored-by: s0me0ne-unkn0wn <[email protected]> Co-authored-by: Kian Paimani <[email protected]> Co-authored-by: Branislav Kontur <[email protected]> Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Francisco Aguirre <[email protected]> Co-authored-by: fellowship-merge-bot[bot] <151052383+fellowship-merge-bot[bot]@users.noreply.github.com> Co-authored-by: Pablo Andrés Dorado Suárez <[email protected]> Co-authored-by: ordian <[email protected]> Co-authored-by: Alistair Singh <[email protected]> Co-authored-by: Sergej Sakac <[email protected]> Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Serban Iorga <[email protected]> Co-authored-by: Xiliang Chen <[email protected]> Co-authored-by: Nikolai Kozlov <[email protected]> Co-authored-by: nkprt <[email protected]> Co-authored-by: Eugenio Paluello <[email protected]> Co-authored-by: Javier Viola <[email protected]> Co-authored-by: polka.dom <[email protected]> Co-authored-by: Dónal Murray <[email protected]> Co-authored-by: Karol Kokoszka <[email protected]> Co-authored-by: joe petrowski <[email protected]> Co-authored-by: Clara van Staden <[email protected]> Co-authored-by: Ankan <[email protected]> Co-authored-by: clangenb <[email protected]> Co-authored-by: Andrei Sandu <[email protected]> Co-authored-by: Andrei Sandu <[email protected]> Co-authored-by: Alexandre Baldé <[email protected]> Co-authored-by: Maksym H <[email protected]> Co-authored-by: Alin Dima <[email protected]> Co-authored-by: Alexander Theißen <[email protected]> Co-authored-by: Christian Langenbacher <[email protected]> Co-authored-by: Ankan <[email protected]> Co-authored-by: Karol Kokoszka <[email protected]> Co-authored-by: brenzi <[email protected]> Co-authored-by: Doordashcon <[email protected]> Co-authored-by: eskimor <[email protected]> Co-authored-by: Robert <[email protected]> Co-authored-by: Raymond Cheung <[email protected]> Co-authored-by: Maciej <[email protected]> Co-authored-by: Paolo La Camera <[email protected]> Co-authored-by: kianenigma <[email protected]> Co-authored-by: Alexandru Vasile <[email protected]> Co-authored-by: Alexander Cyon <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Merges into the AHM branch