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

0 stars 0 forks source link

Function should be declared as external to save gas #218

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

SolidityScan

Vulnerability details

Description

Public functions that are never called by a contract should be declared external in order to conserve gas.

Impact

Smart Contracts are required to have effective Gas usage as they cost real money and each function should be monitored for the amount of gas it costs to make it gas efficient.

Public functions cost more Gas than external functions

PoC

The function l1CirculatingSupply is marked as public but not used anywhere.

https://github.com/livepeer/arbitrum-lpt-bridge/blob/ebf68d11879c2798c5ec0735411b08d0bea4f287/contracts/L2/gateway/L2LPTDataCache.sol#L88-L95

The following function should be declared as external to save gas

Recommended Mitigation Steps

Use the external state visibility for functions that are never called from the contract.

yondonfu commented 2 years ago

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

0xleastwood commented 2 years ago

There are no gas savings in marking a public function as external for Solidity version ^0.8.0.