Skip to content

Commit 1095ae7

Browse files
EmilLutayorik
andauthored
feat(circuit-prover): Add circuit_prover Dockerfile and build rules (matter-labs#2939)
This will enable us to build images for circuit proving (new version). Not tested. --------- Co-authored-by: Yury Akudovich <ya@matterlabs.dev>
1 parent 7026637 commit 1095ae7

File tree

7 files changed

+114
-17
lines changed

7 files changed

+114
-17
lines changed

.github/workflows/build-docker-from-tag.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ jobs:
108108
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
109109
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
110110

111-
build-gar-prover-fri-gpu:
111+
build-gar-prover-fri-gpu-and-circuit-prover-gpu-gar:
112112
name: Build GAR prover FRI GPU
113113
needs: [ setup, build-push-prover-images ]
114-
uses: ./.github/workflows/build-prover-fri-gpu-gar.yml
114+
uses: ./.github/workflows/build-prover-fri-gpu-gar-and-circuit-prover-gpu-gar.yml
115115
if: contains(github.ref_name, 'prover')
116116
with:
117117
setup_keys_id: ${{ needs.setup.outputs.prover_fri_gpu_key_id }}

.github/workflows/build-prover-fri-gpu-gar.yml renamed to .github/workflows/build-prover-fri-gpu-gar-and-circuit-prover-gpu-gar.yml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Prover FRI GPU with builtin setup data
1+
name: Build Prover FRI GPU & Circuit Prover GPU with builtin setup data
22

33
on:
44
workflow_call:
@@ -17,7 +17,7 @@ on:
1717
type: string
1818

1919
jobs:
20-
build-gar-prover-fri-gpu:
20+
build:
2121
name: Build prover FRI GPU GAR
2222
runs-on: [matterlabs-ci-runner-high-performance]
2323
steps:
@@ -39,7 +39,15 @@ jobs:
3939
- name: Set up Docker Buildx
4040
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
4141

42-
- name: Build and push
42+
- name: Login to Asia GAR
43+
run: |
44+
gcloud auth print-access-token --lifetime=7200 --impersonate-service-account=gha-ci-runners@matterlabs-infra.iam.gserviceaccount.com | docker login -u oauth2accesstoken --password-stdin https://asia-docker.pkg.dev
45+
46+
- name: Login to Europe GAR
47+
run: |
48+
gcloud auth print-access-token --lifetime=7200 --impersonate-service-account=gha-ci-runners@matterlabs-infra.iam.gserviceaccount.com | docker login -u oauth2accesstoken --password-stdin https://europe-docker.pkg.dev
49+
50+
- name: Build and push prover-gpu-fri-gar
4351
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0
4452
with:
4553
context: docker/prover-gpu-fri-gar
@@ -49,22 +57,36 @@ jobs:
4957
tags: |
5058
us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/prover-fri-gpu-gar:2.0-${{ inputs.protocol_version }}-${{ inputs.image_tag_suffix }}
5159
52-
- name: Login to Asia GAR
60+
- name: Build and push prover-gpu-fri-gar to Asia GAR
5361
run: |
54-
gcloud auth print-access-token --lifetime=7200 --impersonate-service-account=gha-ci-runners@matterlabs-infra.iam.gserviceaccount.com | docker login -u oauth2accesstoken --password-stdin https://asia-docker.pkg.dev
62+
docker buildx imagetools create \
63+
--tag asia-docker.pkg.dev/matterlabs-infra/matterlabs-docker/prover-fri-gpu-gar:2.0-${{ inputs.protocol_version }}-${{ inputs.image_tag_suffix }} \
64+
us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/prover-fri-gpu-gar:2.0-${{ inputs.protocol_version }}-${{ inputs.image_tag_suffix }}
5565
56-
- name: Build and push to Asia GAR
66+
- name: Build and push prover-gpu-fri-gar to Europe GAR
5767
run: |
5868
docker buildx imagetools create \
59-
--tag asia-docker.pkg.dev/matterlabs-infra/matterlabs-docker/prover-fri-gpu-gar:2.0-${{ inputs.protocol_version }}-${{ inputs.image_tag_suffix }} \
69+
--tag europe-docker.pkg.dev/matterlabs-infra/matterlabs-docker/prover-fri-gpu-gar:2.0-${{ inputs.protocol_version }}-${{ inputs.image_tag_suffix }} \
6070
us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/prover-fri-gpu-gar:2.0-${{ inputs.protocol_version }}-${{ inputs.image_tag_suffix }}
6171
62-
- name: Login to Europe GAR
72+
- name: Build and push circuit-prover-gpu-gar
73+
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0
74+
with:
75+
context: docker/circuit-prover-gpu-gar
76+
build-args: |
77+
PROVER_IMAGE=${{ inputs.protocol_version }}-${{ inputs.image_tag_suffix }}
78+
push: true
79+
tags: |
80+
us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/circuit-prover-gpu-gar:2.0-${{ inputs.protocol_version }}-${{ inputs.image_tag_suffix }}
81+
82+
- name: Build and push circuit-prover-gpu-gar to Asia GAR
6383
run: |
64-
gcloud auth print-access-token --lifetime=7200 --impersonate-service-account=gha-ci-runners@matterlabs-infra.iam.gserviceaccount.com | docker login -u oauth2accesstoken --password-stdin https://europe-docker.pkg.dev
84+
docker buildx imagetools create \
85+
--tag asia-docker.pkg.dev/matterlabs-infra/matterlabs-docker/circuit-prover-gpu-gar:2.0-${{ inputs.protocol_version }}-${{ inputs.image_tag_suffix }} \
86+
us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/circuit-prover-gpu-gar:2.0-${{ inputs.protocol_version }}-${{ inputs.image_tag_suffix }}
6587
66-
- name: Build and push to Europe GAR
88+
- name: Build and push circuit-prover-gpu-gar to Europe GAR
6789
run: |
6890
docker buildx imagetools create \
69-
--tag europe-docker.pkg.dev/matterlabs-infra/matterlabs-docker/prover-fri-gpu-gar:2.0-${{ inputs.protocol_version }}-${{ inputs.image_tag_suffix }} \
70-
us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/prover-fri-gpu-gar:2.0-${{ inputs.protocol_version }}-${{ inputs.image_tag_suffix }}
91+
--tag europe-docker.pkg.dev/matterlabs-infra/matterlabs-docker/circuit-prover-gpu-gar:2.0-${{ inputs.protocol_version }}-${{ inputs.image_tag_suffix }} \
92+
us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/circuit-prover-gpu-gar:2.0-${{ inputs.protocol_version }}-${{ inputs.image_tag_suffix }}

.github/workflows/build-prover-template.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
- witness-generator
5353
- prover-gpu-fri
5454
- witness-vector-generator
55+
- circuit-prover-gpu
5556
- prover-fri-gateway
5657
- prover-job-monitor
5758
- proof-fri-gpu-compressor

.github/workflows/release-test-stage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ jobs:
120120
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
121121
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
122122

123-
build-gar-prover-fri-gpu:
123+
build-gar-prover-fri-gpu-and-circuit-prover-gpu-gar:
124124
name: Build GAR prover FRI GPU
125125
needs: [ setup, build-push-prover-images ]
126-
uses: ./.github/workflows/build-prover-fri-gpu-gar.yml
126+
uses: ./.github/workflows/build-prover-fri-gpu-gar-and-circuit-prover-gpu-gar.yml
127127
if: needs.changed_files.outputs.prover == 'true' || needs.changed_files.outputs.all == 'true'
128128
with:
129129
setup_keys_id: ${{ needs.setup.outputs.prover_fri_gpu_key_id }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ARG PROVER_IMAGE
2+
FROM us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/circuit-prover-gpu:2.0-$PROVER_IMAGE as prover
3+
4+
FROM nvidia/cuda:12.2.0-runtime-ubuntu22.04 as app
5+
6+
# HACK copying to root is the only way to make Docker layer caching work for these files for some reason
7+
COPY *.bin /
8+
9+
RUN apt-get update && apt-get install -y libpq5 ca-certificates openssl && rm -rf /var/lib/apt/lists/*
10+
11+
# copy finalization hints required for assembly generation
12+
COPY --from=prover prover/data/keys/ /prover/data/keys/
13+
COPY --from=prover /usr/bin/zksync_circuit_prover /usr/bin/
14+
15+
ENTRYPOINT ["zksync_circuit_prover"]

docker/circuit-prover-gpu/Dockerfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
FROM nvidia/cuda:12.2.0-devel-ubuntu22.04 AS builder
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
5+
ARG CUDA_ARCH=89
6+
ENV CUDAARCHS=${CUDA_ARCH}
7+
8+
# set of args for use of sccache
9+
ARG SCCACHE_GCS_BUCKET=""
10+
ARG SCCACHE_GCS_SERVICE_ACCOUNT=""
11+
ARG SCCACHE_GCS_RW_MODE=""
12+
ARG RUSTC_WRAPPER=""
13+
14+
ENV SCCACHE_GCS_BUCKET=${SCCACHE_GCS_BUCKET}
15+
ENV SCCACHE_GCS_SERVICE_ACCOUNT=${SCCACHE_GCS_SERVICE_ACCOUNT}
16+
ENV SCCACHE_GCS_RW_MODE=${SCCACHE_GCS_RW_MODE}
17+
ENV RUSTC_WRAPPER=${RUSTC_WRAPPER}
18+
19+
RUN apt-get update && apt-get install -y curl clang openssl libssl-dev gcc g++ \
20+
pkg-config build-essential libclang-dev && \
21+
rm -rf /var/lib/apt/lists/*
22+
23+
ENV RUSTUP_HOME=/usr/local/rustup \
24+
CARGO_HOME=/usr/local/cargo \
25+
PATH=/usr/local/cargo/bin:$PATH
26+
27+
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y && \
28+
rustup install nightly-2024-08-01 && \
29+
rustup default nightly-2024-08-01
30+
31+
RUN curl -Lo cmake-3.24.2-linux-x86_64.sh https://github.com/Kitware/CMake/releases/download/v3.24.2/cmake-3.24.2-linux-x86_64.sh && \
32+
chmod +x cmake-3.24.2-linux-x86_64.sh && \
33+
./cmake-3.24.2-linux-x86_64.sh --skip-license --prefix=/usr/local
34+
35+
# install sccache
36+
RUN curl -Lo sccache-v0.8.1-x86_64-unknown-linux-musl.tar.gz https://github.com/mozilla/sccache/releases/download/v0.8.1/sccache-v0.8.1-x86_64-unknown-linux-musl.tar.gz && \
37+
tar -xzf sccache-v0.8.1-x86_64-unknown-linux-musl.tar.gz && \
38+
cp sccache-v0.8.1-x86_64-unknown-linux-musl/sccache /usr/local/sbin/ && \
39+
rm -rf sccache-v0.8.1-x86_64-unknown-linux-musl.tar.gz && \
40+
rm -rf sccache-v0.8.1-x86_64-unknown-linux-musl && \
41+
chmod +x /usr/local/sbin/sccache
42+
43+
WORKDIR /usr/src/zksync
44+
COPY . .
45+
46+
RUN cd prover && cargo build --release --bin zksync_circuit_prover
47+
48+
FROM nvidia/cuda:12.2.0-runtime-ubuntu22.04
49+
50+
RUN apt-get update && apt-get install -y curl libpq5 ca-certificates && rm -rf /var/lib/apt/lists/*
51+
52+
# copy finalization hints required for assembly generation
53+
COPY prover/data/keys/ /prover/data/keys/
54+
55+
COPY --from=builder /usr/src/zksync/prover/target/release/zksync_circuit_prover /usr/bin/
56+
57+
ENTRYPOINT ["zksync_circuit_prover"]

infrastructure/zk/src/docker.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const IMAGES = [
1111
'witness-generator',
1212
'prover-gpu-fri',
1313
'witness-vector-generator',
14+
'circuit-prover-gpu',
1415
'prover-fri-gateway',
1516
'prover-job-monitor',
1617
'proof-fri-gpu-compressor',
@@ -87,7 +88,8 @@ function defaultTagList(image: string, imageTagSha: string, imageTagShaTS: strin
8788
'prover-fri-gateway',
8889
'prover-gpu-fri',
8990
'witness-generator',
90-
'witness-vector-generator'
91+
'witness-vector-generator',
92+
'circuit-prover-gpu'
9193
].includes(image)
9294
) {
9395
tagList.push(`2.0-${protocolVersionTag}-${imageTagShaTS}`, `${protocolVersionTag}-${imageTagShaTS}`);

0 commit comments

Comments
 (0)