From bb9f69168df94c31cc218ac3514bba207906528d Mon Sep 17 00:00:00 2001 From: Tobi Akerele Date: Thu, 24 Jul 2025 13:07:26 -0400 Subject: [PATCH] feat: add binaries to benchmark --- .gitignore | 1 + Makefile | 15 +++++ clients/README.md | 134 ++++++++++++++++++++++++++++++++++++++ clients/build-geth.sh | 59 +++++++++++++++++ clients/build-rbuilder.sh | 59 +++++++++++++++++ clients/build-reth.sh | 50 ++++++++++++++ clients/versions.env | 19 ++++++ 7 files changed, 337 insertions(+) create mode 100644 clients/README.md create mode 100755 clients/build-geth.sh create mode 100755 clients/build-rbuilder.sh create mode 100755 clients/build-reth.sh create mode 100644 clients/versions.env diff --git a/.gitignore b/.gitignore index 316a4fcf..3f8ebf31 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ data-dir/ output/ .vercel +clients/build/ diff --git a/Makefile b/Makefile index d7e6eaee..61425e9a 100644 --- a/Makefile +++ b/Makefile @@ -30,3 +30,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 diff --git a/clients/README.md b/clients/README.md new file mode 100644 index 00000000..fca1bbf6 --- /dev/null +++ b/clients/README.md @@ -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 \ No newline at end of file diff --git a/clients/build-geth.sh b/clients/build-geth.sh new file mode 100755 index 00000000..5f0a74fb --- /dev/null +++ b/clients/build-geth.sh @@ -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" diff --git a/clients/build-rbuilder.sh b/clients/build-rbuilder.sh new file mode 100755 index 00000000..b475465c --- /dev/null +++ b/clients/build-rbuilder.sh @@ -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" \ No newline at end of file diff --git a/clients/build-reth.sh b/clients/build-reth.sh new file mode 100755 index 00000000..af0ca03c --- /dev/null +++ b/clients/build-reth.sh @@ -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" diff --git a/clients/versions.env b/clients/versions.env new file mode 100644 index 00000000..b110f31a --- /dev/null +++ b/clients/versions.env @@ -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" \ No newline at end of file