Skip to content

Commit

Permalink
A0-4022: Enable pallet contract migrations v12 to v15 (#1610)
Browse files Browse the repository at this point in the history
# Description

`polkadot-1.2.0` has a pallet contracts storage version 15, whereas the
current Testnet has 12. There are 3 migrations to be done:
* `v13` - due to change
paritytech/substrate#14079 storage map
`ContractInfoOf` receives a new field called `delegate_dependencies`.
This is a map that stores all contract account that calls this account
via low-level function `delegate_call` (e.g. used by contract upgrade
scenario). What `v13` migration does is just adds empty
`delegate_dependencies` field to each `ContractInfoOf` element (31 175
on AlephZero Testnet).
* `v14` - due to change
paritytech/substrate#14020 pallet contract start
to use Holds API over deprecated Reserve API. In practice, it changes
nothing, other than that for each account that is the owner of the
uploaded code, there will be `Balances.Holds` set for all such accounts
- holds as total still use reserved funds from `System.Accounts`. `v14`
migration iterates over all members of `CodeInfoOf` map. (6 502 on
AlephZero Testnet).
* `v15` - due to change
paritytech/substrate#14589 that essentially
reverts logic paritytech/substrate#13369 and v10
pallet contract migration, that added `deposit_account` field to
`ContractInfoOf`. The reason it was needed in the first place was the
change introduced in Substrate 0.9.42 version that required ED to be
present on free funds. `v15` migration iterates over all elements of
ContractInfoOf map and:
  * decrease consumer counter for a deposit account, 
* transfers all balance of the deposit account to the contract account,
  * hold that balance on the contract account,
  * reap deposit account.

# Testing

This change needs to be tested on feature net to measure impact on a
chain (prediction is that those will be significant migrations, at least
that heavy as in 12 release). To address that, we limited multi block
migration weight to 1/4 of max block weight,
  • Loading branch information
Marcin-Radecki authored Feb 20, 2024
1 parent 1e903b3 commit ebd98ce
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 132 deletions.
Loading

0 comments on commit ebd98ce

Please sign in to comment.