Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A0-3894: A0-3891 A0-3892 Added pallet-balances-maintenance.py (#1579)
# Description Script for maintenance operations on AlephNode chain with regard to pallet balances. It has the following functionality: * workaround for bug https://github.com/paritytech/polkadot-sdk/pull/2700/files, that make sure all accounts have at least ED as their free balance, * programmatic support for sending Balances.UpgradeAccounts ext for all accounts, * checking pallet balances and account reference counters invariants. By default, it connects to an AlephZero Testnet and performs sanity checks only ie not changing state of the chain at all. Accounts that do not satisfy those checks are written to `accounts-with-failed-invariants.json file`. ## Type of change Please delete options that are not relevant. - New feature (non-breaking change which adds functionality) ## Testing 1) Base functionality (only check invariants for all accounts), regardless 11 or 12 version: `./pallet-balances-maintenance.py --ws-url <test-chain-url>` ``` 2024-01-22 13:01:55,530 [INFO] Connected to Aleph Node: Aleph Zero Development 0.11.4-b7e984c756d 2024-01-22 13:01:55,591 [INFO] Major version of chain connected to is ChainMajorVersion.PRE_12_MAJOR_VERSION 2024-01-22 13:01:56,366 [INFO] Existential deposit is 5e-10 DZERO 2024-01-22 13:01:56,366 [INFO] Performing pallet balances sanity checks. 2024-01-22 13:01:58,548 [INFO] Checked 5000 accounts [...] 2024-01-22 13:03:02,316 [INFO] Checked 190000 accounts 2024-01-22 13:03:02,976 [INFO] Total accounts that match given predicate 'account invariants' is 192885 2024-01-22 13:03:03,280 [INFO] All accounts on chain Aleph Zero Development meet balances invariants. 2024-01-22 13:03:03,280 [INFO] DONE ``` 2) On 11 version, fixing free balance for accounts that would be invalid in 12 version `./pallet-balances-maintenance.py --ws-url <test-chain-url> --fix-free-balance` ``` 2024-01-22 13:03:46,232 [INFO] Connected to Aleph Node: Aleph Zero Development 0.11.4-b7e984c756d 2024-01-22 13:03:46,292 [INFO] Major version of chain connected to is ChainMajorVersion.PRE_12_MAJOR_VERSION 2024-01-22 13:03:47,044 [INFO] Existential deposit is 5e-10 DZERO 2024-01-22 13:03:47,050 [INFO] Using following account for transfers: 5D34dL5prEUaGNQtPPZ3yN5Y6BnkfXunKXXz6fo7ZJbLwRRH 2024-01-22 13:03:47,050 [INFO] Will send at most 64 transfers in a batch. 2024-01-22 13:03:47,051 [INFO] Looking for accounts that would be dust in 12 version. 2024-01-22 13:03:49,350 [INFO] Checked 5000 accounts [...] 2024-01-22 13:04:53,972 [INFO] Checked 190000 accounts 2024-01-22 13:04:54,612 [INFO] Total accounts that match the given predicate 'account valid in pre-12 version but not in 12 version' is 192885 2024-01-22 13:04:54,924 [INFO] Found 510 accounts that will be invalid in 12 version. 2024-01-22 13:04:54,929 [INFO] Wrote file 'dust-accounts.json' 2024-01-22 13:04:54,929 [INFO] Adjusting balances by sending transfers. [...] 2024-01-22 13:05:51,230 [INFO] Extrinsic included in block 0x7e592baddf44c2b9d8f19fb35c5882aeacf64870159b799a4e3aafec9d973824: Paid 0.011088659408 DZERO 2024-01-22 13:05:51,230 [INFO] Transfers done. ``` 3) on 12 version, upgrading all accounts `/pallet-balances-maintenance.py --ws-url <test-chain-url> --upgrade-accounts --upgrade-accounts-in-batch 1024` ``` 2024-01-22 13:30:12,608 [INFO] Connected to Aleph Node: Aleph Zero Development 0.11.4-b7e984c756d 2024-01-22 13:30:12,666 [INFO] Major version of chain connected to is ChainMajorVersion.AT_LEAST_12_MAJOR_VERSION 2024-01-22 13:30:13,450 [INFO] Existential deposit is 5e-10 DZERO 2024-01-22 13:30:13,456 [INFO] Using following account for upgrade_accounts: 5D34dL5prEUaGNQtPPZ3yN5Y6BnkfXunKXXz6fo7ZJbLwRRH 2024-01-22 13:30:13,457 [INFO] Will upgrade at most 1024 accounts in a batch. 2024-01-22 13:30:13,457 [INFO] Querying all accounts. 2024-01-22 13:30:16,667 [INFO] Checked 5000 accounts [...] 2024-01-22 13:31:26,236 [INFO] Checked 190000 accounts 2024-01-22 13:31:27,177 [INFO] Total accounts that match given predicate 'all accounts' is 193500 2024-01-22 13:31:27,917 [INFO] About to upgrade 1024 accounts, each with 5e-10 DZERO 2024-01-22 13:31:28,619 [INFO] Extrinsic included in block 0x37b61a0ad94b5971dbb6a4439aeadf883c8e6a63aab4eb44874ea2aac51ea69a: Paid 0.0 DZERO [...] ```
- Loading branch information