Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coordinator_node-0.1.0.tar.gz (177.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coordinator_node-0.1.0-py3-none-any.whl (55.6 kB view details)

Uploaded Python 3

File details

Details for the file coordinator_node-0.1.0.tar.gz.

File metadata

  • Download URL: coordinator_node-0.1.0.tar.gz
  • Upload date:
  • Size: 177.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for coordinator_node-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2cd2034a15df7c13347b927acf9a84c2e620618f5a2ceb7d4ea0eee9f85e30d0
MD5 ba0be9baad7763b647e5d63540c29c63
BLAKE2b-256 cf7b95f46a578c9e1eb1bd4ccf79f2e58f8a45550014a3808de392e40c3a7bf6

See more details on using hashes here.

File details

Details for the file coordinator_node-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for coordinator_node-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8b5c6adc352ca4bce9565e0a63bfc96e1174af6bdf6eabb73ac4da126bf0bac
MD5 952290efe4908f6eb7f72649989972e1
BLAKE2b-256 9163ee2f152b6b082d4e83fe31b2cc8e917bc576084226315c518d08aded427f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page