Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various contracts - remove unused function parameters to save gas #331

Open
code423n4 opened this issue Dec 1, 2021 · 1 comment
Open
Labels
bug Something isn't working G (Gas Optimization) sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons

Comments

@code423n4
Copy link
Contributor

Handle

ScopeLift

Vulnerability details

Impact

Calldata costs 16 gas per non-zero byte and 4 gas per zero byte. Unused function parameters take up at least 32 bytes, which means unused parameters can cost between 128 and 512 gas

Proof of Concept

N/A

Tools Used

solc

Recommended Mitigation Steps

Remove the unused function parameters identified by the Solidity compiler. For examples like AbstractTransferVerification, the solidity compiler is wrong because it doesn't know you plan to override this function declaration. Instead, AbstractTransferVerification could be an interface without a function definition

contracts/AbstractTransferVerification.sol:9:27: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
  function verifyTransfer(address from, address to, uint256 amount) public view virtual returns (bool, string memory) {
                          ^----------^

contracts/AbstractTransferVerification.sol:9:41: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
  function verifyTransfer(address from, address to, uint256 amount) public view virtual returns (bool, string memory) {
                                        ^--------^

contracts/AbstractTransferVerification.sol:9:53: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
  function verifyTransfer(address from, address to, uint256 amount) public view virtual returns (bool, string memory) {
                                                    ^------------^

contracts/Auction.sol:605:7: Warning: Unused local variable.
      uint256 avgMaltPrice,
      ^------------------^

contracts/AuctionParticipant.sol:127:38: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
  function _handleRewardDistribution(uint256 rewarded) virtual internal {
                                     ^--------------^

contracts/AuctionPool.sol:136:27: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
  function _afterWithdraw(address account, uint256 amount) override internal {
                          ^-------------^

contracts/DexHandlers/UniswapHandler.sol:308:5: Warning: Unused local variable.
    address buyer;
    ^-----------^

contracts/MaltDataLab.sol:159:5: Warning: Unused local variable.
    uint256 rewardDecimals = rewardToken.decimals();
    ^--------------------^

contracts/MiningService.sol:26:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
    address _rewardToken,
    ^------------------^

contracts/PoolTransferVerification.sol:45:53: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
  function verifyTransfer(address from, address to, uint256 amount)
                                                    ^------------^

contracts/RewardSystem/RewardOverflowPool.sol:67:38: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
  function _handleRewardDistribution(uint256 amount) override internal {
@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Dec 1, 2021
code423n4 added a commit that referenced this issue Dec 1, 2021
@0xScotch 0xScotch added the sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons label Dec 9, 2021
@GalloDaSballo
Copy link
Collaborator

Agree with the finding, removing unused parameters will save some gas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working G (Gas Optimization) sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Projects
None yet
Development

No branches or pull requests

3 participants