Repository navigation
Conversation
…lock A canceled ML-DSA-44 address listing can leave its worker on the shared DAG-info route for up to 30 s. GetBalance waited for that route while it held the wallet's read lock, so NewAddress and other writers waited with it, and it kept waiting after its own caller canceled. GetBalance now fetches DAG info before it takes the lock, with the request's context and the same 30 s bound. A slightly older DAA score only keeps more coins pending. GetBalance now asks for DAG info on every call, so an unsynced or empty wallet also waits for the route before it answers. AI disclosure: prepared with AI assistance (OpenAI Codex and Claude by Anthropic). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dline When a recent address batch left the window while a slow poll still had to be verified, the old-cursor re-check was queued at the poll's next time only. That re-check could be served the node's cached negative for an address checked late in the slow poll and cleared the handoff, so a coin waited for the old cursor's next round. The handoff now queues the poll's next time and, when later, its verification deadline as separate re-checks: the first still finds coins at addresses checked early, the second those checked late. Only an identical pending handoff is skipped. AI disclosure: prepared with AI assistance (OpenAI Codex and Claude by Anthropic). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l grows Growing a single-sig ML-DSA-44 pool derived only the missing indexes and kept every stored hash, so a well-formed but wrong hash in keys.json stayed and could later be handed out as an address this wallet cannot spend from. Before this series, growth derived the whole pool again. Growth now derives the stored hashes again, compares them, replaces those that differ and reports how many, with or without --count. This costs re-deriving the stored pool on each growth instead of only the new suffix. The default run's limit still counts only new hashes; its storage limit bounds the re-derived ones. A pool that already covers the requested count is not checked. AI disclosure: prepared with AI assistance (OpenAI Codex and Claude by Anthropic). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
import-mldsa44-keys read keys.json and only then took its lock. A generate-mldsa44-keys run that saved between the two was overwritten with the older snapshot, shortening the local pool again. Import now takes the lock before it reads, as generation does. AI disclosure: prepared with AI assistance (OpenAI Codex and Claude by Anthropic). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a compound pays an owned ML-DSA-44 P2SH address past the last used index, the daemon records that index first. If the save renamed the keys file but the directory sync failed, the plain setters kept the new index in memory, so a retried compound found nothing to save and went ahead without a durable record. Both chains now use a reservation that restores the index on a failed save, as send change already does: ReserveExternalIndex joins ReserveInternalIndex. AI disclosure: prepared with AI assistance (OpenAI Codex and Claude by Anthropic). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…evisits it When the old-address cursor came back to a batch before that batch's re-check was due, it replaced the re-check with a new one 32 s after the revisit. The revisit can be served the same cached negative the re-check waits out, so a coin could be found up to about 30 s later. A cursor scan now clears only the re-checks already due when it started, and queues its own as before. AI disclosure: prepared with AI assistance (OpenAI Codex and Claude by Anthropic). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… no work When a generate-mldsa44-keys run renamed the new keys file into place but failed to sync the directory, it reported the error. A retry then saw the new file, found no work and reported success without syncing, so a power loss could still bring back the old pool. Before this series, multisig generation saved again in that case. A run without work now syncs the keys file's directory, under the file lock, before it reports success. AI disclosure: prepared with AI assistance (OpenAI Codex and Claude by Anthropic). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Test-only. The recent-poll tests now check the node's cache entry for the target at the intended check time, and the fake node records which addresses it answered, so the startup and failed sweeps are shown to have asked about the target and batch 0. The stale-answer test requires the queued re-check before indexing the queue. The forced-sync burst test follows one old batch's re-check and requires that it scans the batch when due. The no-rewrite check takes the file identity from an open handle, which also holds on Windows. AI disclosure: prepared with AI assistance (OpenAI Codex and Claude by Anthropic). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
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.
Base:
2.19.2(the head of #135), so it can go in before #135 merges.This answers CodeRabbit's review of #135. The seven fix commits each address one finding with its own test; the last commit tightens tests for seven test comments. The fixes are separated for review; 5 and 7 share a test helper.
1. wait for DAG info before GetBalance takes the wallet lock (comment)
Problem: a canceled ML-DSA-44 address listing leaves its worker owning the shared DAG-info route until the node RPC (and any reconnect) finishes. GetBalance waited for it while holding the wallet's read lock, so NewAddress and other writers waited too, and it kept waiting after its own caller canceled.
Change: GetBalance fetches DAG info before it takes the lock and limits its combined DAG-info queue and reply wait to 30 s or the caller's earlier deadline. GetBalance now asks for DAG info on every call, so an empty or unsynced wallet also waits for the route before it answers. Other calls that wait for the route under the lock (ML-DSA-44 NewAddress, sends, compounds, external UTXOs) are unchanged.
Test:
TestGetBalanceWaitsForDAGInfoOutsideWalletLockholds the route, waits until GetBalance is blocked on it, then checks that a writer can take the lock; a second case cancels the request and expects a promptCanceled.2. hand off a slow recent poll with its verification deadline (comment)
Problem: when a recent batch left the window during a slow poll's verification, the handoff used the poll's next time only. That re-check could get the node's cached negative for an address checked late and clear the handoff.
Change: the handoff queues the next time and, when later, the verification deadline as two re-checks. Only an identical pending handoff is skipped.
Test:
TestHandoffKeepsSlowPollDeadlines: an address checked early is found at 32 s, one checked late at 36 s (58 s without the change in this fixture).3. check stored single-sig ML-DSA-44 hashes when the pool grows (comment)
Problem: growing a single-sig pool kept every stored hash, so a well-formed but wrong hash in keys.json could later become an address this wallet cannot spend from. Before this series, growth derived the whole pool again.
Change: growth derives the stored hashes again, replaces those that differ and reports how many, with or without
--count. This keeps the pre-series repair on growth rather than the suffix-only growth plus explicit repair that the comment suggested. Cost: each growth re-derives the stored pool, not only the new suffix (for admitted default growth at most about 31,300 derivations, a few seconds on the machine we measured). The default run's work limit still counts only new hashes. Limit: a pool that already covers the requested count is not checked.Test:
TestGenerateMLDSA44SingleSigGrowthRepairsStoredHashes(default growth repairs and reports);TestGenerateMLDSA44ImplicitWorkCountsOnlyNewHashes(a 202-hash extension of a 10,000-index pool still passes the limits).4. lock the keys file before import-mldsa44-keys reads it (review comment, generate_mldsa44_keys.go:175)
Problem: import read keys.json before taking its lock, so a generation run that saved in between was overwritten with the older snapshot.
Change: import takes the lock before it reads. The "stop the wallet daemon" hint stays.
Test:
TestImportMLDSA44KeysReadsUnderLockholds the lock over an unreadable file and expects the lock error, not a decode error.5. keep a compound destination's index save retryable (comment)
Problem: if saving the index of an owned compound destination renamed the file but the directory sync failed, the index stayed in memory, so a retry skipped the save.
Change:
ReserveExternalIndexjoinsReserveInternalIndex; compound tracking uses both.Test:
TestExternalReservationRetriesAfterDirectorySyncFailure: two failed reservations leave the index unrecorded, and the retry saves and syncs once. It does not build without the change; the same test with the plain setter fails. The reservation helper is tested; the two daemon call sites are verified by inspection.6. keep an old batch's pending re-check when the round revisits it (comment)
Problem: a cursor visit before a batch's re-check was due replaced that re-check with a later one, although the visit could get the same cached negative.
Change: a cursor scan clears only the re-checks already due when it started. A batch can now hold more than one pending re-check, and a revisit can cost one extra scan.
Test:
TestOldCursorRevisitKeepsPendingRecheckfinds the coin at the 32 s re-check.TestNoSyncAsksMoreThanBeforestill passes.7. sync the keys directory when ML-DSA-44 generation has no work (comment)
Problem: after a run renamed the new keys file but failed to sync the directory, a retry found no work and reported success without syncing. Before this series, multisig generation saved again in that case.
Change: a run without work syncs the keys file's directory under the file lock (new
File.SyncDirectory; on Windows this stays the existing no-op).Test:
TestGenerateMLDSA44WithoutWorkSyncsDirectory(Unix, not as root) makes the directory unopenable and expects the error;TestSyncDirectoryReportsAndCompletesTheSynccovers the helper.8. tighten wallet sync and key generation tests (comments 4732331181, 4732331186, 4732331192, 4732331195, 4732331201, 4732331210, 4732331223)
Test-only: check the node's cache entry at the intended check time, record which addresses the fake node answered, guard the queue index, follow one re-check through the forced-sync burst, and take the file identity from an open handle (correct on Windows). For 4732331195 only the t=0 cache-entry check is added; the reply-clock ordering is still implied by the fake clock. These pass on the parent by design; the burst check fails if due re-checks are dropped without a scan.
Validation. Each fix's test fails on its parent, except where noted above (5's and 7's helper tests do not build there). On every commit:
gofmt -lempty,go vet ./cmd/htnwallet/...andgo test -race -count=1 ./cmd/htnwallet/...pass with Go 1.27.4 on linux/amd64.Compatibility and limits. No change to the keys file format, the daemon API or the network protocol. Changed behaviour: GetBalance waits for DAG info on every call, and that wait observes caller cancellation; single-sig growth costs a re-derivation of the stored pool; a generation run without work syncs the directory (Unix; a no-op on Windows as before).
Not changed: 4732331172 is real on a network where ML-DSA-44 is not active yet (an owned, not yet discovered ML-DSA-44 P2SH coin can be offered as spendable); deferred. 4732331222 changes a log level only. 4732331234: accepting a corrected peer pool is a missing repair step that predates this series (
keys/mldsa44_exchange.gois unchanged). 4732331176: a test port race, deferred; fixing it needs a daemon start that takes a listener.AI disclosure: prepared with AI assistance (OpenAI Codex and Claude by Anthropic).