-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Replace immutable with constant for _PERMIT_TYPEHASH #3196
Conversation
This commit is related to the following issue discussion: OpenZeppelin/contracts-wizard#89 (comment) Since Solidity version `0.6.12` the `keccak256` of string literals is treated specially and the hash is evaluated at compile time. Since the OpenZeppelin Wizard also uses `constant` for OpenZeppelin's AccessControl's roles declarations, it's good practice to make this consistent.
Hello @pcaversaccio This indeed looks like a significant improvement. It, unfortunately, causes issues with the way our contract are transpiled to the upgradeable version. The immutable version is currently transpiled to "normal" storage: which must be initialized: This is not great. If we apply the changes you propose, we would end up with an upgradeable version that contains one less storage slot. We may be able to fix that by increasing the gap, but the upgrade plugin would consider that an error. The bottom line is yes, we will fix that, but we need to improve the upgrade plugins in order for that fix to be transparent to users of upgradeable contracts. |
@Amxx In light of this discussion, it could be useful to add an additional test to the GitHub actions that check the transpiled contracts for possible warnings/errors for every new PR. |
@pcaversaccio Yes, 100%. |
Blocked on OpenZeppelin/openzeppelin-transpiler#86. |
This is unblocked now: a new version of the transpiler has been released with a |
immutable
with constant
for _PERMIT_TYPEHASH
AFAIK, we have 2 options:
Will will continue to reserve a slot, but not use it anymore. |
@Amxx before we make any further adjustments wouldn't be a good idea to add a further CI transpile test? Concerning your suggestion above I personally would prefer the second option since it implements certain transparency in the code. I would go even further and add a further natspec: bytes32 private constant _PERMIT_TYPEHASH = "...."
/**
* @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.
* However, to ensure consistency with the upgradable transpiler, we will continue
* to reserve a slot.
* @custom:oz-renamed-from _PERMIT_TYPEHASH
*/
bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT; |
Having an automated CI test to check storage compatibility is on the roadmap. Since the transpiler just received significant change, we will check everything manually, and use what we learn in the process to design the CI check |
Lets get that merged. |
It makes sense to reserve the previously used spot so 👍 to |
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
That is being addresses in #3252 unless you want to do it here directly |
Probably it would make sense to put everything related to |
the contract size will be overridden in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @frangio any final words?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good thank you!
This commit is related to the following issue discussion: OpenZeppelin/contracts-wizard#89 (comment)
Since Solidity version
0.6.12
thekeccak256
of string literals is treated specially and the hash is evaluated at compile time. Since the OpenZeppelin Wizard also usesconstant
for OpenZeppelin's AccessControl's roles declarations, it's good practice to make this consistent.PR Checklist