This file provides guidance for AI agents working with this codebase.
Requirements: Go 1.25+, GCC 10+ or Clang, 32GB+ RAM, SSD/NVMe storage
make erigon # Build main binary (./build/bin/erigon)
make integration # Build integration test binary
make lint # Run golangci-lint + mod tidy check
make test-short # Quick unit tests (-short -failfast)
make test-all # Full test suite with coverage
make gen # Generate all auto-generated code (mocks, grpc, etc.)Before committing, always verify changes with: make lint && make erigon integration
Run specific tests:
go test ./execution/stagedsync/...
go test -run TestName ./path/to/package/...Erigon is a high-performance Ethereum execution client with embedded consensus layer. Key design principles:
- Flat KV storage instead of tries (reduces write amplification)
- Staged synchronization (ordered pipeline, independent unwind)
- Modular services (sentry, txpool, downloader can run separately)
| Directory | Purpose | Component Docs |
|---|---|---|
cmd/ |
Entry points: erigon, rpcdaemon, caplin, sentry, downloader | - |
execution/stagedsync/ |
Staged sync pipeline | agents.md |
db/ |
Storage: MDBX, snapshots, ETL | agents.md |
cl/ |
Consensus layer (Caplin) | agents.md |
p2p/ |
P2P networking (DevP2P) | agents.md |
rpc/jsonrpc/ |
JSON-RPC API | - |
./build/bin/erigon --datadir=./data --chain=mainnet
./build/bin/erigon --datadir=dev --chain=dev --mine # DevelopmentCommit messages: prefix with package(s) modified, e.g., eth, rpc: make trace configs optional
Important: Always run make lint after making code changes and before committing. Fix any linter errors before proceeding.
The linter (make lint) is non-deterministic in which files it scans — new issues may appear on subsequent runs. Run lint repeatedly until clean.
Common lint categories and fixes:
- ruleguard (defer tx.Rollback/cursor.Close): The error check must come before
defer tx.Rollback(). Never remove an explicit.Close()or.Rollback()— adddeferas a safety net alongside it, since the timing of the explicit call may matter. - prealloc: Pre-allocate slices when the length is known from a range.
- unslice: Remove redundant
[:]on variables that are already slices. - newDeref: Replace
*new(T)withT{}. - appendCombine: Combine consecutive
appendcalls into one. - rangeExprCopy: Use
&xinrangeto avoid copying large arrays. - dupArg: For intentional
x.Equal(x)self-equality tests, suppress with//nolint:gocritic. - Loop ruleguard in benchmarks: For
BeginRw/BeginRoinside loops wheredeferdoesn't apply, suppress with//nolint:gocritic.