Skip to content

fix(platform-wallet): serialize pending crypto writes with identity removal - #4649

Merged
lklimek merged 3 commits into
v4.2-devfrom
fix/pws-pending-crypto-removal
Sep 10, 2026
Merged

lklimek merged 3 commits into
v4.2-devfrom
fix/pws-pending-crypto-removal

Conversation

@lklimek

@lklimek lklimek commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Prevent background DashPay queue writes from leaving stale records after an identity is removed. Also repair the storage writer's rustdoc link. Follow-up to #4496.

Issue being fixed or feature implemented

A queue write could reach storage after a concurrent identity removal had finished its cleanup. This race predates #4496; the separate documentation issue comes from the writer rename in that PR.

What was done?

  • Keep the wallet manager write guard through synchronous persistence for contact-info decrypt, auto-accept, and deferred account-build enqueue operations.
  • Add deterministic tests for all three paths: removal cannot acquire the guard during queue persistence, and enqueue attempts after owner removal do not write entries.
  • Point ensure_exists documentation to apply_upserts.

How Has This Been Tested?

  • Three new wallet regression tests: failed against the old guard scopes and pass with the fix.
  • All 13 sqlite_identity_hard_delete tests pass, including V018 migration with foreign keys enabled and disabled.
  • cargo fmt -p platform-wallet -p platform-wallet-storage -- --check
  • cargo clippy -p platform-wallet -p platform-wallet-storage --all-targets --all-features --locked -- --no-deps -D warnings

The concurrency tests use a mock SDK and a checking persistence backend; no network is required.

Breaking Changes

None.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Co-authored by Claudius the Magnificent AI Agent

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability when processing pending contact information and contact requests during identity removal.
    • Prevented stale pending-crypto updates from being written after the associated owner identity has been removed.
    • Ensured queued contact updates are processed safely and consistently during concurrent wallet operations.
  • Tests

    • Added coverage for identity removal and pending contact-crypto persistence interactions.
  • Documentation

    • Updated test-helper documentation to reference the current operation name.

lklimek and others added 2 commits September 10, 2026 08:49
Point the test helper documentation to apply_upserts.

Co-Authored-By: Codex <[email protected]>
…emoval

Keep the wallet manager write guard through persistence in all three
pending-crypto enqueue paths. Add deterministic regression tests for
exclusion during storage and rejection after owner removal.

Co-Authored-By: Codex <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 7d8b1c4f-f64b-47da-9a3d-11290901bcd8

📥 Commits

Reviewing files that changed from the base of the PR and between 67cacad and 003d7b1.

📒 Files selected for processing (5)
  • packages/rs-platform-wallet-storage/src/sqlite/schema/identities.rs
  • packages/rs-platform-wallet/src/wallet/identity/network/contact_info.rs
  • packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs
  • packages/rs-platform-wallet/src/wallet/identity/network/mod.rs
  • packages/rs-platform-wallet/src/wallet/identity/network/pending_crypto_tests.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The change extends the wallet-manager write lock through pending contact-crypto persistence. New test fixtures and tests verify that identity removal prevents subsequent enqueue writes.

Changes

Pending crypto serialization

Layer / File(s) Summary
Enqueue lock coverage
packages/rs-platform-wallet/src/wallet/identity/network/contact_info.rs, packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs, packages/rs-platform-wallet-storage/src/sqlite/schema/identities.rs
Enqueue methods retain the wallet-manager write lock through persistence. The schema documentation now references apply_upserts.
Pending crypto test fixture
packages/rs-platform-wallet/src/wallet/identity/network/pending_crypto_tests.rs, packages/rs-platform-wallet/src/wallet/identity/network/mod.rs
Adds checked persistence, wallet setup, event-handler, and identity-removal helpers for lock-ordering tests.
Enqueue serialization tests
packages/rs-platform-wallet/src/wallet/identity/network/contact_info.rs, packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs
Verifies that enqueue operations do not add backend writes after the owner identity is removed.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 003d7

Pending contact-crypto writes are now serialized with identity removal, preventing stale records from being persisted. The covered regression tests and reported checks leave no merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: serializing pending crypto writes with identity removal to fix the race condition.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pws-pending-crypto-removal

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added this to the v4.2.0 milestone Sep 10, 2026
@lklimek
lklimek marked this pull request as ready for review September 10, 2026 13:44
@thepastaclaw

thepastaclaw commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

🕓 Queued for automated review — 19th in line, estimated start in ~6 h (commit 003d7b1)
Estimated review time once started: ~40 min (two-phase automated review; median of recent runs).

  • Request priority review — tick this box and the review moves to the front of the queue.

@llbartekll llbartekll left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 003d7b1. The write-guard scope correctly serializes all three pending-contact-crypto persistence paths with identity removal, and the regression coverage exercises both lock exclusion and post-removal enqueue rejection. No blocking findings.

@lklimek
lklimek merged commit 63cf57f into v4.2-dev Sep 10, 2026
30 checks passed
@lklimek
lklimek deleted the fix/pws-pending-crypto-removal branch September 10, 2026 15:26
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.

3 participants