Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check abi compatibility #360

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

NadavPeled1998
Copy link

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:

  • Removal of a previously deployed function that had 'public'/'external' visibility
  • Change a previously deployed function that had 'public'/'external' visibility to 'internal'/'private' visibility.
  • Changing a previously deployed function's signature (name, order of arguments, or arguments types), which also changes its selector
  • Changing previously deployed function state mutability
  • Changing/removing a previously event selector
  • Changing/removing a previously custom error selector

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

  • Separate between breaking changes and low-priority changes


This PR was created with @fullkomnun help 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant