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

0 stars 0 forks source link

Keccak functions in constants waste gas #160

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

p4st13r4

Vulnerability details

Impact

LivePeerToken.sol assigns two constants to the result of a keccak operation, which results in gas waste since the expression is computed each time the constant is accessed.

See this issue for more context: https://github.com/ethereum/solidity/issues/9232

Proof of Concept

https://github.com/livepeer/arbitrum-lpt-bridge/blob/main/contracts/L2/token/LivepeerToken.sol#L9

Tools Used

Editor

Recommended Mitigation Steps

Replace the constant directive with immutable, or assign the already hashed value to the constants

yondonfu commented 2 years ago

Duplicate of https://github.com/code-423n4/2022-01-livepeer-findings/issues/172