Skip to content

Commit 9874ec0

Browse files
authored
feat: add binaries to benchmark (#105)
1 parent 74b1329 commit 9874ec0

File tree

7 files changed

+338
-1
lines changed

7 files changed

+338
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
data-dir/
55
output/
66
.vercel
7+
clients/build/
78

89
contracts/cache/
910
contracts/out/
1011
contracts/abi/
11-
benchmark/benchmark
12+
benchmark/benchmark

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,18 @@ clean:
3535
.PHONY: test
3636
test:
3737
go test -v ./...
38+
39+
.PHONY: build-reth
40+
build-reth:
41+
cd clients && ./build-reth.sh
42+
43+
.PHONY: build-geth
44+
build-geth:
45+
cd clients && ./build-geth.sh
46+
47+
.PHONY: build-rbuilder
48+
build-rbuilder:
49+
cd clients && ./build-rbuilder.sh
50+
51+
.PHONY: build-binaries
52+
build-binaries: build-reth build-geth build-rbuilder

clients/README.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Client Build Scripts
2+
3+
This directory contains scripts to build client binaries for blockchain nodes.
4+
5+
## Available Scripts
6+
7+
### build-reth.sh
8+
Builds the reth binary from the Paradigm reth repository using Cargo.
9+
10+
**Default Configuration:**
11+
- Repository: `https://github.com/paradigmxyz/reth/`
12+
- Version: `main`
13+
- Build tool: `cargo`
14+
15+
### build-geth.sh
16+
Builds the op-geth binary from the Ethereum Optimism op-geth repository using just.
17+
18+
**Default Configuration:**
19+
- Repository: `https://github.com/ethereum-optimism/op-geth/`
20+
- Version: `optimism`
21+
- Build tool: `go run build/ci.go install`
22+
23+
### build-rbuilder.sh
24+
Builds the op-rbuilder binary from the op-rbuilder repository using Cargo.
25+
26+
**Default Configuration:**
27+
- Repository: `https://github.com/haardikk21/op-rbuilder`
28+
- Version: `a8bb38693ece585e7fa98d52f51290e7dcececff`
29+
- Build tool: `cargo`
30+
31+
## Usage
32+
33+
### Using Makefile (Recommended)
34+
35+
```bash
36+
# Build all binaries
37+
make build-binaries
38+
39+
# Build only reth
40+
make build-reth
41+
42+
# Build only geth
43+
make build-geth
44+
45+
# Build only op-rbuilder
46+
make build-rbuilder
47+
```
48+
49+
### Direct Script Execution
50+
51+
```bash
52+
# Build reth with defaults
53+
cd clients
54+
./build-reth.sh
55+
56+
# Build geth with defaults
57+
./build-geth.sh
58+
59+
# Build op-rbuilder with defaults
60+
./build-rbuilder.sh
61+
```
62+
63+
## Version Management
64+
65+
All client versions are managed in the `versions.env` file. This file contains the default repository URLs and versions for all supported clients. The build scripts automatically source this file if it exists.
66+
67+
### Customizing Repository and Version
68+
69+
You can override the default repository and version in several ways:
70+
71+
#### 1. Edit versions.env (Recommended)
72+
Modify the `versions.env` file to change defaults for all builds:
73+
74+
```bash
75+
# Edit versions.env to update default versions
76+
RETH_VERSION="v0.2.0-beta.5"
77+
GETH_VERSION="v1.13.0"
78+
RBUILDER_VERSION="your-commit-hash"
79+
```
80+
81+
#### 2. Environment Variables
82+
Override specific builds with environment variables:
83+
84+
```bash
85+
# Build reth from a specific commit
86+
RETH_REPO="https://github.com/paradigmxyz/reth/" RETH_VERSION="v0.1.0" ./build-reth.sh
87+
88+
# Build geth from a fork
89+
GETH_REPO="https://github.com/your-fork/op-geth/" GETH_VERSION="your-branch" ./build-geth.sh
90+
91+
# Build op-rbuilder from a different commit
92+
RBUILDER_VERSION="main" ./build-rbuilder.sh
93+
```
94+
95+
### Available Environment Variables
96+
97+
#### For reth (build-reth.sh):
98+
- `RETH_REPO`: Git repository URL (default: https://github.com/paradigmxyz/reth/)
99+
- `RETH_VERSION`: Git branch, tag, or commit hash (default: main)
100+
- `BUILD_DIR`: Directory for source code (default: ./build)
101+
- `OUTPUT_DIR`: Directory for built binaries (default: ../bin)
102+
103+
#### For geth (build-geth.sh):
104+
- `GETH_REPO`: Git repository URL (default: https://github.com/ethereum-optimism/op-geth/)
105+
- `GETH_VERSION`: Git branch, tag, or commit hash (default: optimism)
106+
- `BUILD_DIR`: Directory for source code (default: ./build)
107+
- `OUTPUT_DIR`: Directory for built binaries (default: ../bin)
108+
109+
#### For op-rbuilder (build-rbuilder.sh):
110+
- `RBUILDER_REPO`: Git repository URL (default: https://github.com/haardikk21/op-rbuilder)
111+
- `RBUILDER_VERSION`: Git branch, tag, or commit hash (default: a8bb38693ece585e7fa98d52f51290e7dcececff)
112+
- `BUILD_DIR`: Directory for source code (default: ./build)
113+
- `OUTPUT_DIR`: Directory for built binaries (default: ../bin)
114+
115+
## Prerequisites
116+
117+
### For reth:
118+
- Rust and Cargo installed
119+
- Git
120+
121+
### For geth:
122+
- Go toolchain
123+
- Git
124+
125+
### For op-rbuilder:
126+
- Rust and Cargo installed
127+
- Git
128+
129+
## Output
130+
131+
Built binaries will be placed in the `bin/` directory at the project root:
132+
- `bin/reth` - The reth binary
133+
- `bin/geth` - The op-geth binary
134+
- `bin/op-rbuilder` - The op-rbuilder binary

clients/build-geth.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Source versions if available, otherwise use defaults
6+
if [ -f "versions.env" ]; then
7+
source versions.env
8+
else
9+
# Default values
10+
GETH_REPO="${GETH_REPO:-https://github.com/ethereum-optimism/op-geth/}"
11+
GETH_VERSION="${GETH_VERSION:-optimism}"
12+
BUILD_DIR="${BUILD_DIR:-./build}"
13+
OUTPUT_DIR="${OUTPUT_DIR:-../bin}"
14+
fi
15+
16+
echo "Building op-geth binary..."
17+
echo "Repository: $GETH_REPO"
18+
echo "Version/Commit: $GETH_VERSION"
19+
echo "Build directory: $BUILD_DIR"
20+
echo "Output directory: $OUTPUT_DIR"
21+
22+
# Create build directory if it doesn't exist
23+
mkdir -p "$BUILD_DIR"
24+
cd "$BUILD_DIR"
25+
26+
# Clone or update repository
27+
if [ -d "op-geth" ]; then
28+
echo "Updating existing op-geth repository..."
29+
cd op-geth
30+
git fetch origin
31+
else
32+
echo "Cloning op-geth repository..."
33+
git clone "$GETH_REPO" op-geth
34+
cd op-geth
35+
fi
36+
37+
# Checkout specified version/commit
38+
echo "Checking out version: $GETH_VERSION"
39+
git checkout "$GETH_VERSION"
40+
41+
# Build the binary using Go
42+
echo "Building op-geth with Go..."
43+
go run build/ci.go install -static ./cmd/geth
44+
45+
# Copy binary to output directory
46+
echo "Copying binary to output directory..."
47+
mkdir -p "../../$OUTPUT_DIR"
48+
49+
# The binary is typically built in the build directory
50+
if [ -f "build/bin/geth" ]; then
51+
cp build/bin/geth "../../$OUTPUT_DIR/geth"
52+
elif [ -f "bin/geth" ]; then
53+
cp bin/geth "../../$OUTPUT_DIR/geth"
54+
else
55+
echo "Looking for geth binary..."
56+
find . -name "geth" -type f -executable | head -1 | xargs -I {} cp {} "../../$OUTPUT_DIR/geth"
57+
fi
58+
59+
echo "op-geth binary built successfully and placed in $OUTPUT_DIR/geth"

clients/build-rbuilder.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Source versions if available, otherwise use defaults
6+
if [ -f "versions.env" ]; then
7+
source versions.env
8+
else
9+
# Default values
10+
RBUILDER_REPO="${RBUILDER_REPO:-https://github.com/haardikk21/op-rbuilder}"
11+
RBUILDER_VERSION="${RBUILDER_VERSION:-main}"
12+
BUILD_DIR="${BUILD_DIR:-./build}"
13+
OUTPUT_DIR="${OUTPUT_DIR:-../bin}"
14+
fi
15+
16+
echo "Building op-rbuilder binary..."
17+
echo "Repository: $RBUILDER_REPO"
18+
echo "Version/Commit: $RBUILDER_VERSION"
19+
echo "Build directory: $BUILD_DIR"
20+
echo "Output directory: $OUTPUT_DIR"
21+
22+
# Create build directory if it doesn't exist
23+
mkdir -p "$BUILD_DIR"
24+
cd "$BUILD_DIR"
25+
26+
# Clone or update repository
27+
if [ -d "op-rbuilder" ]; then
28+
echo "Updating existing op-rbuilder repository..."
29+
cd op-rbuilder
30+
git fetch origin
31+
else
32+
echo "Cloning op-rbuilder repository..."
33+
git clone "$RBUILDER_REPO" op-rbuilder
34+
cd op-rbuilder
35+
fi
36+
37+
# Checkout specified version/commit
38+
echo "Checking out version: $RBUILDER_VERSION"
39+
git checkout "$RBUILDER_VERSION"
40+
41+
# Build the binary using cargo
42+
echo "Building op-rbuilder with cargo..."
43+
cargo build --release
44+
45+
# Copy binary to output directory
46+
echo "Copying binary to output directory..."
47+
mkdir -p "../../$OUTPUT_DIR"
48+
49+
# Find the built binary and copy it
50+
if [ -f "target/release/op-rbuilder" ]; then
51+
cp target/release/op-rbuilder "../../$OUTPUT_DIR/"
52+
elif [ -f "target/release/rbuilder" ]; then
53+
cp target/release/rbuilder "../../$OUTPUT_DIR/op-rbuilder"
54+
else
55+
echo "Looking for rbuilder binary..."
56+
find target/release -name "*rbuilder*" -type f -executable | head -1 | xargs -I {} cp {} "../../$OUTPUT_DIR/op-rbuilder"
57+
fi
58+
59+
echo "op-rbuilder binary built successfully and placed in $OUTPUT_DIR/op-rbuilder"

clients/build-reth.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Source versions if available, otherwise use defaults
6+
if [ -f "versions.env" ]; then
7+
source versions.env
8+
else
9+
# Default values
10+
RETH_REPO="${RETH_REPO:-https://github.com/paradigmxyz/reth/}"
11+
RETH_VERSION="${RETH_VERSION:-main}"
12+
BUILD_DIR="${BUILD_DIR:-./build}"
13+
OUTPUT_DIR="${OUTPUT_DIR:-../bin}"
14+
fi
15+
16+
echo "Building reth binary..."
17+
echo "Repository: $RETH_REPO"
18+
echo "Version/Commit: $RETH_VERSION"
19+
echo "Build directory: $BUILD_DIR"
20+
echo "Output directory: $OUTPUT_DIR"
21+
22+
# Create build directory if it doesn't exist
23+
mkdir -p "$BUILD_DIR"
24+
cd "$BUILD_DIR"
25+
26+
# Clone or update repository
27+
if [ -d "reth" ]; then
28+
echo "Updating existing reth repository..."
29+
cd reth
30+
git fetch origin
31+
else
32+
echo "Cloning reth repository..."
33+
git clone "$RETH_REPO" reth
34+
cd reth
35+
fi
36+
37+
# Checkout specified version/commit
38+
echo "Checking out version: $RETH_VERSION"
39+
git checkout "$RETH_VERSION"
40+
41+
# Build the binary using cargo
42+
echo "Building reth with cargo..."
43+
cargo build --release --bin reth
44+
45+
# Copy binary to output directory
46+
echo "Copying binary to output directory..."
47+
mkdir -p "../../$OUTPUT_DIR"
48+
cp target/release/reth "../../$OUTPUT_DIR/"
49+
50+
echo "reth binary built successfully and placed in $OUTPUT_DIR/reth"

clients/versions.env

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Client Binary Versions
2+
# This file contains version information for all client binaries
3+
# Source this file in scripts to use these variables
4+
5+
# Reth Configuration
6+
RETH_REPO="https://github.com/paradigmxyz/reth/"
7+
RETH_VERSION="v1.5.1"
8+
9+
# Op-Geth Configuration
10+
GETH_REPO="https://github.com/ethereum-optimism/op-geth/"
11+
GETH_VERSION="v1.101511.0"
12+
13+
# Op-Rbuilder Configuration
14+
RBUILDER_REPO="https://github.com/haardikk21/op-rbuilder"
15+
RBUILDER_VERSION="a8bb38693ece585e7fa98d52f51290e7dcececff"
16+
17+
# Build Configuration
18+
BUILD_DIR="./build"
19+
OUTPUT_DIR="../bin"

0 commit comments

Comments
 (0)