Skip to content

Commit

Permalink
Merge branch 'tx-to-optional-address' into evm-simulator-base-sc
Browse files Browse the repository at this point in the history
  • Loading branch information
jrchatruc committed Sep 18, 2024
2 parents dfef5ea + 6be103f commit 9700ff3
Show file tree
Hide file tree
Showing 314 changed files with 11,485 additions and 4,713 deletions.
Empty file removed .env
Empty file.
43 changes: 43 additions & 0 deletions .github/scripts/rate_limit_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

set -o errexit
set -o pipefail


api_endpoint="https://api.github.com/users/zksync-era-bot"
wait_time=60
max_retries=60
retry_count=0

while [[ $retry_count -lt $max_retries ]]; do
response=$(run_retried curl -s -w "%{http_code}" -o temp.json "$api_endpoint")
http_code=$(echo "$response" | tail -n1)

if [[ "$http_code" == "200" ]]; then
echo "Request successful. Not rate-limited."
cat temp.json
rm temp.json
exit 0
elif [[ "$http_code" == "403" ]]; then
rate_limit_exceeded=$(jq -r '.message' temp.json | grep -i "API rate limit exceeded")
if [[ -n "$rate_limit_exceeded" ]]; then
retry_count=$((retry_count+1))
echo "API rate limit exceeded. Retry $retry_count of $max_retries. Retrying in $wait_time seconds..."
sleep $wait_time
else
echo "Request failed with HTTP status $http_code."
cat temp.json
rm temp.json
exit 1
fi
else
echo "Request failed with HTTP status $http_code."
cat temp.json
rm temp.json
exit 1
fi
done

echo "Reached the maximum number of retries ($max_retries). Exiting."
rm temp.json
exit 1
159 changes: 159 additions & 0 deletions .github/workflows/build-base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
name: Build base Docker image
on:
workflow_dispatch:
inputs:
repo_ref:
description: "git reference of the zksync-era to build"
required: true
default: main
jobs:
build-images:
name: Build and Push Docker Images
runs-on: ${{ fromJSON('["matterlabs-ci-runner-high-performance", "matterlabs-ci-runner-arm"]')[contains(matrix.arch, 'arm')] }}
outputs:
image_tag_sha: ${{ steps.get-sha.outputs.image_tag_sha }}
# Needed to push to Gihub Package Registry
permissions:
packages: write
contents: read
env:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
REPO_REF: ${{ github.event.inputs.repo_ref }}
strategy:
matrix:
name: [ build-base ]
repository: [ zksync-build-base ]
arch: [ amd64, arm64 ]

steps:
- uses: actions/checkout@6d193bf28034eafb982f37bd894289fe649468fc # v4.1.7
with:
submodules: "recursive"

- name: Login to google container registry
run: |
gcloud auth configure-docker us-docker.pkg.dev -q
- name: Login to DockerHub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get tag
id: get-sha
run: |
echo IMAGE_TAG_SHA=$(git rev-parse --short HEAD) >> $GITHUB_ENV
echo image_tag_sha=$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1

- name: Build and push
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0
with:
push: true
context: .
file: docker/build-base/Dockerfile
labels: |
org.opencontainers.image.source=https://github.com/matter-labs/zksync-era
org.opencontainers.image.licenses="MIT OR Apache-2.0"
tags: |
matterlabs/zksync-build-base:${{ steps.get-sha.outputs.image_tag_sha }}-${{ matrix.arch }}
us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/zksync-build-base:${{ steps.get-sha.outputs.image_tag_sha }}-${{ matrix.arch }}
ghcr.io/${{ github.repository_owner }}/zksync-build-base:${{ steps.get-sha.outputs.image_tag_sha }}-${{ matrix.arch }}
multiarch_manifest:
# Needed to push to Gihub Package Registry
permissions:
packages: write
contents: read
needs: [ build-images ]
env:
IMAGE_TAG_SUFFIX: ${{ needs.build-images.outputs.image_tag_sha }}
runs-on: [ matterlabs-ci-runner-high-performance ]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1

- name: Login to google container registry
run: |
gcloud auth configure-docker us-docker.pkg.dev -q
- name: Login to DockerHub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and push multi-arch manifests for Dockerhub
shell: bash
run: |
images=("zksync-build-base")
archs=("amd64" "arm64")
for img in "${images[@]}"; do
multiarch_tag="matterlabs/zksync-build-base:latest"
individual_images=()
for arch in "${archs[@]}"; do
TAG="$IMAGE_TAG_SUFFIX"
docker pull matterlabs/zksync-build-base:${TAG}-${arch} --platform linux/${arch}
individual_images+=("matterlabs/zksync-build-base:${TAG}-${arch}")
done
docker buildx imagetools create --tag "${multiarch_tag}" "${individual_images[@]}"
done
- name: Create and push multi-arch manifests for GitHub Container Registry
shell: bash
run: |
images=("zksync-build-base")
archs=("amd64" "arm64")
for img in "${images[@]}"; do
multiarch_tag="ghcr.io/${{ github.repository_owner }}/zksync-build-base:latest"
individual_images=()
for arch in "${archs[@]}"; do
TAG="$IMAGE_TAG_SUFFIX"
docker pull ghcr.io/${{ github.repository_owner }}/zksync-build-base:${TAG}-${arch} --platform linux/${arch}
individual_images+=("ghcr.io/${{ github.repository_owner }}/zksync-build-base:${TAG}-${arch}")
done
docker buildx imagetools create --tag "${multiarch_tag}" "${individual_images[@]}"
done
- name: Create and push multi-arch manifests for Google Artifact Registry
shell: bash
run: |
images=("zksync-build-base")
archs=("amd64" "arm64")
for img in "${images[@]}"; do
multiarch_tag="us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/zksync-build-base:latest"
individual_images=()
for arch in "${archs[@]}"; do
TAG="$IMAGE_TAG_SUFFIX"
docker pull us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/zksync-build-base:${TAG}-${arch} --platform linux/${arch}
individual_images+=("us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/zksync-build-base:${TAG}-${arch}")
done
docker buildx imagetools create --tag "${multiarch_tag}" "${individual_images[@]}"
done
9 changes: 3 additions & 6 deletions .github/workflows/build-contract-verifier-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,15 @@ jobs:
ci_run git config --global --add safe.directory /usr/src/zksync/sdk/binaryen
ci_run git config --global --add safe.directory /usr/src/zksync/contracts/system-contracts
ci_run git config --global --add safe.directory /usr/src/zksync/contracts
ci_run zk || true
ci_run yarn zk build
ci_run ./bin/zkt || true
ci_run ./bin/zk || true
ci_run run_retried curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key
- name: build contracts
if: env.BUILD_CONTRACTS == 'true'
run: |
ci_run zk run yarn
ci_run cp etc/tokens/{test,localhost}.json
ci_run zk compiler all
ci_run zk contract build
ci_run zk f yarn run l2-contracts build
ci_run zk_supervisor contracts
- name: Login to Docker registries
if: ${{ inputs.action == 'push' }}
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/build-core-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,15 @@ jobs:
if [ $(jq length <<<"$tags") -eq 0 ]; then
echo "No tag found on all pages."
echo "BUILD_CONTRACTS=true" >> "$GITHUB_ENV"
# TODO Remove it when we migrate to foundry inside contracts repository
mkdir -p contracts/l1-contracts/artifacts/
exit 0
fi
filtered_tag=$(jq -r --arg commit_sha "$commit_sha" 'map(select(.commit.sha == $commit_sha)) | .[].name' <<<"$tags")
if [[ ! -z "$filtered_tag" ]]; then
echo "BUILD_CONTRACTS=false" >> "$GITHUB_ENV"
# TODO Remove it when we migrate to foundry inside contracts repository
mkdir -p contracts/l1-contracts/out
break
fi
((page++))
Expand Down Expand Up @@ -122,18 +126,15 @@ jobs:
ci_run git config --global --add safe.directory /usr/src/zksync/sdk/binaryen
ci_run git config --global --add safe.directory /usr/src/zksync/contracts/system-contracts
ci_run git config --global --add safe.directory /usr/src/zksync/contracts
ci_run zk || true
ci_run yarn zk build
ci_run ./bin/zk || true
ci_run ./bin/zkt || true
ci_run run_retried curl -LO https://storage.googleapis.com/matterlabs-setup-keys-us/setup-keys/setup_2\^26.key
- name: build contracts
if: env.BUILD_CONTRACTS == 'true'
run: |
ci_run zk run yarn
ci_run cp etc/tokens/{test,localhost}.json
ci_run zk compiler all
ci_run zk contract build
ci_run zk f yarn run l2-contracts build
ci_run zk_supervisor contracts
- name: Login to Docker registries
if: ${{ inputs.action == 'push' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-docker-from-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
with:
image_tag_suffix: ${{ needs.setup.outputs.image_tag_suffix }}-avx512
ERA_BELLMAN_CUDA_RELEASE: ${{ vars.ERA_BELLMAN_CUDA_RELEASE }}
CUDA_ARCH: "60;70;75;89"
CUDA_ARCH: "60;70;75;80;89"
WITNESS_GENERATOR_RUST_FLAGS: "-Ctarget_feature=+avx512bw,+avx512cd,+avx512dq,+avx512f,+avx512vl"
secrets:
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build-local-node-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
jobs:
build-images:
name: Local Node - Build and Push Docker Image
runs-on: [matterlabs-ci-runner-high-performance]
runs-on: [ matterlabs-ci-runner-high-performance ]
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
with:
Expand Down Expand Up @@ -61,9 +61,9 @@ jobs:
ci_run git config --global --add safe.directory /usr/src/zksync/contracts
ci_run zk
ci_run zkt
ci_run cp etc/tokens/{test,localhost}.json
ci_run zk compiler all
ci_run zk contract build
ci_run zk_supervisor contracts
- name: update-image
run: |
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/ci-common-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@ jobs:
echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
echo $(pwd)/bin >> $GITHUB_PATH
echo IN_DOCKER=1 >> .env
echo "SCCACHE_GCS_BUCKET=matterlabs-infra-sccache-storage" >> .env
echo "SCCACHE_GCS_SERVICE_ACCOUNT=gha-ci-runners@matterlabs-infra.iam.gserviceaccount.com" >> .env
echo "SCCACHE_GCS_RW_MODE=READ_WRITE" >> .env
echo "RUSTC_WRAPPER=sccache" >> .env
- name: Start services
run: |
run_retried docker-compose -f ${RUNNER_COMPOSE_FILE} pull
mkdir -p ./volumes/postgres
docker-compose -f ${RUNNER_COMPOSE_FILE} up --build -d zk postgres
ci_run sccache --start-server
- name: Init
run: |
ci_run zk
ci_run run_retried rustup show
ci_run zk db setup
ci_run zkt
# This does both linting and "building". We're using `zk lint prover` as it's common practice within our repo
# `zk lint prover` = cargo clippy, which does cargo check behind the scenes, which is a lightweight version of cargo build
- name: Lints
run: ci_run zk lint prover
run: ci_run zk_supervisor lint -t rs --check

5 changes: 4 additions & 1 deletion .github/workflows/ci-core-lint-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ jobs:
echo ZKSYNC_HOME=$(pwd) >> $GITHUB_ENV
echo $(pwd)/bin >> $GITHUB_PATH
echo IN_DOCKER=1 >> .env
echo "SCCACHE_GCS_BUCKET=matterlabs-infra-sccache-storage" >> .env
echo "SCCACHE_GCS_SERVICE_ACCOUNT=gha-ci-runners@matterlabs-infra.iam.gserviceaccount.com" >> .env
echo "SCCACHE_GCS_RW_MODE=READ_WRITE" >> .env
echo "RUSTC_WRAPPER=sccache" >> .env
echo "prover_url=postgres://postgres:notsecurepassword@localhost:5432/zksync_local_prover" >> $GITHUB_ENV
echo "core_url=postgres://postgres:notsecurepassword@localhost:5432/zksync_local" >> $GITHUB_ENV
- name: Start services
run: |
ci_localnet_up
ci_run sccache --start-server
- name: Build
run: |
Expand Down
Loading

0 comments on commit 9700ff3

Please sign in to comment.