Thank you for helping improve the Chia pool reference implementation. This guide covers how to set up a development environment, follow project conventions, and submit changes that pass CI.
For an overview of what the project does, see README.md.
- Before you start
- Development setup
- Project conventions
- Running tests
- Pre-commit and formatting
- Dependency changes
- Pull requests
- Where to contribute
- Search existing issues and PRs on GitHub to avoid duplicate work.
- Open an issue for large or ambiguous changes (new endpoints, payout schemes, storage backends) so maintainers can align on approach before you invest heavily.
- Keep scope focused. Small, reviewable PRs are easier to merge than sweeping refactors mixed with feature work.
- Protocol changes that affect farmers or on-chain behavior need coordination with chia-blockchain and the pooling specification; discuss those in an issue first.
Be respectful and constructive in issues and reviews. For general Chia community support, see Discord.
- Git
- Python 3.10–3.13
- On Windows: Python Launcher (
py), Visual C++ Redistributable 2019+, and Git
Linux / macOS
git clone https://github.com/Chia-Network/pool2-reference.git
cd pool2-reference
./install.sh -d
source ./activateWindows (PowerShell)
git clone https://github.com/Chia-Network/pool2-reference.git
cd pool2-reference
.\Install.ps1 -d
.\venv\Scripts\Activate.ps1The -d flag installs development dependencies (pytest, ruff, mypy, pre-commit, etc.).
Install hooks once per clone:
pre-commit installHooks run automatically on git commit. You can also run everything manually:
pre-commit run --all-filesOn Windows or when the venv is not active, use the project wrapper:
python activated.py -- pre-commit run --all-files| Rule | Detail |
|---|---|
| Line length | 120 characters (ruff.toml) |
| Future annotations | Every .py file must start with from __future__ import annotations |
| Imports | No relative imports — use top-level names (api, service, farmer_rpc, …) as in existing modules under chia_pool/ |
| Formatting | Ruff format (enforced in pre-commit) |
| Linting | Ruff with a broad rule set; some categories are intentionally ignored (docstrings, many TRY/BLE rules) — match surrounding code when fixing lint |
| Types | mypy in strict mode (mypy.ini) — new code should type-check cleanly |
Application code lives under chia_pool/. When running or testing locally, commands are usually issued from that directory or with chia_pool on the module path (see pytest.ini testpaths).
api/— TypedDict configs and protocols (Store,NodeRPC,Wallet, …)farmer_rpc/— HTTP handler implementations (e.g.v2.py)server/— aiohttp wiring and background task schedulingservice/— Core pool logic (partials, rewards, payouts)store/— Persistence (default: SQLite)tests/— Pytest suites; reuses Chia’schia._testsfixtures via rootconftest.py
Pre-commit runs build-init-files.py to ensure every package directory under chia_pool/ has an __init__.py. Do not remove these; add new package folders and let the hook create the file, or run:
python activated.py python build-init-files.py -v --root . --tree chia_poolThe server is asyncio-based. Prefer async/await for I/O; avoid blocking calls in async paths (Ruff flags some of these under ASYNC* rules).
From the repository root with the venv active:
pytest chia_pool/_testsParallel runs (as in CI):
pytest chia_pool/_tests -n 2- Place tests under
chia_pool/_tests/mirroring the module under test (tests/rpc/,tests/service/, …). - Use existing fixtures in
tests/*/conftest.pyandchia_pool/_tests/conftest.py(root_path,reference_service,server_config, wallet environments, etc.). - Prefer
pytest.mark.anyiofor async tests where the suite already does. - Do not add tests that only assert trivial constants unless they guard real regression behavior.
Hooks defined in .pre-commit-config.yaml:
| Hook | Purpose |
|---|---|
init_py_files |
Regenerate missing __init__.py under chia_pool/ |
ruff format |
Format Python |
ruff |
Lint and auto-fix where possible |
poetry |
poetry check --strict and refresh lock when pyproject.toml / poetry.lock change |
prettier |
Format YAML, TOML, Markdown, JSON |
shfmt |
Format shell scripts |
| Standard hooks | YAML syntax, LF line endings, EOF fixer, trailing whitespace, AST check |
mypy |
Type-check the tree |
Fix failures before pushing; CI runs the same hooks on Ubuntu, macOS, and Windows across Python 3.10–3.13.
Dependencies are managed with Poetry (pyproject.toml, poetry.lock).
-
Edit
pyproject.toml(version pins, git rev forchia-blockchain, optionaldevextras). -
Regenerate the lockfile:
python activated.py --poetry poetry lock
-
Pre-commit’s
poetryhook runspoetry-check.py(poetry check --strictandpoetry lock) on lockfile changes — commit bothpyproject.tomlandpoetry.lock. -
Re-run tests after bumping chia-blockchain; pooling APIs and test fixtures often shift between revisions.
- Fork the repo and create a branch from
main. - Make focused commits with clear messages (imperative summary, optional body for “why”). Examples from history:
Fix test from upgrade,Use query for GET requests,Repin chia-blockchain. - Sign your commits with GPG. CI runs check-commit-signing on PRs; unsigned commits will fail.
- Keep your branch up to date with
mainto avoid themerge_conflictlabel (see conflict-check).
Before requesting review:
-
pre-commit run --all-filespasses -
pytest chia_pool/_testspasses - New behavior has tests where practical
- README or config docs updated if user-facing behavior changed
-
pyproject.toml/poetry.lockupdated together if dependencies changed
Maintainers may ask for:
- Smaller follow-up PRs instead of one large diff
- Tests covering edge cases (reorgs, late partials, difficulty bounds)
- Notes on operational impact for pool operators
By contributing, you agree that your contributions are licensed under the same terms as the project: Apache License 2.0 (LICENSE).
| Area | Good first issues / needs |
|---|---|
farmer_rpc/v2.py |
Endpoint behavior, validation, clearer errors |
service/service.py |
Reward collection, payouts, singleton following (TODOs in file) |
store/sqlite.py |
Schema, pagination, performance |
tests/ |
Coverage for RPC and service paths |
| Docs | README, examples, operator runbooks |
| Tooling | CI, install scripts, pre-commit |
Avoid drive-by changes to ignored Ruff categories project-wide unless discussed first — large lint-only PRs are hard to review and often conflict with active work.
- Pooling concepts: Chia Pooling FAQ
- V1 reference pool: pool-reference
- Bugs and features: GitHub Issues
Thank you for contributing.