Skip to content

blindbit-lib: remove the unused full-transaction receive path (SNB-662) - #75

Merged
setavenger merged 4 commits into
integrationfrom
snb-662-remove-full-receive-path
Oct 30, 2026
Merged

setavenger merged 4 commits into
integrationfrom
snb-662-remove-full-receive-path

Conversation

@setavenger

@setavenger setavenger commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #74 (SNB-668, HTTP API removal), which sits on #72 (snb-661-stack-06-docs, top of the Friglet cleanup stack #67–#72); review only the commit after #74. Retargets to integration once #67–#72 land. This change has no code dependency on #74; it is stacked only because SNB-671 (on top) touches the same files as both. The maintainer can reorder.

Implements SNB-662, decided by the maintainer on 2026-10-11. Net −938 lines (174 added, 1,112 removed).

What goes, and why

Scanner::scan_transaction_full was blindbit's original receive path (Nov 2025): the oracle sent each transaction's full outputs and the scanner checked every one. Since 15 Nov 2025 (f6cb002) friglet uses the short path (8-byte output prefixes, then the block over P2P on a probable match). Nothing in the workspace has called the full function since; only BIP-352 vector tests reached it.

  • Scanner::scan_transaction_full and the imports only it used (SpOut, Hash, FullTxItem).
  • utils::construct_dummy_tx, placeholder_txout (the fake transaction it scanned) and their five unit tests.
  • The five full-path vector tests: official_vectors_cover_blindbit_full_receive_boundary, ..._survive_sparse_vout_layouts, ..._enforce_k_max_at_the_blindbit_boundary, ..._cover_both_label_parities (both parity branches stay covered: the live receive test must find the even- and odd-parity vectors' labelled outputs), ..._extra_change_label_is_harmless; and the helpers only they used (full_item, assert_spout_invariants, the sparse vout layout, per-vout amounts). build_transaction_at is folded into build_transaction; every test output now carries the same amount, which no remaining test checks.

What stays or moves

  • BIP352_K_MAX stays (PR fix: enforce BIP-352 K_max on the live receive path (SNB-540) #18 uses it), marked #[expect(dead_code, reason = …)]: the live path does not enforce K_max yet (SNB-540). fix: enforce BIP-352 K_max on the live receive path (SNB-540) #18's compile-time assert against bdk_sp::K_MAX will use it, the expectation then fails, and the attribute has to go (see the fix: enforce BIP-352 K_max on the live receive path (SNB-540) #18 recipe below).
  • Every live/short-path vector test (SNB-541) is unchanged, including the ignored live K_max test; so are fixture_loader_is_strict and the input-tweak test. live_receive takes the label set to register.
  • New official_vectors_derive_expected_addresses: the check against the official expected.addresses used to run only inside the removed full-path boundary test. It now runs over all 29 receiving sub-cases (labelled and unlabelled, both SpIndexerV2::get_address and a SilentPaymentCode re-derivation), plus the sp_address the Electrum index and control socket serve (friglet-ui derives the same address). No scanning, so it is cheap.
  • New official_vectors_extra_change_label_is_harmless_on_the_live_path: the removed test showed that registering the change label m=0 on top of a vector's labels hides nothing, which is what lets the live tests use exactly the vector's labels while production always registers m=0. It now runs on the live receive step for the 26 non-K_max sub-cases and checks that 32 outputs were compared.
  • New official_vectors_live_receive_step_keeps_vouts_among_non_taproot_outputs (added after review): the removed sparse-vout test was the only check that an output paid after a non-taproot output is stored at its real vout. The live path depends on that too (bdk_sp's scan_txouts numbers outputs before it picks the taproot ones), and every other receive test pays taproot outputs only. The new test puts a P2WPKH output in front of every vector output and runs the live receive step.
  • Docs and comments that described the full path are reworded (the vector module doc, constant docs, blindbit_scanner, the section header, the root Cargo.toml secp256k1-sys opt-level comment; the setting stays).

Test time

base 08bf11d this PR
cargo test --workspace wall 37.0 s 12–15 s
blindbit-lib test binary 20.8 s 0.8 s

The two removed tests that scanned the 2,324-output K_max vector through the full path were most of the blindbit-lib time.

Reviews

  • gstack review: ship with fixes. Applied: the restored live vout test above, the opt-level comment wording, and this description's parity wording.
  • thermo-nuclear-review: ship, no findings (only removals and doc changes in non-test code; no live-path function changed; the fix: enforce BIP-352 K_max on the live receive path (SNB-540) #18 recipe matches git merge-tree and every conflicting hunk).

Verification

  • cargo test --workspace: 252 passed, 1 ignored, 0 failed. That is friglet: remove the HTTP API (SNB-668) #74's 259, minus the 5 full-path vector tests and the 5 construct_dummy_tx unit tests, plus the 3 new tests.
  • cargo test -p blindbit-lib --features serde bip352: 7 passed, 1 ignored (the live K_max test, SNB-540).
  • clippy -D warnings on friglet/friglet-ipc/friglet-tray: clean. fmt check: clean. cargo check --workspace --all-targets --all-features: 0 warnings (so #[expect(dead_code)] is fulfilled in lib and test builds).
  • Scan cost: no live-path code changed. Measured anyway, with PR blindbit-lib: one code path in the scan loop (SNB-669) #52's method (release blindbit-cli, signet blocks 274010..=276010, scan key 1 / spend key G, state file deleted before each run, 6 runs per build interleaved in rotating order, /usr/bin/time -v): base 3.23 ± 0.05 s CPU (user+sys) and 3.40 s wall per scan, this PR 3.24 ± 0.02 s CPU and 3.42 s wall. All runs end in the same state file (sha256 8c7aec9071b0…, as in blindbit-lib: one code path in the scan loop (SNB-669) #52).

PR #18 (SNB-540) on top of this

#18 is untouched (open against master, head snb-540-live-kmax 5e9f4c7). It does not merge cleanly onto this branch. Two of its four conflicts come from the cleanup stack regardless of this PR (SNB-670 rewrote the bdk_sp/indexer manifest lines it pins); two come from this PR. A trial merge with the recipe below builds, cargo check --workspace --all-targets --all-features has 0 warnings, and cargo test -p blindbit-lib --features serde bip352 -- --include-ignored passes 7/7, including the live K_max test #18 un-ignores (21.4 s).

Resolution recipe
  1. blindbit-lib/Cargo.toml: take theirs (fix: enforce BIP-352 K_max on the live receive path (SNB-540) #18's 4-line pin comment + both rev = "94b72f60b0015793e4db67355bdab8d240eecc00" lines), minus the four commented-out # bitcoin / # bdk_sp / # indexer lines SNB-670 removed.
  2. friglet/Cargo.toml: edit = fix: enforce BIP-352 K_max on the live receive path (SNB-540) #18's 2-line comment + SNB-670's reduced form with fix: enforce BIP-352 K_max on the live receive path (SNB-540) #18's rev:
    # Same bdk-sp fork rev as blindbit-lib's bdk_sp/indexer (SNB-540, see the comment there);
    # change them together.
    bdk_sp = { git = "https://github.com/setavenger/bdk-sp", rev = "94b72f60b0015793e4db67355bdab8d240eecc00", version = "0.1.0" }
  3. scanning.rs, BIP352_K_MAX doc: edit. Drop the #[expect(dead_code, ...)] (the const _ assert now uses the constant; left in place it raises unfulfilled_lint_expectations, verified). Neither side's doc text (ours says "not enforced yet", theirs links the removed Scanner::scan_transaction_full); use:
    /// BIP-352 limits one recipient group to this many matched outputs.
    ///
    /// The live receive path relies on `bdk_sp::receive::scan_txouts`, which stops at
    /// this limit (`bdk_sp::K_MAX`, SNB-540); the assert below keeps the two equal.
    const BIP352_K_MAX: usize = 2323;
    Keep fix: enforce BIP-352 K_max on the live receive path (SNB-540) #18's const _ assert that follows (auto-merged).
  4. scanning.rs, scan_transaction_full: take ours (the function stays deleted; fix: enforce BIP-352 K_max on the live receive path (SNB-540) #18's comment edit inside it is dropped).
  5. bip352_vectors.rs, big hunk: take ours (drops fix: enforce BIP-352 K_max on the live receive path (SNB-540) #18's doc rewrite of the deleted official_vectors_enforce_k_max_at_the_blindbit_boundary).
  6. bip352_vectors.rs, live K_max hunk: edit = both lines:
    let shared_secret = bdk_sp::compute_shared_secret(&scan_sk, &tweak);
    let (_, found) = live_receive(given, &given.labels, &tx, tweak, "live-kmax");
  7. Follow-ups with no textual conflict (needed to build / keep docs true):

After these steps: grep -rn 'scan_transaction_full\|enforce_k_max_at_the_blindbit_boundary\|full_item' blindbit-lib/src finds nothing; no conflict markers.

Nothing calls Scanner::scan_transaction_full: the daemon receives through
scan_transaction_short plus apply_block_relevant on the external indexer,
and only the BIP-352 vector tests reached the full path.

Removed:
- Scanner::scan_transaction_full and the imports only it used
- utils::construct_dummy_tx, placeholder_txout and their unit tests
- the five full-path vector tests (full receive boundary, sparse vout
  layouts, K_max at the boundary, both label parities, extra change
  label) and the helpers only they used (full_item,
  assert_spout_invariants, the sparse layout and per-vout amounts);
  build_transaction_at is folded into build_transaction

Kept:
- BIP352_K_MAX, now #[expect(dead_code)]: SNB-540 (PR #18) uses it for
  the live-path enforcement and its compile-time assert against
  bdk_sp::K_MAX, which will fail the expectation and force its removal
- every live/short-path vector test unchanged (including the ignored
  live K_max test), fixture_loader_is_strict and the input-tweak test

Added:
- official_vectors_derive_expected_addresses: the address check that
  only ran inside the full-path boundary test, now for all 29 receiving
  sub-cases, plus the sp_address the Electrum index serves
- official_vectors_extra_change_label_is_harmless_on_the_live_path: the
  change-label comparison ported to the live receive step (live_receive
  takes the label set to register)

Docs and comments that described the full path are reworded, including
the root Cargo.toml secp256k1-sys opt-level comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
setavenger and others added 3 commits October 11, 2026 08:00
…uts (SNB-662)

Review follow-up. The removed sparse-vout test was the only check that an
output paid after a non-taproot output is stored at its real vout; the live
path depends on that too (bdk_sp's scan_txouts numbers outputs before it
picks the taproot ones), and every other receive test pays taproot outputs
only. The new test puts a P2WPKH output in front of every vector output and
runs the live receive step.

Also rewords the secp256k1-sys opt-level comment, which read as if the
ignored K_max test still ran in CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in the SNB-668 review follow-up (README: http_addr is obsolete but
still accepted). No conflicts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in integration (the merged deslop stack #67-#72) via snb-668-remove-http-api.
No code change: this branch's tree stays the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from snb-668-remove-http-api to integration October 30, 2026 06:33
@setavenger
setavenger merged commit e71bb6f into integration Oct 30, 2026
2 checks passed
@setavenger
setavenger deleted the snb-662-remove-full-receive-path branch October 30, 2026 06:33
setavenger added a commit that referenced this pull request Oct 30, 2026
Brings #18 up to date with master after the Friglet Deslop cleanup (#67-#76).
Conflicts resolved as described in #75:

- blindbit-lib/Cargo.toml, friglet/Cargo.toml: keep #18's bdk-sp rev pin and
  comments on top of the reduced manifest lines from SNB-670.
- scanning.rs: BIP352_K_MAX loses its #[expect(dead_code)] (the compile-time
  assert against bdk_sp::K_MAX now uses it); its doc no longer mentions the
  removed scan_transaction_full, which stays deleted.
- bip352_vectors.rs: the full-path K_max boundary test stays deleted; the live
  K_max test takes the label set and imports BIP352_K_MAX; its doc no longer
  links the deleted test.
- Cargo.toml: the secp256k1-sys comment no longer says the live K_max test is
  ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant