wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.17k stars 283 forks source link

fetchIfDifferent returns differences: true 100% of the time for UUPS deployments #426

Open stshort opened 1 year ago

stshort commented 1 year ago

Describe the bug If you deploy a UUPS contract, the function fetchIfDifferent returns differences: true in the return object 100% of the time. This is because the transaction it uses to compare the transaction data seems to be the transaction which deployed the proxy contract, not the implementation contract. I would expect to be able to detect differences so I can write a proper skip function and utilize this helper, however because of this issue, it will report changes 100% of the time, regardless of whether contract data actually changed:

https://github.com/wighawag/hardhat-deploy/blob/master/src/helpers.ts#L973

This is the line the check fails at every time.

To Reproduce Steps to reproduce the behavior:

  1. Create a UUPS contract deployment script
  2. Specify a skip function that uses the fetchIfDifferent function to determine whether a deploy script should be skipped.
  3. Deploy the proxy contract
  4. Re-run the same deployment script. Notice that the skip function incorrectly determines there were changes, and will rerun the deployment.

Expected behavior If the actual implementation contract for a UUPS contract has changed, this should return differences: true. If no data has changed from the implementation contract, it should return differences: false.

This could be likely fixed by checking the deploy options to see if it is a proxy, and if so, use the transaction hash for the implementation contract instead of the proxy contract when fetching the contract data for this comparison.

versions

Additional context Add any other context about the problem here.