POC: IPC tracing interface #32898

pull ryanofsky wants to merge 4 commits into bitcoin:master from ryanofsky:pr/trace changing 42 files +468 −46
  1. ryanofsky commented at 8:45 pm on July 7, 2025: contributor

    This a is proof-of-concept adding an IPC interface for tracing as discussed in https://github.com/bitcoin-core/libmultiprocess/issues/185. As mentioned there, this is a naive implementation that would need to be optimized to have good performance, but it does show an end-to-end demo of how tracing could work using IPC.

    The can be tested by building with -DENABLE_IPC=ON and running:

    0build/bin/bitcoin-node -regtest -ipcbind=unix  # Start node listening on IPC socket
    1build/bin/bitcoin-trace -regtest -debug        # Run bitcoin-trace and connect to socket
    2build/bin/bitcoin-cli -regtest -generate       # Create a block to generate sample traces
    
  2. ipc: Add MakeBasicInit function
    Add a MakeBasicInit() function so simpler standalone IPC clients like
    bitcoin-mine in #30437 and bitcoin-cli in #32297 that only initiate IPC
    connections without exposing any IPC interfaces themselves can to avoid needing
    to implement their own specialized interfaces::Init subclasses.
    09733c2b24
  3. interface_ui: move from node to common library
    Allows InitError and InitWarning to be used by other executables beside
    bitcoind and bitcoin-node.
    c348507128
  4. util: Add kernel::Traces struct
    Add kernel::Traces struct and pass it places where it will be used next commit
    to support emitting IPC traces.
    
    Similar structs like wallet::Traces could be added to enable traces from other
    parts of the code.
    f880817d54
  5. POC: IPC tracing interface
    This a is proof-of-concept adding an IPC interface for tracing as discussed in
    https://github.com/bitcoin-core/libmultiprocess/issues/185. As mentioned there,
    this is a naive implementation that would need to be optimized to have good
    performance, but it does show an end-to-end demo of how tracing could work
    using IPC.
    
    The can be tested by building with -DENABLE_IPC=ON and running:
    
    build/bin/bitcoin-node -regtest -ipcbind=unix  # Start node listening on IPC socket
    build/bin/bitcoin-trace -regtest -debug        # Run bitcoin-trace and connect to socket
    build/bin/bitcoin-cli -regtest -generate       # Create a block to generate sample traces
    8e09fbe805
  6. DrahtBot commented at 8:45 pm on July 7, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32898.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #32575 (refactor: Split multithreaded case out of CheckInputScripts by fjahr)
    • #32317 (kernel: Separate UTXO set access from validation functions by TheCharlatan)
    • #32297 (bitcoin-cli: Add -ipcconnect option by ryanofsky)
    • #31679 (cmake: Move internal binaries from bin/ to libexec/ by ryanofsky)
    • #31132 (validation: fetch block inputs on parallel threads 10% faster IBD by andrewtoth)
    • #30437 (ipc: add bitcoin-mine test program by ryanofsky)
    • #29641 (scripted-diff: Use LogInfo over LogPrintf [WIP, NOMERGE, DRAFT] by maflcko)
    • #29409 (multiprocess: Add capnp wrapper for Chain interface by ryanofsky)
    • #29060 (Policy: Report reason inputs are non standard by ismaelsadeeq)
    • #26966 (index: initial sync speedup, parallelize process by furszy)

    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.

  7. ryanofsky marked this as a draft on Jul 7, 2025
  8. ryanofsky commented at 2:35 am on July 8, 2025: contributor

    Notes on current implementation of this:

    • The third commit f880817d54d9558938c697a37d0ef9acd4f34cf4 would be a lot simpler if it added a Traces* g_traces or similar global variable, which would be a reasonable thing to do. Initially, I wanted to avoid globals because they are hard to get rid of, and avoiding them could have benefits like being able to attach different tracers to different CCoinsViewCache instances, but this may not be worth extra complexity.
    • In the main commit 8e09fbe805fe77838363b7563d1dd0f2c934c1db, the duplication between src/interfaces/tracing.h and src/ipc/capnp/tracing.capnp isn’t very nice. Maybe some code generation could be done to generate one file from the other. This would be difficult to do for general IPC calls but might be easier for simple tracing definitions.
    • In the main commit 8e09fbe805fe77838363b7563d1dd0f2c934c1db, I made the coins.cpp traces verbose and explicit for clarity, but a real implementation should replace all of that tracing code with single Trace() calls like Trace<&UtxoCache::add>(UtxoInfo{outpoint.hash, ...}) which would reduce verbosity, and could be optimized to avoid locking and blocking for efficiency.
  9. 0xB10C commented at 8:40 am on July 8, 2025: contributor
    Awesome, thanks! I’ll play around with this over the next few weeks.
  10. ryanofsky commented at 1:20 pm on July 8, 2025: contributor

    Awesome, thanks! I’ll play around with this over the next few weeks.

    Great! Will close this PR since I’m not planning to do more work on it, and we can continue to discuss in https://github.com/bitcoin-core/libmultiprocess/issues/185

  11. ryanofsky closed this on Jul 8, 2025


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-07-09 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me