Skip to content

feat: load epoch schedule from genesis.bin for warmup-aware epoch math - #51

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

feat: load epoch schedule from genesis.bin for warmup-aware epoch math#51
Mctursh wants to merge 6 commits into
solana-rpc:mainfrom
Mctursh:feat/epoch-schedule-ingest-store

Conversation

@Mctursh

@Mctursh Mctursh commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Loads the cluster's epoch schedule from a genesis.bin file so warmup-aware epoch math (getInflationReward) uses the real network schedule instead of a hardcoded constant.

Per review, this moved from storing the schedule in a ClickHouse table to reading it from genesis.bin, the canonical per-network source, so there's no full schema for one immutable row.

How it works

  • --genesis-path / GENESIS_PATH (optional): path to the cluster's genesis.bin; the RPC reads the EpochSchedule from it once at startup into AppState.
  • Unset: falls back to the no-warmup schedule (432000 slots), which is what mainnet and devnet return. Testnet runs a warmup schedule, so set --genesis-path there.
  • Set but unreadable/unparseable: the server fails to start, instead of silently using the wrong schedule.

What changed

  • Removed the epoch_schedule ClickHouse table (local/cluster/replicated DDL + the k8s apply step) and the ingestor-side getEpochSchedule fetch.
  • getInflationReward reads the schedule from AppState (genesis or the fallback); its query path is otherwise unchanged.
  • Genesis loading sits in its own module so the superbank-verify PoH work can reuse it.

Testing
Unit tests cover the genesis decode (round-trip + malformed + file-not-found) and the epoch-bounds math (mainnet-matches-old vs warmup-differs).

getEpochSchedule (#36) still returns a hardcoded schedule; wiring that to this shared schedule is the follow-up, along with getEpochInfo (#30) once it lands.

Closes #47.

)))
}

pub async fn load_epoch_schedule(&self) -> EpochSchedule {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of storing this in the databases, couldn't this be loaded from a genesis.bin file? If you want to have epoch schedule calculations you can add genesis.bin to the config file of superbank?

Otherwise we add a full schema for just a single row that never changes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. genesis.bin would provide us a more SVM generic interface that can support a wider range of chains/networks.

It's also going to be needed for the superbank-verify PoH workflows, so will serve multiple purposes if it's included.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, agreed with both of you. I'll rework the PR to load the schedule from a genesis.bin path in the config instead of the ClickHouse table.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed the rework. The epoch_schedule ClickHouse table and the ingestor fetch are gone. The RPC now loads the schedule from a genesis.bin (``--genesis-path/GENESIS_PATH`) at startup. No path set falls back to the standard no-warmup schedule, which is what mainnet and devnet actually return (checked against live RPC); testnet runs a warmup schedule, so point `--genesis-path` at its genesis there. A set-but-unreadable path fails boot instead of silently guessing.

Kept the genesis loading in its own module so it's easy to reuse for the superbank-verify PoH work later. getInflationReward reads the schedule from state the same way, just populated from genesis now.

@Mctursh Mctursh changed the title feat: ingest and store the epoch schedule for warmup-aware epoch math feat: load epoch schedule from genesis.bin for warmup-aware epoch math Jul 28, 2026
@Mctursh

Mctursh commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

GoReleaser hit File exists (os error 17) after every crate built. It passed on the parent commit 919cb87, and the only change since is a two-line doc edit, so it's not from this PR.

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

3 participants