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 - stricter function mutability for gas savings #330

Open
code423n4 opened this issue Dec 1, 2021 · 1 comment
Open
Labels
bug Something isn't working G (Gas Optimization) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Handle

ScopeLift

Vulnerability details

Impact

There are four functions that can have stricter function mutability declarations. Using a stricter declaration can help the compiler save gas when it knows whether reads and writes will occur in a function

Proof of Concept

N/A

Tools Used

solc

Recommended Mitigation Steps

Implement the changes suggested 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:3: Warning: Function state mutability can be restricted to pure
  function verifyTransfer(address from, address to, uint256 amount) public view virtual returns (bool, string memory) {
  ^ (Relevant source part starts here and spans across multiple lines).

contracts/AuctionEscapeHatch.sol:168:3: Warning: Function state mutability can be restricted to view
  function _calculateMaltRequiredForExit(uint256 _auctionId, uint256 amount) internal returns(uint256) {
  ^ (Relevant source part starts here and spans across multiple lines).

contracts/AuctionParticipant.sol:127:3: Warning: Function state mutability can be restricted to pure
  function _handleRewardDistribution(uint256 rewarded) virtual internal {
  ^ (Relevant source part starts here and spans across multiple lines).

contracts/MaltDataLab.sol:202:3: Warning: Function state mutability can be restricted to pure
  function _normalizedPrice(
  ^ (Relevant source part starts here and spans across multiple lines).
@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 confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Dec 10, 2021
@GalloDaSballo
Copy link
Collaborator

Agree with restricting to pure, esp when the compiler flags it up.
The first finding is for a test file so it's not that important

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 confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

3 participants