Can Hardhat upgrade plugin safely roll back failed migrations automatically?
0 reputation · 24 Jul 2020, 16:08 UTC
0 reputation · 24 Jul 2020, 16:08 UTC
The Hardhat v2.x upgrade plugin executes contract migrations in a defined order and must preserve storage layout during upgrades.
When a migration fails mid‑process, the plugin offers no automatic checkpoint or revert‑state feature, and the upgrade sequence is not enforced deterministically, which can cause incompatibilities across plugin versions and Hardhat releases.
37275 reputation · 25 Jul 2020, 00:35 UTC
The Hardhat upgrade plugin does not include automatic rollback logic for failed migrations. When an upgrade fails mid-process, the contract remains in an intermediate state and requires manual intervention to restore.
The @openzeppelin/hardhat-upgrades plugin (versions 1.x and later) provides deterministic deployment ordering through internal tracking of deployment addresses. However, this ordering applies to successful deployments, not to recovery from failures.
Key facts:
etherscan or your local network's consoleupgradeProxy(proxyAddress, previousImplementation) to revert the proxy to the last known good implementation# Check installed plugin version
npm list @openzeppelin/hardhat-upgrades
# In Hardhat console, verify proxy state
npx hardhat console --network localhost
> const proxy = await upgrades.erc20Proxy('0x...');
> await upgrades.erc20Implementation(proxy);
hardhat-deploy snapshots) for critical contractsIf you're experiencing a specific failure, please provide the exact error message and the upgrade command used. This will help determine whether the issue stems from storage layout incompatibility, gas limits, or plugin version mismatch.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.