Open code423n4 opened 2 years ago
TomFrench
Increase gas costs on all onlyAdmin operations
onlyAdmin
The SLINGSHOT_ADMIN_ROLE variable is marked as constant: https://github.com/code-423n4/2021-10-slingshot/blob/f6e7a0a39e3267bbe3c7fe60d6074cbf54f5750f/contracts/Adminable.sol#L11
SLINGSHOT_ADMIN_ROLE
constant
This results in the keccak operation being performed whenever the variable is used, increasing gas costs relative to just storing the output hash. Changing to immutable will only perform hashing on contract deployment which will save gas.
keccak
immutable
See: https://github.com/ethereum/solidity/issues/9232#issuecomment-646131646
Change the variable to be immutable rather than constant
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#L11This 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: https://github.com/ethereum/solidity/issues/9232#issuecomment-646131646
Recommended Mitigation Steps
Change the variable to be
immutable
rather thanconstant