Skip to content

Commit cdb952e

Browse files
ManuelBilbaoilitterifedacking
authored
refactor(l1,l2): separate binaries (#4829)
**Motivation** We aim to reintroduce the L2 feature flag making so that ethrex has 3 available binaries, the L1 execution client, the L2 client and the L2+GPU client. This is done for the following advantages: - Less crates needed for the L1 as the UI, L2, zkVMs crates are excluded. - L1, L2, y zkVMs are compiled with the optimum crates for performance and their needs. - The L1 user only downloads a client without unneeded functionality. **Description** - Added feature flag l2 to ethrex to compile l2 dependencies separately - Added feature flag l2-sql to ethrex to launch l2 with the SQL database for the rollup - Modified CI to create 2 tar images of ethrex for testing, ethrex:main and ethrex:main-l2 - Modified lint commands in makefile to lint l1 and l2 separately. L1 can't handle the workspace flag, due to some l2 crates in the workspace. --------- Co-authored-by: ilitteri <[email protected]> Co-authored-by: Francisco Xavier Gauna <[email protected]>
1 parent a90b1fd commit cdb952e

File tree

32 files changed

+836
-617
lines changed

32 files changed

+836
-617
lines changed

.github/actions/build-docker/action.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ inputs:
1919
description: "Whether to push the built image to the registry"
2020
required: false
2121
default: "false"
22+
artifact_path:
23+
description: "The name of the artifact that is going to be pushed"
24+
required: false
25+
default: "ethrex_image.tar"
26+
build_args:
27+
description: "The arguments that are sent to the dockerfile to built. Format ARG=value"
28+
required: false
29+
default: ""
2230

2331
outputs:
2432
artifact_path:
@@ -31,7 +39,7 @@ runs:
3139
- id: vars
3240
shell: bash
3341
run: |
34-
echo "artifact_path=/tmp/ethrex_image.tar" >> $GITHUB_OUTPUT
42+
echo "artifact_path=/tmp/${{ inputs.artifact_path }}" >> $GITHUB_OUTPUT
3543
3644
- name: Login to Docker registry
3745
if: inputs.username != '' && inputs.password != ''
@@ -54,6 +62,7 @@ runs:
5462
outputs: ${{ inputs.push == 'false' && format('type=docker,dest={0}', steps.vars.outputs.artifact_path) || '' }}
5563
cache-from: type=gha
5664
cache-to: type=gha,mode=max
65+
build-args: ${{ inputs.build_args }}
5766

5867
# Since we're exporting the image as a tar, we need to load it manually as well
5968
- name: Load image locally

.github/workflows/main_docker_publish.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,25 @@ jobs:
2525
- name: Checkout repository
2626
uses: actions/checkout@v4
2727

28-
# Pushes to ghcr.io/lambdaclass/ethrex
29-
- name: Build and push Docker image
30-
id: push
28+
# Pushes l1 to ghcr.io/lambdaclass/ethrex
29+
- name: Build and push L1 Docker image
30+
id: push_l1
3131
uses: ./.github/actions/build-docker
3232
with:
3333
registry: ${{ env.REGISTRY }}
3434
username: ${{ github.actor }}
3535
password: ${{ secrets.GITHUB_TOKEN }}
3636
push: true
3737
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main
38+
39+
# Pushe l2 to ghcr.io/lambdaclass/ethrex
40+
- name: Build and push L2 Docker image
41+
id: push_l2
42+
uses: ./.github/actions/build-docker
43+
with:
44+
registry: ${{ env.REGISTRY }}
45+
username: ${{ github.actor }}
46+
password: ${{ secrets.GITHUB_TOKEN }}
47+
push: true
48+
build_args: BUILD_FLAGS=--features l2,l2-sql
49+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:main-l2

.github/workflows/main_prover.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
- name: Build test
5757
# if: ${{ always() && github.event_name == 'merge_group' }}
5858
run: |
59-
cargo test l2 --no-run --release
59+
cargo test l2 --features l2 --no-run --release
6060
6161
- name: Start L1 & Deploy contracts
6262
# if: ${{ always() && github.event_name == 'merge_group' }}

.github/workflows/pr-main_l1.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ jobs:
3131
with:
3232
components: rustfmt, clippy
3333

34+
# We don't run with workspace, as members of the workspace require l2. We run it with workspace
35+
# om the l2 lint
3436
- name: Run cargo check
35-
run: cargo check --workspace
37+
run: cargo check
3638

3739
- name: Run cargo clippy
3840
run: |
39-
cargo clippy --workspace -- -D warnings
4041
cargo clippy -- -D warnings
4142
4243
- name: Run cargo fmt

.github/workflows/pr-main_l2.yaml

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ jobs:
5252
touch crates/l2/prover/src/guest_program/src/sp1/out/riscv32im-succinct-zkvm-elf
5353
5454
- name: Run cargo check
55-
run: cargo check --workspace
55+
run: cargo check --workspace --features l2,l2-sql
5656

5757
- name: Run cargo clippy
5858
run: |
59-
cargo clippy --workspace -- -D warnings
59+
cargo clippy --workspace --features l2,l2-sql -- -D warnings
6060
make lint
6161
6262
- name: Run cargo fmt
@@ -86,10 +86,37 @@ jobs:
8686
name: ethrex_image
8787
path: /tmp/ethrex_image.tar
8888

89+
# We build the docker image for the l2 usage. It needs to add
90+
# The build args for l2.
91+
build-docker-l2:
92+
name: Build docker image L2
93+
runs-on: ubuntu-latest
94+
steps:
95+
- name: Checkout sources
96+
uses: actions/checkout@v4
97+
98+
- name: Set up Docker Buildx
99+
uses: docker/setup-buildx-action@v3
100+
101+
- name: Build L2 docker image
102+
uses: ./.github/actions/build-docker
103+
with:
104+
username: ${{ vars.DOCKERHUB_USERNAME }}
105+
password: ${{ secrets.DOCKERHUB_TOKEN }}
106+
tags: ethrex:main-l2
107+
artifact_path: ethrex_image_l2.tar
108+
build_args: BUILD_FLAGS=--features l2
109+
110+
- name: Upload artifacts
111+
uses: actions/upload-artifact@v4
112+
with:
113+
name: ethrex_image_l2
114+
path: /tmp/ethrex_image_l2.tar
115+
89116
integration-test:
90117
name: Integration Test - ${{ matrix.name }}
91118
runs-on: ubuntu-latest
92-
needs: build-docker
119+
needs: [build-docker, build-docker-l2]
93120
strategy:
94121
matrix:
95122
include:
@@ -145,7 +172,7 @@ jobs:
145172
146173
- name: Build test
147174
run: |
148-
cargo test l2 --no-run --release
175+
cargo test l2 --features l2 --no-run --release
149176
150177
- name: Start Web3Signer
151178
if: matrix.web3signer
@@ -163,6 +190,16 @@ jobs:
163190
run: |
164191
docker load --input /tmp/ethrex_image.tar
165192
193+
- name: Download ethrex L2 image artifact
194+
uses: actions/download-artifact@v4
195+
with:
196+
name: ethrex_image_l2
197+
path: /tmp
198+
199+
- name: Load ethrex L2 image
200+
run: |
201+
docker load --input /tmp/ethrex_image_l2.tar
202+
166203
- name: Start L1
167204
run: |
168205
cd crates/l2
@@ -258,7 +295,7 @@ jobs:
258295
integration-test-tdx:
259296
name: Integration Test - TDX
260297
runs-on: ubuntu-latest
261-
needs: build-docker
298+
needs: [build-docker, build-docker-l2]
262299
steps:
263300
- name: Free Disk Space (Ubuntu)
264301
uses: jlumbroso/[email protected]
@@ -288,6 +325,16 @@ jobs:
288325
run: |
289326
docker load --input /tmp/ethrex_image.tar
290327
328+
- name: Download ethrex L2 image artifact
329+
uses: actions/download-artifact@v4
330+
with:
331+
name: ethrex_image_l2
332+
path: /tmp
333+
334+
- name: Load ethrex L2 image
335+
run: |
336+
docker load --input /tmp/ethrex_image_l2.tar
337+
291338
- name: Set up Nix
292339
uses: cachix/install-nix-action@v31
293340

@@ -355,7 +402,7 @@ jobs:
355402
state-diff-test:
356403
name: State Reconstruction Tests
357404
runs-on: ubuntu-latest
358-
needs: build-docker
405+
needs: [build-docker, build-docker-l2]
359406
steps:
360407
- name: Checkout sources
361408
uses: actions/checkout@v4
@@ -372,6 +419,16 @@ jobs:
372419
run: |
373420
docker load --input /tmp/ethrex_image.tar
374421
422+
- name: Download ethrex L2 image artifact
423+
uses: actions/download-artifact@v4
424+
with:
425+
name: ethrex_image_l2
426+
path: /tmp
427+
428+
- name: Load ethrex L2 image
429+
run: |
430+
docker load --input /tmp/ethrex_image_l2.tar
431+
375432
- name: Install solc
376433
uses: lambdaclass/get-solc@master
377434
with:

.github/workflows/tag_release.yaml

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,45 @@ jobs:
2222
- ubuntu-22.04
2323
- ubuntu-24.04-arm
2424
- macos-latest
25-
gpu:
26-
- true
27-
- false
25+
stack:
26+
- l1
27+
- l2
28+
- l2_gpu
29+
exclude:
30+
- platform: macos-latest
31+
stack: l2_gpu
2832
include:
2933
- platform: ubuntu-22.04
3034
os: linux
3135
arch: x86_64
32-
prover_features: sp1,risc0
3336
cpu_flags: RUSTFLAGS='-C target-cpu=x86-64-v2'
3437
- platform: ubuntu-24.04-arm
3538
os: linux
3639
arch: aarch64
37-
prover_features: sp1
3840
- platform: macos-latest
3941
os: macos
4042
arch: aarch64
41-
- gpu: true
43+
- platform: macos-latest
44+
stack: l2
45+
features: l2,l2-sql
46+
- platform: ubuntu-22.04
47+
stack: l2
48+
features: l2,l2-sql,sp1,risc0
49+
- platform: ubuntu-22.04
50+
stack: l2_gpu
51+
features: l2,l2-sql,sp1,risc0,gpu
52+
- platform: ubuntu-24.04-arm
53+
stack: l2
54+
features: l2,l2-sql,sp1
55+
- platform: ubuntu-24.04-arm
56+
stack: l2_gpu
57+
features: l2,l2-sql,sp1,gpu
58+
- stack: l2_gpu
4259
gpu_flags: NVCC_PREPEND_FLAGS='-arch=sm_70'
43-
gpu_feature: ",gpu"
60+
l2_suffix: "-l2"
4461
gpu_suffix: "-gpu"
45-
exclude:
46-
- platform: macos-latest
47-
gpu: true
62+
- stack: l2
63+
l2_suffix: "-l2"
4864
runs-on: ${{ matrix.platform }}
4965
steps:
5066
- name: Free Disk Space (Ubuntu)
@@ -57,10 +73,8 @@ jobs:
5773
- name: Checkout code
5874
uses: actions/checkout@v4
5975

60-
- name: Rustup toolchain install
61-
uses: dtolnay/rust-toolchain@master
62-
with:
63-
toolchain: ${{ vars.RUST_VERSION }}
76+
- name: Setup Rust Environment
77+
uses: ./.github/actions/setup-rust
6478

6579
- name: Install SP1 (only Linux)
6680
if: ${{ matrix.os == 'linux' }}
@@ -89,7 +103,7 @@ jobs:
89103
90104
- name: Install CUDA (only Linux x86 GPU)
91105
uses: Jimver/[email protected]
92-
if: ${{ matrix.platform == 'ubuntu-22.04' && matrix.gpu }}
106+
if: ${{ matrix.platform == 'ubuntu-22.04' && matrix.stack == 'l2_gpu' }}
93107
id: cuda-toolkit
94108
with:
95109
cuda: "12.9.0"
@@ -116,11 +130,12 @@ jobs:
116130
117131
- name: Build ethrex
118132
run: |
119-
COMPILE_CONTRACTS=true ${{ matrix.cpu_flags }} ${{ matrix.gpu_flags }} cargo build --release --features "${{ matrix.prover_features }}${{ matrix.gpu_feature }}" --bin ethrex
120-
mv target/release/ethrex ethrex-${{ matrix.os }}_${{ matrix.arch }}${{ matrix.gpu_suffix }}
133+
COMPILE_CONTRACTS=true ${{ matrix.cpu_flags }} ${{ matrix.gpu_flags }} cargo build --release --features "${{ matrix.features }}" --bin ethrex
134+
chmod +x target/release/ethrex
135+
mv target/release/ethrex ethrex${{ matrix.l2_suffix }}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.gpu_suffix }}
121136
122137
- name: Copy verification keys
123-
if: ${{ matrix.platform == 'ubuntu-22.04' && matrix.gpu }} # Run only once
138+
if: ${{ matrix.platform == 'ubuntu-22.04' && matrix.stack == 'l2_gpu' }} # Run only once
124139
run: |
125140
mkdir -p ./verification_keys
126141
mv crates/l2/prover/src/guest_program/src/risc0/out/riscv32im-risc0-vk verification_keys/ethrex-riscv32im-risc0-vk
@@ -129,11 +144,11 @@ jobs:
129144
- name: Upload artifact
130145
uses: actions/upload-artifact@v4
131146
with:
132-
name: ethrex-${{ matrix.os }}_${{ matrix.arch }}${{ matrix.gpu_suffix }}
133-
path: ethrex-${{ matrix.os }}_${{ matrix.arch }}${{ matrix.gpu_suffix }}
147+
name: ethrex${{ matrix.l2_suffix }}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.gpu_suffix }}
148+
path: ethrex${{ matrix.l2_suffix }}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.gpu_suffix }}
134149

135150
- name: Upload verification keys
136-
if: ${{ matrix.platform == 'ubuntu-22.04' && matrix.gpu }} # Run only once
151+
if: ${{ matrix.platform == 'ubuntu-22.04' && matrix.stack == 'l2_gpu' }} # Run only once
137152
uses: actions/upload-artifact@v4
138153
with:
139154
name: verification_keys
@@ -183,8 +198,8 @@ jobs:
183198
run: echo "TAG_VERSION=$(echo ${{ github.ref_name }} | tr -d v)" >> $GITHUB_ENV
184199

185200
# Pushes to ghcr.io/lambdaclass/ethrex
186-
- name: Build and push Docker image
187-
id: push
201+
- name: Build and push L1 Docker image
202+
id: push_l1
188203
uses: ./.github/actions/build-docker
189204
with:
190205
registry: ${{ env.REGISTRY }}
@@ -193,7 +208,19 @@ jobs:
193208
push: true
194209
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_VERSION }}
195210

196-
# Creates a draft release on GitHub with the binaries
211+
# Pushes to ghcr.io/lambdaclass/ethrex
212+
- name: Build and push L2 Docker image
213+
id: push_l2
214+
uses: ./.github/actions/build-docker
215+
with:
216+
registry: ${{ env.REGISTRY }}
217+
username: ${{ github.actor }}
218+
password: ${{ secrets.GITHUB_TOKEN }}
219+
push: true
220+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-l2,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_VERSION }}-l2
221+
build_args: BUILD_FLAGS=--features l2,l2-sql
222+
223+
# Creates a release on GitHub with the binaries
197224
finalize-release:
198225
needs:
199226
- build-ethrex
@@ -218,6 +245,9 @@ jobs:
218245
echo "PREVIOUS_TAG: $name"
219246
echo "PREVIOUS_TAG=$name" >> $GITHUB_ENV
220247
248+
- name: Check release type
249+
run: echo "TAG_SUFFIX=$(echo ${{ github.ref_name }}- | cut -d- -f2)" >> $GITHUB_ENV
250+
221251
- name: Update CHANGELOG
222252
id: changelog
223253
uses: requarks/changelog-action@v1
@@ -233,8 +263,8 @@ jobs:
233263
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
234264
with:
235265
files: ./bin/**/*
236-
draft: false
237-
prerelease: false
266+
draft: ${{ startsWith(env.TAG_SUFFIX, 'rc') }}
267+
prerelease: ${{ startsWith(env.TAG_SUFFIX, 'rc') }}
238268
tag_name: ${{ github.ref_name }}
239269
name: "ethrex: ${{ github.ref_name }}"
240270
body: >

0 commit comments

Comments
 (0)