|
| 1 | +# AGENTS Guidelines for This Repository |
| 2 | + |
| 3 | +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. |
| 4 | + |
| 5 | +## 1. Use Headless Mode for Development Testing |
| 6 | + |
| 7 | +* **Always use headless mode** with short test durations during development. |
| 8 | +* **Start with minimal load** (few users, low spawn rate) to validate changes. |
| 9 | +* **Do _not_ run long-duration tests** during agent development sessions. |
| 10 | +* **Use `--autoquit`** flag to ensure tests terminate properly. |
| 11 | + |
| 12 | +Example test command: |
| 13 | +```bash |
| 14 | +poetry run chainbench start --profile evm.light --users 5 --workers 1 --test-time 30s --target https://test-node --headless --autoquit |
| 15 | +``` |
| 16 | + |
| 17 | +## 2. Keep Dependencies in Sync |
| 18 | + |
| 19 | +If you add or update dependencies: |
| 20 | + |
| 21 | +1. Use Poetry to manage dependencies: `poetry add <package>` or `poetry add --group dev <package>`. |
| 22 | +2. Run `poetry lock --no-update` to update the lock file. |
| 23 | +3. Install updated dependencies with `poetry install`. |
| 24 | +4. Verify compatibility with Python 3.10+ as specified in the project. |
| 25 | + |
| 26 | +## 3. Coding Conventions |
| 27 | + |
| 28 | +* Follow Black formatting (120-character line length). |
| 29 | +* Use isort for import sorting (Black-compatible profile). |
| 30 | +* Follow Flake8 linting rules (ignore E203 and W503 for Black compatibility). |
| 31 | +* Use type hints where appropriate. |
| 32 | +* Keep MyPy checks passing. |
| 33 | + |
| 34 | +## 4. Code Quality Checks |
| 35 | + |
| 36 | +Before completing any task, run these quality checks: |
| 37 | + |
| 38 | +| Command | Purpose | |
| 39 | +| ------------------------ |----------------------------------| |
| 40 | +| `poetry run black .` | Format code to project standards | |
| 41 | +| `poetry run isort .` | Sort imports | |
| 42 | +| `poetry run flake8` | Run linting checks | |
| 43 | +| `poetry run mypy .` | Run type checks | |
| 44 | + |
| 45 | +Or use pre-commit hooks: |
| 46 | +```bash |
| 47 | +poetry run pre-commit run --all-files |
| 48 | +``` |
| 49 | +If running pre-commit hooks for the first time, run this first: |
| 50 | +```bash |
| 51 | +poetry run pre-commit install |
| 52 | +``` |
| 53 | + |
| 54 | +## 5. Testing Guidelines |
| 55 | + |
| 56 | +Test changes progressively: |
| 57 | + |
| 58 | +1. **Unit testing**: Test individual user classes and methods |
| 59 | +2. **Profile validation**: Verify profiles load correctly |
| 60 | + ```bash |
| 61 | + poetry run chainbench list profiles |
| 62 | + ``` |
| 63 | +3. **Short headless tests**: Run brief tests with minimal load |
| 64 | +4. **Method discovery**: Test endpoint compatibility |
| 65 | + ```bash |
| 66 | + poetry run chainbench discover https://test-node --clients geth |
| 67 | + ``` |
| 68 | + |
| 69 | +## 6. Profile Development |
| 70 | + |
| 71 | +When creating or modifying profiles: |
| 72 | + |
| 73 | +* Place custom profiles in the canonical directory: `chainbench/profile/<network>/…` |
| 74 | +* Follow existing profile structure and conventions. |
| 75 | +* Include docstrings explaining profile purpose. |
| 76 | +* Test with small data sizes first (`--size XS`). |
| 77 | +* Validate against multiple node types when applicable. |
| 78 | + |
| 79 | +## 7. Working with Test Data |
| 80 | + |
| 81 | +* Start with smallest data size (`--size XS`) for development. |
| 82 | +* Use `--use-latest-blocks` for nodes with limited history. |
| 83 | +* Consider using `--ref-url` for test data generation from a reference node. |
| 84 | +* Monitor memory usage with larger data sizes. |
| 85 | + |
| 86 | +## 8. Development Workflow |
| 87 | + |
| 88 | +1. Make changes to source code |
| 89 | +2. Run formatting: `poetry run black . && poetry run isort .` |
| 90 | +3. Run linting: `poetry run flake8` |
| 91 | +4. Run type checking: `poetry run mypy .` |
| 92 | +5. Test with minimal profile first |
| 93 | +6. Gradually increase complexity and load |
| 94 | + |
| 95 | +## 9. Useful Commands Recap |
| 96 | + |
| 97 | +| Command | Purpose | |
| 98 | +| ------------------------------------------------ | ------------------------------------- | |
| 99 | +| `poetry install` | Install all dependencies | |
| 100 | +| `poetry run chainbench --help` | Show all available commands | |
| 101 | +| `poetry run chainbench start --help` | Show options for running a benchmark | |
| 102 | +| `poetry run chainbench --version` | Show CLI version | |
| 103 | +| `poetry run chainbench list methods` | List supported RPC methods | |
| 104 | +| `poetry run chainbench list profiles` | List available profiles | |
| 105 | +| `poetry run chainbench list shapes` | List load pattern shapes | |
| 106 | +| `poetry run chainbench discover <url>` | Discover available methods | |
| 107 | + |
| 108 | +## 10. Safety Reminders |
| 109 | + |
| 110 | +* **Test against test/dev nodes first** before production nodes. |
| 111 | +* **Monitor target node health** during benchmarks. |
| 112 | +* **Use appropriate rate limits** to avoid overwhelming nodes. |
| 113 | +* **Start with light profiles** before heavy ones. |
| 114 | +* **Keep test durations short** during development. |
| 115 | + |
| 116 | +--- |
| 117 | + |
| 118 | +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. |
0 commit comments