Use of constant keccak
variables results in extra hashing (and so gas).
#3
Labels
bug
Something isn't working
G (Gas Optimization)
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
TomFrench
Vulnerability details
Impact
Increase gas costs on all
onlyAdmin
operationsProof of Concept
The
SLINGSHOT_ADMIN_ROLE
variable is marked asconstant
:https://github.com/code-423n4/2021-10-slingshot/blob/f6e7a0a39e3267bbe3c7fe60d6074cbf54f5750f/contracts/Adminable.sol#L11
This results in the
keccak
operation being performed whenever the variable is used, increasing gas costs relative to just storing the output hash. Changing toimmutable
will only perform hashing on contract deployment which will save gas.See: ethereum/solidity#9232 (comment)
Recommended Mitigation Steps
Change the variable to be
immutable
rather thanconstant
The text was updated successfully, but these errors were encountered: