Skip to content

Commit 9e0d0a5

Browse files
ManuelBilbaoCopilotilitteri
authored
chore(l2): do not use docker to compile prover except on releases (#5315)
**Motivation** <!-- Why does this pull request exist? What are its goals? --> We use docker to generate reproducible guest program elfs. This slows down a lot the compilation time (about 15 minutes in a Mac). **Description** <!-- A clear and concise general description of the changes this PR introduces --> Don't use docker by default but only when releasing binaries. The docker build is triggered by setting the `PROVER_REPRODUCIBLE_BUILD` env var. <!-- Link to issues: Resolves #111, Resolves #222 --> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: ilitteri <ilitteri@fi.uba.ar>
1 parent b6b7eac commit 9e0d0a5

File tree

5 files changed

+39
-33
lines changed

5 files changed

+39
-33
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: "Install RISC0"
2+
description: "Install RISC0 Toolchain"
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Install RISC0
8+
shell: bash
9+
run: |
10+
curl -L https://risczero.com/install | bash
11+
~/.risc0/bin/rzup install cargo-risczero 3.0.3
12+
~/.risc0/bin/rzup install risc0-groth16
13+
~/.risc0/bin/rzup install rust
14+
~/.risc0/bin/rzup install cpp
15+
~/.risc0/bin/rzup install r0vm 3.0.3

.github/workflows/pr-main_l2.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ jobs:
6969
- name: Install RISC0
7070
env:
7171
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72-
run: |
73-
curl -L https://risczero.com/install | bash
74-
~/.risc0/bin/rzup install cargo-risczero 3.0.3
75-
~/.risc0/bin/rzup install risc0-groth16
76-
~/.risc0/bin/rzup install rust
72+
uses: ./.github/actions/install-risc0
7773

7874
- name: Create placeholder SP1 ELF
7975
run: |

.github/workflows/pr-main_l2_prover.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,11 @@ jobs:
3030
- name: Add Rust Cache
3131
uses: Swatinem/rust-cache@v2
3232

33-
- name: RISC-V Risc0 toolchain install
33+
- name: Install RISC0
3434
if: matrix.backend == 'risc0'
3535
env:
3636
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37-
# should be able to specify a version for `rzup install rust` (toolchain version)
38-
# but it throws a "error decoding response body" in that case
39-
run: |
40-
curl -L https://risczero.com/install | bash
41-
~/.risc0/bin/rzup install cargo-risczero 3.0.3
42-
~/.risc0/bin/rzup install risc0-groth16
43-
~/.risc0/bin/rzup install rust
37+
uses: ./.github/actions/install-risc0
4438

4539
- name: RISC-V SP1 toolchain install
4640
if: matrix.backend == 'sp1'

.github/workflows/tag_release.yaml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ permissions:
1818
env:
1919
REGISTRY: ghcr.io
2020
IMAGE_NAME: ${{ github.repository }}
21+
PROVER_REPRODUCIBLE_BUILD: true
2122

2223
jobs:
2324
build-ethrex:
@@ -96,11 +97,8 @@ jobs:
9697
if: ${{ matrix.platform == 'ubuntu-22.04' }}
9798
env:
9899
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99-
run: |
100-
curl -L https://risczero.com/install | bash
101-
~/.risc0/bin/rzup install cargo-risczero 3.0.3
102-
~/.risc0/bin/rzup install risc0-groth16
103-
~/.risc0/bin/rzup install rust
100+
uses: ./.github/actions/install-risc0
101+
104102
- name: Install CUDA (only Linux x86 GPU)
105103
uses: Jimver/cuda-toolkit@v0.2.24
106104
if: ${{ matrix.platform == 'ubuntu-22.04' && matrix.stack == 'l2_gpu' }}
@@ -185,11 +183,7 @@ jobs:
185183
if: ${{ matrix.zkvm == 'risc0' }}
186184
env:
187185
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
188-
run: |
189-
curl -L https://risczero.com/install | bash
190-
~/.risc0/bin/rzup install cargo-risczero 3.0.3
191-
~/.risc0/bin/rzup install risc0-groth16
192-
~/.risc0/bin/rzup install rust
186+
uses: ./.github/actions/install-risc0
193187

194188
- name: Build ethrex elf - ${{ matrix.zkvm }}
195189
run: |

crates/l2/prover/src/guest_program/build.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,22 @@ fn build_risc0_program() {
1919
vec![]
2020
};
2121

22-
let docker_options = DockerOptionsBuilder::default()
23-
.root_dir(format!("{}/../../../../../", env!("CARGO_MANIFEST_DIR")))
24-
.build()
25-
.unwrap();
26-
let guest_options = GuestOptionsBuilder::default()
27-
.features(features)
28-
.use_docker(docker_options)
29-
.build()
30-
.unwrap();
22+
let guest_options = if option_env!("PROVER_REPRODUCIBLE_BUILD").is_some() {
23+
let docker_options = DockerOptionsBuilder::default()
24+
.root_dir(format!("{}/../../../../../", env!("CARGO_MANIFEST_DIR")))
25+
.build()
26+
.unwrap();
27+
GuestOptionsBuilder::default()
28+
.features(features)
29+
.use_docker(docker_options)
30+
.build()
31+
.unwrap()
32+
} else {
33+
GuestOptionsBuilder::default()
34+
.features(features)
35+
.build()
36+
.unwrap()
37+
};
3138

3239
let built_guests = embed_methods_with_options(std::collections::HashMap::from([(
3340
"zkvm-risc0-program",
@@ -66,7 +73,7 @@ fn build_sp1_program() {
6673
output_directory: Some("./src/sp1/out".to_string()),
6774
elf_name: Some("riscv32im-succinct-zkvm-elf".to_string()),
6875
features,
69-
docker: true,
76+
docker: option_env!("PROVER_REPRODUCIBLE_BUILD").is_some(),
7077
tag: "v5.0.8".to_string(),
7178
workspace_directory: Some(format!("{}/../../../../../", env!("CARGO_MANIFEST_DIR"))),
7279
..Default::default()

0 commit comments

Comments
 (0)