This repository contains Chainbench, a blockchain infrastructure benchmarking tool built on Locust. When working on the project interactively with an agent (e.g. the Codex CLI) please follow the guidelines below for efficient development and testing.
- Always use headless mode with short test durations during development.
- Start with minimal load (few users, low spawn rate) to validate changes.
- Do not run long-duration tests during agent development sessions.
- Use
--autoquitflag to ensure tests terminate properly.
Example test command:
poetry run chainbench start --profile evm.light --users 5 --workers 1 --test-time 30s --target https://test-node --headless --autoquitIf you add or update dependencies:
- Use Poetry to manage dependencies:
poetry add <package>orpoetry add --group dev <package>. - Run
poetry lock --no-updateto update the lock file. - Install updated dependencies with
poetry install. - Verify compatibility with Python 3.10+ as specified in the project.
- Follow Black formatting (120-character line length).
- Use isort for import sorting (Black-compatible profile).
- Follow Flake8 linting rules (ignore E203 and W503 for Black compatibility).
- Use type hints where appropriate.
- Keep MyPy checks passing.
Before completing any task, run these quality checks:
| Command | Purpose |
|---|---|
poetry run black . |
Format code to project standards |
poetry run isort . |
Sort imports |
poetry run flake8 |
Run linting checks |
poetry run mypy . |
Run type checks |
Or use pre-commit hooks:
poetry run pre-commit run --all-filesIf running pre-commit hooks for the first time, run this first:
poetry run pre-commit installTest changes progressively:
- Unit testing: Test individual user classes and methods
- Profile validation: Verify profiles load correctly
poetry run chainbench list profiles
- Short headless tests: Run brief tests with minimal load
- Method discovery: Test endpoint compatibility
poetry run chainbench discover https://test-node --clients geth
When creating or modifying profiles:
- Place custom profiles in the canonical directory:
chainbench/profile/<network>/… - Follow existing profile structure and conventions.
- Include docstrings explaining profile purpose.
- Test with small data sizes first (
--size XS). - Validate against multiple node types when applicable.
- Start with smallest data size (
--size XS) for development. - Use
--use-latest-blocksfor nodes with limited history. - Consider using
--ref-urlfor test data generation from a reference node. - Monitor memory usage with larger data sizes.
- Make changes to source code
- Run formatting:
poetry run black . && poetry run isort . - Run linting:
poetry run flake8 - Run type checking:
poetry run mypy . - Test with minimal profile first
- Gradually increase complexity and load
| Command | Purpose |
|---|---|
poetry install |
Install all dependencies |
poetry run chainbench --help |
Show all available commands |
poetry run chainbench start --help |
Show options for running a benchmark |
poetry run chainbench --version |
Show CLI version |
poetry run chainbench list methods |
List supported RPC methods |
poetry run chainbench list profiles |
List available profiles |
poetry run chainbench list shapes |
List load pattern shapes |
poetry run chainbench discover <url> |
Discover available methods |
- Test against test/dev nodes first before production nodes.
- Monitor target node health during benchmarks.
- Use appropriate rate limits to avoid overwhelming nodes.
- Start with light profiles before heavy ones.
- Keep test durations short during development.
Following these practices ensures reliable development, prevents overwhelming blockchain nodes, and maintains code quality. Always prioritize controlled testing and gradual load increases when benchmarking infrastructure.