How can Initializer be called again after upgrading?

It seems like when I use Upgrade Plugin's upgradeProxy function to update an implementation, the initialize function would not be called again. How can I make it so that the initializer does get called again? (for example if the update to the implementation is in the initializer?)

Hello @EgyptianCactus

Currently, it's not possible to re-initialize after an upgrade. This is an issue we are aware of. A fix should be available soon (it's one of our top priorities). Please understand that for a contract fix to be possible, we also need to drastically improve our plugins so that it is not seen as a storage violation.

1 Like

Thanks for the info! A follow up question: is the point of the plugins

  1. to provide some security checks, and
  2. so that we don't need to call the upgradeTo/upgradeToAndCall functions ourselves?

When you say plugins need to be drastically improved, does that mean I should still call the upgradeTo/upgradeToAndCall functions myself, instead of using the plugins, at least for now?

The point of the plugin is to help you perform secure upgrades. In particular, the plugin performs checks on the storage layouts, to ensure the upgrade is safe. The plugin will prevent upgrades that changes storage slots types, as this is likely an error.

We have plans to allow "re-initialization" with "step" tracking ... this however require to do a booluint8 update. If we do that change now, the plugin will see it as an error, so before we do the change we must teach the plugin to recognise this as a safe update.

1 Like

How do the initializer modifier work exactly? is the called only once check global (ie, it locks out every function with the initializer modifier), or enforced on a per-function bassis?

putting it in another way, can i work arround the limitation by creating "upgrades" initializer, giving the initializer the revision name (or something that guarantees the signature is different), and manually calling it after the update?

Initializers are per-proxy.

Re-initializers that can be used for upgrades are available in the release candidate for Contracts 4.6.

1 Like