diff --git a/.claude/skills/ev-reth-core.md b/.claude/skills/ev-reth-core.md index 46e11e1..4d3a988 100644 --- a/.claude/skills/ev-reth-core.md +++ b/.claude/skills/ev-reth-core.md @@ -97,9 +97,9 @@ The chainspec parser supports Evolve-specific extras via `EvolveEip1559Config`: ## Development Commands ```bash -make build # Release build -make run-dev # Run with debug logs -make test-node # Test node crate +just build # Release build +just run-dev # Run with debug logs +just test-node # Test node crate ``` ## Exploration Starting Points diff --git a/.claude/skills/ev-reth-evolve.md b/.claude/skills/ev-reth-evolve.md index 3ab8306..28957ff 100644 --- a/.claude/skills/ev-reth-evolve.md +++ b/.claude/skills/ev-reth-evolve.md @@ -97,7 +97,7 @@ Executed and included in block ## Development Commands ```bash -make test-evolve +just test-evolve # Or directly: cargo test -p evolve-ev-reth ``` diff --git a/.claude/skills/ev-reth-testing.md b/.claude/skills/ev-reth-testing.md index fbacf2b..c73c55a 100644 --- a/.claude/skills/ev-reth-testing.md +++ b/.claude/skills/ev-reth-testing.md @@ -142,9 +142,9 @@ pub const TEST_BASE_FEE: u64 = 0; ## Development Commands ```bash -make test # Run all tests -make test-verbose # Run with output -make test-integration # Integration tests only +just test # Run all tests +just test-verbose # Run with output +just test-integration # Integration tests only # Run specific test cargo test -p ev-reth-tests test_payload_with_transactions diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 80246d5..14385a9 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -74,4 +74,16 @@ jobs: export AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar export PKG_CONFIG_ALLOW_CROSS=1 export DOCKER_TAG=${{ steps.set-tag.outputs.DOCKER_TAG }} - make docker-build-push + FEATURES="${FEATURES:-jemalloc}" + PROFILE="${PROFILE:-release}" + cross build --bin ev-reth --target x86_64-unknown-linux-gnu --features "$FEATURES" --profile "$PROFILE" + JEMALLOC_SYS_WITH_LG_PAGE=16 cross build --bin ev-reth --target aarch64-unknown-linux-gnu --features "$FEATURES" --profile "$PROFILE" + mkdir -p dist/bin/linux/amd64 dist/bin/linux/arm64 + cp "target/x86_64-unknown-linux-gnu/$PROFILE/ev-reth" dist/bin/linux/amd64/ev-reth + cp "target/aarch64-unknown-linux-gnu/$PROFILE/ev-reth" dist/bin/linux/arm64/ev-reth + docker buildx build --file ./Dockerfile.cross . \ + --platform linux/amd64,linux/arm64 \ + --tag "$DOCKER_IMAGE_NAME:$DOCKER_TAG" \ + --provenance=false \ + --sbom=false \ + --push diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e5dd953..92c350f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,7 +41,7 @@ jobs: sudo apt-get install -y gcc-aarch64-linux-gnu - name: Build release binary - run: make build-maxperf + run: RUSTFLAGS="-C target-cpu=native" cargo build --profile maxperf --features jemalloc,asm-keccak --bin ev-reth - name: Create tarball if: matrix.os != 'windows-latest' diff --git a/CLAUDE.md b/CLAUDE.md index 3b1ddc1..b30d2c8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -5,26 +5,26 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co ## Common Development Commands ### Building -- **Release build**: `make build` -- **Debug build**: `make build-dev` -- **Build all workspace members**: `make build-all` +- **Release build**: `just build` +- **Debug build**: `just build-dev` +- **Build all workspace members**: `just build-all` ### Testing -- **Run all tests**: `make test` -- **Run tests with output**: `make test-verbose` -- **Unit tests only**: `make test-unit` -- **Integration tests**: `make test-integration` -- **Test specific crate**: `make test-node`, `make test-evolve`, `make test-common` +- **Run all tests**: `just test` +- **Run tests with output**: `just test-verbose` +- **Unit tests only**: `just test-unit` +- **Integration tests**: `just test-integration` +- **Test specific crate**: `just test-node`, `just test-evolve`, `just test-common` ### Code Quality -- **Format code**: `make fmt` -- **Check formatting**: `make fmt-check` -- **Run linter**: `make lint` -- **Run all checks**: `make check-all` +- **Format code**: `just fmt` +- **Check formatting**: `just fmt-check` +- **Run linter**: `just lint` +- **Run all checks**: `just check-all` ### Running the Node -- **Run with defaults**: `make run` -- **Run with debug logs**: `make run-dev` +- **Run with defaults**: `just run` +- **Run with debug logs**: `just run-dev` - **Direct execution**: `./target/release/lumen node --chain --datadir --http --ws` ## High-Level Architecture diff --git a/Makefile b/Makefile deleted file mode 100644 index d822579..0000000 --- a/Makefile +++ /dev/null @@ -1,171 +0,0 @@ -.PHONY: all build test clean fmt lint run help - -# Build configuration -CARGO = cargo -BINARY_NAME = ev-reth -TARGET_DIR = target - -# Default target -all: build - -## help: Display this help message -help: - @echo "Available targets:" - @awk 'BEGIN {FS = ":.*##"; printf "\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) - -##@ Building - -## build: Build the ev-reth binary in release mode -build: - $(CARGO) build --release --bin $(BINARY_NAME) - -## build-dev: Build the ev-reth binary in debug mode -build-dev: - $(CARGO) build --bin $(BINARY_NAME) - -## build-maxperf: Build ev-reth with the most aggressive optimizations -build-maxperf: - RUSTFLAGS="-C target-cpu=native" $(CARGO) build --profile maxperf --features jemalloc,asm-keccak --bin $(BINARY_NAME) - -##@ Testing - -## test: Run all tests -test: - $(CARGO) test --workspace - -## test-verbose: Run all tests with verbose output -test-verbose: - $(CARGO) test --workspace -- --nocapture - -## test-unit: Run unit tests only -test-unit: - $(CARGO) test --lib - -## test-integration: Run integration tests only -test-integration: - $(CARGO) test -p ev-tests - -##@ Development - -## run: Run the ev-reth node with default settings -run: build-dev - ./$(TARGET_DIR)/debug/$(BINARY_NAME) node - -## run-dev: Run with debug logs enabled -run-dev: build-dev - RUST_LOG=debug ./$(TARGET_DIR)/debug/$(BINARY_NAME) node - -## fmt: Format code using rustfmt (nightly) -fmt: - $(CARGO) +nightly fmt --all - -## fmt-check: Check if code is formatted correctly (nightly) -fmt-check: - $(CARGO) +nightly fmt --all --check - -## lint: Run clippy linter -lint: - $(CARGO) clippy --all-targets --all-features -- -D warnings - -## check: Run cargo check -check: - $(CARGO) check --workspace - -##@ Maintenance - -## clean: Clean build artifacts -clean: - $(CARGO) clean - -## update: Update dependencies -update: - $(CARGO) update - -## audit: Audit dependencies for security vulnerabilities -audit: - $(CARGO) audit - -##@ Documentation - -## doc: Build documentation -doc: - $(CARGO) doc --no-deps --open - -## doc-all: Build documentation including dependencies -doc-all: - $(CARGO) doc --open - -##@ Workspace Management - -## build-all: Build all workspace members -build-all: - $(CARGO) build --workspace --release - -## test-node: Test only the node crate -test-node: - $(CARGO) test -p ev-node - -## test-evolve: Test only the evolve crate -test-evolve: - $(CARGO) test -p evolve-ev-reth - -## test-common: Test only the common crate -test-common: - $(CARGO) test -p ev-common - -##@ Docker - -# Docker configuration -GIT_TAG ?= $(shell git describe --tags --abbrev=0 || echo "latest") -GIT_COMMIT ?= $(shell git rev-parse --short HEAD || echo "unknown") -DOCKER_TAG ?= $(GIT_COMMIT) -BIN_DIR = dist/bin -DOCKER_IMAGE_NAME ?= ghcr.io/$(shell git config --get remote.origin.url | sed 's/.*github.com[:/]\(.*\)\.git/\1/' | cut -d'/' -f1)/ev-reth -PROFILE ?= release - -# List of features to use when building -FEATURES ?= jemalloc - -## docker-build: Build Docker image (tagged with git commit hash by default) -docker-build: - @echo "Building Docker image: $(DOCKER_IMAGE_NAME):$(DOCKER_TAG)" - docker build -t $(DOCKER_IMAGE_NAME):$(DOCKER_TAG) . - -## docker-build-push: Build and push a cross-arch Docker image -docker-build-push: - $(call docker_build_push,$(DOCKER_TAG),$(DOCKER_TAG)) - -## docker-build-push-latest: Build and push a cross-arch Docker image tagged with latest -docker-build-push-latest: - $(call docker_build_push,$(GIT_TAG),latest) - -# Cross-compilation targets -build-x86_64-unknown-linux-gnu: - cross build --bin $(BINARY_NAME) --target x86_64-unknown-linux-gnu --features "$(FEATURES)" --profile "$(PROFILE)" - -build-aarch64-unknown-linux-gnu: - JEMALLOC_SYS_WITH_LG_PAGE=16 cross build --bin $(BINARY_NAME) --target aarch64-unknown-linux-gnu --features "$(FEATURES)" --profile "$(PROFILE)" - -# Create a cross-arch Docker image with the given tags and push it -define docker_build_push - $(MAKE) build-x86_64-unknown-linux-gnu - mkdir -p $(BIN_DIR)/linux/amd64 - cp $(TARGET_DIR)/x86_64-unknown-linux-gnu/$(PROFILE)/$(BINARY_NAME) $(BIN_DIR)/linux/amd64/$(BINARY_NAME) - - $(MAKE) build-aarch64-unknown-linux-gnu - mkdir -p $(BIN_DIR)/linux/arm64 - cp $(TARGET_DIR)/aarch64-unknown-linux-gnu/$(PROFILE)/$(BINARY_NAME) $(BIN_DIR)/linux/arm64/$(BINARY_NAME) - - docker buildx build --file ./Dockerfile.cross . \ - --platform linux/amd64,linux/arm64 \ - --tag $(DOCKER_IMAGE_NAME):$(1) \ - --tag $(DOCKER_IMAGE_NAME):$(2) \ - --provenance=false \ - --sbom=false \ - --push -endef - -##@ CI Helpers - -## check-all: Run all checks (fmt, lint, test) -check-all: fmt-check lint test diff --git a/README.md b/README.md index 423048a..5f1af9d 100644 --- a/README.md +++ b/README.md @@ -136,10 +136,10 @@ git clone https://github.com/evstack/ev-reth.git cd ev-reth # Build the project -make build +just build # Run tests -make test +just test ``` ## Usage @@ -534,7 +534,7 @@ ev-reth/ ├── etc/ # Configuration files │ └── ev-reth-genesis.json # Genesis configuration ├── Cargo.toml # Workspace configuration -├── Makefile # Build automation +├── justfile # Build automation └── README.md # This file ``` @@ -542,10 +542,10 @@ ev-reth/ ```bash # Run all tests -make test +just test # Run with verbose output -make test-verbose +just test-verbose # Run specific test cargo test test_name @@ -555,10 +555,10 @@ cargo test test_name ```bash # Debug build -make build-dev +just build-dev # Run with debug logs -make run-dev +just run-dev ``` ## Troubleshooting diff --git a/justfile b/justfile new file mode 100644 index 0000000..b50b8a0 --- /dev/null +++ b/justfile @@ -0,0 +1,163 @@ +# Build configuration +cargo := "cargo" +binary := "ev-reth" +target_dir := "target" + +# Docker configuration +git_tag := `git describe --tags --abbrev=0 2>/dev/null || echo "latest"` +git_commit := `git rev-parse --short HEAD 2>/dev/null || echo "unknown"` +docker_tag := env("DOCKER_TAG", git_commit) +bin_dir := "dist/bin" +docker_image := env("DOCKER_IMAGE_NAME", `echo "ghcr.io/$(git config --get remote.origin.url | sed 's/.*github.com[:/]\(.*\)\.git/\1/' | cut -d'/' -f1)/ev-reth"`) +profile := env("PROFILE", "release") +features := env("FEATURES", "jemalloc") + +# Default: list available recipes +default: + @just --list + +# Building ───────────────────────────────────────────── + +# Build the ev-reth binary in release mode +build: + {{cargo}} build --release --bin {{binary}} + +# Build the ev-reth binary in debug mode +build-dev: + {{cargo}} build --bin {{binary}} + +# Build ev-reth with the most aggressive optimizations +build-maxperf: + RUSTFLAGS="-C target-cpu=native" {{cargo}} build --profile maxperf --features jemalloc,asm-keccak --bin {{binary}} + +# Build all workspace members +build-all: + {{cargo}} build --workspace --release + +# Testing ────────────────────────────────────────────── + +# Run all tests +test: + {{cargo}} test --workspace + +# Run all tests with verbose output +test-verbose: + {{cargo}} test --workspace -- --nocapture + +# Run unit tests only +test-unit: + {{cargo}} test --lib + +# Run integration tests only +test-integration: + {{cargo}} test -p ev-tests + +# Test only the node crate +test-node: + {{cargo}} test -p ev-node + +# Test only the evolve crate +test-evolve: + {{cargo}} test -p evolve-ev-reth + +# Test only the common crate +test-common: + {{cargo}} test -p ev-common + +# Development ────────────────────────────────────────── + +# Run the ev-reth node with default settings +run: build-dev + ./{{target_dir}}/debug/{{binary}} node + +# Run with debug logs enabled +run-dev: build-dev + RUST_LOG=debug ./{{target_dir}}/debug/{{binary}} node + +# Format code using rustfmt (nightly) +fmt: + {{cargo}} +nightly fmt --all + +# Check if code is formatted correctly (nightly) +fmt-check: + {{cargo}} +nightly fmt --all --check + +# Run clippy linter +lint: + {{cargo}} clippy --all-targets --all-features -- -D warnings + +# Run cargo check +check: + {{cargo}} check --workspace + +# Run all checks (fmt, lint, test) +check-all: fmt-check lint test + +# Maintenance ────────────────────────────────────────── + +# Clean build artifacts +clean: + {{cargo}} clean + +# Update dependencies +update: + {{cargo}} update + +# Audit dependencies for security vulnerabilities +audit: + {{cargo}} audit + +# Documentation ──────────────────────────────────────── + +# Build documentation +doc: + {{cargo}} doc --no-deps --open + +# Build documentation including dependencies +doc-all: + {{cargo}} doc --open + +# Docker ─────────────────────────────────────────────── + +# Build Docker image (tagged with git commit hash by default) +docker-build: + @echo "Building Docker image: {{docker_image}}:{{docker_tag}}" + docker build -t {{docker_image}}:{{docker_tag}} . + +# Build and push a cross-arch Docker image +docker-build-push: _build-x86_64 _build-aarch64 + mkdir -p {{bin_dir}}/linux/amd64 + cp {{target_dir}}/x86_64-unknown-linux-gnu/{{profile}}/{{binary}} {{bin_dir}}/linux/amd64/{{binary}} + mkdir -p {{bin_dir}}/linux/arm64 + cp {{target_dir}}/aarch64-unknown-linux-gnu/{{profile}}/{{binary}} {{bin_dir}}/linux/arm64/{{binary}} + docker buildx build --file ./Dockerfile.cross . \ + --platform linux/amd64,linux/arm64 \ + --tag {{docker_image}}:{{docker_tag}} \ + --tag {{docker_image}}:{{docker_tag}} \ + --provenance=false \ + --sbom=false \ + --push + +# Build and push a cross-arch Docker image tagged with latest +docker-build-push-latest: _build-x86_64 _build-aarch64 + mkdir -p {{bin_dir}}/linux/amd64 + cp {{target_dir}}/x86_64-unknown-linux-gnu/{{profile}}/{{binary}} {{bin_dir}}/linux/amd64/{{binary}} + mkdir -p {{bin_dir}}/linux/arm64 + cp {{target_dir}}/aarch64-unknown-linux-gnu/{{profile}}/{{binary}} {{bin_dir}}/linux/arm64/{{binary}} + docker buildx build --file ./Dockerfile.cross . \ + --platform linux/amd64,linux/arm64 \ + --tag {{docker_image}}:{{git_tag}} \ + --tag {{docker_image}}:latest \ + --provenance=false \ + --sbom=false \ + --push + +# Cross-compile for x86_64 +[private] +_build-x86_64: + cross build --bin {{binary}} --target x86_64-unknown-linux-gnu --features "{{features}}" --profile "{{profile}}" + +# Cross-compile for aarch64 +[private] +_build-aarch64: + JEMALLOC_SYS_WITH_LG_PAGE=16 cross build --bin {{binary}} --target aarch64-unknown-linux-gnu --features "{{features}}" --profile "{{profile}}"