mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:47:36 +00:00
tracing: add block header and compact block tracepoints #35368
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!35368
Loading…
Reference in a new issue
No description provided.
Delete branch "tracing-compact-block-usdt"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR adds two USDT tracepoints for compact block relay:
net:block_header: fires when a new valid header is received from a peer (viaheadersorcmpctblock).net:compact_block_reconstructed: fires when a compact block is successfully reconstructed, just before validation.The motivation is to expose structured, low-overhead observability for compact block relay behavior.
Compact block relay is performance-sensitive: whether a node reconstructs a block without round trips depends on mempool overlap, extra transaction pool usefulness, and peer behavior.
Today this information is mostly available only through debug logs, which are string-based, less precise for tooling, and not ideal for continuous measurement.
What they enable measuring:
getblocktxnround trip.Design notes.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
cmpctblockmessage reconstruction statistics [part of prefill series] by davidgumberg)If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
CI error unrelated. See https://github.com/bitcoin/bitcoin/issues/34731.
Generally in favor of having a way of exposing data about this in a non-logging way. Especially since fast compact block relay and reconstructions seem to be somewhat of a share priority by contributors. Concept ACK on exposing this data.
In https://github.com/peer-observer/peer-observer/pull/420, @m4ycon has been working on reading very similar information for the debug log. My understanding is that this works well, but is obviously brittle.
There's also the question about adding more tracepoints now, or investing time into seeing if #35142 is feasible...
With tracepoints essentially matching the log statements, I wonder if there's some way of combine the two - but that's obviously out of scope for this PR.
Concept ACK
Also a suggestion on additional info.
While monitoring dashboards from https://github.com/peer-observer/peer-observer/pull/420, my node had a pretty weird period where it was always requesting txs from other nodes (
stats.requested_txn_count > 0). The image below, this panels measures time taken to reconstruct a block, left panel shows reconstructions that didn't need to request txs, and the right one shows more than zero requested transactions.One of the things that people suggested to me, it was that I look at what kind of transactions were being requested, if there was some pattern or things like that. Unfortunately, I didn't have
-debug=netenabled which probably would have helped me to answer it.But with your PR, it makes me think if this isn't an interesting information to pass through tracepoints: all the txids from
vtx_missing. What do you guys think? Maybe this is too much data to send? As a real sample from my node, the highest "transactions requested" was 2041 in the last 30 days.I think a structured logging interface as discussed in https://github.com/bitcoin/bitcoin/issues/35369 would be a good solution avoiding duplication between logging statements and tracepoints. We'd get the same information about compact block reconstructions in a machine-to-machine interface.
It's rather impractical to pass lists or sets via tracaepoints, they don't really support it. While it might work by concatenating the txids and passing the length and passing the concatenated bytes, I don't think we should do these kind of hacks if we can avoid it.
Note that you only need compact block logging enabled. However, we only print the txids if there were less than 5 transactions missing. I've in the past ran a patched bitcoind that removed this limitation and logged all missing txids. To look up why your node didn't know about a certain transaction, you probably want to have
-debug=netenabled. It might tell you that a transaction was replaced, evicted from orphanage, you never got an inv for it, ...github.com/bitcoin/bitcoin@de925455c8/src/blockencodings.cpp (L222-L232)I agree it would make more sense to clarify that first before adding more tracepoints.
I don't think the IPC tracing discussion should block this functionality, assuming there is demand for it.
My understanding is that IPC tracing is a promising direction, but not a drop-in replacement for USDT today.
With the current libmultiprocess-generated C++ proxy interfaces, calls are synchronous by default, so a naive tracing implementation where an instrumentation site directly invokes subscriber callbacks would block the Bitcoin Core thread until the subscriber replies.
That callback model is a poor fit for high-frequency tracing, especially for events like raw P2P messages or per-UTXO cache events, unless it is designed with non-blocking buffering, batching, filtering, and backpressure/drop handling.
So I see IPC tracing as a longer-term project with its own tradeoffs, while this PR is a small addition to the existing USDT tracing interface.
🐙 This pull request conflicts with the target branch and needs rebase.
@w0xlt can you rebase this?
This has been in need of rebase for a few months now. Are you still working on this?
Base:
152a55397e451fed9c10041bddf01aa6839847d5Head:
ef3121b6e028b4bd6ecc07f713006ed1a7ba99edNo verified findings are available from this review.
Review coverage was incomplete.
Review limitations
Full review report
@sedited Rebased. Thanks
🐙 This pull request conflicts with the target branch and needs rebase.
Not sure about adding code that will be removed soon anyway? Ref https://github.com/bitcoin/bitcoin/issues/35142#issuecomment-5992319514
But no strong opinion. If there are active users that want this pull, it should be trivial for them to step up and review it? Though, if those users are compiling from source anyway, they can just use this code (or any other code their LLM writes) without having to go through review here. Again, no objection. I am just curious about the direction and impact.
Thanks for the feedback. Added my two cents in the thread: https://github.com/bitcoin/bitcoin/issues/35142#issuecomment-6346952054