-
Notifications
You must be signed in to change notification settings - Fork 138
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
Use immutable
for OpenZeppelin AccessControl's Roles Declarations
#89
Comments
Your observation is correct about
|
Yeah, you are right - thanks for the clarification. For the sake of completeness, there is however a general issue that is still open: ethereum/solidity#3157. |
* replace `immutable` with `constant` for _PERMIT_TYPEHASH 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. * Update CHANGELOG * fix: ensure transpiler compatibility * fix: fixing var-name-mixedcase * prettier & lint check Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch> Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
* replace `immutable` with `constant` for _PERMIT_TYPEHASH 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. * Update CHANGELOG * fix: ensure transpiler compatibility * fix: fixing var-name-mixedcase * prettier & lint check Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch> Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Access roles marked as
constant
results in computing thekeccak256
operation each time the variable is used because assigned operations forconstant
variables are re-evaluated every time. Changing the variables toimmutable
results in computing the hash only once on deployment, leading to gas savings. Some background information can be found here and here.The text was updated successfully, but these errors were encountered: