Skip to content

feat: ingest and store the epoch schedule for warmup-aware epoch math#51

Open
Mctursh wants to merge 3 commits into
solana-rpc:mainfrom
Mctursh:feat/epoch-schedule-ingest-store
Open

feat: ingest and store the epoch schedule for warmup-aware epoch math#51
Mctursh wants to merge 3 commits into
solana-rpc:mainfrom
Mctursh:feat/epoch-schedule-ingest-store

Conversation

@Mctursh

@Mctursh Mctursh commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Makes the epoch math use the cluster's real schedule instead of the hardcoded mainnet constant.

What it does

  • Ingestor: when RPC_URL is set, fetches getEpochSchedule at startup and writes it to a new single-row epoch_schedule table. Best-effort, a failure logs and doesn't block ingestion.
  • RPC: reads it once at startup into AppState. The read is outside create_tables(), so a missing table doesn't break existing deployments. It falls back to the mainnet schedule (without_warmup) and logs which path it took.
  • getInflationReward derives its default epoch and slot bounds from the stored schedule. getEpochInfo (feat: implement getEpochInfo RPC method #30) and getEpochSchedule (feat: implement getEpochSchedule RPC method #36) are still open, so those are a small follow-up once they merge.

Your two calls on #47

  • No new crate: solana-epoch-schedule is already in the tree via solana-sdk, so this just promotes it to a direct dep. Zero added build cost.
  • Config for other clusters: went with RPC_URL instead of the config flags you floated on Ingest and store the epoch schedule so the epoch methods are correct off mainnet #47, since the cluster already knows its own schedule. The ingestor just pulls it from whatever cluster RPC_URL points at (devnet/testnet/etc). Can add explicit override flags on top if you'd rather have that knob.

Singleton table
First single-row table in the repo, so worth a look at the shape. ReplacingMergeTree keyed on slots_per_epoch, so re-ingesting the same schedule collapses to one row; cluster and replicated wrap it in Distributed like the rest. One difference from the other tables: they all pass a version column (ReplacingMergeTree(slot)), this one doesn't, which is fine while the schedule is immutable. If you'd want a re-ingest to overwrite instead, that's a version column plus a constant key.

Testing
Unit tests cover the mainnet-matches-old-math and warmup-differs cases. E2E on a local ClickHouse: ingest wrote the row, RPC loaded it, and dropping the table fell back to mainnet and still started.

Closes #47.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ingest and store the epoch schedule so the epoch methods are correct off mainnet

1 participant