feat(cli): add node peers, mempool, and metrics subcommands#669
Closed
ByteYue wants to merge 2 commits into
Closed
feat(cli): add node peers, mempool, and metrics subcommands#669ByteYue wants to merge 2 commits into
ByteYue wants to merge 2 commits into
Conversation
Thin wrappers over reth's existing JSON-RPC so operators can ask the
common health questions without remembering the RPC method names:
- `node peers [--detail]` → `admin_peers`. Default view shortens the
peer ID / enode into a single readable line; `--detail` dumps each
entry as JSON; global `--output json` emits the raw array.
- `node mempool [--content]` → `txpool_status`, optionally combined
with `txpool_content` which groups pending tx counts by sender.
- `node metrics` → aggregates chain_id, block_number, peer_count,
txpool_pending / queued, and eth_syncing into one snapshot. Each
sub-query has an independent 3s timeout and failures fall through
to `?` / null fields so the command stays useful on nodes that
expose only a subset of RPC namespaces.
Added a `-32601 / Method not found` hint to errors.rs pointing at the
node's `--http.api` list so users don't guess that `admin_*` requires
opt-in on the node side.
No node-side changes — everything layers on reth RPC that is already
exposed when the right namespaces are enabled.
|
This PR is stale because it has been open 45 days with no activity. Remove the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Thin wrappers over reth's existing JSON-RPC so operators can ask the common health questions without remembering the RPC method names:
node peers [--detail]→admin_peers. Default view shortens each peer into a single readable line (id prefix, inbound/outbound, client name, enode prefix);--detaildumps each entry as JSON;--output jsonemits the raw array.node mempool [--content]→txpool_status, optionally combined withtxpool_contentgrouping pending tx counts by sender.node metrics→ aggregateschain_id,block_number,peer_count,txpool_pending / queued, andeth_syncinginto one snapshot. Each sub-query has an independent 3s timeout; failures become?/ null fields so the command still works on nodes that expose only a subset of RPC namespaces.Added a
-32601 / Method not foundhint inerrors.rspointing at the node's--http.apilist —admin_*/net_*typically require opt-in that users don't always know about.No node-side changes
Every RPC method used is already exposed by reth when the relevant namespaces are enabled on the execution node.
Test plan
cargo build -p gravity_cli --profile quick-releaseclean withRUSTFLAGS=\"--cfg tokio_unstable\"node metricsagainst live localnet →chain_id=31337, block_number=676, txpool_pending=0, syncing=nodisplayed correctly;peer_count=?gracefully whennet_peerCountnot exposednode metrics --output json→ structured output withnullfor unexposed methodsnode mempoolagainst live localnet →pending: 0 / queued: 0node peersagainst node withoutadminnamespace → clean error + new hintnode metricsagainst unreachable RPC → all?fields, exit 0 (defensive)node mempoolwithout--rpc-url→ clean required-flag error withinithint