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

Unused function parameters #154

Closed
code423n4 opened this issue Nov 17, 2021 · 3 comments
Closed

Unused function parameters #154

code423n4 opened this issue Nov 17, 2021 · 3 comments
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working duplicate This issue or pull request already exists

Comments

@code423n4
Copy link
Contributor

Handle

WatchPug

Vulnerability details

Unused function parameters increase contract size and gas usage at deployment.

https://github.com/code-423n4/2021-11-nested/blob/f646002b692ca5fa3631acfff87dda897541cf41/contracts/NestedFactory.sol#L557-L559

function _calculateFees(address _user, uint256 _amount) private view returns (uint256) {
    return _amount / 100;
}

_user is unused.

https://github.com/code-423n4/2021-11-nested/blob/f646002b692ca5fa3631acfff87dda897541cf41/contracts/operators/Flat/FlatOperator.sol#L13-L29

function commitAndRevert(
    address self,
    address token,
    uint256 amount
) external payable override returns (uint256[] memory amounts, address[] memory tokens) {
    require(amount > 0, "FlatOperator::commitAndRevert: Amount must be greater than zero");

    amounts = new uint256[](2);
    tokens = new address[](2);

    // Output amounts
    amounts[0] = amount;
    amounts[1] = amount;
    // Output token
    tokens[0] = token;
    tokens[1] = token;
}

self is unused.

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Nov 17, 2021
code423n4 added a commit that referenced this issue Nov 17, 2021
@maximebrugel
Copy link
Collaborator

The first point is a duplicate of #167

@maximebrugel
Copy link
Collaborator

Refute the second point. In fact, every operator needs the self parameter even if it's not used (keep the same interface).

@maximebrugel maximebrugel added the duplicate This issue or pull request already exists label Nov 22, 2021
@alcueca
Copy link
Collaborator

alcueca commented Dec 3, 2021

Also comments are wrong (#194)

@CloudEllie CloudEllie added 1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments and removed G (Gas Optimization) labels Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants