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

0 stars 0 forks source link

redundant function argument #192

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

egjlmn1

Vulnerability details

Impact

functions outboundTransfer and finalizeInboundTransfer in L1LPTGateway.sol and L2LPTGateway.sol have the argument address _l1Token but they require it to always be the state variable l1Lpt which makes the argument redundant since its better to just copy the variable instead of receiving it in the function arguments and than checking its validation.

Proof of Concept

having an extra argument in the function waste more gas than saving the state variable in a memory variable (instead of calldata int the function argument) Checked on Remix, save over 300 gas every function call. which is a lot

Tools Used

Manual code review

Recommended Mitigation Steps

remove the argument from the function declaration and create a local variable and set it to l1Lpt instead

yondonfu commented 2 years ago

Won't change because the arg is needed for the Arbitrum GatewayRouter contracts on L1 and L2.

https://github.com/OffchainLabs/arbitrum/blob/master/packages/arb-bridge-peripherals/contracts/tokenbridge/libraries/gateway/GatewayRouter.sol#L94