Near-One / near-plugins

Implementation of common patterns used for NEAR smart contracts.
Creative Commons Zero v1.0 Universal
27 stars 12 forks source link

`Upgradable`: don't deploy code if state migration fails #76

Closed mooori closed 1 year ago

mooori commented 1 year ago

It seems sub-optimal to me that a failed migration could leave a contract is a totally broken state and all we do as mitigation is warn people this might happen. I wonder if it makes sense to extend the upgrade plugin to include an optional string which is the name of the migration method. Then the promise produced by up_deploy_code could itself be a batch which includes both the deploy and the migration call. This would ensure that the migration and deploy are always atomic.

Edit: creating a batch promise with both deploy and migration is how we do it in Aurora Engine for example.

_Originally posted by @birchmd in https://github.com/aurora-is-near/near-plugins/pull/74#discussion_r1086796106_