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
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,41 @@ Recipes (e.g. `l1`, `opstack`) assemble opinionated components and pre-baked con
- Running repeatable CI and e2e scenarios
- Experimenting with fork configurations and client combinations

Quick start:
## Installation

### Install with script (recommended)

On Linux and macOS, you can install the latest version to `/usr/local/bin` with:

```bash
# L1 environment with mev-boost relay
builder-playground start l1
curl -sSfL https://raw.githubusercontent.com/flashbots/builder-playground/main/install.sh | bash
```

# L2 OpStack with external builder support
builder-playground start opstack --external-builder http://localhost:4444
If you need to install a specific version, you can use the `VERSION` env var in the beginning like:
```bash
VERSION=1.2.3 curl -sSfL https://raw.githubusercontent.com/flashbots/builder-playground/main/install.sh | bash
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: VERSION=1.2.3 curl ... | bash sets VERSION as an environment variable only for the curl process, not for the bash process on the right side of the pipe. The script will never see VERSION.

Should be:

Suggested change
```
curl -sSfL https://raw.githubusercontent.com/flashbots/builder-playground/main/install.sh | VERSION=1.2.3 bash

Or:

export VERSION=1.2.3 && curl -sSfL https://raw.githubusercontent.com/flashbots/builder-playground/main/install.sh | bash


## Installation
### Install from repository

```
$ go install github.com/flashbots/builder-playground@latest
Extend the `PATH` variable with `GOPATH/bin` (or `GOBIN` if set), then clone the repository and do:
```bash
go install .
```

or clone the repository and do:
---

```
$ go install .
```
These commands install to different directories as mentioned above so make sure to verify with `which $(builder-playground)` to avoid confusion!

or do `go build .` and run from the repository like `./builder-playground`.
## Quick Examples

```bash
# L1 environment with mev-boost relay
builder-playground start l1

# L2 OpStack with external builder support
builder-playground start opstack --external-builder http://localhost:4444
```

## CI / GitHub Actions

Expand Down
54 changes: 54 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
set -euo pipefail

REPO="flashbots/builder-playground"
BIN="builder-playground"
API="https://api.github.com/repos/${REPO}/releases/latest"

# Detect OS
OS="$(uname | tr '[:upper:]' '[:lower:]')"
case "$OS" in
linux|darwin) ;;
*) echo "Unsupported OS: $OS"; exit 1 ;;
esac

# Detect ARCH
ARCH="$(uname -m)"
case "$ARCH" in
x86_64) ARCH="amd64" ;;
arm64|aarch64) ARCH="arm64" ;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac

if [ -n "${VERSION:-}" ]; then
# Normalize: ensure tag has a "v" prefix
TAG="${VERSION#v}"
TAG="v${TAG}"
echo "Checking version: $TAG"
if ! curl -sSfL "https://api.github.com/repos/${REPO}/releases/tags/${TAG}" > /dev/null 2>&1; then
echo "Error: version '${TAG}' not found. Check available releases at https://github.com/${REPO}/releases"
exit 1
fi
else
echo "Fetching latest release..."
TAG=$(curl -sSfL "$API" | grep -oP '"tag_name": "\K(.*)(?=")')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: grep -oP uses Perl-compatible regex which is not available on macOS (BSD grep). This will fail on darwin even though the script explicitly supports it at line 11.

A portable alternative:

Suggested change
TAG=$(curl -sSfL "$API" | grep -oP '"tag_name": "\K(.*)(?=")')
TAG=$(curl -sSfL "$API" | grep '"tag_name"' | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')

Or using awk:

TAG=$(curl -sSfL "$API" | awk -F'"' '/"tag_name"/{print $4}')

echo "Latest version: $TAG"
fi

ASSET="${BIN}_${TAG}_${OS}_${ARCH}.zip"
URL="https://github.com/${REPO}/releases/download/${TAG}/${ASSET}"

echo "Downloading $ASSET..."
curl -sSfL "$URL" -o "$ASSET"

echo "Extracting..."
unzip -o "$ASSET"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script downloads and extracts into the user's current working directory. This can pollute the CWD with the zip and extracted binary, and will fail if the CWD is read-only. Consider using a temp directory:

TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT

curl -sSfL "$URL" -o "$TMP/$ASSET"
unzip -o "$TMP/$ASSET" -d "$TMP"
chmod +x "$TMP/$BIN"
sudo mv "$TMP/$BIN" /usr/local/bin/

Also, unzip is not guaranteed to be installed on all systems (e.g., minimal Docker images, some Linux distros). A check or fallback to jar / python3 -m zipfile would be more robust.


echo "Installing to /usr/local/bin..."
chmod +x "$BIN"
sudo mv "$BIN" /usr/local/bin/

echo "Cleaning up..."
rm -f "$ASSET"

echo "✅ Installed $BIN $TAG for ${OS}-${ARCH}"