mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
248 lines
6.7 KiB
Makefile
248 lines
6.7 KiB
Makefile
# Subnet EVM Makefile
|
|
|
|
# Root directory
|
|
EVM_PATH := $(shell pwd)
|
|
|
|
# Load constants - these will be set via shell commands
|
|
GOPATH := $(shell go env GOPATH)
|
|
DEFAULT_PLUGIN_DIR := $(HOME)/.luxd/plugins
|
|
DEFAULT_VM_NAME := evm
|
|
DEFAULT_VM_ID := srEXiWaHuhNyGwPUi444Tu47ZEDwxTWrbQiuD7FmgSAQ6X7Dy
|
|
|
|
# Git commit
|
|
EVM_COMMIT := $(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
|
|
CURRENT_BRANCH := $(shell git describe --tags --exact-match 2>/dev/null || git symbolic-ref -q --short HEAD || git rev-parse --short HEAD || echo "unknown")
|
|
|
|
# Lux version from go.mod
|
|
LUX_VERSION := $(shell go list -m github.com/luxfi/luxd 2>/dev/null | awk '{print $$2}')
|
|
|
|
# Build flags
|
|
LDFLAGS := -X github.com/luxfi/evm/plugin/evm.GitCommit=$(EVM_COMMIT)
|
|
STATIC_LD_FLAGS :=
|
|
CGO_ENABLED := 1
|
|
CGO_CFLAGS := -O2 -D__BLST_PORTABLE__
|
|
|
|
# Binary path
|
|
BINARY_PATH := $(DEFAULT_PLUGIN_DIR)/$(DEFAULT_VM_ID)
|
|
|
|
# Export necessary variables
|
|
export CGO_ENABLED
|
|
export CGO_CFLAGS
|
|
|
|
.PHONY: all build clean test lint install setup generate help
|
|
|
|
# Default target
|
|
all: build
|
|
|
|
# Help target
|
|
help:
|
|
@echo "Subnet EVM Makefile"
|
|
@echo ""
|
|
@echo "Usage:"
|
|
@echo " make [target]"
|
|
@echo ""
|
|
@echo "Targets:"
|
|
@echo " all Build Subnet EVM (default)"
|
|
@echo " build Build Subnet EVM binary"
|
|
@echo " install Build and install to default plugin directory"
|
|
@echo " clean Clean build artifacts"
|
|
@echo " test Run all tests"
|
|
@echo " test-unit Run unit tests"
|
|
@echo " test-e2e Run end-to-end tests"
|
|
@echo " lint Run linters"
|
|
@echo " lint-all Run all lint checks"
|
|
@echo " generate Generate code (mocks, codecs)"
|
|
@echo " setup Setup development environment"
|
|
@echo " docker Build Docker image"
|
|
@echo " check-version Check luxd version"
|
|
@echo ""
|
|
@echo "Build options:"
|
|
@echo " BINARY_PATH Set custom binary output path (default: $(BINARY_PATH))"
|
|
@echo " STATIC_COMPILATION=1 Enable static compilation"
|
|
|
|
# Build the Subnet EVM binary
|
|
build: ensure-deps
|
|
@echo "Building Subnet EVM @ GitCommit: $(EVM_COMMIT)"
|
|
go build -ldflags "$(LDFLAGS) $(STATIC_LD_FLAGS)" -o bin/$(DEFAULT_VM_ID) ./plugin/*.go
|
|
|
|
# Ensure dependencies are in place
|
|
ensure-deps:
|
|
@echo "Checking dependencies..."
|
|
@if [ ! -f go.sum ]; then \
|
|
echo "go.sum missing, running go mod download..."; \
|
|
go mod download; \
|
|
fi
|
|
|
|
# Fix dependencies - download missing modules and generate go.sum
|
|
fix-deps:
|
|
@echo "Fixing dependencies..."
|
|
@echo "Downloading modules..."
|
|
go mod download
|
|
@echo "Dependencies fixed."
|
|
|
|
# Build with custom output path
|
|
build-custom:
|
|
@echo "Building Subnet EVM @ GitCommit: $(EVM_COMMIT) at $(BINARY_PATH)"
|
|
go build -ldflags "$(LDFLAGS) $(STATIC_LD_FLAGS)" -o "$(BINARY_PATH)" ./plugin/*.go
|
|
|
|
# Install to default plugin directory
|
|
install: build
|
|
@echo "Installing Subnet EVM to $(DEFAULT_PLUGIN_DIR)"
|
|
@mkdir -p $(DEFAULT_PLUGIN_DIR)
|
|
@cp bin/$(DEFAULT_VM_ID) $(DEFAULT_PLUGIN_DIR)/
|
|
|
|
# Clean build artifacts
|
|
clean:
|
|
@echo "Cleaning build artifacts..."
|
|
@rm -rf bin/
|
|
@rm -f $(DEFAULT_PLUGIN_DIR)/$(DEFAULT_VM_ID)
|
|
@go clean -cache
|
|
|
|
# Run all tests
|
|
test:
|
|
@echo "Running all tests..."
|
|
./scripts/build_test.sh
|
|
|
|
# Run unit tests only
|
|
test-unit:
|
|
@echo "Running unit tests..."
|
|
go test -v -timeout=30m ./...
|
|
|
|
# Run unit tests with race detection
|
|
test-race:
|
|
@echo "Running tests with race detection..."
|
|
go test -v -race -timeout=30m ./...
|
|
|
|
# Run E2E tests
|
|
test-e2e: test-e2e-precompile test-e2e-load test-e2e-warp
|
|
|
|
test-e2e-precompile:
|
|
@echo "Running E2E precompile tests..."
|
|
./scripts/run_ginkgo_precompile.sh
|
|
|
|
test-e2e-load:
|
|
@echo "Running E2E load tests..."
|
|
./scripts/run_ginkgo_load.sh
|
|
|
|
test-e2e-warp:
|
|
@echo "Running E2E warp tests..."
|
|
./scripts/run_ginkgo_warp.sh
|
|
|
|
# Benchmarks
|
|
bench:
|
|
@echo "Running benchmarks..."
|
|
./scripts/build_bench_precompiles.sh
|
|
|
|
# Coverage
|
|
coverage:
|
|
@echo "Generating coverage report..."
|
|
go test -v -coverprofile=coverage.out ./...
|
|
./scripts/coverage.sh
|
|
|
|
# Linting
|
|
lint:
|
|
@echo "Running linters..."
|
|
./scripts/lint.sh
|
|
|
|
lint-all:
|
|
@echo "Running all lint checks..."
|
|
@$(MAKE) lint
|
|
@./scripts/actionlint.sh
|
|
@./scripts/shellcheck.sh
|
|
@$(MAKE) check-generate
|
|
|
|
# Code generation
|
|
generate: generate-mocks generate-codec
|
|
|
|
generate-mocks:
|
|
@echo "Generating mocks..."
|
|
@grep -lr -E '^// Code generated by MockGen\. DO NOT EDIT\.' . | xargs -r rm
|
|
@go generate -run "go.uber.org/mock/mockgen" ./...
|
|
|
|
generate-codec:
|
|
@echo "Generating codec..."
|
|
@grep -lr -E '^// Code generated by github\.com\/fjl\/gencodec\. DO NOT EDIT\.' . | xargs -r rm
|
|
@go generate -run "github.com/fjl/gencodec" ./...
|
|
|
|
# Check if generated files are up to date
|
|
check-generate: generate
|
|
@echo "Checking if generated files are up to date..."
|
|
@git diff --exit-code || (echo "Generated files are out of date. Please run 'make generate'." && exit 1)
|
|
|
|
# Setup development environment
|
|
setup:
|
|
@echo "Setting up development environment..."
|
|
@echo "Installing dependencies..."
|
|
go mod download
|
|
@echo "Installing tools..."
|
|
go install -v github.com/fjl/gencodec@latest
|
|
go install -v go.uber.org/mock/mockgen@latest
|
|
@echo "Setting up contracts..."
|
|
cd contracts && npm ci && npx hardhat clean && npx hardhat compile
|
|
|
|
# Docker image
|
|
docker:
|
|
@echo "Building Docker image..."
|
|
./scripts/build_docker_image.sh
|
|
|
|
docker-test:
|
|
@echo "Testing Docker image build..."
|
|
./scripts/tests.build_docker_image.sh
|
|
|
|
# Version management
|
|
check-version:
|
|
@echo "Checking luxd version..."
|
|
@echo "Current luxd version: $(LUX_VERSION)"
|
|
./scripts/update_luxd_version.sh
|
|
|
|
# Install luxd for testing
|
|
install-luxd:
|
|
@echo "Installing luxd..."
|
|
./scripts/install_luxd_release.sh
|
|
|
|
# Development helpers
|
|
dev-shell:
|
|
@echo "Starting development shell..."
|
|
./scripts/dev_shell.sh
|
|
|
|
# Run local node for testing
|
|
run-local: build
|
|
@echo "Running local node..."
|
|
./scripts/run.sh
|
|
|
|
# Format code
|
|
fmt:
|
|
@echo "Formatting Go code..."
|
|
go fmt ./...
|
|
gofmt -s -w .
|
|
|
|
# Check go mod tidy
|
|
check-go-mod:
|
|
@echo "Checking go.mod..."
|
|
go mod tidy
|
|
@git diff --exit-code go.mod go.sum || (echo "go.mod or go.sum is out of date. Please run 'go mod tidy'." && exit 1)
|
|
|
|
# Run simulator
|
|
simulator: build
|
|
@echo "Running simulator..."
|
|
./scripts/run_simulator.sh
|
|
|
|
# Antithesis testing
|
|
antithesis-images:
|
|
@echo "Building Antithesis images..."
|
|
./scripts/build_antithesis_images.sh
|
|
|
|
test-antithesis: install-luxd build
|
|
@echo "Running Antithesis tests..."
|
|
go run ./tests/antithesis --luxd-path=/tmp/e2e-test/luxd/luxd --duration=60s
|
|
|
|
# Quick build for development
|
|
dev: build
|
|
|
|
# Full CI pipeline
|
|
ci: check-go-mod lint-all test coverage
|
|
|
|
.PHONY: build-custom test-unit test-race test-e2e test-e2e-precompile test-e2e-load test-e2e-warp
|
|
.PHONY: bench coverage generate-mocks generate-codec check-generate setup docker docker-test
|
|
.PHONY: check-version install-luxd dev-shell run-local fmt check-go-mod simulator
|
|
.PHONY: antithesis-images test-antithesis dev ci |