Skip to content

Release the cryptonote refresh lock on every exit - #1500

Open
sneurlax wants to merge 1 commit into
stagingfrom
fix/cryptonote-refresh-lock
Open

sneurlax wants to merge 1 commit into
stagingfrom
fix/cryptonote-refresh-lock

Conversation

@sneurlax

@sneurlax sneurlax commented Nov 3, 2026

Copy link
Copy Markdown
Member

refresh() in the Monero, Wownero and Salvium wallets released refreshMutex only on success, so a throw after acquire (the Tor mismatch check, or a null wallet) held the lock for the session and wedged every later refresh and rescan. The body now runs under refreshMutex.protect, which also retires the release-at-100% workaround in onSyncingUpdate. Wallet-layer part of the closed #1490; reproduced and verified on Linux with a forced Tor mismatch followed by a successful rescan.

refresh() in the Monero, Wownero and Salvium wallets acquires refreshMutex
and released it only on the success path. Anything thrown after the acquire
(the Tor and clearnet mismatch check, or wallet being null because open()
failed) left the lock held for the rest of the session. Later refreshes
returned early on the isLocked check and recover()'s refreshMutex.protect
waited forever, which is the stuck rescan dialog in stack-wallet #103.

The body now runs under refreshMutex.protect, which releases in a finally
and rethrows, the same way the other wallets and recover() in these files
already use it. That makes the release-at-100% workaround in onSyncingUpdate
redundant, so it is gone from all three wallets. In the Monero wallet
highestPercentCached is reset on both sides of rescanBlockchain: before it,
so a throw leaves the guard at zero, and after it, so a progress reading
from before the rescan cannot be ordered after the reset. Wownero and
Salvium call rescanBlockchain unawaited, so the second reset would change
nothing there and they keep their order.

This is the wallet-layer part of the closed PR #1490, taken on its own.
@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 11.62%. Comparing base (ad1efd5) to head (7e83425).
⚠️ Report is 27 commits behind head on staging.

Files with missing lines Patch % Lines
...wallets/wallet/intermediate/lib_monero_wallet.dart 0.00% 22 Missing ⚠️
...allets/wallet/intermediate/lib_salvium_wallet.dart 0.00% 7 Missing ⚠️
...allets/wallet/intermediate/lib_wownero_wallet.dart 0.00% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           staging    #1500      +/-   ##
===========================================
+ Coverage    10.74%   11.62%   +0.87%     
===========================================
  Files         1132     1134       +2     
  Lines       113993   114177     +184     
===========================================
+ Hits         12254    13272    +1018     
+ Misses      101739   100905     -834     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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