substrate icon indicating copy to clipboard operation
substrate copied to clipboard

Multi-stage pallet-contracts v9 migration

Open Dinonard opened this issue 3 years ago • 2 comments

Summary

Using pallet-contracts V9 storage migration can result in huge PoV size, essentially stopping the block production. This happened on Shibuya testnet and hardfork was required to recover it.

To bypass this limitation, a multi-stage storage migration logic was introduced (https://github.com/AstarNetwork/Astar/pull/803). This PR intends to add multi-stage migration logic directly into pallet-contracts, as requested in https://github.com/paritytech/substrate/issues/12908.

Personally I'm not sure if code such as this should be part of pallet-contracts or core substrate. I'm very much looking forward to review & comments :slightly_smiling_face: .

Solution Overview

A new extrinsic call migrate_storage is introduced. Caller has to specify the version to which migration is being done and can specify max allowed weight limit of the migration.

Extrinsic call is used because unlike on_initialize or on_idle logic, it gives more control in case something goes wrong. If we specify too large weigh limit, our call would just get rejected (or we could override in the tx queue).

The migration step will execute migration logic until weight limit has been reached. At this point, migration state is saved and can be reused in the following call to resume migration from the point where it stopped.

OPEN QUESTIONS

  • [ ] Do we want to emit event in case of successful migration step?
  • [ ] Do we want to introduce a flag via which we can enable/disable the migrate_storage extrinsic call?
  • [ ] Not sure if PoV size calculation is correct (seems to be an overestimate) so that needs to be checked.

Dinonard avatar Jan 04 '23 12:01 Dinonard

Hi @athei, here's my first proposal for the solution as discussed here.

I migrated solution used in Astar into pallet-contracts but expect things will need to be changed.

Before I start polishing and testing the PR, I'd like to get solution/design locked in.

Dinonard avatar Jan 04 '23 12:01 Dinonard

I will look into this. Just have my hands full right now. Thanks for the PR.

athei avatar Jan 17 '23 18:01 athei

Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Feb 17 '23 00:02 stale[bot]