confirm: cut stamp/write CPU copies - #249
Merged
Merged
Conversation
added 7 commits
August 25, 2026 15:34
Direct IBD already stamps create_fk. tx_fk_by_txid_tip on the
optimistic walk was a dual path that IBD never needed (cold=0)
and re-probed pin via has_parent_out before get_parent_txout_parts.
Unstamped parents are Corrupt("invariant: lookup stage miss").
Full mode still uses tip fk + has_parent_out for durable spentness.
input_create_heights is allocated only in Full (BIP68 at assemble).
take_from_plan pins from packed create_fk, so rebuilding create_by_txid with SipHash on S0 was wasted. plan=None still fills it for thin edges. Script jobs attach Arc<[TxPrecompute]> + idx instead of Arc::new(p.clone()) so assemble does not copy midstates.
stamp_external_parents already idx-fills resolved parents. A second packed rewalk + fill_missing was a no-op idx batch on Direct IBD. Pre-stamped reconstruct create_fk still joins txids in the stamp loop and fill_missing runs only when that set grew.
SH collect is a no-op under IndexMode::Direct, so write_create_pins was an unused FkMap of Arc clones. Tip still fills it. One tx_body_range_batch(planned_fks) now feeds both layout holes and RecentCreates. Spent.idx batch stays holes-only. Rows take &[CreatePin] instead of a third Option-wrapped clone vec.
Lookup already sorts need-vouts. Load now moves that map instead of cloning and re-sorting. Same-header spends stay off parent_vouts — assemble values them from the wire TxOut. Cross-height creates in the same write pack still pin. The pin-covered contract walk is debug_assert only (still_need empty is the release check).
Load copies spent_range; write ensure is holes-only. Invariants regression table covers the new stamp/pin/write pins.
Assemble attaches Arc<[TxPrecompute]> via with_pre_slice. The Owned with_pre helper was only used from tests and failed lib dead_code on CI (test/windows/macos).
rearden-grok
Bot
force-pushed
the
confirm/one-spend-edge
branch
from
August 25, 2026 22:36
f57b0ed to
eeddd33
Compare
validate_block_connect is Optimistic: an unstamped parent is Corrupt(\"invariant: lookup stage miss\"), not MissingPrevout via head recover. The analog still requires the connect to fail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Below-milestone IBD still spends CPU re-encoding parent/spend facts and cloning pin/pres Arcs that lookup already built. After #245/#246,
ensure=/thin=dropped; remaining waste is structure, not missing idx.What
Phase A of the confirm-pipeline CPU plan (same-thread occupancy and encode-at-write stay later PRs).
invariant: lookup stage miss, nottx_fk_by_txid_tiprecover. Full mode still uses tip fk +has_parent_out.Arc<[TxPrecompute]>+ idx (noArc::new(p.clone())).take_from_plandoes not SipHash-invertcreate_by_txid(plan=None still does).plan_batch: onefill_missing_parent_rangesunless packed adds pre-stamped fks.write_create_pinsFkMap. Onetx_body_range_batch(planned_fks)feeds layout holes and RecentCreates; spent.idx stays holes-only.parent_vouts(no clone+re-sort). Same-header creates stay off the pin (wireTxOut); cross-height same-pack still pins. Pin-covered contract walk isdebug_assertonly.Follow-ups on this branch if needed
CreatePin-backed pin (no script clone on plan hit), one spend-edge list (drop IBD
BatchThin), structural/annotate consume that list once.Not this PR: stamp-on-lookup occupancy, encode packed at write,
class_c_join/ OA seal / pin_hit.Test
No workflow YAML. Do not merge unless asked.