This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Stratus is a high-performance EVM-compatible blockchain infrastructure written in Rust, designed as an EVM executor and JSON-RPC server with custom storage capabilities. It supports 10k TPS for reads and 2.5k TPS for writes, with a distributed leader-follower architecture.
just build- Build Stratus with debug options (default: dev features)just build stratus release- Build optimized release versionjust check- Check compilation without generating codejust lint- Format and lint all code (Rust + TypeScript)just lint-check- Check formatting and run clippy with strict warningsjust test- Run Rust tests with coverage reportingjust clean- Clean build artifacts
just stratusorjust run- Run as leader node (development mode)just stratus-follower- Run as follower nodeRELEASE=1 just run- Run optimized release versionjust stratus-test- Run with test coverage instrumentation
just db-compileorjust sqlx- Compile SQLx queries offline- Database URL:
postgres://postgres:123@0.0.0.0:5432/stratus(default) - SQL is only used for the rpc_downloader and importer-offline binaries
- Storage options: RocksDB (default) or In-Memory
just test- Unit tests with coveragejust e2e-stratus- End-to-end tests with Stratusjust e2e-hardhat- End-to-end tests with Hardhatjust e2e-leader-follower-up- Leader-follower integration testsjust contracts-test-stratus- CloudWalk contracts testingjust e2e-genesis- Genesis configuration tests
just rpc-downloader- Download external RPC blocks to temp storagejust importer-offline- Import external RPC blocks to Stratus storage
src/eth/- Ethereum functionalityexecutor/- EVM execution engine using REVMrpc/- JSON-RPC server implementationstorage/- Storage layer (RocksDB + In-Memory)primitives/- Ethereum primitive typesminer/- Block mining functionalityfollower/- Follower node with consensus and importerexternal_rpc/- External blockchain RPC with PostgreSQL
src/infra/- Infrastructure (metrics, tracing, Kafka, Sentry)src/ledger/- Ledger event managemente2e/- TypeScript/Hardhat end-to-end tests
- Leader-follower distributed architecture
- EVM execution with REVM integration
- RocksDB storage with replication support
- Kafka integration for event streaming
- Comprehensive observability (Prometheus, OpenTelemetry, Grafana)
- Full Ethereum JSON-RPC compatibility
- Rust version: 1.86 (specified in rust-toolchain.toml)
- Max line width: 160 characters
- Import style: Item-level granularity, grouped by StdExternalCrate
- Formatting: Use
just lintwhich runscargo fmtandcargo clippy - Linting: Warnings treated as errors, but
unwrap(),expect(),panic!()allowed in tests
unwrap_used = "allow"- Allowed in all contextsexpect_used = "warn"- Discouraged but not forbiddenpanic = "warn"- Discouraged but not forbiddendisallowed_names = "warn"- Avoid variable names like "lock"wildcard_imports = "warn"- Avoiduse module::*
- Default features:
["metrics", "tracing"] - Development: Use
--features devfor development builds - Release: Use
--features dev --releasefor optimized development builds - Special features:
jeprof(memory profiling),flamegraph,jemalloc
- Unit tests:
cargo testwith coverage viacargo llvm-cov - E2E tests: Hardhat/TypeScript tests against running Stratus instance
- Integration tests: CloudWalk contracts testing
- Performance tests: TPS benchmarks and profiling
- Leader-follower tests: Distributed consensus testing
- Node.js: v20.10.0 and v21.6.1 (use asdf)
- Solidity: v0.8.16
- Setup: Run
just setupto install dependencies - Infrastructure: Use
docker-compose.yamlfor PostgreSQL, Kafka, etc.
- Always use
justrecipes for consistent test execution - Tests automatically instrument code for coverage
- E2E tests start/stop Stratus instances automatically
- Use
just run-test <recipe>for tests with coverage and cleanup
- Rust (1.86)
- just (task runner)
- Git
- Docker & Docker Compose
- Node.js (via asdf)
cargo killport- Kill processes on specific portscargo wait-service- Wait for services to be availablecargo flamegraph- Performance profiling
config/- Environment-specific configurationsLOCAL_ENV_PATH- Override environment file path.envfiles supported viadotenvy
RUST_BACKTRACE- Backtrace verbosity (default: 0)RELEASE- Build in release mode when set to 1NIGHTLY- Use nightly toolchain when set to 1DATABASE_URL- PostgreSQL connection string
- Read TPS: 10,000 transactions per second
- Write TPS: 2,500 transactions per second (~540M gas/second)
- Future goals: 5k TPS single node, 1M TPS clustered
- Metrics: Prometheus metrics at
/metricsendpoint - Tracing: OpenTelemetry with Jaeger (UI at localhost:16686)
- Logs: Structured logging with tracing-subscriber
- Error tracking: Sentry integration
- Dashboards: Grafana dashboards included
- Always run
cargo checkafter making changes
- When editing StratusStorage pay attention to the transient_state_lock contract, "Always acquire a lock when reading slots or accounts from latest (cache OR perm) and when saving a block"