Skip to content

blindbit-lib: remove dead scanner API and P2P leftovers (SNB-663) - #44

Closed
setavenger wants to merge 1 commit into
integrationfrom
snb-663-dead-scanner-api
Closed

setavenger wants to merge 1 commit into
integrationfrom
snb-663-dead-scanner-api

Conversation

@setavenger

@setavenger setavenger commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Linear: SNB-663

Net: 62 insertions, 383 deletions (−321 lines), all in blindbit-lib/src/scanner/.

What was removed and why it was dead

I searched for every item in this workspace and in the other repos that use blindbit-lib (blindbit-node-apps, blindbit-testkit, blindbit-desktop, and the talk benchmark rust_scan_bench). None of them uses any of these items.

  • broadcast_tx (p2p.rs) and its re-export. Its only caller was friglet's Electrum broadcast, which has used friglet's own relay since fix(friglet): real tip headers, honest broadcast, honest fee answers #26.
  • Scanner::from_config, get_last_scanned_block_height_rescan, staged_mut, take_staged, and the commented-out get_outputs.
  • watch_chain: friglet calls watch_chain_until. Its doc text moved to watch_chain_until, and comments that named watch_chain now name watch_chain_until.
  • BlockIdentifierDisplay (only .0.block_height was ever read; the debug line now logs height directly), OwnedOutput (never built), ProbableMatch::new (replaced by a struct literal), _match_short_pubkey_bytes, and the commented-out ScannerConfig Default.
  • pub mod electrum_index is now private. Everything friglet uses from it is still re-exported from scanner.
  • The spent-outpoint and probabilistic-match channels (subscribe_to_spent_outpoints, subscribe_to_probabilistic_matches, their fields and senders), and the code that only fed them:
    • They had no subscribers, and they never sent anything: each send was behind if sender.is_empty() { continue }. is_empty() means "no queued value", so the send was always skipped.
    • The malformed-hash branch in scan_short_block_data only existed to guard those sends, and it cannot run. check_block_identifier rejects any block whose hash is not 32 bytes before scan_short_block_data is called, and the test helpers that call it directly always pass a real hash. The spent-output prefix check therefore now runs unconditionally, which is what already happened in every reachable case.
    • The "possible spend of owned output; fetching block to confirm" log line is kept.
  • save_to_file back-filling the keys and max_label_num (done only because the item was proven):
    • stage gets both keys and max_label_num in new and in from_changeset. ChangeSet::merge never clears them, and only take_staged could replace stage with an empty one.
    • Proof: I temporarily replaced the back-fill with assertions that it would change nothing (keys present; max_label_num != 0 || label_lookup.len() <= 1) and ran cargo test --workspace. All 254 tests passed, and no assertion fired. Those tests cover fresh scanners, restores from the old-format fixture, reorg rollbacks and friglet's own saves.
  • P2P leftovers in p2p.rs:
    • TimeoutParams read/write setters: bitcoin-p2p's handshake (rev 322c4ab, src/net.rs) reads only ping_interval from TimeoutParams. The socket read/write timeouts were already set directly on the stream, so the handshake now gets TimeoutParams::default(), which has the same ping interval.
    • History notes about deleted code (the old 1-second timeout, the removed post-handshake drain). The technical point of the second note is kept in the present tense.
    • The fetch retry doc listed only connect/closed/broken as retried. It now points at FetchFailure::is_transient, which also retries a witness-stripped or bad block (added in fix(scanner): fetch witness blocks so Sparrow gets whole transactions (SNB-657, stacked on #35) #36).

Why behaviour is unchanged

No code path that runs today changes. The removed items have no callers. The removed sends never fired, and the removed branch could not be reached. The back-fill never did anything; the assertion run above shows that. The handshake gets the same parameters it actually read. Log strings friglet-ui matches are untouched, and so are Scanner::new, scan_transaction_short and OracleServiceClient::new (the talk benchmark uses them).

Verification

  • cargo check --workspace --all-targets --all-features → 0 warnings (baseline 0).
  • cargo check -p blindbit-lib --no-default-features --all-targets → 5 warnings (baseline 5, the same ones in load.rs).
  • cargo clippy --no-deps -p friglet -p friglet-ipc -p friglet-tray --all-targets -- -D warnings → clean.
  • cargo fmt -p friglet -p friglet-ipc -p friglet-tray -- --check → clean. blindbit-lib edits are formatted by hand to match the surrounding code.
  • cargo test --workspace → 254 passed, 1 ignored, 0 failed (baseline is the same; no test removed).

Deliberately left out

  • The re-exports of ChangeSet, STATE_FORMAT_VERSION, REORG_LOOKBACK, ReorgTooDeep and OwnedOutputRecord (the issue's mod.rs:36,46,48). They are not unused:
    • load.rs and the tests use them through these paths.
    • These types appear in public signatures and docs: staged(), from_changeset, load_from_file, owned_outputs(), and scan_block_range documents ReorgTooDeep as its error. Dropping the names would leave callers unable to name or downcast them.
    • SNB-661 lists narrowing pub that is only visibility noise as not planned.
    • Only the re-exports of deleted items (BlockIdentifierDisplay, OwnedOutput, broadcast_tx) are removed.
  • The stale todo in scan_short_block_data belongs to SNB-669 (scan-loop comments) and is left for that PR.

Remove public items nothing calls, in this workspace or in the other
repos that use blindbit-lib (blindbit-node-apps, testkit, the talk
benchmark):

- broadcast_tx: its only caller, friglet's Electrum broadcast, uses
  friglet's own relay since #26.
- Scanner::from_config, get_last_scanned_block_height_rescan,
  staged_mut, take_staged and the commented-out get_outputs.
- watch_chain: friglet calls watch_chain_until; its doc moves there.
- BlockIdentifierDisplay (only .0.block_height was read), OwnedOutput
  (never built), ProbableMatch::new, _match_short_pubkey_bytes and the
  commented-out ScannerConfig Default. electrum_index becomes a private
  module; its items stay re-exported.
- The spent-outpoint and probabilistic-match channels and the code that
  only fed them. They had no subscribers and never sent anything: the
  sends were guarded by Sender::is_empty(), which means "no queued
  value", so they were always skipped. The malformed-hash branch that
  guarded them cannot run: check_block_identifier rejects such a block
  before scan_short_block_data sees it. The "possible spend of owned
  output" log line stays.
- save_to_file's back-fill of keys and max_label_num: stage holds them
  from construction on and only take_staged could clear them. A test
  run with assertions in place of the back-fill passed every workspace
  test.
- P2P: TimeoutParams setters the handshake never reads (it only uses
  the ping interval; the socket timeouts are set directly), history
  notes about deleted code, and a retry doc that predates the
  witness-stripped and bad-block retries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@setavenger

Copy link
Copy Markdown
Owner Author

Merged into integration through #68 on 2026-10-11 (the user live-tested the combined stack first). GitHub's stacked-PR merge rebased the stack, so this PR's commits landed with new IDs and GitHub can't mark it merged itself. The code is identical: integration now has the same tree as the tested branch friglet-deslop-live-test (08bf11d), which contains this PR's head. Closing as merged via #68.

@setavenger setavenger closed this Oct 11, 2026
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