#36584 kernel: make btck_LogEntry opaque

ReviewabilityReviewsAgreementSize
#36584 stickies-v kernel: make btck_LogEntry opaqueReady2Strong175
  • Avoid breaking backwards compatibility for external library consumers when log fields are added or changed
  • Align logging entry types with the rest of the kernel library C interface
  • Ready to review
  • Strong support with no open objections
  • Verified by testing all getters from the logging callback locally (musaHaruna)
  • Approval without stated reasons after docstring style query was answered (sedited)
  • 175 lines added or modified outside tests
  • 0 lines added or modified in tests
  • 78 lines removed in total
  • 3 files, 1 commits
Kernel (libbitcoinkernel)#15 of 18
P3 · cleanup
  • P3 because it improves ABI extensibility for kernel consumers by avoiding a fixed struct layout
  • It is an internal C API refinement and reasonably deferrable
Reviewability: ReadyStalePaused
Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets
Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs.
Size: lines added or modified outside tests, then in tests; greener = smaller.

Goal

Replaces the public struct definition of `btck_LogEntry` in the libbitcoinkernel C API with an opaque handle and explicit getter functions (`btck_log_entry_get_*`). String fields are returned as non-owning `btck_StringView` structs rather than raw pointer and length pairs. Field values are extracted lazily upon access rather than eagerly converted before calling the registered logging callback.

Problem: Exposing `btck_LogEntry` as a public C struct fixes its memory layout in the library ABI, preventing the addition or alteration of log fields without breaking backwards compatibility. It also deviates from almost all other libbitcoinkernel types, which use opaque handles.

Evidence of importance:

  • Author note in description: 'This allows adding or changing fields without breaking the ABI, and is consistent with ~all other kernel objects. Follow-up to https://github.com/bitcoin/bitcoin/pull/34374#discussion_r4207440088.'
  • Author microbenchmarks show negligible overhead: callback log statement duration shifts between −2.5 ns and +5.4 ns depending on how many fields are read.

Risk of a mistake: low (other). Mistakes are confined to libbitcoinkernel logging callback wrappers and getters, causing corrupted log fields or compilation issues for external kernel consumers.

Changed since the previous assessment: Diff provided; matches the previous description.

Reviewability

Ready

Nothing known that would invalidate a review now.

Waiting on (from the thread read):

  • nothing

Agreement

Strong

substantive support, no open objection (musaHaruna)

Thread notes: Initial record. sedited raised a style suggestion regarding docstring comments on getters, which the author answered, and both sedited and musaHaruna have ACKed the PR. / Initial record for the PR. sedited raised a minor docstring style suggestion which stickies-v answered, followed by ACKs from both sedited and musaHaruna.

Objections, suggestions, and questions:

ReviewerTypeHarm, request, or questionStatusMust beAuthor repliedQuote
sedited (member)suggestion, styleuse one-line `///` descriptions for trivial gettersanswered · author replied preferring Doxygen docstring consistency across public functions, leaving as-is for nowansweredyes2026-10-21: 'Might a one-line `///` description be better for these trivial getters?'
Status from: 2026-10-21: stickies-v: 'I personally prefer the consistency of using doxygen docstrings for all public functions, but don't care too strongly either way'

Support:

  • sedited (member) (ACK, 2026-10-21): (no reason given) [not substantive]
  • musaHaruna (contributor) (ACK, 2026-10-21) [tested]: Tested locally, including calling all nine getters from the logging callback and checking the message, timestamp, source location, level, and category for the connection and disconnection messages.

Participants:

  • musaHaruna (contributor, support, 1 statements 2026-10-21 to 2026-10-21): ACKed; tested getters and logging callback locally
  • sedited (member, support, 2 statements 2026-10-21 to 2026-10-21): ACKed; suggested one-line comments for trivial getters

Files

0 lines under test/bench/ci.

  • src/kernel/bitcoinkernel.h +103/-38
  • src/kernel/bitcoinkernel.cpp +53/-24
  • src/kernel/bitcoinkernel_wrapper.h +19/-16

Card

The short text the ranking pass compares across PRs.

Makes btck_LogEntry an opaque handle in the libbitcoinkernel C interface, exposing fields via btck_log_entry_get_* accessor functions. A public struct layout made it impossible to add or change log metadata fields without breaking ABI compatibility for kernel consumers, unlike other kernel API handles. Fields are now converted lazily when read, and author benchmarks show no meaningful performance impact (delta between -2.5 ns and +5.4 ns per log statement).

Data

dossier JSON · extract JSON · model ledger, generated 2026-10-22T01:17, confidence high, input hash 607e5a20c98c5359
thread read through 2026-10-21 (4 statements), head b2c077394a
labels: Validation

Categories

Kernel (libbitcoinkernel)

P3 · cleanup

Making `btck_LogEntry` opaque aligns it with other kernel types and avoids fixing struct layout in the ABI. As the author notes, this 'allows adding or changing fields without breaking the ABI, and is consistent with ~all other kernel objects.' While it improves library ABI extensibility, the work is an internal C API refinement and reasonably deferrable.

Membership: Modifies `src/kernel/bitcoinkernel.h`, `bitcoinkernel.cpp`, and `bitcoinkernel_wrapper.h` to change the public libbitcoinkernel C API logging interface.

Factors: security/stability 0, bug 0, performance 0, user value 1, leverage 1