Skip to content

Commit

Permalink
add foundry to ci (#815)
Browse files Browse the repository at this point in the history
Signed-off-by: Danil <[email protected]>
Co-authored-by: otani <[email protected]>
  • Loading branch information
Deniallugo and otani88 committed Sep 17, 2024
1 parent a999079 commit f3178f7
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 93 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ inputs.commit }}
submodules: recursive

- name: Install foundry-zksync
run: |
mkdir ./foundry-zksync
curl -LO https://github.com/matter-labs/foundry-zksync/releases/download/nightly/foundry_nightly_linux_amd64.tar.gz
tar zxf foundry_nightly_linux_amd64.tar.gz -C ./foundry-zksync
chmod +x ./foundry-zksync/forge ./foundry-zksync/cast
echo "$PWD/foundry-zksync" >> $GITHUB_PATH
- name: Use Node.js
uses: actions/setup-node@v3
Expand All @@ -37,9 +46,16 @@ jobs:
- name: Build contracts
run: |
yarn l1 build
yarn l2 build
yarn sc build
cd l1-contracts/ && forge build
cd ..
cd l2-contracts/ && forge build --zksync --zk-enable-eravm-extensions
cd ..
cd system-contracts
yarn install
yarn preprocess:system-contracts
forge build --zksync --zk-enable-eravm-extensions
yarn preprocess:bootloader
forge build --zksync --zk-enable-eravm-extensions
- name: Prepare artifacts
run: |
Expand Down
50 changes: 32 additions & 18 deletions .github/workflows/l1-contracts-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,38 @@ jobs:
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install foundry-zksync
run: |
mkdir ./foundry-zksync
curl -LO https://github.com/matter-labs/foundry-zksync/releases/download/nightly/foundry_nightly_linux_amd64.tar.gz
tar zxf foundry_nightly_linux_amd64.tar.gz -C ./foundry-zksync
chmod +x ./foundry-zksync/forge ./foundry-zksync/cast
echo "$PWD/foundry-zksync" >> $GITHUB_PATH
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.18.0
cache: yarn

- name: Install dependencies
run: yarn

- name: Build artifacts
run: yarn l1 build
run: cd l1-contracts/ && forge build

- name: Build L2 artifacts
run: yarn l2 build
run: cd l2-contracts/ && forge build --zksync --zk-enable-eravm-extensions

- name: Create cache
uses: actions/cache/save@v3
with:
key: artifacts-l1-${{ github.sha }}
path: |
l1-contracts/artifacts
l1-contracts/cache
l1-contracts/typechain
l2-contracts/artifacts-zk
l2-contracts/cache-zk
l2-contracts/typechain
l1-contracts/cache-forge
l1-contracts/out
l2-contracts/cache-forge
l2-contracts/zkout
lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -72,15 +77,19 @@ jobs:
with:
submodules: recursive

- name: Use Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.18.0
cache: yarn

- name: Install foundry-zksync
run: |
mkdir ./foundry-zksync
curl -LO https://github.com/matter-labs/foundry-zksync/releases/download/nightly/foundry_nightly_linux_amd64.tar.gz
tar zxf foundry_nightly_linux_amd64.tar.gz -C ./foundry-zksync
chmod +x ./foundry-zksync/forge ./foundry-zksync/cast
echo "$PWD/foundry-zksync" >> $GITHUB_PATH
- name: Install dependencies
run: yarn

Expand Down Expand Up @@ -128,7 +137,7 @@ jobs:
l2-contracts/typechain
- name: Run tests
run: yarn l1 test --no-compile
run: yarn l1 test

check-verifier-generator:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -164,15 +173,20 @@ jobs:
with:
submodules: recursive

- name: Use Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.18.0
cache: yarn

- name: Install foundry-zksync
run: |
mkdir ./foundry-zksync
curl -LO https://github.com/matter-labs/foundry-zksync/releases/download/nightly/foundry_nightly_linux_amd64.tar.gz
tar zxf foundry_nightly_linux_amd64.tar.gz -C ./foundry-zksync
chmod +x ./foundry-zksync/forge ./foundry-zksync/cast
echo "$PWD/foundry-zksync" >> $GITHUB_PATH
- name: Install dependencies
run: yarn

Expand Down
28 changes: 18 additions & 10 deletions .github/workflows/l2-contracts-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ jobs:
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install foundry-zksync
run: |
mkdir ./foundry-zksync
curl -LO https://github.com/matter-labs/foundry-zksync/releases/download/nightly/foundry_nightly_linux_amd64.tar.gz
tar zxf foundry_nightly_linux_amd64.tar.gz -C ./foundry-zksync
chmod +x ./foundry-zksync/forge ./foundry-zksync/cast
echo "$PWD/foundry-zksync" >> $GITHUB_PATH
- name: Use Node.js
uses: actions/setup-node@v3
Expand All @@ -20,23 +30,21 @@ jobs:
- name: Install dependencies
run: yarn

- name: Build L1 artifacts
run: yarn l1 build
- name: Build artifacts
run: cd l1-contracts/ && forge build

- name: Build L2 artifacts
run: yarn l2 build
run: cd l2-contracts/ && forge build --zksync --zk-enable-eravm-extensions

- name: Create cache
uses: actions/cache/save@v3
with:
key: artifacts-l2-${{ github.sha }}
key: artifacts-l1-${{ github.sha }}
path: |
l1-contracts/artifacts
l1-contracts/cache
l1-contracts/typechain
l2-contracts/artifacts-zk
l2-contracts/cache-zk
l2-contracts/typechain
l1-contracts/cache-forge
l1-contracts/out
l2-contracts/cache-forge
l2-contracts/zkout
lint:
runs-on: ubuntu-latest
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/slither.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,18 @@ jobs:
with:
python-version: 3.8

- name: Install foundry-zksync
run: |
mkdir ./foundry-zksync
curl -LO https://github.com/matter-labs/foundry-zksync/releases/download/nightly/foundry_nightly_linux_amd64.tar.gz
tar zxf foundry_nightly_linux_amd64.tar.gz -C ./foundry-zksync
chmod +x ./foundry-zksync/forge ./foundry-zksync/cast
echo "$PWD/foundry-zksync" >> $GITHUB_PATH
- name: Install Slither
run: |
pip install slither-analyzer
- name: Use Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Remove non-compiled files
run: |
rm -rf ./l1-contracts/contracts/state-transition/utils/
Expand Down
74 changes: 23 additions & 51 deletions .github/workflows/system-contracts-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,39 @@ jobs:
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install foundry-zksync
run: |
mkdir ./foundry-zksync
curl -LO https://github.com/matter-labs/foundry-zksync/releases/download/nightly/foundry_nightly_linux_amd64.tar.gz
tar zxf foundry_nightly_linux_amd64.tar.gz -C ./foundry-zksync
chmod +x ./foundry-zksync/forge ./foundry-zksync/cast
echo "$PWD/foundry-zksync" >> $GITHUB_PATH
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.18.0
cache: yarn

- name: Install dependencies
run: yarn

- name: Build artifacts
run: yarn sc build
run: |
cd system-contracts
yarn install
yarn preprocess:system-contracts
forge build --zksync --zk-enable-eravm-extensions
yarn preprocess:bootloader
forge build --zksync --zk-enable-eravm-extensions
- name: Create cache
uses: actions/cache/save@v3
with:
key: artifacts-system-${{ github.sha }}
path: |
system-contracts/artifacts-zk
system-contracts/cache-zk
system-contracts/typechain
system-contracts/contracts-preprocessed
system-contracts/bootloader/build
system-contracts/zkout
system-contracts/cache-forge
lint:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -72,11 +82,8 @@ jobs:
fail-on-cache-miss: true
key: artifacts-system-${{ github.sha }}
path: |
system-contracts/artifacts-zk
system-contracts/cache-zk
system-contracts/typechain
system-contracts/contracts-preprocessed
system-contracts/bootloader/build
system-contracts/zkout
system-contracts/cache-forge
- name: Run bootloader tests
run: |
Expand Down Expand Up @@ -111,47 +118,12 @@ jobs:
fail-on-cache-miss: true
key: artifacts-system-${{ github.sha }}
path: |
system-contracts/artifacts-zk
system-contracts/cache-zk
system-contracts/typechain
system-contracts/contracts-preprocessed
system-contracts/bootloader/build
system-contracts/zkout
system-contracts/cache-forge
- name: Run tests
run: yarn sc test

- name: Print output logs of era_test_node
if: always()
run: cat era_test_node.log

check-hashes:
needs: [build]
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.18.0
cache: yarn

- name: Install dependencies
run: yarn

- name: Restore artifacts cache
uses: actions/cache/restore@v3
with:
fail-on-cache-miss: true
key: artifacts-system-${{ github.sha }}
path: |
system-contracts/artifacts-zk
system-contracts/cache-zk
system-contracts/typechain
system-contracts/contracts-preprocessed
system-contracts/bootloader/build
- name: Check hashes
run: yarn sc calculate-hashes:check
2 changes: 1 addition & 1 deletion l2-contracts/contracts/ConsensusRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.20;
pragma solidity ^0.8.20;

import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable-v4/access/Ownable2StepUpgradeable.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable-v4/proxy/utils/Initializable.sol";
Expand Down
2 changes: 1 addition & 1 deletion l2-contracts/contracts/dev-contracts/DevL2SharedBridge.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.24;
pragma solidity ^0.8.20;

import {L2SharedBridge} from "../bridge/L2SharedBridge.sol";
import {L2StandardERC20} from "../bridge/L2StandardERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion l2-contracts/contracts/dev-contracts/Multicall3.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
pragma solidity 0.8.24;

/// @title Multicall3
/// @notice Aggregate results from multiple function calls
Expand Down
2 changes: 1 addition & 1 deletion l2-contracts/contracts/interfaces/IConsensusRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.20;
pragma solidity ^0.8.20;

/// @author Matter Labs
/// @custom:security-contact [email protected]
Expand Down
8 changes: 4 additions & 4 deletions system-contracts/scripts/calculate-hashes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ const findFilesEndingWith = (path: string, endingWith: string): string[] => {
}
};

const SOLIDITY_ARTIFACTS_DIR = "artifacts-zk";
const SOLIDITY_ARTIFACTS_DIR = "zkout";

const getSolidityContractDetails = (dir: string, contractName: string): ContractDetails => {
const bytecodePath = join(SOLIDITY_ARTIFACTS_DIR, dir, contractName + ".sol", contractName + ".json");
const bytecodePath = join(SOLIDITY_ARTIFACTS_DIR, contractName + ".sol", contractName + ".json");
const sourceCodePath = join(dir, contractName + ".sol");
return {
contractName,
Expand All @@ -55,7 +55,7 @@ const getSolidityContractDetails = (dir: string, contractName: string): Contract
};

const getSolidityContractsDetails = (dir: string): ContractDetails[] => {
const bytecodesDir = join(SOLIDITY_ARTIFACTS_DIR, dir);
const bytecodesDir = SOLIDITY_ARTIFACTS_DIR;
const dirsEndingWithSol = findDirsEndingWith(bytecodesDir, ".sol");
const contractNames = dirsEndingWithSol.map((d) => d.replace(".sol", ""));
const solidityContractsDetails = contractNames.map((c) => getSolidityContractDetails(dir, c));
Expand Down Expand Up @@ -100,7 +100,7 @@ const readBytecode = (details: ContractDetails): string => {
try {
if (details.bytecodePath.endsWith(".json")) {
const jsonFile = fs.readFileSync(absolutePath, "utf8");
return ethers.utils.hexlify(JSON.parse(jsonFile).bytecode);
return ethers.utils.hexlify("0x" + JSON.parse(jsonFile).bytecode.object);
} else {
return ethers.utils.hexlify(fs.readFileSync(absolutePath));
}
Expand Down

0 comments on commit f3178f7

Please sign in to comment.