From 7efdc45f75fb9e0bdfc29fddebc0974369570cca Mon Sep 17 00:00:00 2001 From: Dean Date: Thu, 21 Mar 2024 03:49:55 -0400 Subject: [PATCH 1/2] feat: add codecov action (#253) * feat: add codecov action * feat: run on main * feat: add cancel in progress --- .github/workflows/codecov.yaml | 59 +++++++++++++++++++ .github/workflows/conventional-commits.yaml | 4 ++ .github/workflows/lint.yaml | 4 ++ .../workflows/{slither.yml => slither.yaml} | 4 ++ .github/workflows/test.yaml | 4 ++ 5 files changed, 75 insertions(+) create mode 100644 .github/workflows/codecov.yaml rename .github/workflows/{slither.yml => slither.yaml} (74%) diff --git a/.github/workflows/codecov.yaml b/.github/workflows/codecov.yaml new file mode 100644 index 00000000..fd161e0d --- /dev/null +++ b/.github/workflows/codecov.yaml @@ -0,0 +1,59 @@ +name: Coverage + +on: + pull_request: + push: + branches: + - main + - releases/** + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + coverage: + name: Code Coverage + strategy: + matrix: + node-version: + - 18.x + os: + - ubuntu-latest + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Install Dependencies + run: npm ci + + - name: Build + run: npm run build > build.log 2>&1 + + - name: Check for build warnings + run: | + if grep -q -i "error" build.log || grep -q -i "warning" build.log; then + echo "Build contains following errors or warnings..." + + cat build.log + + exit 1 + else + exit 0; + fi + + - name: Generate code coverage + run: npm run coverage + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: lcov.info + fail_ci_if_error: true diff --git a/.github/workflows/conventional-commits.yaml b/.github/workflows/conventional-commits.yaml index 93621d04..c26f9950 100644 --- a/.github/workflows/conventional-commits.yaml +++ b/.github/workflows/conventional-commits.yaml @@ -3,6 +3,10 @@ name: Ensure Conventional Commit message on: pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: ensure-CC: runs-on: ubuntu-latest diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 7f6ab96f..9a545d5e 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -3,6 +3,10 @@ name: Linting on: - pull_request +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: lint: strategy: diff --git a/.github/workflows/slither.yml b/.github/workflows/slither.yaml similarity index 74% rename from .github/workflows/slither.yml rename to .github/workflows/slither.yaml index ce618da6..14ce8d31 100644 --- a/.github/workflows/slither.yml +++ b/.github/workflows/slither.yaml @@ -3,6 +3,10 @@ name: Slither Static Analysis on: - pull_request +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: analyze: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index db4e8dac..7fd0d7f5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -3,6 +3,10 @@ name: Testing on: - pull_request +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: test: strategy: From 02708c3250e214fcf64de81dc0f77e29cee78c04 Mon Sep 17 00:00:00 2001 From: Milap Sheth Date: Thu, 21 Mar 2024 11:53:30 -0400 Subject: [PATCH 2/2] fix(factory): remove unused using directives (#254) * fix(factory): remove unused using directives * remove more unused * add InterchainToken bytecode check * update test --- contracts/InterchainTokenFactory.sol | 5 ----- contracts/InterchainTokenService.sol | 6 ------ test/InterchainToken.js | 17 ++++++++++++++++- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/contracts/InterchainTokenFactory.sol b/contracts/InterchainTokenFactory.sol index a5b90129..1d3209fc 100644 --- a/contracts/InterchainTokenFactory.sol +++ b/contracts/InterchainTokenFactory.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.0; import { AddressBytes } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/AddressBytes.sol'; -import { SafeTokenTransfer, SafeTokenTransferFrom, SafeTokenCall } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/SafeTransfer.sol'; import { Multicall } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/Multicall.sol'; import { Upgradable } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/upgradable/Upgradable.sol'; import { IAxelarGateway } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IAxelarGateway.sol'; @@ -19,11 +18,7 @@ import { IInterchainToken } from './interfaces/IInterchainToken.sol'; * @notice This contract is responsible for deploying new interchain tokens and managing their token managers. */ contract InterchainTokenFactory is IInterchainTokenFactory, ITokenManagerType, Multicall, Upgradable { - using AddressBytes for bytes; using AddressBytes for address; - using SafeTokenTransfer for IInterchainToken; - using SafeTokenTransferFrom for IInterchainToken; - using SafeTokenCall for IInterchainToken; IInterchainTokenService public immutable interchainTokenService; bytes32 public immutable chainNameHash; diff --git a/contracts/InterchainTokenService.sol b/contracts/InterchainTokenService.sol index a0e41ac5..e018b8f8 100644 --- a/contracts/InterchainTokenService.sol +++ b/contracts/InterchainTokenService.sol @@ -8,9 +8,7 @@ import { IAxelarGateway } from '@axelar-network/axelar-gmp-sdk-solidity/contract import { ExpressExecutorTracker } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/express/ExpressExecutorTracker.sol'; import { Upgradable } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/upgradable/Upgradable.sol'; import { Create3Address } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/deploy/Create3Address.sol'; -import { SafeTokenTransferFrom, SafeTokenCall } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/SafeTransfer.sol'; import { AddressBytes } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/AddressBytes.sol'; -import { StringToBytes32, Bytes32ToString } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/Bytes32String.sol'; import { Multicall } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/Multicall.sol'; import { Pausable } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/Pausable.sol'; import { InterchainAddressTracker } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/InterchainAddressTracker.sol'; @@ -44,12 +42,8 @@ contract InterchainTokenService is InterchainAddressTracker, IInterchainTokenService { - using StringToBytes32 for string; - using Bytes32ToString for bytes32; using AddressBytes for bytes; using AddressBytes for address; - using SafeTokenTransferFrom for IERC20; - using SafeTokenCall for IERC20; IAxelarGateway public immutable gateway; IAxelarGasService public immutable gasService; diff --git a/test/InterchainToken.js b/test/InterchainToken.js index 5ae6961a..a7ff687a 100644 --- a/test/InterchainToken.js +++ b/test/InterchainToken.js @@ -4,9 +4,10 @@ const { ethers } = require('hardhat'); const { constants: { AddressZero, HashZero, MaxUint256 }, getContractAt, + utils: { keccak256 }, } = ethers; const { expect } = require('chai'); -const { getRandomBytes32, expectRevert } = require('./utils'); +const { getRandomBytes32, expectRevert, getEVMVersion } = require('./utils'); const { deployContract } = require('../scripts/deploy'); describe('InterchainToken', () => { @@ -138,4 +139,18 @@ describe('InterchainToken', () => { expect(finalAllowance).to.eq(initialAllowance); }); }); + + describe('Bytecode checks [ @skip-on-coverage ]', () => { + it('Should preserve the same bytecode', async () => { + const contract = await ethers.getContractFactory('InterchainToken', owner); + const contractBytecode = contract.bytecode; + const contractBytecodeHash = keccak256(contractBytecode); + + const expected = { + london: '0xa01cf28b0b6ce6dc3b466e995585d69486400d671fce0ea8d06beba583e6f3bb', + }[getEVMVersion()]; + + expect(contractBytecodeHash).to.be.equal(expected); + }); + }); });