Runtime engine for Crunch coordinator nodes
Project description
crunch-node
Runtime engine for Crunch coordinator nodes. Published as crunch-node on PyPI, imported as coordinator_node.
pip install crunch-node
Architecture
Pipeline
Feed → Input → Prediction → Score → Snapshot → Checkpoint → On-chain
Workers:
| Worker | Purpose |
|---|---|
feed-data-worker |
Ingests feed data (Pyth, Binance, etc.) via WebSocket + backfill |
predict-worker |
Event-driven: gets data → ticks models → collects predictions |
score-worker |
Resolves actuals → scores predictions → writes snapshots → rebuilds leaderboard |
checkpoint-worker |
Aggregates snapshots → builds EmissionCheckpoint for on-chain submission |
report-worker |
FastAPI: leaderboard, predictions, feeds, snapshots, checkpoints, emissions |
Contract
All type shapes and behavior are defined in a single CrunchContract:
from coordinator_node.contracts import CrunchContract
class CrunchContract(BaseModel):
raw_input_type: type[BaseModel] = RawInput
output_type: type[BaseModel] = InferenceOutput
score_type: type[BaseModel] = ScoreResult
scope: PredictionScope = PredictionScope()
aggregation: Aggregation = Aggregation()
# Callables
resolve_ground_truth: Callable = default_resolve_ground_truth
aggregate_snapshot: Callable = default_aggregate_snapshot
build_emission: Callable = default_build_emission
Feed Dimensions
| Dimension | Example | Env var |
|---|---|---|
source |
pyth, binance | FEED_SOURCE |
subject |
BTC, ETH | FEED_SUBJECTS |
kind |
tick, candle | FEED_KIND |
granularity |
1s, 1m | FEED_GRANULARITY |
Status Lifecycles
Input: RECEIVED → RESOLVED
Prediction: PENDING → SCORED / FAILED / ABSENT
Checkpoint: PENDING → SUBMITTED → CLAIMABLE → PAID
Emission Checkpoints
Checkpoints produce EmissionCheckpoint matching the on-chain protocol:
{
"crunch": "<pubkey>",
"cruncher_rewards": [{"cruncher_index": 0, "reward_pct": 350_000_000}, ...],
"compute_provider_rewards": [...],
"data_provider_rewards": [...],
}
reward_pct uses frac64 (1,000,000,000 = 100%).
Report API
| Endpoint | Description |
|---|---|
GET /reports/leaderboard |
Current leaderboard |
GET /reports/models |
Registered models |
GET /reports/predictions |
Prediction history |
GET /reports/feeds |
Active feed subscriptions |
GET /reports/snapshots |
Per-model period summaries |
GET /reports/checkpoints |
Checkpoint history |
GET /reports/checkpoints/{id}/emission |
Raw emission (frac64) |
GET /reports/checkpoints/{id}/emission/cli-format |
CLI JSON format |
GET /reports/emissions/latest |
Latest emission |
POST /reports/checkpoints/{id}/confirm |
Record tx_hash |
PATCH /reports/checkpoints/{id}/status |
Advance status |
Scaffolding
Use crunch-cli init-workspace <name> to create a new competition workspace from the base/ template.
Development
uv run pytest tests/ -q
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crunch_node-0.1.0.tar.gz.
File metadata
- Download URL: crunch_node-0.1.0.tar.gz
- Upload date:
- Size: 177.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f0f978aa795663116c68b6df9d7c6d4aab2fd326cb5f4f9c7ad87f6e46c14f7
|
|
| MD5 |
347ab5a567f7193e4765bad88bda399b
|
|
| BLAKE2b-256 |
f35e8ed05ad3da237637056222c34706412a2b20a6fec2f71a2136bb6c2e0604
|
File details
Details for the file crunch_node-0.1.0-py3-none-any.whl.
File metadata
- Download URL: crunch_node-0.1.0-py3-none-any.whl
- Upload date:
- Size: 55.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1ed6a3369f144601d652880cc7ecda5cbed53a1842d4fe40b53fbd6c7499817
|
|
| MD5 |
3672b7a8ae09fac1b481475dcd87eadc
|
|
| BLAKE2b-256 |
c73ee11728baa22a23cd5fc26545f5c1b26d7bec5e5af8dc9f22f594535cb056
|