Repository navigation
fix(friglet): real tip headers, honest broadcast, honest fee answers - #26
Merged
Merged
Conversation
Tip headers (SNB-626). New-block notifications carried whatever header the scanner had stored in the index tip. That is the previous matched block's header, or none at all before the first match, after a restart and after a reorg rollback. Sparrow ignores a tip whose header does not parse, so confirmations froze; a stale header was recorded at the wrong height. The Electrum server now ignores the stored tip header. It uses the header stored for exactly that height, or asks the oracle for the block hash at that height and fetches the 80-byte header from the P2P peer (getheaders with an empty locator), checked against that hash. Each tip is announced once. A tip whose header cannot be fetched is not announced; friglet retries every 15 s. blockchain.block.header backfill uses the same path and no longer downloads whole blocks. Broadcast (SNB-627). Broadcasting sent an unsolicited tx to the peer and always reported success. friglet now has its own small P2P client: bitcoin_p2p hard-codes relay=false, and with that Bitcoin Core never serves mempool transactions. A broadcast: - asks with getdata whether the peer already has the tx, - announces it with inv and hands it over on the peer's getdata, - succeeds only once the peer serves it from its mempool. These end the wait early with a real error: - the peer asks for a parent: bad-txns-inputs-missingorspent; - the peer drops the connection after the hand-over: consensus-invalid; - the fee is below the peer's feefilter: "mempool min fee not met", the wording Sparrow parses. Bitcoin Core's context-free checks run locally first. A resend of the same tx (Sparrow resends after its 3 s read timeout) gets the first attempt's answer. Accepted txs are kept in <state>.pending.json and shown as unconfirmed again after a restart. Every 10 minutes, once the scan has caught up, pending txs are forgotten when confirmed, dropped when a conflicting tx confirms, and re-announced when the peer's mempool lost them. A newer broadcast spending the same input replaces the older one. Fees (SNB-628). estimatefee returns -1, the Electrum protocol's "no estimate"; it used to return a made-up 10 sat/vB. relayfee returns the peer's feefilter (0.1 sat/vB on the signet peer, which runs Bitcoin Core 30) instead of a fixed 1 sat/vB. The fee histogram stays empty, because an error there makes Sparrow reconnect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Live check on signet: a new block reached the Electrum client with its real header. The throwaway wallet has no matches, so no header was stored for this height. The notification therefore took the oracle-hash plus P2P The smoke client hashes the announced 80-byte header and compares it with mempool.space/signet's hash for that height. It also checks that the header's prev-hash equals the previous tip's hash. CI ( |
setavenger
added a commit
that referenced
this pull request
Oct 1, 2026
…nto dogfood/preview No textual conflicts. Resolved by hand so all behaviours stay: - control: restore the `scanner` module import (track A's scan_health mapping uses scanner::ScanHealth); scan_health stays in GetStatus alongside the restart-on-apply semantics. - config: moving a legacy state file to its per-wallet name also moves #26's pending-broadcast file (`*.pending.json`), so unconfirmed broadcasts survive the migration; the pending file is per wallet because it follows the keyed state path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
setavenger
added a commit
that referenced
this pull request
Oct 1, 2026
…ood/preview Brings in the #17/#20/#19/#21/#31 stack. One conflict, in friglet/src/electrum/mod.rs, resolved keeping both sides: - #26's ChainSource (p2p/network/oracle) and pending-broadcast store, - #21's reorg handling: checkpoints behind a mutex, reorg_rx feeding forget_blocks_above; its test now builds the server state with #26's test helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 1, 2026
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.
This makes friglet's Electrum server tell Sparrow the truth about three things: new blocks, broadcasts, and fees.
Linear: SNB-626 (tip headers) · SNB-627 (broadcast) · SNB-628 (fees) · follow-up SNB-629 (verification)
Tip headers (SNB-626)
Problem
WalletElectrumIndex.tip.ElectrumServer.java:2927-2938), so confirmations froze. A stale header was recorded at the wrong height.Fix
tip_headerno longer reads the tip's stored hex.getheadersand an empty locator, on one reused connection, and checks it against the hash.blockchain.block.headerbackfill uses the same path. It no longer downloads a whole block to read 80 bytes.Honest broadcast (SNB-627)
Problem
txand always answered success.rejectsince 0.20, so the old code could not tell a rejection from success.New P2P client:
electrum/p2p.rsbitcoin_p2phard-codesrelay = falsein its version message. With that, Core answers every mempoolgetdatawithnotfound, and we need those answers.How a broadcast works:
electrum/relay.rsgetdata→tx/notfound).inv, and hand it over on the peer'sgetdata.sendrawtransaction, and it usually takes 5–10 s.What ends the wait early with a real error
bad-txns-inputs-missingorspent: …. Sparrow shows its "UTXOs missing or already spent" dialog.feefilter→the transaction was rejected by network rules. … mempool min fee not met, X < Y. Sparrow parses this and tells the user the fee to pay.CheckTransactionreasons) run locally first.Fitting Sparrow's timeouts
TcpTransport.java:37-41,RetryLogic).Persistence:
electrum/pending.rs,<state>.pending.jsonDecided: no fan-out to other peers. Broadcasting from your own IP to random nodes marks you as the origin. The configured peer stays the only relay.
Fees (SNB-628)
What Sparrow 2.5.5 does (from its source):
-1becomes 1 sat/vB.relayfeeormempool.get_fee_histogramdrops the connection.What friglet now answers:
blockchain.estimatefee→-1, the protocol's "no estimate". Before, it returned a made-up 10 sat/vB. friglet has no mempool or fee-market view, and P2P cannot supply fees because input values are unknown.blockchain.relayfee→ the peer'sfeefilter, i.e. its current mempool minimum. The signet peer reports 0.1 sat/vB, as Bitcoin Core 30 does. If the peer can't be read, the answer is 1 sat/vB.mempool.get_fee_histogram→[], unchanged.Verification task 4: not in this PR
blockchain.block.headerswould be cheap with the new header path.transaction.get_merkleneeds a full block per wallet tx. Sparrow also turns any reply other than-32601into "verification refused" and marks the tx unconfirmed. Both stay-32601(verification cleanly off). The design and costs are in SNB-629.Verified
cargo test --workspace: all pass. That includes friglet's 50 tests, 25 of them new.cargo clippy --no-deps -p friglet -p friglet-ipc -p friglet-tray --all-targets -- -D warnings: clean.cargo fmt -p friglet --check: clean.…01), the hosted signet oracle, and peer152.53.151.148:38333(Bitcoin Core 30). The client was a small python script.Not covered live: a fresh, valid tx going through the full
inv→getdata→tx→accepted path. That needs signet coins. The scripted-peer tests cover this path.Notes for other tracks
tip_headerignores the blank header thatrollback_toputs intip. The tip cache is checked against the oracle's hash each time, so a rollback needs no invalidation hook.electrum/mod.rswhen merging fix(scanner): detect chain reorganisations and roll back to the fork point #21:ElectrumServerStatefields:chainreplacesp2p_peer/network/oracle_url, while fix(scanner): detect chain reorganisations and roll back to the fork point #21 wrapsblock_checkpointsin a Mutex.run()arguments: fix(scanner): detect chain reorganisations and roll back to the fork point #21 addsreorg_rx, this PR addspending_file.resolve_block_hash, whose oracle part becomesstate.chain.block_hash(height).ElectrumServerState.main.rschanges by 2 lines: it derivespending_fileviablockheader::pending_pathand passes it toelectrum::run.blindbit_lib::scanner::broadcast_tx(p2p.rs:24-97) has no caller left in friglet. It could be removed.