hardhat-zksync icon indicating copy to clipboard operation
hardhat-zksync copied to clipboard

fix: don't check for assignment if variable is immutable

Open gabspeck opened this issue 6 months ago • 0 comments

What :computer:

  • Do not check for state-variable-assignment if the variable is immutable

Why :hand:

  • immutable variables have their own separate check with state-variable-immutable, but adding an exception by annotating an immutable variable with @custom:oz-upgrades-unsafe-allow state-variable-immutable still triggers state-variable-assignment
  • OZ's UUPSUpgradeable contract on v5 uses an immutable variable annotated with @custom:oz-upgrades-unsafe-allow state-variable-immutable that passes validation with the OZ plugin but fails it with the zkSync one.
  • This is the behavior of the original upgradeable plugin: https://github.com/OpenZeppelin/openzeppelin-upgrades/blob/742415c28f8858fe93c0c21bc979414d90ed2ce6/packages/core/src/validate/run.ts#L513

Evidence :camera:

Include screenshots, screen recordings, or console output here demonstrating that your changes work as intended

cache/validations.json before:

        "errors": [
          {
            "kind": "delegatecall",
            "src": "@openzeppelin/contracts/utils/Address.sol:105"
          },
          {
            "kind": "state-variable-assignment",
            "name": "__self",
            "src": "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol:22"
          }
       ]

cache/validations.json after:

        "errors": [
          {
            "kind": "delegatecall",
            "src": "@openzeppelin/contracts/utils/Address.sol:105"
          }
        ]

gabspeck avatar Jul 26 '24 11:07 gabspeck