Skip to content

Latest commit

 

History

History
113 lines (98 loc) · 6.8 KB

File metadata and controls

113 lines (98 loc) · 6.8 KB

AGENTS instructions

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.

Repo structure

  • 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

Coding guidelines and style

  • 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 nameof operator instead of string literals for member references
  • Use is null and is not null instead of == null and != null
  • Use ?. null-conditional operator where applicable
  • Use the ArgumentNullException.ThrowIfNull method for null checks and other similar methods
  • Use the ObjectDisposedException.ThrowIf method 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 simple foreach or for loop 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 #region and #endregion pragmas
  • Do not alter anything in the src/bench_precompiles and src/tests directories

Project structure

The codebase in src/Nethermind is organized into three independent solutions:

Architecture

Pull request guidelines

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

Prerequisites

See global.json for the required .NET SDK version.