Skip to content

Commit

Permalink
Mirror the private repo (#5)
Browse files Browse the repository at this point in the history
# What ❔

Synchronized this repo with the private mirror.

## Why ❔

The compiler-tester will soon be fully open-source.

## Checklist

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [x] Tests for the changes have been added / updated.
- [x] Documentation comments have been added / updated.
- [x] Code has been formatted via `cargo fmt` and checked with `cargo
clippy`.

---------

Co-authored-by: Anton Baliasnikov <[email protected]>
  • Loading branch information
hedgar2017 and antonbaliasnikov authored Mar 15, 2024
1 parent ff8f7bf commit 076a46c
Show file tree
Hide file tree
Showing 251 changed files with 4,994 additions and 2,500 deletions.
79 changes: 79 additions & 0 deletions .github/actions/build-llvm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: 'Build LLVM'
description: 'Builds backend LLVM framework'
inputs:
target:
description: 'Specific build target triplet.'
required: false
default: ''
runs:
using: "composite"
steps:
- name: Prepare environment
if: runner.os == 'macOS'
run: brew install cmake ninja
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}

- name: Define build target
id: build-target
if: inputs.target != ''
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
run: |
rustup target add ${{ inputs.target }}
echo "target=--target ${{ inputs.target }}" >> $GITHUB_OUTPUT
- name: Clone LLVM framework
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
run: |
cargo install compiler-llvm-builder ${{ steps.build-target.outputs.target }}
zkevm-llvm clone
- name: Define ccache key
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
id: ccache-key
run: |
LLVM_BRANCH="$(git -C ./llvm rev-parse --abbrev-ref HEAD)"
LLVM_SHORT_SHA="$(git -C ./llvm rev-parse --short HEAD)"
echo "key=llvm-${LLVM_BRANCH}-${LLVM_SHORT_SHA}-${{ runner.os }}-${{ runner.arch }}" | tee -a "${GITHUB_OUTPUT}"
- name: Prepare ccache installation
if: runner.os == 'Linux'
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
run: apt update

- name: Set up compiler cache
uses: hendrikmuhs/[email protected]
env:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_NOHASHDIR: "true"
CCACHE_COMPILERCHECK: "content"
with:
key: ${{ steps.ccache-key.outputs.key }}
restore-keys: ${{ steps.ccache-key.outputs.key }}
append-timestamp: false
max-size: "2G"
verbose: 2
save: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/v') }}

- name: Build LLVM Linux
if: ${{ runner.os == 'Linux' }}
uses: nick-fields/retry@v2
env:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_NOHASHDIR: "true"
CCACHE_COMPILERCHECK: "content"
LIBSTDCPP_SOURCE_PATH: "C:/a/_temp/msys64/mingw64/lib/libstdc++.a"
with:
timeout_minutes: 60
max_attempts: 16 # protection mechanism for sporadic dependencies download failure
command: zkevm-llvm build --targets 'EVM' --use-ccache

- name: Build LLVM MacOS and Windows
if: ${{ runner.os != 'Linux' }}
shell: ${{ runner.os == 'Windows' && 'msys2 {0}' || 'bash' }}
env:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_NOHASHDIR: "true"
CCACHE_COMPILERCHECK: "content"
LIBSTDCPP_SOURCE_PATH: "C:/a/_temp/msys64/mingw64/lib/libstdc++.a"
run: |
zkevm-llvm build --targets 'EVM' --use-ccache
123 changes: 123 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Benchmarks

on:
pull_request:
workflow_dispatch:
inputs:
llvm_build_type:
description: "LLVM build type: debug | release"
required: true
default: "release"
compiler_tester_reference_branch:
description: "compiler-tester branch to use as a benchmark reference"
required: true
default: "main"
compiler_tester_candidate_branch:
description: "compiler-tester branch to use as a benchmark candidate"
required: true
default: "main"
compiler_llvm_benchmark_mode:
description: "Mode filter for compiler-llvm benchmarks"
required: false
default: "^M^B3"
compiler_llvm_benchmark_path:
description: "Path filter for compiler-llvm benchmarks"
required: false
default: ""

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
benchmarks:
strategy:
matrix:
type: ["reference", "candidate"]
name: ${{ matrix.type }}
runs-on: matterlabs-ci-runner
container:
image: matterlabs/llvm_runner:ubuntu22-llvm15-latest
options: -m 110g
env:
LLVM_BENCHMARK_MODE: ${{ github.event.inputs.compiler_llvm_benchmark_mode || '^M^B3' }}
LLVM_BENCHMARK_PATH: ${{ github.event.inputs.compiler_llvm_benchmark_path || '' }}
steps:
- name: Define branches
run: |
if [ "${{ matrix.type }}" = "candidate" ]; then
echo "COMPILER_TESTER_BRANCH_NAME=${{ github.event.inputs.compiler_tester_candidate_branch || 'main' }}" >> $GITHUB_ENV
else
echo "COMPILER_TESTER_BRANCH_NAME=${{ github.event.inputs.compiler_tester_reference_branch || 'main' }}" >> $GITHUB_ENV
fi
- name: Checkout compiler-tester
uses: actions/checkout@v4
with:
repository: matter-labs/era-compiler-tester
ref: ${{ env.COMPILER_TESTER_BRANCH_NAME }}
submodules: recursive

- name: Build LLVM
uses: ./.github/actions/build-llvm
with:
debug: ${{ github.event.inputs.llvm_build_type || 'release' }}

- name: Benchmark
env:
RUST_BACKTRACE: full
run: |
export LLVM_SYS_150_PREFIX="$(pwd)/target-llvm/target-final/"
cargo build --verbose --release --bin 'compiler-tester'
cargo build --verbose --release --manifest-path /usr/local/cargo/git/checkouts/era-compiler-solidity-*/*/Cargo.toml --target-dir './target-zksolc/'
cargo build --verbose --release --manifest-path /usr/local/cargo/git/checkouts/era-compiler-vyper-*/*/Cargo.toml --target-dir './target-zkvyper/'
./target/release/compiler-tester \
--zksolc './target-zksolc/release/zksolc' \
--zkvyper './target-zkvyper/release/zkvyper' \
--path=${{ env.LLVM_BENCHMARK_PATH }} \
--mode=${{ env.LLVM_BENCHMARK_MODE }} \
--benchmark=${{ matrix.type }}.json
- uses: actions/upload-artifact@v4
with:
name: compiler-llvm-${{ matrix.type }}-benchmark
path: ${{ matrix.type }}.json

analysis:
name: "Benchmark comparison"
runs-on: matterlabs-ci-runner
container:
image: matterlabs/llvm_runner:ubuntu22-llvm15-latest
needs: benchmarks
steps:
- name: Checking out the compiler-tester repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.compiler_tester_candidate_branch || 'main' }}
submodules: recursive

- uses: actions/download-artifact@v4
with:
pattern: compiler-llvm-*
merge-multiple: true

- name: Comparing the LLVM framework benchmark results
run: |
cargo run --release --bin benchmark-analyzer -- \
--reference reference.json --candidate candidate.json --output-file result.txt
- name: Posting the LLVM benchmark results to the summary
run: |
printf "Benchmark results:\n" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat result.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat $GITHUB_STEP_SUMMARY > result.txt
- name: Posting the LLVM benchmark results to a PR comment
if: github.event_name == 'pull_request'
uses: mshick/add-pr-comment@v2
env:
GITHUB_TOKEN: ${{ secrets.ZKSYNC_ADMIN_BOT_ORG_REPO_WRITE }}
with:
message-path: result.txt
48 changes: 48 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Tests

on:
pull_request:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
testing:
runs-on: [self-hosted, ci-runner-compiler]
timeout-minutes: 720
container:
image: matterlabs/llvm_runner:ubuntu22-llvm15-latest
options: -m 110g
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build LLVM
uses: ./.github/actions/build-llvm

- name: Run tests
run: |
export RUST_BACKTRACE='full'
export LLVM_SYS_150_PREFIX="$(pwd)/target-llvm/target-final/"
cargo build --verbose --release --bin 'compiler-tester'
cargo build --verbose --release --manifest-path /usr/local/cargo/git/checkouts/era-compiler-solidity-*/*/Cargo.toml --target-dir './target-zksolc/'
cargo build --verbose --release --manifest-path /usr/local/cargo/git/checkouts/era-compiler-vyper-*/*/Cargo.toml --target-dir './target-zkvyper/'
./target/release/compiler-tester \
--zksolc './target-zksolc/release/zksolc' \
--zkvyper './target-zkvyper/release/zkvyper'
- name: Send Slack notification
uses: 8398a7/action-slack@v3
if: ${{ failure() || success() }} # Skip canceled jobs
with:
status: ${{ job.status }}
fields: repo,commit,author,action,eventName,ref,workflow,job,took,pullRequest
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
19 changes: 10 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# Generated by Cargo
# will have compiled files and executables
/target/
# Compiled files and executables
/target*/

# These are backup files generated by rustfmt
**/*.rs.bk

# The LLVM framework source and build
# MacOS
/**/.DS_Store

# IDE
/.idea/
/.vscode/

# The LLVM framework source
/llvm/
/target-llvm*/

# External compilers
/solc-bin/*
Expand All @@ -20,7 +25,3 @@
# The dependency locks
# /Cargo.lock
# /LLVM.lock

# IDE
/.idea/
/.vscode/
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
path = solidity
url = https://github.com/ethereum/solidity
branch = develop
[submodule "system-contracts"]
path = system-contracts
url = https://github.com/matter-labs/era-system-contracts
branch = main
[submodule "era-contracts"]
path = era-contracts
url = https://github.com/matter-labs/era-contracts
branch = release-v20-1.4.1-short-term-fee-model
Loading

0 comments on commit 076a46c

Please sign in to comment.