Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
data-dir/
output/
.vercel
clients/build/

contracts/cache/
contracts/out/
contracts/abi/
benchmark/benchmark
benchmark/benchmark
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,18 @@ clean:
.PHONY: test
test:
go test -v ./...

.PHONY: build-reth
build-reth:
cd clients && ./build-reth.sh

.PHONY: build-geth
build-geth:
cd clients && ./build-geth.sh

.PHONY: build-rbuilder
build-rbuilder:
cd clients && ./build-rbuilder.sh

.PHONY: build-binaries
build-binaries: build-reth build-geth build-rbuilder
134 changes: 134 additions & 0 deletions clients/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Client Build Scripts

This directory contains scripts to build client binaries for blockchain nodes.

## Available Scripts

### build-reth.sh
Builds the reth binary from the Paradigm reth repository using Cargo.

**Default Configuration:**
- Repository: `https://github.com/paradigmxyz/reth/`
- Version: `main`
- Build tool: `cargo`

### build-geth.sh
Builds the op-geth binary from the Ethereum Optimism op-geth repository using just.

**Default Configuration:**
- Repository: `https://github.com/ethereum-optimism/op-geth/`
- Version: `optimism`
- Build tool: `go run build/ci.go install`

### build-rbuilder.sh
Builds the op-rbuilder binary from the op-rbuilder repository using Cargo.

**Default Configuration:**
- Repository: `https://github.com/haardikk21/op-rbuilder`
- Version: `a8bb38693ece585e7fa98d52f51290e7dcececff`
- Build tool: `cargo`

## Usage

### Using Makefile (Recommended)

```bash
# Build all binaries
make build-binaries

# Build only reth
make build-reth

# Build only geth
make build-geth

# Build only op-rbuilder
make build-rbuilder
```

### Direct Script Execution

```bash
# Build reth with defaults
cd clients
./build-reth.sh

# Build geth with defaults
./build-geth.sh

# Build op-rbuilder with defaults
./build-rbuilder.sh
```

## Version Management

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.

### Customizing Repository and Version

You can override the default repository and version in several ways:

#### 1. Edit versions.env (Recommended)
Modify the `versions.env` file to change defaults for all builds:

```bash
# Edit versions.env to update default versions
RETH_VERSION="v0.2.0-beta.5"
GETH_VERSION="v1.13.0"
RBUILDER_VERSION="your-commit-hash"
```

#### 2. Environment Variables
Override specific builds with environment variables:

```bash
# Build reth from a specific commit
RETH_REPO="https://github.com/paradigmxyz/reth/" RETH_VERSION="v0.1.0" ./build-reth.sh

# Build geth from a fork
GETH_REPO="https://github.com/your-fork/op-geth/" GETH_VERSION="your-branch" ./build-geth.sh

# Build op-rbuilder from a different commit
RBUILDER_VERSION="main" ./build-rbuilder.sh
```

### Available Environment Variables

#### For reth (build-reth.sh):
- `RETH_REPO`: Git repository URL (default: https://github.com/paradigmxyz/reth/)
- `RETH_VERSION`: Git branch, tag, or commit hash (default: main)
- `BUILD_DIR`: Directory for source code (default: ./build)
- `OUTPUT_DIR`: Directory for built binaries (default: ../bin)

#### For geth (build-geth.sh):
- `GETH_REPO`: Git repository URL (default: https://github.com/ethereum-optimism/op-geth/)
- `GETH_VERSION`: Git branch, tag, or commit hash (default: optimism)
- `BUILD_DIR`: Directory for source code (default: ./build)
- `OUTPUT_DIR`: Directory for built binaries (default: ../bin)

#### For op-rbuilder (build-rbuilder.sh):
- `RBUILDER_REPO`: Git repository URL (default: https://github.com/haardikk21/op-rbuilder)
- `RBUILDER_VERSION`: Git branch, tag, or commit hash (default: a8bb38693ece585e7fa98d52f51290e7dcececff)
- `BUILD_DIR`: Directory for source code (default: ./build)
- `OUTPUT_DIR`: Directory for built binaries (default: ../bin)

## Prerequisites

### For reth:
- Rust and Cargo installed
- Git

### For geth:
- Go toolchain
- Git

### For op-rbuilder:
- Rust and Cargo installed
- Git

## Output

Built binaries will be placed in the `bin/` directory at the project root:
- `bin/reth` - The reth binary
- `bin/geth` - The op-geth binary
- `bin/op-rbuilder` - The op-rbuilder binary
59 changes: 59 additions & 0 deletions clients/build-geth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

set -e

# Source versions if available, otherwise use defaults
if [ -f "versions.env" ]; then
source versions.env
else
# Default values
GETH_REPO="${GETH_REPO:-https://github.com/ethereum-optimism/op-geth/}"
GETH_VERSION="${GETH_VERSION:-optimism}"
BUILD_DIR="${BUILD_DIR:-./build}"
OUTPUT_DIR="${OUTPUT_DIR:-../bin}"
fi

echo "Building op-geth binary..."
echo "Repository: $GETH_REPO"
echo "Version/Commit: $GETH_VERSION"
echo "Build directory: $BUILD_DIR"
echo "Output directory: $OUTPUT_DIR"

# Create build directory if it doesn't exist
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"

# Clone or update repository
if [ -d "op-geth" ]; then
echo "Updating existing op-geth repository..."
cd op-geth
git fetch origin
else
echo "Cloning op-geth repository..."
git clone "$GETH_REPO" op-geth
cd op-geth
fi

# Checkout specified version/commit
echo "Checking out version: $GETH_VERSION"
git checkout "$GETH_VERSION"

# Build the binary using Go
echo "Building op-geth with Go..."
go run build/ci.go install -static ./cmd/geth

# Copy binary to output directory
echo "Copying binary to output directory..."
mkdir -p "../../$OUTPUT_DIR"

# The binary is typically built in the build directory
if [ -f "build/bin/geth" ]; then
cp build/bin/geth "../../$OUTPUT_DIR/geth"
elif [ -f "bin/geth" ]; then
cp bin/geth "../../$OUTPUT_DIR/geth"
else
echo "Looking for geth binary..."
find . -name "geth" -type f -executable | head -1 | xargs -I {} cp {} "../../$OUTPUT_DIR/geth"
fi

echo "op-geth binary built successfully and placed in $OUTPUT_DIR/geth"
59 changes: 59 additions & 0 deletions clients/build-rbuilder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

set -e

# Source versions if available, otherwise use defaults
if [ -f "versions.env" ]; then
source versions.env
else
# Default values
RBUILDER_REPO="${RBUILDER_REPO:-https://github.com/haardikk21/op-rbuilder}"
RBUILDER_VERSION="${RBUILDER_VERSION:-main}"
BUILD_DIR="${BUILD_DIR:-./build}"
OUTPUT_DIR="${OUTPUT_DIR:-../bin}"
fi

echo "Building op-rbuilder binary..."
echo "Repository: $RBUILDER_REPO"
echo "Version/Commit: $RBUILDER_VERSION"
echo "Build directory: $BUILD_DIR"
echo "Output directory: $OUTPUT_DIR"

# Create build directory if it doesn't exist
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"

# Clone or update repository
if [ -d "op-rbuilder" ]; then
echo "Updating existing op-rbuilder repository..."
cd op-rbuilder
git fetch origin
else
echo "Cloning op-rbuilder repository..."
git clone "$RBUILDER_REPO" op-rbuilder
cd op-rbuilder
fi

# Checkout specified version/commit
echo "Checking out version: $RBUILDER_VERSION"
git checkout "$RBUILDER_VERSION"

# Build the binary using cargo
echo "Building op-rbuilder with cargo..."
cargo build --release

# Copy binary to output directory
echo "Copying binary to output directory..."
mkdir -p "../../$OUTPUT_DIR"

# Find the built binary and copy it
if [ -f "target/release/op-rbuilder" ]; then
cp target/release/op-rbuilder "../../$OUTPUT_DIR/"
elif [ -f "target/release/rbuilder" ]; then
cp target/release/rbuilder "../../$OUTPUT_DIR/op-rbuilder"
else
echo "Looking for rbuilder binary..."
find target/release -name "*rbuilder*" -type f -executable | head -1 | xargs -I {} cp {} "../../$OUTPUT_DIR/op-rbuilder"
fi

echo "op-rbuilder binary built successfully and placed in $OUTPUT_DIR/op-rbuilder"
50 changes: 50 additions & 0 deletions clients/build-reth.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

set -e

# Source versions if available, otherwise use defaults
if [ -f "versions.env" ]; then
source versions.env
else
# Default values
RETH_REPO="${RETH_REPO:-https://github.com/paradigmxyz/reth/}"
RETH_VERSION="${RETH_VERSION:-main}"
BUILD_DIR="${BUILD_DIR:-./build}"
OUTPUT_DIR="${OUTPUT_DIR:-../bin}"
fi

echo "Building reth binary..."
echo "Repository: $RETH_REPO"
echo "Version/Commit: $RETH_VERSION"
echo "Build directory: $BUILD_DIR"
echo "Output directory: $OUTPUT_DIR"

# Create build directory if it doesn't exist
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"

# Clone or update repository
if [ -d "reth" ]; then
echo "Updating existing reth repository..."
cd reth
git fetch origin
else
echo "Cloning reth repository..."
git clone "$RETH_REPO" reth
cd reth
fi

# Checkout specified version/commit
echo "Checking out version: $RETH_VERSION"
git checkout "$RETH_VERSION"

# Build the binary using cargo
echo "Building reth with cargo..."
cargo build --release --bin reth

# Copy binary to output directory
echo "Copying binary to output directory..."
mkdir -p "../../$OUTPUT_DIR"
cp target/release/reth "../../$OUTPUT_DIR/"

echo "reth binary built successfully and placed in $OUTPUT_DIR/reth"
19 changes: 19 additions & 0 deletions clients/versions.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Client Binary Versions
# This file contains version information for all client binaries
# Source this file in scripts to use these variables

# Reth Configuration
RETH_REPO="https://github.com/paradigmxyz/reth/"
RETH_VERSION="v1.5.1"

# Op-Geth Configuration
GETH_REPO="https://github.com/ethereum-optimism/op-geth/"
GETH_VERSION="v1.101511.0"

# Op-Rbuilder Configuration
RBUILDER_REPO="https://github.com/haardikk21/op-rbuilder"
RBUILDER_VERSION="a8bb38693ece585e7fa98d52f51290e7dcececff"

# Build Configuration
BUILD_DIR="./build"
OUTPUT_DIR="../bin"
Loading