Skip to content

Commit 64ae24f

Browse files
authored
Add AGENTS.md (#114)
* Add AGENTS.md
1 parent 7199be1 commit 64ae24f

File tree

3 files changed

+129
-0
lines changed

3 files changed

+129
-0
lines changed

AGENTS.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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.
File renamed without changes.

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ Other available shapes are:
170170
- `step` - The load will increase in steps. `--spawn-rate` flag is required to specify the step size. The number of steps will be calculated based on `--users` divided by `--spawn-rate`. The duration of each step will be calculated based on `--test-time` divided by the number of steps.
171171
- `spike` - The load will run in a spike pattern. The load will ramp up to 10% of the total users for 40% of the test duration and then spike to 100% of the total users as specified by `--users` for 20% of test duration and then reduce back to 10% of total users until the test duration is over.
172172

173+
Use the following command to list all shapes in chainbench/shapes
174+
```shell
175+
chainbench list shapes
176+
```
177+
You may add your own custom shapes by copying one of the existing shapes in chainbench/shapes and modifying them to fit your requirements.
178+
179+
173180
### Test Data Size
174181
You may specify the test data size using the `--size` flag. This will determine how much data is used in the test.
175182
Take note that larger data size will result in longer test data generation time before the test starts.
@@ -251,3 +258,7 @@ If you don't specify the `--clients` option, the tool will default to Ethereum J
251258

252259
## License
253260
This project is licensed under the [Apache 2.0 License](LICENSE).
261+
262+
## Development
263+
- [Contributing](CONTRIBUTING.md)
264+
- [Agents](AGENTS.md)

0 commit comments

Comments
 (0)