diff --git a/.github/workflows/solhint.yml b/.github/workflows/solhint.yml new file mode 100644 index 0000000..98421ae --- /dev/null +++ b/.github/workflows/solhint.yml @@ -0,0 +1,21 @@ +name: Solhint + +on: + push: + branches: + - master + - develop + pull_request: + +jobs: + solhint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Install node dependencies + run: npm install solhint + + - name: Validate PR commits with solhint + run: npx solhint "contracts/protocol/*.sol" --max-warnings 0 diff --git a/.solhint.json b/.solhint.json index 5f2ca75..183ac35 100644 --- a/.solhint.json +++ b/.solhint.json @@ -21,6 +21,9 @@ "contract-name-camelcase": "off", "func-name-mixedcase": "off", "var-name-mixedcase": "off", - "compiler-version": "off" + "compiler-version": "off", + "custom-errors": "off", + "no-global-import": "off", + "immutable-vars-naming": "off" } } diff --git a/Makefile b/Makefile index 5955b22..fb37bff 100644 --- a/Makefile +++ b/Makefile @@ -98,6 +98,9 @@ format: npx prettier --write {test,util}/**/*.js forge fmt +solhint: + npx solhint "contracts/protocol/*.sol" + .PHONY: format # Register one random operator diff --git a/contracts/protocol/LagrangeCommittee.sol b/contracts/protocol/LagrangeCommittee.sol index 5b51359..c85281f 100644 --- a/contracts/protocol/LagrangeCommittee.sol +++ b/contracts/protocol/LagrangeCommittee.sol @@ -37,7 +37,7 @@ contract LagrangeCommittee is Initializable, OwnableUpgradeable, ILagrangeCommit // ChainID => Operator address[] mapping(uint32 => address[]) public committeeAddrs; // Tree Depth => Node Value - mapping(uint8 => bytes32) zeroHashes; + mapping(uint8 => bytes32) private zeroHashes; mapping(address => OperatorStatus) public operatorsStatus; diff --git a/contracts/protocol/VoteWeigher.sol b/contracts/protocol/VoteWeigher.sol index d6f37cb..fe1e72e 100644 --- a/contracts/protocol/VoteWeigher.sol +++ b/contracts/protocol/VoteWeigher.sol @@ -19,7 +19,7 @@ contract VoteWeigher is Initializable, OwnableUpgradeable, IVoteWeigher { IStakeManager public immutable stakeManager; - uint8[] quorumNumbers; // list of all quorum numbers + uint8[] public quorumNumbers; // list of all quorum numbers event QuorumAdded(uint8 indexed quorumNumber, TokenMultiplier[] multipliers); event QuorumRemoved(uint8 indexed quorumNumber); @@ -67,7 +67,7 @@ contract VoteWeigher is Initializable, OwnableUpgradeable, IVoteWeigher { quorumMultipliers[quorumNumber].push(multiplier); } else { uint256 _length = quorumMultipliers[quorumNumber].length; - for (uint i; i < _length; i++) { + for (uint256 i; i < _length; i++) { if (i != index) { require(quorumMultipliers[quorumNumber][i].token != multiplier.token, "Multiplier already exists"); }