wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.18k stars 286 forks source link

Check abi compatibility #360

Open NadavPeled1998 opened 1 year ago

NadavPeled1998 commented 1 year ago

The PR aims to prevent bugs and issues created by breaking changes between an old contact and a new one. If the contract already has clients that use him, changing the ABI of the contract (e.g., while upgrading) can lead to some critical bugs. Even if we deploy a new version of our contract, we need to be sure that nothing will break in our frontend, backend, or other third-party consumers. If some stuff changes, it would be beneficial to have an auto-generated report that we could give to the relevant consumers.

Breaking changes according to this PR:

We solved this issue by adding a script that checks if there are breaking changes between the old ABI and the new ABI. This script runs before each deployment and validates that there are no breaking changes between the deployed contracts and the new ones. By default, if there are some breaking changes, the deployment would fail. If you still want to deploy the contracts, you need to add the flag "allowBreakingAbiCompatbility". If you have an artifact whose name is not the same as the contract name, you should add a JSON string with this data to the replace param. e.g. hardhat deploy --replace '{"contractName": "artifactName"}' It's also possible to export all the breaking changes to JSON files.

Also, there is a new task: 'validate-abi-compat'. In this task, you can check the ABI compatibility for a specific contract or all of them.

Possible Enhancements



This PR was created with @fullkomnun help 🙏