feat(platform-wallet): watermark monotonic-merge#3647
Conversation
…accessor Make incremental-sync watermark updates monotonic so concurrent or out-of-order sync completions can never roll a watermark backward. `update_sync_state` now takes the per-field `max()` of the existing watermark and the incoming `AddressSyncResult` (height, timestamp, last_known_recent_block) instead of blind assignment. Add a `pub last_known_recent_block()` provider accessor and `PlatformAddressWallet::sync_watermark()` so callers can read the watermark without going through the `AddressProvider` trait. Includes an in-file unit-test module covering forward advance, backward rejection, per-field merge, and unconditional load-time overwrite. Carved out of #3549 (cluster G, SHA 59cba08 + merges) as a standalone production change. No e2e tests, no rust-dashcore bump: verified `cargo build`/`cargo clippy -p platform-wallet` clean on v3.1-dev against rust-dashcore 53130869 (the watermark logic uses only integer max() and pre-existing types). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR updates sync watermark handling in the platform address provider to use monotonic per-field merges during incremental updates, preventing watermark regression on out-of-order or stale sync completions. A new public ChangesWatermark Monotonicity Guarantee
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
Review GateCommit:
|
Issue being fixed or feature implemented
Incremental platform-address sync watermarks were updated by blind
assignment in
PlatformPaymentAddressProvider::update_sync_state. Whensync results complete out of order (a stale incremental scan finishing
after a newer one), the older result could roll the watermark
backward, causing the wallet to re-scan or under-report sync
progress.
Standalone carve-out of cluster G from #3549 (the e2e PR), extracted
so this correctness fix can land independently of the e2e test suite.
SHA of origin:
59cba08af5(+ merges).What was done?
update_sync_statenow merges each watermark field withmax()(
sync_height,sync_timestamp,last_known_recent_block) so thewatermark is monotonic non-decreasing regardless of completion order.
PlatformPaymentAddressProvider::last_known_recent_block()(
pub) — read-only mirror so wallet-level helpers can read thewatermark without going through the
AddressProvidertrait.PlatformAddressWallet::sync_watermark() -> Option<u64>(zero reported as
None, matching the existing "no storedwatermark" convention).
set_stored_sync_statedocumented as the unconditional load-timeoverwrite (monotonic invariant enforced at update-time, not load).
Only two production files changed:
provider.rs,wallet.rsunderrs-platform-wallet/src/wallet/platform_addresses/. No e2e tests,no rust-dashcore bump, no other clusters.
How Has This Been Tested?
#[cfg(test)]module: forward advance, full backwardrejection, per-field merge (advance + regression + tie), and
unconditional load-time overwrite.
cargo build -p platform-wallet— clean onv3.1-devagainstrust-dashcore
53130869(the pre-bump baseline; this cluster usesonly integer
max()and pre-existing types, so it does notdepend on the test(rs-platform-wallet): e2e suite, Found-025 fix + triage pins #3549 rust-dashcore chainlock bump).
cargo clippy -p platform-wallet --all-targets— zero warnings.Breaking Changes
None. Additive accessors plus a stricter (monotonic) internal merge.
Checklist:
For repository code-owners and collaborators only
Carved out of #3549 (cluster G). 🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests