Skip to content

add: getblockchaininfo RPC support - #321

Merged
0xB10C merged 1 commit into
peer-observer:masterfrom
GuiSchet:rpc-extractor-getblockchaininfo
Jan 19, 2026
Merged

0xB10C merged 1 commit into
peer-observer:masterfrom
GuiSchet:rpc-extractor-getblockchaininfo

Conversation

@GuiSchet

Copy link
Copy Markdown
Contributor

Add getblockchaininfo RPC Support

This PR adds support for extracting and monitoring getblockchaininfo RPC data, following the same pattern established for other RPC extractors.

Changes

  • RPC Extractor: Added getblockchaininfo query and NATS publishing in extractors/rpc
  • Protobuf Schema: Added BlockchainInfo message definition with all relevant fields
  • Prometheus Metrics: Added 8 metrics for blockchain state monitoring:
    • rpc_blockchaininfo_blocks - Current block height
    • rpc_blockchaininfo_headers - Current header count
    • rpc_blockchaininfo_difficulty - Current difficulty
    • rpc_blockchaininfo_verification_progress - Sync progress [0..1]
    • rpc_blockchaininfo_initial_block_download - IBD status (0/1)
    • rpc_blockchaininfo_size_on_disk - Disk usage in bytes
    • rpc_blockchaininfo_pruned - Pruning status (0/1)
    • rpc_blockchaininfo_warnings - Warnings present (0/1)

Privacy Considerations

Similar to getnetworkinfo, this implementation follows a privacy-conscious approach:

Low Risk Fields (exposed in both NATS and Prometheus):

  • Block height, headers, difficulty - Public blockchain state
  • Verification progress, IBD status - Operational state (low sensitivity)
  • Size on disk, pruning status - Configuration info (low sensitivity)

Moderate Risk Fields (exposed in NATS, not in Prometheus):

  • bestblockhash - Could aid in fingerprinting specific node state
  • chainwork - Total work calculation (could help identify node)
  • time / mediantime - Block timestamps (could aid temporal fingerprinting)
  • chain - Network identifier (main/test/regtest)
  • pruneheight / prune_target_size - Pruning configuration details

Recommendations:

  • Ensure NATS server is only accessible on localhost or private network
  • Consider adding authentication if NATS is shared across hosts
  • The privacy risk is lower than getnetworkinfo since no network identifiers are exposed

@GuiSchet GuiSchet changed the title Rpc extractor getblockchaininfo add: getblockchaininfo RPC support Dec 24, 2025
@0xB10C
0xB10C self-requested a review December 24, 2025 14:05
@0xB10C
0xB10C marked this pull request as draft January 5, 2026 16:06
@0xB10C

0xB10C commented Jan 5, 2026

Copy link
Copy Markdown
Collaborator

Since this depends on #319, I'm marking this as a draft for now.

@0xB10C

0xB10C commented Jan 16, 2026

Copy link
Copy Markdown
Collaborator

With #319 merged, this can be rebased :)

@GuiSchet

Copy link
Copy Markdown
Contributor Author

Hey 0xB10C! I'll rebase this PR shortly. Sorry for the delay, I was caught up with the Boss's challenges :)

@GuiSchet
GuiSchet force-pushed the rpc-extractor-getblockchaininfo branch from 1f335a7 to 5872cef Compare January 17, 2026 02:57
@GuiSchet

Copy link
Copy Markdown
Contributor Author

Changes since rebase:

  • Decoupled from --disable-getchaintxstats flag to allow independent usage
  • Changed warnings field to repeated string to support multiple warnings

@0xB10C
0xB10C force-pushed the rpc-extractor-getblockchaininfo branch from 22641e8 to 36635d3 Compare January 17, 2026 09:06
@0xB10C
0xB10C marked this pull request as ready for review January 17, 2026 09:07
Comment on lines +502 to +503
ig!(rpc_blockchaininfo_blocks, "Height of the most-work fully-validated chain from getblockchaininfo.", registry);
ig!(rpc_blockchaininfo_headers, "Current number of headers validated from getblockchaininfo.", registry);

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.

Nice. I want to add some alerting for this in a followup: when we have more headers than blocks, but rpc_blockchaininfo_initial_block_download is 0, there might be a problem

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Excellent idea!

Comment thread tools/metrics/src/metrics.rs Resolved
Comment thread tools/metrics/tests/integration.rs Resolved
Comment thread protobuf/rpc_extractor.proto Resolved
@0xB10C
0xB10C force-pushed the rpc-extractor-getblockchaininfo branch from 36635d3 to 3a95178 Compare January 17, 2026 12:08
@0xB10C

0xB10C commented Jan 17, 2026

Copy link
Copy Markdown
Collaborator

addresses my review comments and added the following metrics:

peerobserver_rpc_blockchaininfo_prune_height
peerobserver_rpc_blockchaininfo_prune_target_size

Comment thread extractors/rpc/src/lib.rs Resolved
Comment thread protobuf/rpc_extractor.proto Resolved
@0xB10C
0xB10C force-pushed the rpc-extractor-getblockchaininfo branch from 3a95178 to 0fab6c6 Compare January 19, 2026 12:28
@0xB10C

0xB10C commented Jan 19, 2026

Copy link
Copy Markdown
Collaborator

Ok, that was the final round of review! Thank you again @GuiSchet for this and #319!

@0xB10C
0xB10C merged commit 6e0292d into peer-observer:master Jan 19, 2026
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