Skip to content

feat(cli): add node peers, mempool, and metrics subcommands#669

Closed
ByteYue wants to merge 2 commits into
mainfrom
feat/cli-node-monitoring
Closed

feat(cli): add node peers, mempool, and metrics subcommands#669
ByteYue wants to merge 2 commits into
mainfrom
feat/cli-node-monitoring

Conversation

@ByteYue

@ByteYue ByteYue commented Apr 19, 2026

Copy link
Copy Markdown
Contributor

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); --detail dumps each entry as JSON; --output json emits the raw array.
  • node mempool [--content]txpool_status, optionally combined with txpool_content grouping 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; failures become ? / null fields so the command still works on nodes that expose only a subset of RPC namespaces.

Added a -32601 / Method not found hint in errors.rs pointing at the node's --http.api list — 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-release clean with RUSTFLAGS=\"--cfg tokio_unstable\"
  • node metrics against live localnet → chain_id=31337, block_number=676, txpool_pending=0, syncing=no displayed correctly; peer_count=? gracefully when net_peerCount not exposed
  • node metrics --output json → structured output with null for unexposed methods
  • node mempool against live localnet → pending: 0 / queued: 0
  • node peers against node without admin namespace → clean error + new hint
  • node metrics against unreachable RPC → all ? fields, exit 0 (defensive)
  • node mempool without --rpc-url → clean required-flag error with init hint

ByteYue added 2 commits April 19, 2026 18:38
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.
@ByteYue ByteYue marked this pull request as draft April 22, 2026 02:09
@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

This PR is stale because it has been open 45 days with no activity. Remove the stale label, comment or push a commit - otherwise this will be closed in 15 days.

@github-actions github-actions Bot added the Stale label Jun 6, 2026
@github-actions github-actions Bot closed this Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant