Skip to content

feat(core): implement validatorapi node_version and proposer_duties handlers#449

Open
varex83 wants to merge 5 commits into
mainfrom
bohdan/validatorapi-2
Open

feat(core): implement validatorapi node_version and proposer_duties handlers#449
varex83 wants to merge 5 commits into
mainfrom
bohdan/validatorapi-2

Conversation

@varex83
Copy link
Copy Markdown
Collaborator

@varex83 varex83 commented May 28, 2026

Summary

First two slices of the validatorapi port. Lands the router state plumbing and two handlers end-to-end so the next handler PRs can drop straight in.

  • AppState<H> + Arc<AppState<H>> threaded through new_router via with_state.
  • node_version and proposer_duties routes implemented against the Handler trait.
  • Re-uses the auto-generated pluto_eth2api envelopes (GetVersionResponseResponse, GetProposerDutiesResponseResponse) as the on-the-wire shape — no hand-rolled parallel types. The validatorapi/types.rs module re-exports them under shorter names (NodeVersionResponse, ProposerDutiesResponse, ProposerDuty).
  • New testutils.rs with TestHandler — implements all 19 Handler methods (2 real, 17 unimplemented!() stubs); future handler PRs override the relevant method to drive their unit test.

This sets the pattern for the remaining handler PRs: each method returns its endpoint's spec-precise auto-gen envelope rather than the generic EthResponse<T> wrapper, which will be retired per-PR as handlers land. Middleware (timeout, content-type validation, metrics) and the reverse-proxy fallback come in their own PRs after a few more handlers land.

Test plan

  • cargo check -p pluto-core --tests
  • cargo clippy -p pluto-core --all-targets --all-features -- -D warnings
  • cargo +nightly fmt --all -- --check
  • cargo test -p pluto-core validatorapi::router::testsnode_version_wraps_handler_value and proposer_duties_wraps_handler_value pass

varex83 added 2 commits May 28, 2026 14:08
Threads the Handler through Axum state via AppState<H> + with_state,
wires the node_version route to the real handler, and adds a TestHandler
mock that future PRs will extend per-endpoint.
Copy link
Copy Markdown
Collaborator

@emlautarom1 emlautarom1 left a comment

Choose a reason for hiding this comment

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

Small stuff:

Comment thread crates/core/src/validatorapi/body.rs Outdated
Comment on lines +3 to +17
use serde::Serialize;

/// Wire body for `GET /eth/v1/node/version`.
#[derive(Debug, Clone, Serialize)]
pub struct NodeVersionResponse {
/// Version payload.
pub data: NodeVersionData,
}

/// `data` field of [`NodeVersionResponse`].
#[derive(Debug, Clone, Serialize)]
pub struct NodeVersionData {
/// Node version string.
pub version: String,
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Already exists under eth2api as GetNodeVersionRequest and associated types.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've realized that in the #450

Re-uses the auto-generated pluto_eth2api envelopes
(GetProposerDutiesResponseResponse, GetVersionResponseResponse) as the
on-the-wire shape rather than hand-rolling parallel types. node_version
is migrated to the same pattern; the body.rs hand-rolled wrapper module
is removed.
@varex83 varex83 changed the title feat(core): implement validatorapi node_version handler feat(core): implement validatorapi node_version and proposer_duties handlers May 28, 2026
varex83 added 2 commits May 28, 2026 15:56
Drops the per-handler generic parameter and routes through
Arc<dyn Handler> via AppState. The Handler trait is object-safe
(Send + Sync + 'static + async_trait-generated methods), so this
is a pure type change with no surface impact.
Adds the Handler impl that the router has been calling through.
node_version returns the obolnetwork/pluto/{version}-{commit}/{arch}-{os}
identity string; proposer_duties calls the upstream beacon node and
rewrites known DV root public keys to this node's public share so the
validator client sees keys matching its keystore. The remaining 17
trait methods are unimplemented!() stubs that land per-PR as their
router handlers are ported.
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.

2 participants