Skip to content

add: p2p-extractor (initially keeps track of ping-pong durations) - #256

Merged
0xB10C merged 7 commits into
masterfrom
2025-09-add-p2p-extractor
Sep 22, 2025
Merged

0xB10C merged 7 commits into
masterfrom
2025-09-add-p2p-extractor

Conversation

@0xB10C

@0xB10C 0xB10C commented Sep 16, 2025 •

Copy link
Copy Markdown
Collaborator

This adds a p2p-extractor. The extractor listens on a TCP socket and accepts inbound connections from a Bitcoin node. A Bitcoin node configured with --addnode=ip:port will connect (and reconnect) to the extractor. Additionally, the connection will count as a manual connection and not reduce the number of normal outbound (and not inbounds) the node makes. The extractor does only support P2Pv1 for now. This means, the node and the extractor must have the same network magic. The node will open a v2 connection to the p2p-extractor at first, which will be closed. The node will then retry with a v1 connection which then should succeed.

Currently, the p2p-extractor only sends a ping and measures the time it takes for the node to respond to a pong. When done on localhost (to reduce network latency), this measures the time it takes for the node to process all other network messages that arrived before it. In a way, we measure the Bitcoin node backlog here.

Additional measurements and events can be extracted in the future. Some ideas are in: #263

part of #141
closes #212

@0xB10C 0xB10C mentioned this pull request Sep 15, 2025
4 of 7 tasks
@0xB10C
0xB10C force-pushed the 2025-09-add-p2p-extractor branch 2 times, most recently from 1ae50d2 to 112a95e Compare September 17, 2025 11:06
@0xB10C

0xB10C commented Sep 17, 2025 •

Copy link
Copy Markdown
Collaborator Author

@0xB10C

0xB10C commented Sep 17, 2025

Copy link
Copy Markdown
Collaborator Author

Also, CI fails do to not up-to-date docs.

🔍 Checking tool: logger
Warning: Missing line in README for logger:       --p2p-extractor                If passed, show p2p-extractor events
Error: Some help lines for 'logger' are missing in its README
📢 Have you forgotten to update the documentation for logger?
🔍 Checking tool: websocket
🔍 Checking tool: metrics
🔍 Checking tool: connectivity-check
❌ Documentation mismatch detected.
Error: Process completed with exit code 1.

@0xB10C
0xB10C force-pushed the 2025-09-add-p2p-extractor branch from 26c9537 to eb02aa9 Compare September 19, 2025 11:05
The P2P extractor starts a TCP server and listens for connections
from a Bitcoin node. A node can be configured to connect to it with
e.g. --addnode=127.0.0.1:9333. Once connected, the extractor and the
node will do a version handshake. Once that's done, the extractor can
perform measurements over the P2P interface of the node. For example,
it can send pings and record the time it takes for a pong response to
arrive. This gives insights about the nodes processing backlog.
@0xB10C
0xB10C force-pushed the 2025-09-add-p2p-extractor branch from eb02aa9 to 0b2bf32 Compare September 19, 2025 11:23
@0xB10C
0xB10C force-pushed the 2025-09-add-p2p-extractor branch from 0b2bf32 to 53b72aa Compare September 19, 2025 12:24
@0xB10C 0xB10C changed the title wip: add p2p-extractor add: p2p-extractor (initially keeps track of ping-pong durations) Sep 19, 2025
@0xB10C
0xB10C marked this pull request as ready for review September 19, 2025 12:52
0xB10C added a commit to 0xB10C/nix that referenced this pull request Sep 19, 2025
@0xB10C

0xB10C commented Sep 22, 2025

Copy link
Copy Markdown
Collaborator Author

I've been running this for a few days and it seems to work as intended.

@0xB10C
0xB10C merged commit 74907a8 into master Sep 22, 2025
0xB10C added a commit to 0xB10C/nix that referenced this pull request Sep 22, 2025
@0xB10C
0xB10C deleted the 2025-09-add-p2p-extractor branch January 6, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

metrics tool: track time it takes for us to respond to an inbound ping with a pong

1 participant