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
62 changes: 62 additions & 0 deletions create-l2-rollup-example/.example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# OP Stack L2 Rollup Environment Configuration
# Copy this file to .env and fill in your actual values
# This uses direnv for automatic environment loading

# ==========================================
# REQUIRED: L1 Configuration (Sepolia testnet)
# ==========================================
# Option 1: Public endpoint (no API key required - recommended for testing)
L1_RPC_URL="https://ethereum-sepolia-rpc.publicnode.com"
L1_BEACON_URL="https://ethereum-sepolia-beacon-api.publicnode.com"

# Option 2: Private endpoint (requires API key from Infura/Alchemy)
# L1_RPC_URL="https://eth-sepolia.g.alchemy.com/v2/YOUR_API_KEY"
# L1_BEACON_URL="https://ethereum-sepolia-beacon-api.publicnode.com"

# ==========================================
# REQUIRED: Private Key for Deployment & Operations
# ==========================================
# IMPORTANT: Never commit this to version control!
# Get this from your MetaMask or other self-custody wallet
# Remove the 0x prefix if present
PRIVATE_KEY="YOUR_PRIVATE_KEY_WITHOUT_0X_PREFIX"

# ==========================================
# OPTIONAL: Public IP for P2P Networking
# ==========================================
# For local testing, defaults to 127.0.0.1
# For production/testnet, run `curl ifconfig.me` to get your public IP
P2P_ADVERTISE_IP="127.0.0.1"

# ==========================================
# OPTIONAL: Custom Configuration
# ==========================================
# Default L2 Chain ID (can be any number between 10000-99999 for testing)
L2_CHAIN_ID="16584"

# L1 Beacon API URL for op-node (usually same provider as L1_RPC_URL)
L1_BEACON_URL="https://ethereum-sepolia-beacon-api.publicnode.com"

# ==========================================
# ADVANCED: Component Environment Variables
# ==========================================
# These follow OP Stack conventions and can be overridden in the main .env file
# The setup script creates service-specific .env files with these OP_* prefixed variables

# Batcher Environment Variables
OP_BATCHER_POLL_INTERVAL="1s"
OP_BATCHER_SUB_SAFETY_MARGIN="6"
OP_BATCHER_NUM_CONFIRMATIONS="1"
OP_BATCHER_SAFE_ABORT_NONCE_TOO_LOW_COUNT="3"

# Proposer Environment Variables
OP_PROPOSER_PROPOSAL_INTERVAL="3600s"
OP_PROPOSER_GAME_TYPE="0"
OP_PROPOSER_POLL_INTERVAL="20s"

# ==========================================
# DEVELOPMENT: Local Network (Alternative to Sepolia)
# ==========================================
# Uncomment these for local development with a local L1 network
# L1_RPC_URL="http://host.docker.internal:8545"
# L1_BEACON_URL="http://host.docker.internal:5052"
45 changes: 45 additions & 0 deletions create-l2-rollup-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Environment files
.env
.env.local
**/.env

# Deployment artifacts
deployer/

# Generated service directories
sequencer/
batcher/
proposer/
challenger/

# Optimism monorepo
optimism/

# Downloaded binaries
op-deployer

# Logs
*.log
logs/

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# IDE files
.vscode/
.idea/
*.swp
*.swo

# Node modules (if any)
node_modules/

# Temporary files
tmp/
temp/
89 changes: 89 additions & 0 deletions create-l2-rollup-example/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# OP Stack L2 Rollup Makefile

.PHONY: help setup up down logs clean reset

# Default target
help: ## Show this help message
@echo "OP Stack L2 Rollup Management Commands:"
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

setup: ## Deploy L1 contracts and configure rollup components
mkdir -p deployer
@if [ ! -f op-deployer ]; then \
echo "❌ Error: op-deployer not found. Run 'make download' first."; \
exit 1; \
fi
@if [ ! -f .env ]; then \
echo "❌ Error: .env file not found. Copy .example.env to .env and configure it."; \
exit 1; \
fi
@echo "Running setup script..."
@./scripts/setup-rollup.sh

up: ## Start all services
docker-compose up -d --wait
@make test-l2

down: ## Stop all services
docker-compose down

logs: ## View logs from all services
docker-compose logs -f

logs-%: ## View logs from a specific service (e.g., make logs-sequencer)
docker-compose logs -f $*

status: ## Show status of all services
docker-compose ps

restart: ## Restart all services
docker-compose restart

restart-%: ## Restart a specific service (e.g., make restart-batcher)
docker-compose restart $*

clean: ## Remove all containers and volumes
@# Create minimal env files if they don't exist to avoid docker-compose errors
@mkdir -p batcher proposer challenger sequencer
@echo "# Minimal env for cleanup" > batcher/.env 2>/dev/null || true
@echo "# Minimal env for cleanup" > proposer/.env 2>/dev/null || true
@echo "# Minimal env for cleanup" > challenger/.env 2>/dev/null || true
docker-compose down -v --remove-orphans 2>/dev/null || true

reset: ## Complete reset - removes all data and redeploys
@echo "This will completely reset your L2 rollup deployment!"
@read -p "Are you sure? (y/N) " confirm && [ "$$confirm" = "y" ] || exit 1
make clean
rm -rf deployer sequencer batcher proposer challenger
@echo "Reset complete. Run 'make setup' to redeploy."

test-l2: ## Test L2 connectivity
@echo "Testing L2 RPC connection..."
@curl -s -X POST -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
http://localhost:8545 | jq -r '.result' 2>/dev/null && echo "✅ L2 connection successful" || echo "❌ L2 connection failed"

test-l1: ## Test L1 connectivity
@echo "Testing L1 RPC connection..."
@if [ -f .env ]; then \
set -a; source .env; set +a; \
fi; \
curl -s -X POST -H "Content-Type: application/json" \
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
"$$L1_RPC_URL" | jq -r '.result' 2>/dev/null && echo "✅ L1 connection successful" || echo "❌ L1 connection failed"

deps: ## Install development dependencies with mise (optional)
mise install

download: ## Download op-deployer binary
./scripts/download-op-deployer.sh

init: ## Initialize the project
./scripts/download-op-deployer.sh
@if [ ! -f .env ]; then \
cp .example.env .env; \
echo "Please edit .env with your actual configuration values"; \
else \
echo ".env already exists, skipping copy"; \
fi
@echo "Then run: make setup"
Loading