Skip to content

Kobe API: Read jitosol_validators/:vote_account history through a projection - #67

Open
ggnine-jito wants to merge 1 commit into
masterfrom
api/jitosol-stake-history-projection
Open

Kobe API: Read jitosol_validators/:vote_account history through a projection#67
ggnine-jito wants to merge 1 commit into
masterfrom
api/jitosol-stake-history-projection

Conversation

@ggnine-jito

Copy link
Copy Markdown
Contributor

What

Follow-up to #66. In production the unbounded request (/api/v1/jitosol_validators/:vote_account with no epoch range) returns 500, while any range from epoch 599 on works:

?start_epoch=599   → 200, 424 entries, ~0.2s
?start_epoch=590   → 500 {"vote_account":"","history":[]}
(no range)         → 500

The validators collection still holds records older than ~epoch 598 written before the current Validator fields existed, and try_collect::<Vec<Validator>>() fails on the first one. find() never trips on this because it only reads the two newest epochs — it's the same reason jitosol_validators 500s for epoch 598.

Fix

Read this query through a 3-field projection (epoch, target_pool_active_lamports, target_pool_staked) into a small ValidatorPoolStake struct with serde defaults. Old records deserialize and read as "not in pool" (null), and Mongo returns three fields per doc instead of ~40. Response shape is unchanged.

Verification

  • cargo fmt --all --check, cargo clippy -p kobe-api -p kobe-core --all-features -- -D warnings, cargo check -p kobe-api — clean.
  • After deploy: the unbounded URL should return 200 for 3N7s9zXMZ4QqvHQR15t5GNHyqc89KduzMP7423eWiD5g and 6hkfqeNAbURk7CmAQsP4Qm6WwHVF4LxHupEvQf7Tkrf1 (currently 500).

Refs MEV-12617, jito-labs/stake-pool-fe#919.

The unbounded request 500'd in production: the validators collection
still holds records from before the current `Validator` fields existed,
and `try_collect::<Vec<Validator>>()` fails on the first one (`find()`
never hits this because it only reads the two newest epochs; the same
reason `jitosol_validators` 500s for epoch 598).

Project just `epoch` / `target_pool_active_lamports` /
`target_pool_staked` into `ValidatorPoolStake` with serde defaults, so
those epochs read as "not in pool" (null) instead of failing the query.
Also trims what Mongo sends back to the three fields actually used.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant