The linked constant declarations are meant to be assigned to the result of a keccak256 instruction. Contrary to the expected, constant variables are evaluated as expressions and as such the gas optimization of caching the result of the keccak256 instruction is actually not achieved here.
We advise the immutable keyword to be utilized instead to actually take advantage of the gas benefit of pre-calculating the keccak256 hash. For more information, consult this issue in the Solidity compiler.
SCS-01C: Inefficient Hash Constants
Description:
The linked
constant
declarations are meant to be assigned to the result of akeccak256
instruction. Contrary to the expected,constant
variables are evaluated as expressions and as such the gas optimization of caching the result of thekeccak256
instruction is actually not achieved here.Example:
Recommendation:
We advise the
immutable
keyword to be utilized instead to actually take advantage of the gas benefit of pre-calculating thekeccak256
hash. For more information, consult this issue in the Solidity compiler.