code-423n4 / 2022-01-livepeer-findings

0 stars 0 forks source link

Immutable variables #213

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

defsec

Vulnerability details

Impact

'immutable' greatly reduces gas costs. There are variables that do not change so they can be marked as immutable to greatly improve the gas costs.

Proof of Concept

  1. For instance : https://github.com/livepeer/arbitrum-lpt-bridge/blob/ebf68d11879c2798c5ec0735411b08d0bea4f287/contracts/L2/pool/DelegatorPool.sol#L50

Tools Used

Code Review

Recommended Mitigation Steps

Mark variables as immutable.

yondonfu commented 2 years ago

In the referenced contract, the variables cannot be immutable because they need to be set in an initialize() function.

0xleastwood commented 2 years ago

Agree, immutable variables must be set within the constructor.