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

contract check lint #316

Merged
merged 4 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
{
"extends": "solhint:default"
"extends": "solhint:recommended",
"rules": {
"max-line-length": [
"error",
200
],
"avoid-suicide": "error",
"no-console": "error",
"const-name-snakecase": "error",
"contract-name-camelcase": "error",
"func-visibility": [
"warn",
{
"ignoreConstructors": true
}
],
"reason-string": [
"warn",
{
"maxLength": 60
}
],
"gas-custom-errors": "off"
}
}
2 changes: 2 additions & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
test/
4 changes: 1 addition & 3 deletions contracts/contracts/l2/staking/Distribute.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/Own
import {EnumerableSetUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol";

import {Predeploys} from "../../libraries/constants/Predeploys.sol";
import {IL2Staking} from "./IL2Staking.sol";
import {IRecord} from "./IRecord.sol";
import {IDistribute} from "./IDistribute.sol";
import {IMorphToken} from "../system/IMorphToken.sol";

Expand Down Expand Up @@ -290,7 +288,7 @@ contract Distribute is IDistribute, OwnableUpgradeable {
) external view returns (uint256 reward) {
uint256 totalAmount;
uint256 delegatorAmount;
uint start = unclaimed[delegator].unclaimedStart[delegatee];
uint256 start = unclaimed[delegator].unclaimedStart[delegatee];
for (uint256 i = start; i < mintedEpochCount; i++) {
if (distributions[delegatee][i].amounts[delegator] > 0) {
delegatorAmount = distributions[delegatee][i].amounts[
Expand Down
3 changes: 1 addition & 2 deletions contracts/contracts/l2/staking/Gov.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {EnumerableSetUpgradeable} from "@openzeppelin/contracts-upgradeable/util
import {Predeploys} from "../../libraries/constants/Predeploys.sol";
import {ISequencer} from "./ISequencer.sol";
import {IGov} from "./IGov.sol";
import {IL2Staking} from "./IL2Staking.sol";

contract Gov is IGov, OwnableUpgradeable {
using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;
Expand Down Expand Up @@ -297,7 +296,7 @@ contract Gov is IGov, OwnableUpgradeable {
address[] memory latestSequencerSet = ISequencer(SEQUENCER_CONTRACT)
.getSequencerSet2();
uint256 validVotes = 0;
for (uint i = 0; i < latestSequencerSet.length; i++) {
for (uint256 i = 0; i < latestSequencerSet.length; i++) {
if (votes[proposalID].contains(latestSequencerSet[i])) {
validVotes = validVotes + 1;
}
Expand Down
2 changes: 0 additions & 2 deletions contracts/contracts/l2/staking/IRecord.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;

import {Types} from "../../libraries/common/Types.sol";

interface IRecord {
/***********
* Structs *
Expand Down
2 changes: 0 additions & 2 deletions contracts/contracts/l2/staking/ISequencer.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;

import "../../libraries/common/Types.sol";

interface ISequencer {
/**********
* Events *
Expand Down
3 changes: 0 additions & 3 deletions contracts/contracts/l2/staking/Record.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ pragma solidity =0.8.24;
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

import {Predeploys} from "../../libraries/constants/Predeploys.sol";
import {Types} from "../../libraries/common/Types.sol";
import {IMorphToken} from "../system/IMorphToken.sol";
import {IL2Staking} from "./IL2Staking.sol";
import {ISequencer} from "./ISequencer.sol";
import {IDistribute} from "./IDistribute.sol";
import {IGov} from "./IGov.sol";
import {IRecord} from "./IRecord.sol";

contract Record is IRecord, OwnableUpgradeable {
Expand Down
1 change: 0 additions & 1 deletion contracts/contracts/l2/staking/Sequencer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma solidity =0.8.24;

import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

import {Types} from "../../libraries/common/Types.sol";
import {Predeploys} from "../../libraries/constants/Predeploys.sol";
import {ISequencer} from "./ISequencer.sol";

Expand Down
1 change: 0 additions & 1 deletion contracts/contracts/l2/system/L2ToL1MessagePasser.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity =0.8.24;

import {Tree} from "../../libraries/common/Tree.sol";
import {AddressAliasHelper} from "../../libraries/common/AddressAliasHelper.sol";
import {Predeploys} from "../../libraries/constants/Predeploys.sol";

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/contracts/mock/L1OverflowTester.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ contract L1OverflowTester {
gas_limit = _gasLimit;
}

function crossHash(string calldata _message, uint count) public {
function crossHash(string calldata _message, uint256 count) public {
MESSENGER.sendMessage(
OTHERTESTER,
0,
Expand Down
8 changes: 4 additions & 4 deletions contracts/contracts/mock/L2OverflowTester.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ pragma solidity =0.8.24;

contract L2OverflowTester {
bytes32 private messageHash;
uint private hashCount;
uint256 private hashCount;

constructor() {}

function hash(string calldata _message, uint count) public {
function hash(string calldata _message, uint256 count) public {
bytes memory hashed = bytes(_message);
for (uint i = 0; i < count; i++) {
for (uint256 i = 0; i < count; i++) {
messageHash = keccak256(hashed);
hashed = abi.encodePacked(messageHash);
}
Expand All @@ -21,7 +21,7 @@ contract L2OverflowTester {
return messageHash;
}

function getHashCount() public view returns (uint) {
function getHashCount() public view returns (uint256) {
return hashCount;
}
}
10 changes: 4 additions & 6 deletions contracts/contracts/test/Distribute.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
pragma solidity =0.8.24;

import {L2StakingBaseTest} from "./base/L2StakingBase.t.sol";
import {Distribute} from "../l2/staking/Distribute.sol";
import {IDistribute} from "../l2/staking/IDistribute.sol";

contract DistributeTest is L2StakingBaseTest {
address firstStaker;
uint256 mockReward;
uint256 mockCommission;
address public firstStaker;
uint256 public mockReward;
uint256 public mockCommission;

function setUp() public virtual override {
super.setUp();
Expand All @@ -27,7 +25,7 @@ contract DistributeTest is L2StakingBaseTest {
uint256[] memory delegatorRewards = new uint256[](updateEpochNum);
uint256[] memory commissions = new uint256[](updateEpochNum);

for (uint i = 0; i < updateEpochNum; i++) {
for (uint256 i = 0; i < updateEpochNum; i++) {
sequencers[i] = address(uint160(beginSeq + i));
delegatorRewards[i] = mockReward;
commissions[i] = mockCommission;
Expand Down
3 changes: 1 addition & 2 deletions contracts/contracts/test/Gov.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity =0.8.24;

import {L2StakingBaseTest} from "./base/L2StakingBase.t.sol";
import {Gov} from "../l2/staking/Gov.sol";
import {IGov} from "../l2/staking/IGov.sol";
import {Types} from "../libraries/common/Types.sol";
import {ICrossDomainMessenger} from "../libraries/ICrossDomainMessenger.sol";
Expand Down Expand Up @@ -183,7 +182,7 @@ contract GovTest is L2StakingBaseTest {
assertFalse(canBeApproved);

// invalide votes
for (uint i = 0; i < removed.length - 1; i++) {
for (uint256 i = 0; i < removed.length - 1; i++) {
assertTrue(gov.isVoted(currentproposalID, removed[i]));
}

Expand Down
5 changes: 2 additions & 3 deletions contracts/contracts/test/L1CrossDomainMessenger.t.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;

import {L1MessageQueueWithGasPriceOracle} from "../l1/rollup/L1MessageQueueWithGasPriceOracle.sol";
import {IL1CrossDomainMessenger} from "../l1/L1CrossDomainMessenger.sol";
import {IRollup} from "../l1/rollup/IRollup.sol";
import {Predeploys} from "../libraries/constants/Predeploys.sol";
import {ICrossDomainMessenger} from "../libraries/ICrossDomainMessenger.sol";
import {L1MessageBaseTest} from "./base/L1MessageBase.t.sol";

contract L1CrossDomainMessengerTest is L1MessageBaseTest {
uint256 L1CrossDomainMessenger_provenWithdrawals_slot = 251;
address refundAddress = address(2048);
uint256 public l1CrossDomainMessengerProvenWithdrawalsSlot = 251;
address public refundAddress = address(2048);

function test_proveWithdrawalTransaction_relayMessage_succeeds() external {
// tx msg set
Expand Down
1 change: 0 additions & 1 deletion contracts/contracts/test/L1CustomERC20Gateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {L1GatewayBaseTest} from "./base/L1GatewayBase.t.sol";
import {L1CustomERC20Gateway} from "../l1/gateways/L1CustomERC20Gateway.sol";
import {L1GatewayRouter} from "../l1/gateways/L1GatewayRouter.sol";
import {IL1ERC20Gateway} from "../l1/gateways/IL1ERC20Gateway.sol";
import {L2CustomERC20Gateway} from "../l2/gateways/L2CustomERC20Gateway.sol";
import {IL1MessageQueue} from "../l1/rollup/IL1MessageQueue.sol";
import {IL2ERC20Gateway} from "../l2/gateways/IL2ERC20Gateway.sol";
import {ICrossDomainMessenger} from "../libraries/ICrossDomainMessenger.sol";
Expand Down
5 changes: 2 additions & 3 deletions contracts/contracts/test/L1ERC721Gateway.t.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;

import "@rari-capital/solmate/src/test/utils/mocks/MockERC721.sol";
import "@rari-capital/solmate/src/tokens/ERC721.sol";
import {MockERC721} from "@rari-capital/solmate/src/test/utils/mocks/MockERC721.sol";
import {ERC721TokenReceiver} from "@rari-capital/solmate/src/tokens/ERC721.sol";

import {AddressAliasHelper} from "../libraries/common/AddressAliasHelper.sol";
import {ICrossDomainMessenger} from "../libraries/ICrossDomainMessenger.sol";
import {L2ERC721Gateway} from "../l2/gateways/L2ERC721Gateway.sol";
import {IL2ERC721Gateway} from "../l2/gateways/IL2ERC721Gateway.sol";
import {IL1ERC721Gateway} from "../l1/gateways/IL1ERC721Gateway.sol";
import {L1ERC721Gateway} from "../l1/gateways/L1ERC721Gateway.sol";
Expand Down
3 changes: 1 addition & 2 deletions contracts/contracts/test/L1ETHGateway.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;

import {Predeploys} from "../libraries/constants/Predeploys.sol";
import {AddressAliasHelper} from "../libraries/common/AddressAliasHelper.sol";
import {ICrossDomainMessenger} from "../libraries/ICrossDomainMessenger.sol";
import {IL1MessageQueue} from "../l1/rollup/IL1MessageQueue.sol";
Expand All @@ -10,7 +9,7 @@ import {IL1ETHGateway} from "../l1/gateways/IL1ETHGateway.sol";
import {L1GatewayBaseTest} from "./base/L1GatewayBase.t.sol";

contract L1ETHGatewayTest is L1GatewayBaseTest {
address counterpartGateway;
address public counterpartGateway;

function setUp() public virtual override {
super.setUp();
Expand Down
4 changes: 1 addition & 3 deletions contracts/contracts/test/L1MessageQueue.t.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;

import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";

import {AddressAliasHelper} from "../libraries/common/AddressAliasHelper.sol";
import {IL1MessageQueue} from "../l1/rollup/IL1MessageQueue.sol";
import {L1MessageBaseTest} from "./base/L1MessageBase.t.sol";
import {L1MessageQueueWithGasPriceOracle} from "../l1/rollup/L1MessageQueueWithGasPriceOracle.sol";

contract L1MessageQueueTest is L1MessageBaseTest {
L1MessageQueueWithGasPriceOracle l1MessageQueue;
L1MessageQueueWithGasPriceOracle public l1MessageQueue;

function setUp() public virtual override {
super.setUp();
Expand Down
3 changes: 1 addition & 2 deletions contracts/contracts/test/L1StandardERC20Gateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma solidity =0.8.24;

import {MockERC20} from "@rari-capital/solmate/src/test/utils/mocks/MockERC20.sol";

import {Predeploys} from "../libraries/constants/Predeploys.sol";
import {ICrossDomainMessenger} from "../libraries/ICrossDomainMessenger.sol";
import {AddressAliasHelper} from "../libraries/common/AddressAliasHelper.sol";
import {IL2ERC20Gateway} from "../l2/gateways/IL2ERC20Gateway.sol";
Expand All @@ -14,7 +13,7 @@ import {FeeOnTransferToken} from "../mock/tokens/FeeOnTransferToken.sol";
import {L1GatewayBaseTest} from "./base/L1GatewayBase.t.sol";

contract L1StandardERC20GatewayTest is L1GatewayBaseTest {
address counterpartGateway;
address public counterpartGateway;
MockERC20 private l1Token;
MockERC20 private l2Token;
TransferReentrantToken private reentrantToken;
Expand Down
1 change: 0 additions & 1 deletion contracts/contracts/test/L2CrossDomainMessenger.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity =0.8.24;
import {Predeploys} from "../libraries/constants/Predeploys.sol";
import {AddressAliasHelper} from "../libraries/common/AddressAliasHelper.sol";
import {ICrossDomainMessenger} from "../libraries/ICrossDomainMessenger.sol";
import {Tree} from "../libraries/common/Tree.sol";
import {L2MessageBaseTest} from "./base/L2MessageBase.t.sol";

contract L2CrossDomainMessengerTest is L2MessageBaseTest {
Expand Down
1 change: 0 additions & 1 deletion contracts/contracts/test/L2CustomERC20Gateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {MockERC20} from "@rari-capital/solmate/src/test/utils/mocks/MockERC20.so

import {AddressAliasHelper} from "../libraries/common/AddressAliasHelper.sol";
import {ICrossDomainMessenger} from "../libraries/ICrossDomainMessenger.sol";
import {Predeploys} from "../libraries/constants/Predeploys.sol";
import {L2CustomERC20Gateway} from "../l2/gateways/L2CustomERC20Gateway.sol";
import {L2GatewayRouter} from "../l2/gateways/L2GatewayRouter.sol";
import {IL2ERC20Gateway} from "../l2/gateways/IL2ERC20Gateway.sol";
Expand Down
3 changes: 0 additions & 3 deletions contracts/contracts/test/L2ERC1155Gateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ pragma solidity =0.8.24;
import {MockERC1155} from "@rari-capital/solmate/src/test/utils/mocks/MockERC1155.sol";
import {ERC1155TokenReceiver} from "@rari-capital/solmate/src/tokens/ERC1155.sol";

import {Predeploys} from "../libraries/constants/Predeploys.sol";
import {L2GatewayBaseTest} from "./base/L2GatewayBase.t.sol";
import {L1ERC1155Gateway} from "../l1/gateways/L1ERC1155Gateway.sol";
import {L2ERC1155Gateway} from "../l2/gateways/L2ERC1155Gateway.sol";
import {MockCrossDomainMessenger} from "../mock/MockCrossDomainMessenger.sol";
import {AddressAliasHelper} from "../libraries/common/AddressAliasHelper.sol";

contract L2ERC1155GatewayTest is L2GatewayBaseTest, ERC1155TokenReceiver {
uint256 private constant TOKEN_COUNT = 100;
Expand Down
3 changes: 0 additions & 3 deletions contracts/contracts/test/L2ERC721Gateway.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ pragma solidity =0.8.24;

import {MockERC721} from "@rari-capital/solmate/src/test/utils/mocks/MockERC721.sol";

import {Predeploys} from "../libraries/constants/Predeploys.sol";
import {L2GatewayBaseTest} from "./base/L2GatewayBase.t.sol";
import {L1ERC721Gateway} from "../l1/gateways/L1ERC721Gateway.sol";
import {L2ERC721Gateway} from "../l2/gateways/L2ERC721Gateway.sol";
import {MockCrossDomainMessenger} from "../mock/MockCrossDomainMessenger.sol";
import {AddressAliasHelper} from "../libraries/common/AddressAliasHelper.sol";

contract L2ERC721GatewayTest is L2GatewayBaseTest {
uint256 private constant TOKEN_COUNT = 100;
Expand Down
1 change: 0 additions & 1 deletion contracts/contracts/test/L2ETHGateway.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity =0.8.24;

import {Predeploys} from "../libraries/constants/Predeploys.sol";
import {L2ToL1MessagePasser} from "../l2/system/L2ToL1MessagePasser.sol";
import {IL2ETHGateway} from "../l2/gateways/IL2ETHGateway.sol";
import {L2ETHGateway} from "../l2/gateways/L2ETHGateway.sol";
Expand Down
3 changes: 0 additions & 3 deletions contracts/contracts/test/L2GatewayRouter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ pragma solidity =0.8.24;

import {MockERC20} from "@rari-capital/solmate/src/test/utils/mocks/MockERC20.sol";

import {Predeploys} from "../libraries/constants/Predeploys.sol";
import {L2GatewayBaseTest} from "./base/L2GatewayBase.t.sol";
import {L2GatewayRouter} from "../l2/gateways/L2GatewayRouter.sol";
import {IL2GatewayRouter} from "../l2/gateways/IL2GatewayRouter.sol";
import {L2CrossDomainMessenger} from "../l2/L2CrossDomainMessenger.sol";

import {MockCrossDomainMessenger} from "../mock/MockCrossDomainMessenger.sol";

contract L2GatewayRouterTest is L2GatewayBaseTest {
L2GatewayRouter private router;
L2CrossDomainMessenger private l2Messenger;
Expand Down
Loading
Loading