Skip to content

Migrate block-state, fee-state and reward-state endpoints#4285

Draft
ss-es wants to merge 1 commit into
ss/axum-4from
ss/axum-5
Draft

Migrate block-state, fee-state and reward-state endpoints#4285
ss-es wants to merge 1 commit into
ss/axum-4from
ss/axum-5

Conversation

@ss-es
Copy link
Copy Markdown
Contributor

@ss-es ss-es commented May 11, 2026

Migrates the fee-state, block-state and reward-state endpoints to axum

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces V1 API traits and implementations for block-state, fee-state, and reward-state, along with corresponding Axum handlers, routes, and parity tests. Feedback suggests mapping client-side parsing errors to ApiError::BadRequest instead of ApiError::Internal for better HTTP status accuracy. Additionally, the reviewer noted a discrepancy where V1 URL prefixes return V2 data via shared handlers, recommending clarification in the documentation.

Comment on lines +605 to +691
let get_block_state_height = |State(state): State<S>| async move {
state
.get_block_state_height()
.await
.map(Json)
.map_err(ApiError::Internal)
};
let get_block_state_path = |State(state): State<S>, Path((height, key)): Path<(u64, u64)>| async move {
state
.get_block_state_path(height, key)
.await
.map(Json)
.map_err(ApiError::Internal)
};
let get_block_state_path_by_commit =
|State(state): State<S>, Path((commit, key)): Path<(String, u64)>| async move {
state
.get_block_state_path_by_commit(commit, key)
.await
.map(Json)
.map_err(ApiError::Internal)
};

// Fee-State API handlers
let get_fee_state_height = |State(state): State<S>| async move {
state
.get_fee_state_height()
.await
.map(Json)
.map_err(ApiError::Internal)
};
let get_fee_state_path =
|State(state): State<S>, Path((height, address)): Path<(u64, String)>| async move {
state
.get_fee_state_path(height, address)
.await
.map(Json)
.map_err(ApiError::Internal)
};
let get_fee_state_path_by_commit =
|State(state): State<S>, Path((commit, address)): Path<(String, String)>| async move {
state
.get_fee_state_path_by_commit(commit, address)
.await
.map(Json)
.map_err(ApiError::Internal)
};
let get_fee_balance = |State(state): State<S>, Path(address): Path<String>| async move {
state
.get_fee_balance(address)
.await
.map(Json)
.map_err(ApiError::Internal)
};

// Reward-State (V1) API handlers
let get_reward_state_height = |State(state): State<S>| async move {
state
.get_reward_state_height()
.await
.map(Json)
.map_err(ApiError::Internal)
};
let get_reward_state_path =
|State(state): State<S>, Path((height, address)): Path<(u64, String)>| async move {
state
.get_reward_state_path(height, address)
.await
.map(Json)
.map_err(ApiError::Internal)
};
let get_reward_state_path_by_commit =
|State(state): State<S>, Path((commit, address)): Path<(String, String)>| async move {
state
.get_reward_state_path_by_commit(commit, address)
.await
.map(Json)
.map_err(ApiError::Internal)
};
let get_reward_state_proof =
|State(state): State<S>, Path((height, address)): Path<(u64, String)>| async move {
state
.get_reward_state_proof(height, address)
.await
.map(Json)
.map_err(ApiError::Internal)
};
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.

medium

The new handlers for block-state, fee-state, and reward-state map all errors to ApiError::Internal (500 Internal Server Error). This includes client-side errors such as invalid address formats or invalid commitment strings that fail to parse in the underlying implementation. Consider mapping these parsing errors to ApiError::BadRequest (400) to provide more accurate HTTP status codes.

/// Path: GET /v1/reward-state/proof/{height}/{address}
pub const REWARD_STATE_PROOF_ROUTE: &str = "/v1/reward-state/proof/{height}/{address}";

/// Get latest V1 reward account proof (shared handler with reward-state-v2)
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.

medium

The comment describes this as the 'latest V1 reward account proof', but the handler get_latest_reward_account_proof (shared with reward-state-v2) returns a V2 proof. This discrepancy between the URL prefix (/v1/reward-state/) and the returned data version (V2) should be clarified in the documentation or the comment.

@github-actions
Copy link
Copy Markdown
Contributor

Nextest failures (2) in this run

Test Attempts Time (s) Main history
espresso-node::api::test::test_merklized_state_catchup_on_restart::case_2 3 305.73 passing
espresso-node::api::test::test_merklized_state_catchup_on_restart::case_2 3 282.99 passing

See the step summary for flaky tests and slowest tests.

@github-actions
Copy link
Copy Markdown
Contributor

Nextest failures (1) in this run

Test Attempts Time (s) Main history
hotshot-testing::test_vid2_upgrade::test_vid2_upgrade::testtypes_::memoryimpl_::test_vid2_upgrade 1 15.07 passing

See the step summary for flaky tests and slowest tests.

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