Skip to content

Commit d160b6d

Browse files
authored
feat: run rbuilder in examples (#147)
1 parent 98e00a8 commit d160b6d

File tree

11 files changed

+455
-173
lines changed

11 files changed

+455
-173
lines changed

.github/scripts/run-example-benchmarks.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ BENCHMARK_CONFIGS=(
99
configs/examples/erc20.yml
1010
configs/examples/simulator.yml
1111
configs/examples/sload.yml
12-
# configs/examples/snapshot.yml
12+
configs/examples/rbuilder.yml
1313
configs/examples/sstore.yml
14+
# configs/examples/snapshot.yml
1415
# configs/examples/tx-fuzz-geth.yml
1516
)
1617

@@ -26,5 +27,6 @@ for config in "${BENCHMARK_CONFIGS[@]}"; do
2627
--root-dir $TEMP_DIR/data-dir \
2728
--output-dir $TEMP_DIR/output \
2829
--reth-bin $TEMP_DIR/bin/reth \
29-
--geth-bin $TEMP_DIR/bin/geth
30+
--geth-bin $TEMP_DIR/bin/geth \
31+
--rbuilder-bin $TEMP_DIR/bin/rbuilder
3032
done
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
# Reusable workflow for building all binaries
2+
# This workflow is called by other workflows to build reth, geth, rbuilder, op-program, and contracts
3+
name: Build Binaries
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
reth_version:
9+
description: "Reth version to build"
10+
required: false
11+
type: string
12+
default: "27a8c0f5a6dfb27dea84c5751776ecabdd069646"
13+
geth_version:
14+
description: "Geth version to build"
15+
required: false
16+
type: string
17+
default: "6cbfcd5161083bcd4052edc3022d9f99c6fe40e0"
18+
rbuilder_version:
19+
description: "Rbuilder version to build"
20+
required: false
21+
type: string
22+
default: "23f42c8e78ba3abb45a8840df7037a27e196e601"
23+
24+
# Set minimal permissions for all jobs by default
25+
permissions:
26+
contents: read
27+
28+
jobs:
29+
build-contracts:
30+
runs-on: ubuntu-latest
31+
permissions:
32+
contents: read
33+
actions: write # Required for artifact upload
34+
steps:
35+
- name: Harden the runner (Audit all outbound calls)
36+
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
37+
with:
38+
egress-policy: audit
39+
40+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
41+
42+
- name: Install Foundry
43+
uses: foundry-rs/foundry-toolchain@82dee4ba654bd2146511f85f0d013af94670c4de # v1.4.0
44+
- name: Cache Forge artifacts
45+
uses: actions/cache@2f8e54208210a422b2efd51efaa6bd6d7ca8920f # v3.4.3
46+
with:
47+
path: |
48+
contracts/out
49+
contracts/cache
50+
key: ${{ runner.os }}-forge-${{ hashFiles('**/foundry.toml', '**/*.sol') }}
51+
restore-keys: |
52+
${{ runner.os }}-forge-
53+
54+
- name: Build Contracts
55+
run: |
56+
forge build --force
57+
58+
- name: Upload contract artifacts
59+
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
60+
with:
61+
name: contracts
62+
path: contracts/out/
63+
retention-days: 1
64+
65+
build-reth:
66+
runs-on: ubuntu-latest
67+
permissions:
68+
contents: read
69+
actions: write # Required for artifact upload
70+
steps:
71+
- name: Harden the runner (Audit all outbound calls)
72+
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
73+
with:
74+
egress-policy: audit
75+
76+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
77+
78+
- name: Set up Rust
79+
uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1.11.0
80+
81+
- name: Cache reth binary
82+
uses: actions/cache@2f8e54208210a422b2efd51efaa6bd6d7ca8920f # v3.4.3
83+
id: cache-reth
84+
with:
85+
path: ~/bin/reth
86+
key: ${{ runner.os }}-reth-${{ inputs.reth_version }}
87+
88+
- name: Build reth
89+
if: steps.cache-reth.outputs.cache-hit != 'true'
90+
run: |
91+
unset CI
92+
mkdir -p ~/bin
93+
cd clients
94+
RETH_VERSION=${{ inputs.reth_version }} OUTPUT_DIR=~/bin ./build-reth.sh
95+
# Rename op-reth to reth for consistency
96+
[ -f ~/bin/op-reth ] && mv ~/bin/op-reth ~/bin/reth || true
97+
98+
- name: Upload reth artifact
99+
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
100+
with:
101+
name: reth
102+
path: ~/bin/reth
103+
retention-days: 1
104+
105+
build-geth:
106+
runs-on: ubuntu-latest
107+
permissions:
108+
contents: read
109+
actions: write # Required for artifact upload
110+
steps:
111+
- name: Harden the runner (Audit all outbound calls)
112+
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
113+
with:
114+
egress-policy: audit
115+
116+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
117+
118+
- name: Set up Go
119+
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
120+
121+
- name: Cache geth binary
122+
uses: actions/cache@2f8e54208210a422b2efd51efaa6bd6d7ca8920f # v3.4.3
123+
id: cache-geth
124+
with:
125+
path: ~/bin/geth
126+
key: ${{ runner.os }}-geth-${{ inputs.geth_version }}
127+
128+
- name: Build geth
129+
if: steps.cache-geth.outputs.cache-hit != 'true'
130+
run: |
131+
unset CI
132+
mkdir -p ~/bin
133+
cd clients
134+
GETH_VERSION=${{ inputs.geth_version }} OUTPUT_DIR=~/bin ./build-geth.sh
135+
136+
- name: Upload geth artifact
137+
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
138+
with:
139+
name: geth
140+
path: ~/bin/geth
141+
retention-days: 1
142+
143+
build-rbuilder:
144+
runs-on: ubuntu-latest
145+
permissions:
146+
contents: read
147+
actions: write # Required for artifact upload
148+
steps:
149+
- name: Harden the runner (Audit all outbound calls)
150+
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
151+
with:
152+
egress-policy: audit
153+
154+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
155+
156+
- name: Set up Rust
157+
uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1.11.0
158+
159+
- name: Cache rbuilder binary
160+
uses: actions/cache@2f8e54208210a422b2efd51efaa6bd6d7ca8920f # v3.4.3
161+
id: cache-rbuilder
162+
with:
163+
path: ~/bin/rbuilder
164+
key: ${{ runner.os }}-rbuilder-${{ inputs.rbuilder_version }}
165+
166+
- name: Build rbuilder
167+
if: steps.cache-rbuilder.outputs.cache-hit != 'true'
168+
run: |
169+
unset CI
170+
mkdir -p ~/bin
171+
cd clients
172+
RBUILDER_VERSION=${{ inputs.rbuilder_version }} OUTPUT_DIR=~/bin ./build-rbuilder.sh
173+
# Rename op-rbuilder to rbuilder for consistency
174+
[ -f ~/bin/op-rbuilder ] && mv ~/bin/op-rbuilder ~/bin/rbuilder || true
175+
176+
- name: Upload rbuilder artifact
177+
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
178+
with:
179+
name: rbuilder
180+
path: ~/bin/rbuilder
181+
retention-days: 1
182+
183+
build-op-program:
184+
runs-on: ubuntu-latest
185+
permissions:
186+
contents: read
187+
actions: write # Required for artifact upload
188+
steps:
189+
- name: Harden the runner (Audit all outbound calls)
190+
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
191+
with:
192+
egress-policy: audit
193+
194+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
195+
196+
- name: Cache op-program binary
197+
uses: actions/cache@2f8e54208210a422b2efd51efaa6bd6d7ca8920f # v3.4.3
198+
id: cache-op-program
199+
with:
200+
path: op-program/versions/v1.6.1-rc.1/op-program
201+
key: ${{ runner.os }}-op-program-${{ hashFiles('op-program/**') }}
202+
203+
- name: Build op-program
204+
if: steps.cache-op-program.outputs.cache-hit != 'true'
205+
run: |
206+
curl https://mise.run | sh
207+
pushd op-program
208+
mise x -- ./build.sh
209+
popd
210+
211+
- name: Upload op-program artifact
212+
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
213+
with:
214+
name: op-program
215+
path: op-program/versions/v1.6.1-rc.1/op-program
216+
retention-days: 1

.github/workflows/build.yaml

Lines changed: 57 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ on:
66
branches: ["main"]
77
pull_request:
88

9+
# Set minimal permissions for all jobs by default
10+
permissions:
11+
contents: read
12+
913
jobs:
1014
go-lint:
1115
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
1218
steps:
1319
- name: Harden the runner (Audit all outbound calls)
1420
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
@@ -35,6 +41,8 @@ jobs:
3541
outputs:
3642
COVERAGE: ${{ steps.unit.outputs.coverage }}
3743
runs-on: ubuntu-latest
44+
permissions:
45+
contents: read
3846
steps:
3947
- name: Harden the runner (Audit all outbound calls)
4048
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
@@ -54,11 +62,23 @@ jobs:
5462
run: |
5563
go test -v -coverprofile=coverage.out ./...
5664
65+
# Call the reusable workflow that builds all binaries in parallel
66+
build-binaries:
67+
permissions:
68+
contents: read
69+
actions: write # Required for reusable workflow to upload artifacts
70+
uses: ./.github/workflows/_build-binaries.yaml
71+
with:
72+
reth_version: 27a8c0f5a6dfb27dea84c5751776ecabdd069646
73+
geth_version: 6cbfcd5161083bcd4052edc3022d9f99c6fe40e0
74+
rbuilder_version: 23f42c8e78ba3abb45a8840df7037a27e196e601
75+
5776
basic-benchmarks:
5877
runs-on: ubuntu-latest
59-
env:
60-
RETH_VERSION: 27a8c0f5a6dfb27dea84c5751776ecabdd069646
61-
GETH_VERSION: 6cbfcd5161083bcd4052edc3022d9f99c6fe40e0
78+
needs: build-binaries
79+
permissions:
80+
contents: read
81+
actions: read # Required for artifact download
6282
steps:
6383
- name: Harden the runner (Audit all outbound calls)
6484
uses: step-security/harden-runner@002fdce3c6a235733a90a27c80493a3241e56863 # v2.12.1
@@ -70,59 +90,52 @@ jobs:
7090
- name: Set up Go
7191
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
7292

73-
- name: Set up Rust
74-
uses: actions-rust-lang/setup-rust-toolchain@9399c7bb15d4c7d47b27263d024f0a4978346ba4 # v1.11.0
75-
7693
- name: Install project dependencies
7794
run: |
7895
go mod download
7996
80-
- name: Install Foundry
81-
uses: foundry-rs/foundry-toolchain@82dee4ba654bd2146511f85f0d013af94670c4de # v1.4.0
82-
83-
- name: Cache binaries
84-
uses: actions/cache@2f8e54208210a422b2efd51efaa6bd6d7ca8920f # v3.4.3
85-
id: cache-bin
97+
- name: Download contract artifacts
98+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
8699
with:
87-
path: ${{ runner.temp }}/bin
88-
key: ${{ runner.os }}-binaries-reth-${{ env.RETH_VERSION }}-geth-${{ env.GETH_VERSION }}
89-
90-
- name: Build Contracts
91-
run: |
92-
forge build --force
93-
94-
- name: Download geth and reth
95-
if: steps.cache-bin.outputs.cache-hit != 'true'
96-
run: |
97-
unset CI
98-
mkdir -p ${{ runner.temp }}/bin
100+
name: contracts
101+
path: contracts/out/
99102

100-
git clone https://github.com/paradigmxyz/reth
101-
git -C reth checkout --force ${{ env.RETH_VERSION }}
103+
- name: Download reth binary
104+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
105+
with:
106+
name: reth
107+
path: ${{ runner.temp }}/bin/
102108

103-
pushd reth
104-
cargo build --features asm-keccak,jemalloc --profile release --bin op-reth --manifest-path crates/optimism/bin/Cargo.toml
105-
cp ./target/release/op-reth ${{ runner.temp }}/bin/reth
106-
popd
107-
chmod +x ${{ runner.temp }}/bin/reth
109+
- name: Download geth binary
110+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
111+
with:
112+
name: geth
113+
path: ${{ runner.temp }}/bin/
108114

109-
git clone https://github.com/ethereum-optimism/op-geth
110-
git -C op-geth checkout --force ${{ env.GETH_VERSION }}
115+
- name: Download rbuilder binary
116+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
117+
with:
118+
name: rbuilder
119+
path: ${{ runner.temp }}/bin/
111120

112-
pushd op-geth
113-
make geth
114-
cp ./build/bin/geth ${{ runner.temp }}/bin/geth
115-
chmod +x ${{ runner.temp }}/bin/geth
116-
popd
121+
- name: Download op-program binary
122+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
123+
with:
124+
name: op-program
125+
path: ${{ runner.temp }}/bin/
117126

118-
echo "binaries compiled:"
127+
- name: Make binaries executable
128+
run: |
129+
chmod +x ${{ runner.temp }}/bin/*
130+
echo "Downloaded binaries:"
119131
ls -la ${{ runner.temp }}/bin
120132
133+
- name: Setup op-program directory
134+
run: |
135+
mkdir -p op-program/versions/v1.6.1-rc.1
136+
cp ${{ runner.temp }}/bin/op-program op-program/versions/v1.6.1-rc.1/
137+
du -h -d 2 .
138+
121139
- name: Run examples
122-
id: op-program
123140
run: |
124-
curl https://mise.run | sh
125-
pushd op-program
126-
mise x -- ./build.sh
127-
popd
128141
./.github/scripts/run-example-benchmarks.sh ${{ runner.temp }}

0 commit comments

Comments
 (0)