Repository navigation
friglet: count restored wallet outputs at startup (SNB-689) - #64
Closed
setavenger wants to merge 6 commits into
Closed
setavenger wants to merge 6 commits into
setavenger wants to merge 6 commits into
Conversation
The Electrum server built the same things in several places. One copy of each now: - notification(): the JSON-RPC notification line (was written out four times); sp_subscription(): the SP subscription object and its notification, shared by the push task and the subscribe handler. - invalid_param(): the -32602 answer for a missing or mistyped first parameter (block.header, scripthash.subscribe/get_history, transaction.get); the messages are unchanged. - save_header_sidecar(): the header-sidecar write after a backfill and after a reorg. - Peer::header_by_hash() takes one hash (its only caller passed a one-element slice) and returns only a header with that hash, so the two re-checks of the same hash in ChainSource::header and backfill_header go. - relay: connect_settled() (connect + settle, the 2 s literal is now p2p::SETTLE_WAIT, also used by ChainSource::fee_filter), Candidate::wire_tx() and Signals::announce() replace two or three copies each. - index_unconfirmed_tx: two match arms that both did nothing are one condition. - Two tests build their request with call() like the others. The bytes on the wire are unchanged: a scripted session of 52 requests and 8 push batches gives byte-identical output before and after. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(SNB-664) Leftovers from the live scanner swap and from earlier refactors: - ControlCtx keeps the Electrum index and the label addresses directly; the std Mutex around each was never written after the live rebuild-and-swap went away (#29). The Start comment that still described the swap is fixed. - One-line wrappers around friglet-ipc are gone (default_config_path, default_key_file, write_config_file, write_key_file, replace_scan_key); apply() writes the key it already parsed instead of having replace_scan_key parse it again. - pick_tip was `oracle.or(electrum)`; inlined, with its test. - control's unix_now duplicated pending::now_secs. - The key file's "first non-empty line" is read by one helper. - ResolvedConfig no longer copies oracle_url, max_label_num, http_addr and electrum_addr out of `raw`. - main no longer sets sp_start_height a second time right after rebuild_electrum_index_from_graph set it. - control::run takes the ControlCtx instead of a generic handler; its only other user was get_status_roundtrip_over_control_socket, which repeated friglet-ipc's roundtrip test and every serve_ctx test. - supervisor: stop_during_a_download_pauses_at_once repeated the cooperative-cancel tests and left a 30 s thread behind. - fake_peer: the single-field Seen struct is a Vec. - Stale comments: types.rs, the --oracle-url default, electrum::run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(SNB-685) apply() took apply_lock first and then looked up a new wallet's birthday at the oracle (up to 15 s) and resolved the P2P host name (blocking DNS) while holding it, so a Stop or Start sent during an ApplySettings with start_at_tip waited for both. Both lookups now run in prepare(), before the lock. Under the lock apply() still reads the current settings, compares, persists and requests the restart, so a settings change still never interleaves with Start/Stop or another apply. A SetScanKey (no config of its own) whose settings snapshot was replaced by another apply while it waited for the lock prepares again from the newer settings, as if the two had run one after the other. Tests: Stop and Start answer within a second while an apply waits on an oracle that never answers (the old code timed out after 2 s); a SetScanKey that waited behind another apply keeps that apply's settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: when a SetScanKey's settings snapshot had been replaced by another apply while it waited for the lock, it prepared again (oracle birthday lookup, blocking DNS) while holding apply_lock, so Start/Stop could still wait behind the network in that case, and the field doc was not true. apply() now drops the lock, prepares again from the new settings and takes the lock again to check; it persists only once the settings it prepared from are the ones under the lock. Comparing and persisting still happen under the lock only, so Start/Stop never see a half-applied change and two applies never mix their writes. New test: settings replaced (by a config whose preparation waits on an oracle that never answers) while a SetScanKey waited for the lock; Stop and Start still answer within a second, nothing is persisted. With the re-prepare under the lock, Stop timed out after 2 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Initialize outputs_found from the restored scanner instead of parsing the state JSON again. Legacy state files rebuild their owned-output records on restore, so the startup status now reports the wallet's actual count. Keep coverage for absent, invalid and bare-key legacy state files. The regression test reports 0 instead of 2 with the old counter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Use the legacy fixture's wallet keys and abort the runtime-owned oracle listener after restore, avoiding process-lifetime server threads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Merged into |
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.
Stacked on #60 (on #53); review only the commit after it.
Fixes SNB-689. Startup status now counts the restored scanner's owned outputs instead of parsing the state JSON a second time. Old-format wallets rebuild these records during restore, so a wallet with two known outputs now reports
outputs_found = 2immediately.The restore and migration code is unchanged. The existing state-tolerance test now covers real restore of missing, invalid, format-0 and bare-key legacy files. It fails on the old counter (
0instead of2) and passes with the fix.Validation (debug builds, private target directory):
cargo check --workspace --all-targets --all-features: passed, no warnings.cargo clippy --no-deps -p friglet -p friglet-ipc -p friglet-tray --all-targets -- -D warnings: passed.cargo fmt -p friglet -p friglet-ipc -p friglet-tray -- --check: passed.cargo test --workspace: 254 passed, 1 ignored, 0 failed.cargo build -p friglet: passed. Real daemon using a copy of the legacy fixture and an isolated config/key/state directory: control socket answered after 23 ms withoutputs_found = 2; Shutdown returned Ok and the process exited cleanly.No live oracle or real wallet files were used.
Independent review: production change cleared. Follow-up matches the fixture wallet keys and aborts a runtime-owned oracle listener after restore. All pre-push checks passed again (254 passed, 1 ignored). One earlier rerun hit the unchanged
a_node_that_drops_every_connection_says_how_to_fix_ittiming assertion (peer closed during handshake); the subsequent full run passed.