Repository navigation
refactor(platform-wallet): wake the SPV readiness wait on events instead of polling - #5426
Claudius-Maginificent wants to merge 2 commits into
Conversation
…of polling `SpvRuntime::wait_until_ready` slept 250 ms between readiness checks. It now parks on a `tokio::sync::Notify` woken by the two transitions that can make a broadcast possible: `start` storing the client, and `PeerTracker` storing a dash-spv `PeersUpdated` snapshot. The waiter enables its `Notified` before each check, so a transition racing the check is never lost; it stays inside `tokio::time::timeout`, so huge FFI budgets still saturate instead of panicking. The "peers listed but client gone" window that `stop` leaves until it clears the tracker no longer costs a re-check every 250 ms: the wait stays parked until something actually changes. Requested in review of #5307 (point 6). <sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PSi8cX229kW2fmLxKW6ir4
|
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 ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Final review complete — no blockers (commit 76c6a1a) · triage: low |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Verified the supplied findings against head 76c6a1a and found no actionable in-scope defects. The readiness waiter registers before checking state, and both readiness-producing transitions notify after storing their updates; the reported constructor concern is speculative, while the fixture duplication is routine cleanup. Validation was static only: the supplied CI snapshot shows Rust wallet and workspace tests skipped, with other checks queued or pending, so the author's reported test results remain independently unconfirmed.
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — The diff is a small, contained replacement of readiness polling with notifications and focused tests, without changing transaction processing or other critical surfaces. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer,glm-5.3-flash— rust-quality (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 98% left, weekly 93% left; passed overgemini-3.8-flash-high(antigravity below 15% reserve: weekly 14% left, 5h 100% left) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort medium); agentphase2-reviewer
|
Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. Wait for the missing reviews, or a writer can post |
|
@coderabbitai review No review for |
|
Ready for review — files with no dedicated owner: QuantumExplorer or shumkov. |
TL;DR
When the app starts with a transaction waiting to be re-sent, the wallet now sends it as soon as it connects to the Dash network, instead of noticing the connection up to a quarter of a second later.
User story
As a wallet user whose pending transaction is re-sent when the app starts, I want it sent the moment the wallet connects to the network, without an extra delay.
Scenario
Actual behavior
The wallet checks four times a second whether it is connected and only sends after the next check, so sending can lag the connection by up to 250 ms.
Expected behavior
The wallet reacts to the connection itself and sends immediately. The visible effect is small: up to 250 ms less delay, and no repeated checks while waiting.
Detailed discussion
Issue being fixed or feature implemented
Raised by the dash-spv author on #5307 (comment, point 6):
SpvRuntime::wait_until_readysleep-polledis_broadcast_ready()(client started and peer snapshot non-empty) every 250 ms.What was done?
wait_until_readynow waits on atokio::sync::Notify. It is woken by the only two transitions that can make the client ready:start()stores the client;PeerTrackerstores a dash-spvPeersUpdatedsnapshot.tokio::time::timeout, so an unrestricted timeout from FFI still saturates instead of panicking. Cancelling the wait is safe.stophas removed the client but not yet cleared the peer tracker, the wait stays parked instead of rechecking every 250 ms.SPV_READINESS_POLL_INTERVALis removed.The return contract is unchanged:
trueonce ready,falseat timeout.How Has This Been Tested?
New tests use paused tokio time:
PeersUpdatedevent;All three failed before the change. The existing readiness tests still pass.
cargo test -p platform-walletpasses. Clippy--all-features --all-targets -D warningsis clean.Breaking Changes
None.
Checklist
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull request🤖 Co-authored by Claudius the Magnificent AI Agent
🤖 Generated with Claude Code
https://claude.ai/code/session_01PSi8cX229kW2fmLxKW6ir4
PR Hygiene ·
76c6a1aCHANGELOG.md) — QuantumExplorer or shumkovrs-platform-wallet(packages/rs-platform-wallet/src/spv/peers.rs,packages/rs-platform-wallet/src/spv/runtime.rs) — approved by llbartekllWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.