Skip to content

Kobe API: Add jitosol_validators/:vote_account stake history endpoint - #66

Merged
aoikurokawa merged 4 commits into
masterfrom
api/jitosol-validator-stake-history
Aug 25, 2026
Merged

aoikurokawa merged 4 commits into
masterfrom
api/jitosol-validator-stake-history

Conversation

@ggnine-jito

Copy link
Copy Markdown
Contributor

What

Adds GET /api/v1/jitosol_validators/:vote_account — one validator's JitoSOL stake-pool delegation per epoch, in a single call.

GET /api/v1/jitosol_validators/6hkfqeNAbURk7CmAQsP4Qm6WwHVF4LxHupEvQf7Tkrf1?start_epoch=900&end_epoch=1016
{
  "vote_account": "6hkfq…Tkrf1",
  "history": [
    { "epoch": 900, "jito_sol_active_lamports": 52700000000000 },
    …
  ]
}
  • start_epoch / end_epoch are optional and inclusive; omit both for the full history.
  • jito_sol_active_lamports is the same target_pool_active_lamports that jitosol_validators already serves; it is null for epochs where the validator was not in the pool's validator list (target_pool_staked == false), so "not in pool" and "0 stake" stay distinguishable.
  • Ascending by epoch. Invalid pubkey or start_epoch > end_epoch → 400. Cached 60s per (vote_account, range) like the neighbouring wrappers.

Why

jitosol_validators returns every pool validator for a single epoch (~300KB), so charting one validator's history from jito.network means one request per epoch (see jito-labs/stake-pool-fe#917, which built a KV cache + backfill around that). This endpoint replaces that with one indexed read.

Changes

  • core/src/db_models/validators.rs — ValidatorStore::find_by_vote_account(vote_account, start_epoch, end_epoch).
  • api/src/schemas/validator.rs — request/response types.
  • api/src/resolvers/query_resolver.rs — get_jitosol_validator_stake_history + #[cached] wrapper.
  • api/src/main.rs — handler + route, next to validators/:vote_account.

Ops note

The query filters on vote_account (and optionally epoch). The repo doesn't create indexes in code, so please make sure the validators collection has an index covering { vote_account: 1, epoch: 1 } before/at deploy — without it this is a collection scan per cold request (~1.5k validators × ~420 epochs).

Verification

  • cargo fmt --all --check, cargo clippy -p kobe-api -p kobe-core --all-features -- -D warnings, cargo check -p kobe-api — clean.
  • Not exercised against a live Mongo from this machine; the query shape mirrors find() / get_highest_epoch() in the same store.

Refs MEV-12617.

ggnine-jito and others added 2 commits August 24, 2026 16:49
Per-validator, per-epoch JitoSOL stake-pool delegation in one call.
`jitosol_validators` already exposes `jito_sol_active_lamports`, but only
for every pool validator at a single epoch, so charting one validator's
history from a client means one request per epoch.

GET /api/v1/jitosol_validators/:vote_account?start_epoch=&end_epoch=
-> { vote_account, history: [{ epoch, jito_sol_active_lamports }] }

Reads the same `target_pool_active_lamports` the existing endpoint
serves, straight from the validator records (one doc per epoch per
validator), ascending by epoch. `jito_sol_active_lamports` is null for
epochs where the validator was not in the pool's validator list
(`target_pool_staked == false`). Invalid pubkey or inverted range -> 400.
Cached 60s per (vote_account, range) like the neighbouring wrappers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
An inverted range just yields an empty history from Mongo, which is an
honest 200; no need for a second validation branch.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ggnine-jito

Copy link
Copy Markdown
Contributor Author

CI note — the two red lint jobs are pre-existing, not from this PR:

  • lint / lint: clippy result_large_err at core/src/rpc_utils.rs:27/39/56, which this PR doesn't touch. CI runs floating stable; the same job fails on ak/metrics (Aug 21). cargo clippy -p kobe-api -p kobe-core --all-features -- -D warnings is clean locally on 1.90.
  • lint / security_audit: 6 RUSTSEC advisories in transitive deps; Cargo.lock is unchanged here. ak/metrics passed this job three days ago, so these are newly published advisories.

build, run_tests, and udeps pass.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds an API endpoint for retrieving one validator’s historical JitoSOL delegation by epoch.

Changes:

  • Adds optional epoch-range filtering and ordered MongoDB retrieval.
  • Adds request/response schemas, caching, resolver logic, handler, and route.
  • Updates dependencies, audit exclusions, and boxes several large RPC errors.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
api/src/main.rs Registers the stake-history endpoint.
api/src/schemas/validator.rs Defines request and response models.
api/src/resolvers/query_resolver.rs Implements cached history resolution.
api/src/resolvers/error.rs Boxes Jito transaction errors.
core/src/db_models/validators.rs Adds the historical validator query.
core/src/rpc_utils.rs Boxes RPC errors.
cranker/src/utils.rs Boxes client errors.
Cargo.lock Updates transitive dependencies.
.cargo/audit.toml Adds ignored security advisories.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread core/src/db_models/validators.rs
Comment thread api/src/resolvers/query_resolver.rs
@aoikurokawa
aoikurokawa requested a review from ebatsell August 25, 2026 01:38
@aoikurokawa
aoikurokawa merged commit c7f0ae4 into master Aug 25, 2026
6 checks passed
@aoikurokawa
aoikurokawa deleted the api/jitosol-validator-stake-history branch August 25, 2026 21:21
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.

4 participants