sherlock-audit / 2024-10-gamma-rewarder-judging

7 stars 3 forks source link

Joyous Pistachio Lark - [GAS-2] For Operations that will not overflow, you could use unchecked #242

Closed sherlock-admin3 closed 2 weeks ago

sherlock-admin3 commented 2 weeks ago

Joyous Pistachio Lark

Low/Info

[GAS-2] For Operations that will not overflow, you could use unchecked

[GAS-2] For Operations that will not overflow, you could use unchecked

Instances (91):

File: GammaRewarder.sol

4: import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

4: import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

4: import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

4: import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

5: import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

5: import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

5: import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

5: import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

5: import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

6: import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";

6: import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";

6: import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";

6: import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";

7: import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

7: import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

7: import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

8: import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

8: import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

8: import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

9: import "./brevis/lib/BrevisApp.sol";

9: import "./brevis/lib/BrevisApp.sol";

9: import "./brevis/lib/BrevisApp.sol";

10: import "./brevis/lib/IBrevisProof.sol";

10: import "./brevis/lib/IBrevisProof.sol";

10: import "./brevis/lib/IBrevisProof.sol";

45:     uint256 public MAX_DISTRIBUTION_BLOCKS = 9_676_800; // Blocks for 4 weeks

45:     uint256 public MAX_DISTRIBUTION_BLOCKS = 9_676_800; // Blocks for 4 weeks

76:     event Revoked(); // With this event an indexer could maintain a table (timestamp, merkleRootUpdate)

76:     event Revoked(); // With this event an indexer could maintain a table (timestamp, merkleRootUpdate)

118:         require(_startBlockNum > block.number && (_endBlockNum - _startBlockNum) <= MAX_DISTRIBUTION_BLOCKS, "Distribution start block number is less than current block number or the duration is greater than 4 weeks.");

120:         require((_endBlockNum - _startBlockNum) % blocksPerEpoch == 0, "Distribution length must be multiples of blocks per epoch");

125:         uint256 fee = _amount * protocolFee / BASE_9;

125:         uint256 fee = _amount * protocolFee / BASE_9;

126:         uint256 realAmountToDistribute = _amount - fee;

127:         uint256 amountPerEpoch = realAmountToDistribute / ((_endBlockNum - _startBlockNum) / blocksPerEpoch);

127:         uint256 amountPerEpoch = realAmountToDistribute / ((_endBlockNum - _startBlockNum) / blocksPerEpoch);

127:         uint256 amountPerEpoch = realAmountToDistribute / ((_endBlockNum - _startBlockNum) / blocksPerEpoch);

145:         nonces[msg.sender] = senderNonce + 1;

165:         require(startBlock < endBlock && (endBlock - startBlock) % blocksPerEpoch == 0, "Claim period must be valid");

202:         require(startBlock < endBlock && (endBlock - startBlock) % blocksPerEpoch == 0, "Claim period must be valid");

247:         require(_protocolFee < BASE_9, "Protocol fee is based on 10**9");

247:         require(_protocolFee < BASE_9, "Protocol fee is based on 10**9");

255:         uint256 toggleStatus = 1 - isWhitelistedRewardToken[token];
File: MockERC20Token.sol

5: import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

5: import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

5: import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

5: import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

6: import "@openzeppelin/contracts/access/Ownable.sol";

6: import "@openzeppelin/contracts/access/Ownable.sol";

6: import "@openzeppelin/contracts/access/Ownable.sol";
File: brevis/lib/BrevisApp.sol

4: import "./IBrevisProof.sol";
File: brevis/lib/IBrevisProof.sol

4: import "./Lib.sol";
File: brevis/lib/Lib.sol

4: import "solidity-rlp/contracts/RLPReader.sol";

4: import "solidity-rlp/contracts/RLPReader.sol";

4: import "solidity-rlp/contracts/RLPReader.sol";

7:     uint256 constant NumField = 5; // supports at most 5 fields per receipt log

7:     uint256 constant NumField = 5; // supports at most 5 fields per receipt log

11:         uint64 receiptIndex; // ReceiptIndex in the block

11:         uint64 receiptIndex; // ReceiptIndex in the block

17:         uint64 logIndex; // LogIndex of the field

17:         uint64 logIndex; // LogIndex of the field

23:         uint64 valueIndex; // index of the fields in topic or data

23:         uint64 valueIndex; // index of the fields in topic or data

54:         uint256 length; // for contract computing proof only

54:         uint256 length; // for contract computing proof only

56:         bytes32 appCommitHash; // zk-program computing circuit commit hash

56:         bytes32 appCommitHash; // zk-program computing circuit commit hash

56:         bytes32 appCommitHash; // zk-program computing circuit commit hash

57:         bytes32 appVkHash; // zk-program computing circuit Verify Key hash

57:         bytes32 appVkHash; // zk-program computing circuit Verify Key hash

57:         bytes32 appVkHash; // zk-program computing circuit Verify Key hash

58:         bytes32 smtRoot; // for zk-program computing proof only

58:         bytes32 smtRoot; // for zk-program computing proof only

58:         bytes32 smtRoot; // for zk-program computing proof only

76:         address from; // calculate from V R S

76:         address from; // calculate from V R S

104:         uint8 lenBytes = prefix - 0xf7; // assume lenBytes won't larger than 2, means the tx rlp data size won't exceed 2^16

104:         uint8 lenBytes = prefix - 0xf7; // assume lenBytes won't larger than 2, means the tx rlp data size won't exceed 2^16

104:         uint8 lenBytes = prefix - 0xf7; // assume lenBytes won't larger than 2, means the tx rlp data size won't exceed 2^16

106:             unsignedTxRawDataLength = uint8(bytes1(txRaw[2:3])) - 67; //67 is the bytes of r,s,v

106:             unsignedTxRawDataLength = uint8(bytes1(txRaw[2:3])) - 67; //67 is the bytes of r,s,v

106:             unsignedTxRawDataLength = uint8(bytes1(txRaw[2:3])) - 67; //67 is the bytes of r,s,v

108:             unsignedTxRawDataLength = uint16(bytes2(txRaw[2:2 + lenBytes])) - 67;

108:             unsignedTxRawDataLength = uint16(bytes2(txRaw[2:2 + lenBytes])) - 67;

111:             unsignedTxRaw = abi.encodePacked(txRaw[:2], txRaw[3:txRaw.length - 67]);

112:             unsignedTxRaw[1] = bytes1(0xc0 + uint8(unsignedTxRawDataLength));

119:                     txRaw[2 + lenBytes:txRaw.length - 67]

119:                     txRaw[2 + lenBytes:txRaw.length - 67]

126:                     txRaw[2 + lenBytes:txRaw.length - 67]

126:                     txRaw[2 + lenBytes:txRaw.length - 67]

135:             v += 27;