Skip to content

Commit b92c785

Browse files
ilitteriCopilot
authored andcommitted
chore(l2): include zkVM ELFs and VKs in the releases (#5244)
**Motivation** We need releases of ethrex's ELFs and VKs to use independently for proving L1 blocks execution. **Description** - Adds a `build-ethrex-guest` workflow to run with a mattrix strategy (for sp1 and risc0) that builds the `guest_program` crate with the features `sp1` and `risc0`. We need this as a separate job and cannot reuse the builds from ubuntu-22.04 for l2_gpu because the guest program being built there is different than the one we need for statelessly verifying L1 blocks. - Adds a `package-ethrex-guests` workflow to create `ethrex-guests.tar.gz` compressing SP1 and RISC0 elf and vks. - RISC0's ELF file is now generated. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 31957d4 commit b92c785

File tree

2 files changed

+112
-1
lines changed

2 files changed

+112
-1
lines changed

.github/workflows/tag_release.yaml

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,111 @@ jobs:
149149
name: verification_keys
150150
path: verification_keys/
151151

152+
# There's a separate job to build the guest programs for SP1 and RISC0 since
153+
# they need to be built without the l2 features.
154+
build-ethrex-guest:
155+
strategy:
156+
matrix:
157+
zkvm:
158+
- sp1
159+
- risc0
160+
runs-on: ubuntu-latest
161+
steps:
162+
- name: Checkout code
163+
uses: actions/checkout@v4
164+
165+
- name: Free Disk Space
166+
uses: ./.github/actions/free-disk
167+
168+
- name: Setup Rust Environment
169+
uses: ./.github/actions/setup-rust
170+
171+
- name: Install SP1
172+
if: ${{ matrix.zkvm == 'sp1' }}
173+
env:
174+
SHELL: /bin/bash
175+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
176+
run: |
177+
curl -L https://sp1up.succinct.xyz | bash
178+
~/.sp1/bin/sp1up --version 5.0.8
179+
180+
- name: Install RISC0
181+
if: ${{ matrix.zkvm == 'risc0' }}
182+
env:
183+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
184+
run: |
185+
curl -L https://risczero.com/install | bash
186+
~/.risc0/bin/rzup install cargo-risczero 3.0.3
187+
~/.risc0/bin/rzup install risc0-groth16
188+
~/.risc0/bin/rzup install rust
189+
190+
- name: Build ethrex elf - ${{ matrix.zkvm }}
191+
run: |
192+
cargo build --release --package guest_program --features ${{ matrix.zkvm }}
193+
mkdir -p ${{ matrix.zkvm }}_verification_keys
194+
if [ "${{ matrix.zkvm }}" = "sp1" ]; then
195+
mv crates/l2/prover/src/guest_program/src/${{ matrix.zkvm }}/out/riscv32im-succinct-zkvm-elf ethrex-riscv32im-${{ matrix.zkvm }}-elf-${{ github.ref_name }}
196+
mv crates/l2/prover/src/guest_program/src/${{ matrix.zkvm }}/out/riscv32im-succinct-zkvm-vk-bn254 ${{ matrix.zkvm }}_verification_keys/ethrex-riscv32im-${{ matrix.zkvm }}-vk-bn254-${{ github.ref_name }}
197+
mv crates/l2/prover/src/guest_program/src/${{ matrix.zkvm }}/out/riscv32im-succinct-zkvm-vk-u32 ${{ matrix.zkvm }}_verification_keys/ethrex-riscv32im-${{ matrix.zkvm }}-vk-u32-${{ github.ref_name }}
198+
elif [ "${{ matrix.zkvm }}" = "risc0" ]; then
199+
mv crates/l2/prover/src/guest_program/src/${{ matrix.zkvm }}/out/riscv32im-risc0-elf ethrex-riscv32im-${{ matrix.zkvm }}-elf-${{ github.ref_name}}
200+
mv crates/l2/prover/src/guest_program/src/${{ matrix.zkvm }}/out/riscv32im-risc0-vk ${{ matrix.zkvm }}_verification_keys/ethrex-riscv32im-${{ matrix.zkvm }}-vk-${{ github.ref_name}}
201+
fi
202+
203+
- name: Upload ethrex guest elf artifact - ${{ matrix.zkvm }}
204+
uses: actions/upload-artifact@v4
205+
with:
206+
name: ethrex-riscv32im-${{ matrix.zkvm }}-elf-${{ github.ref_name }}
207+
path: ethrex-riscv32im-${{ matrix.zkvm }}-elf-${{ github.ref_name }}
208+
209+
- name: Upload ethrex guest verification keys - ${{ matrix.zkvm }}
210+
uses: actions/upload-artifact@v4
211+
with:
212+
name: ${{ matrix.zkvm }}_verification_keys
213+
path: ${{ matrix.zkvm }}_verification_keys/
214+
215+
# Creates ethrex-guests.tar.gz artifact including both SP1 and
216+
# RISC0 elf and verification keys.
217+
package-ethrex-guest:
218+
needs:
219+
- build-ethrex-guest
220+
runs-on: ubuntu-latest
221+
steps:
222+
- name: Download SP1 elf artifact
223+
uses: actions/download-artifact@v4
224+
with:
225+
name: ethrex-riscv32im-sp1-elf-${{ github.ref_name }}
226+
path: ethrex_guests/sp1/
227+
228+
- name: Download SP1 verification keys artifacts
229+
uses: actions/download-artifact@v4
230+
with:
231+
name: sp1_verification_keys
232+
path: ethrex_guests/sp1/
233+
234+
- name: Download RISC0 elf artifact
235+
uses: actions/download-artifact@v4
236+
with:
237+
name: ethrex-riscv32im-risc0-elf-${{ github.ref_name }}
238+
path: ethrex_guests/risc0/
239+
240+
- name: Download RISC0 verification keys artifacts
241+
uses: actions/download-artifact@v4
242+
with:
243+
name: risc0_verification_keys
244+
path: ethrex_guests/risc0/
245+
246+
- name: Archive ethrex guests
247+
run: |
248+
cd ethrex_guests/
249+
tar -czvf ../ethrex-guests.tar.gz .
250+
251+
- name: Upload ethrex guests artifact
252+
uses: actions/upload-artifact@v4
253+
with:
254+
name: ethrex-guests.tar.gz
255+
path: ethrex-guests.tar.gz
256+
152257
package-contracts:
153258
needs:
154259
- build-ethrex
@@ -221,8 +326,10 @@ jobs:
221326
finalize-release:
222327
needs:
223328
- build-ethrex
329+
- build-ethrex-guest
224330
- build-docker
225331
- package-contracts
332+
- package-ethrex-guest
226333
runs-on: ubuntu-latest
227334
steps:
228335
- name: Checkout Code
@@ -234,7 +341,7 @@ jobs:
234341
uses: actions/download-artifact@v4
235342
with:
236343
path: ./bin
237-
pattern: "ethrex*"
344+
pattern: "ethrex*" # This includes the binaries, elf files, ethrex-verification-keys.tar.gz, and ethrex-contracts.tar.gz
238345

239346
- name: Get previous tag
240347
run: |

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,15 @@ fn build_risc0_program() {
3333
"zkvm-risc0-program",
3434
guest_options,
3535
)]));
36+
let elf = built_guests[0].elf.clone();
3637
let image_id = built_guests[0].image_id;
3738

3839
// this errs if the dir already exists, so we don't handle an error.
3940
let _ = std::fs::create_dir("./src/risc0/out");
4041

42+
std::fs::write("./src/risc0/out/riscv32im-risc0-elf", &elf)
43+
.expect("could not write Risc0 elf to file");
44+
4145
std::fs::write(
4246
"./src/risc0/out/riscv32im-risc0-vk",
4347
format!("0x{}\n", hex::encode(image_id.as_bytes())),

0 commit comments

Comments
 (0)