enha: use machine name as client identifier - #2632
Conversation
There was a problem hiding this comment.
Summary
Looks good overall. This change consistently migrates follower->leader client identification from RPC params to transport headers (x-client) across HTTP and WS client builders, and updates call sites/signatures accordingly.
I did not find concrete correctness, security, or deploy-safety regressions in the provided diff. The parameter removal for eth_sendRawTransaction forwarding is internally consistent with the new header-based attribution model.
There was a problem hiding this comment.
Nice simplification overall—moving client identity to transport headers reduces API coupling and removes extra RPC params cleanly.
I found one blocking correctness/API-compat issue:
-
Blocking: changed JSON-RPC params for
eth_sendRawTransactionmay break upstream leader compatibility
InBlockchainClient::send_raw_transaction_to_leader, request changed from[tx, rpc_client]to[tx]. Unless the leader-side method now accepts the standard single-param form (or supports both), follower->leader forwarding can fail at runtime with invalid params.- Impact: followers may be unable to forward transactions, causing tx submission failures in follower mode.
- Where:
src/eth/rpc/blockchain_client/blockchain_client.rs(methodsend_raw_transaction_to_leader) - Suggested fix: ensure server-side
eth_sendRawTransactionhandler accepts header-based attribution without requiring 2nd param, ideally keeping backward compatibility for both arities during rollout; add an integration test for follower forwarding against leader endpoint.
Non-blocking note: machine_name() doc says fallback to "unknown" but code uses "stratus"—just align comment/string to avoid confusion.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1e193f745
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if let Ok(value) = HttpHeaderValue::from_str(&machine_name) { | ||
| headers.insert("x-client", value); | ||
| } |
There was a problem hiding this comment.
Preserve a fallback for header-unsafe hostnames
When hostname::get() succeeds but returns a hostname containing non-ASCII or control characters, HttpHeaderValue::from_str fails and this branch silently omits x-client. The leader's parse_client_app then attributes these requests to Unknown, defeating the new identification behavior; use the documented fallback value or return an error when the hostname cannot be encoded as a header.
Useful? React with 👍 / 👎.
PR Type
Enhancement
Description
Include machine name in x-client header
Simplify forward_to_leader call signature
Update RPC clients to set headers
Add hostname dependency
Diagram Walkthrough
File Walkthrough
consensus.rs
Simplify forward_to_leader signaturesrc/eth/follower/consensus.rs
rpc_clientparameter fromforward_to_leaderblockchain_client.rs
Add client headers for RPC requestssrc/eth/rpc/blockchain_client/blockchain_client.rs
client_headersandmachine_namefunctionsserver.rs
Update server RPC forwarding callsrc/eth/rpc/server.rs
forward_to_leadersignaturerpc_clientargumentCargo.toml
Add hostname dependencyCargo.toml
hostnamecrate dependency