This guide helps to get started with the Nethermind Ethereum execution client repository. It covers the project structure, how to build and test the code, and follow the PR workflow.
- src/Nethermind: The Nethermind codebase
- tools: Various servicing tools for testing, monitoring, etc.
- scripts: The build scripts and stuff used by GitHub Actions workflows
- See README.md for more info
- Do follow the CONTRIBUTING.md guidelines
- Do follow the .editorconfig rules
- Do prefer low-allocation code patterns
- Prefer the latest C# syntax and conventions
- Prefer file-scoped namespaces (for existing files, follow their style)
- Prefer pattern matching and switch expressions over the traditional control flow
- Use the
nameofoperator instead of string literals for member references - Use
is nullandis not nullinstead of== nulland!= null - Use
?.null-conditional operator where applicable - Use the
ArgumentNullException.ThrowIfNullmethod for null checks and other similar methods - Use the
ObjectDisposedException.ThrowIfmethod for disposal checks - Use documentation comments for all public APIs with proper structure
- Consider performance implications in high-throughput paths
- Trust null annotations, do not add redundant null checks
- Add tests to existing test files rather than creating new ones
- Code comments must explain why, not what
- NEVER suggest using LINQ (
.Select(),.Where(),.Any(), etc.) when a simpleforeachorforloop would work. LINQ has overhead and is less readable for simple iterations. Use LINQ only for complex queries where the declarative syntax significantly improves clarity. - Do not use the
#regionand#endregionpragmas - Do not alter anything in the src/bench_precompiles and src/tests directories
The codebase in src/Nethermind is organized into three independent solutions:
- Nethermind.slnx: The Nethermind client codebase and tests
- EthereumTests.slnx: The Ethereum Foundation test suite
- Benchmarks.slnx: Performance benchmarking
- Entry point and initialization
- Nethermind.Runner: The app entry point and startup orchestration
- Nethermind.Init: Initialization logic, memory management, metrics
- General API
- Nethermind.Api: Core API interfaces and plugin API
- Nethermind.Config: Configuration handling
- Nethermind.Logging: Logging
- Consensus algorithms
- Nethermind.Consensus.AuRa: Authority round (Aura)
- Nethermind.Consensus.Clique: Proof of Authority (PoA)
- Nethermind.Consensus.Ethash: Proof of Work (PoW)
- Nethermind.Merge.Plugin: Proof of Stake (PoS)
- Core blockchain
- Nethermind.Blockchain: Block processing, chain management, validators
- Nethermind.Core: Foundational types
- Nethermind.Crypto: Core cryptographic algorithms
- Nethermind.Evm: EVM implementation
- Nethermind.Evm.Precompiles: EVM precompiled contracts
- Nethermind.Specs: Network specifications and hard fork rules
- State and storage:
- Nethermind.Db: Database abstraction layer
- Nethermind.Db.Rocks: RocksDB implementation (primary storage backend)
- Nethermind.State: World state management, accounts, contract storage
- Nethermind.Trie: Merkle Patricia trie implementation
- Networking:
- Nethermind.Network: devp2p protocol implementation
- Nethermind.Network.Discovery: Peer discovery
- Nethermind.Network.Dns: DNS-based node discovery
- Nethermind.Network.Enr: Ethereum Node Records (ENR) handling
- Nethermind.Synchronization: Block synchronization strategies (fast sync, snap sync)
- Nethermind.UPnP.Plugin: UPnP support
- Transaction management:
- Nethermind.TxPool: Transaction pool (mempool) management, validation, sorting
- RPC and external interface:
- Nethermind.Facade: High-level API facades for external interaction
- Nethermind.JsonRpc: JSON-RPC server
- Nethermind.Sockets: WebSocket server
- Monitoring
- Nethermind.HealthChecks: Health checks
- Nethermind.Monitoring: Monitoring API
- Nethermind.Seq: Seq integration
- Serialization:
- Nethermind.Serialization.Json: JSON serialization
- Nethermind.Serialization.Rlp: RLP serialization
- Nethermind.Serialization.Ssz: SSZ serialization
- Third-party integration:
- Nethermind.Flashbots: Flashbots integration
- Nethermind.Optimism: Optimism network (OP Stack) support
- Nethermind.Taiko: Taiko network support
- Tests
- Test suites reside in Nethermind.*.Test directories
Before creating a pull request:
- Ensure the code compiles
- Add tests covering your changes and ensure they pass:
dotnet test --project path/to/.csproj -c release -- --filter FullyQualifiedName~TestName - Ensure the code is well-formatted:
dotnet format whitespace src/Nethermind/ --folder
- Use pull_request_template.md
See global.json for the required .NET SDK version.