Skip to content

Promote integration to master: P2P resilience, witness blocks, working tray controls and logs - #38

Merged
setavenger merged 8 commits into
masterfrom
promote/2026-10-02
Oct 2, 2026
Merged

setavenger merged 8 commits into
masterfrom
promote/2026-10-02

Conversation

@setavenger

Copy link
Copy Markdown
Owner

Promotes integration (017131a) to master. It contains the fixes for what first-user testing on mainnet turned up on 1 Oct.

The PR comes from promote/2026-10-02, a copy of integration, so the repo's auto-delete-on-merge removes that copy and leaves integration in place. Merge with a merge commit.

What changes for a user

Upgrade notes

  • On first start, existing wallets re-fetch each block that holds one of their transactions, once, to restore witness data.
  • The new log file is created automatically. Set FRIGLET_LOG_FILE=off to disable it, or point it elsewhere.

Verification

Not verified yet

  • Real Hyprland/Omarchy.
  • A full mainnet session with Sparrow.
  • Stopping during a real 90 s download: covered only by a unit test. Making the download cancellable is the next change.

setavenger and others added 8 commits October 1, 2026 21:33
The placeholder icon drew a refrigerator, a misreading of the name.
Friglet is a lightweight take on Frigate, Sparrow's Silent Payments
Electrum server, so the mark is now a little ship: two white sails over
an orange hull on the same dark rounded square.

generate.py stays the stdlib-only source of every icon file and now
anti-aliases with 4x4 supersampling. The sizes and Tauri paths are
unchanged, and a rerun reproduces the committed files byte for byte.

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

A first mainnet run stalled on block 921,763 with "block fetch from
152.53.151.148:8333 failed (peer closed the connection) ... failed to fill
whole buffer". Probing that node shows it closes every inbound connection
44-350 ms after accepting it, even with no request at all. A fetch only
succeeds when the 0.8 MB block arrives first (4 of 10 attempts from here).
The old fetch gave up after 4 attempts and published the raw I/O error.
watch_chain then retried every 10 s, without saying so or what to do.

- p2p::BlockFetcher replaces Scanner::fetch_block_with_retry's loop. Each
  attempt opens a fresh connection, and waits of 1, 2, 4 and 8 s separate
  the 5 attempts. Failures a retry cannot fix (notfound, silence, wrong
  network, failed handshake) end the round at once.
- Each failure is classified (FetchFailure). BlockFetchError's message
  says what the node did and what to do about it. The cases: a node that
  drops friglet (whitelist=download,noban@IP, -maxuploadtarget for
  historical blocks), a node that rejects the handshake (another network,
  including a port hint; banned; full), a pruned node (prune=0), a syncing
  node, refused connections, and a service that is not Bitcoin P2P.
- watch_chain retries a block the node will not serve after 30 s, then on
  an interval that doubles up to 5 min (FetchBackoff). The stall message
  states the next try and how often it has failed.
- examples/fetch_block fetches one block the way the scanner does, for
  checking a node by hand.

Refs SNB-657

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The scanner asked for blocks with MSG_BLOCK, so every block came stripped
of witness data. The wallet stored its transactions that way, and
blockchain.transaction.get served them to Sparrow that way. Txids were
right but sizes and fee rates were wrong. Witness-bearing copies of
broadcast transactions were also overwritten once they confirmed.

- getdata asks for MSG_WITNESS_BLOCK.
- Every fetched block is checked before use: it must be the block asked
  for, match its merkle root, and match its witness commitment. A
  committed block whose coinbase lacks the reserved value was stripped
  (FetchFailure::WitnessStripped). Any other mismatch is a BadBlock.
  Both are retried on a fresh connection and explained in the message.
- State files written before this fix hold stripped wallet transactions.
  watch_chain now fetches their blocks again, once, and puts the
  witnesses back into the BDK graph (which keeps the non-empty witness),
  the saved state (stripped copies dropped) and the Electrum index. If a
  block can't be fetched, it waits 5 min before trying again.
- txid vs wtxid: every Electrum key and history entry already uses the
  txid, and mempool membership lookups only compare txids, so neither
  changes. The tests check that the served bytes keep their wtxid.

Tests: a fake node that, like Bitcoin Core, serves witnesses only to
MSG_WITNESS_BLOCK. A taproot payment fetched over P2P round-trips with
its witness to the Electrum index and through a restart. A node that
strips witnesses is refused and retried. Stored stripped transactions
get their witnesses back. A friglet test checks that
blockchain.transaction.get returns the spend with its witness, wtxid
and vsize.

Refs SNB-657

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s, log files (SNB-658)

Scanning controls
- ScanSupervisor kept reporting "not running" the moment Stop was asked,
  while the scan task could not end until its next await: blindbit-lib's
  P2P block download is blocking I/O inside the scan future (up to 90 s
  per attempt). The UI then offered Start, and the Stop request held the
  apply lock, so a Start queued behind it resumed scanning right after.
  The task entry now stays until the task really ended (ScanState
  Stopping -> Paused), Stop answers within 3 s (with a note while still
  stopping), Start while stopping is refused, the select! checks the
  cancellation first, and the pause survives an in-process restart.
- GetStatus no longer waits on the oracle (a background poller keeps the
  tip): an unresponsive oracle made every status answer take ~2 s, longer
  than the tray's poll timeout, so the tray called the daemon unreachable
  and eventually killed it as wedged.

Daemon controls
- Stop daemon / Start daemon in the window and the tray menu, for a
  tray-spawned daemon and an attached external one alike; the Status tab
  says who started it and what Quit does. An explicit stop, and a daemon
  exiting with status 0, are never undone by the auto-restart supervisor.

Errors vs waiting
- view.rs derives what is shown: a stall or oracle outage is "waiting" for
  2 minutes, an unanswering daemon "reconnecting" for 10 s, then an error.
  Errors stay under "Needs attention" with their start time until
  resolved and remain in a Recent errors list; each one is logged.
- The setup flow no longer flashes "Daemon unreachable": attach/spawn
  publishes the daemon's status at once instead of waiting for the next
  poll.

Logs
- The daemon writes friglet.log and the tray friglet-tray.log in
  $XDG_STATE_HOME/friglet (macOS ~/Library/Logs/friglet, Windows
  %LOCALAPPDATA%\friglet\logs), 10 MiB cap with two rotations;
  FRIGLET_LOG_FILE overrides or turns off the daemon's. Logging starts
  before the config is read, so config errors land in the file too. The
  tray forwards daemon output at its own level (info/warn/error), shows
  both paths and has an Open log folder button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix(scanner): fetch witness blocks so Sparrow gets whole transactions (SNB-657, stacked on #35)
friglet-tray: real Stop scanning / daemon controls, no flashing errors, daemon log file (SNB-658)
@setavenger
setavenger merged commit 40e6af0 into master Oct 2, 2026
5 of 6 checks passed
@setavenger
setavenger deleted the promote/2026-10-02 branch October 2, 2026 12:59
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