Skip to content

swift-sdk: store the DashPay backfill record so iOS does not rewind again on every launch #5864

Open

Description

@llbartekll

Problem

On iOS the DashPay coreHeight backfill is not durable. A wallet that needed the backfill rescan (a contact request created below the wallet's sync cursor) rewinds and walks the same block range again on every launch. This is the #4302 behaviour: slow, never lossy.

#5026 fixed it for hosts that store the wallet's DashPayBackfillRecord and hand it back on load. Kotlin does. #5479 adds it to the SQLite backend. The Swift SDK does not store the record.

Evidence

Checked on v5.1-dev at c8a284b6c0. This is from reading the code; I have not measured the re-run on a device.

  • FFIPersister::stores_dashpay_backfill() is true only when the host registers on_persist_wallet_dashpay_backfill_fn in PersistenceCallbacksExtension (packages/rs-platform-wallet-ffi/src/persistence.rs).
  • makePersistenceCallbacksExtension() in PlatformWalletPersistenceHandler.swift does not set that slot, and nothing under packages/swift-sdk/Sources refers to the record.
  • The doc comment on PersistWalletDashPayBackfillFn states the result: "A host without the slot keeps today's behaviour: the backfill re-fires on every launch".
  • The restore entry fields has_dashpay_backfill, dashpay_backfill_floor, dashpay_backfill_rewound_from and dashpay_backfill_covered stay at their defaults on iOS.

What the Swift SDK needs

  • Store the record. Register on_persist_wallet_dashpay_backfill_fn and keep floor, rewound_from and the covered contacts in SwiftData. Every write carries the whole record, so the host replaces it and never merges. The callback fires inside the round's begin/end bracket, so the write belongs in the same transaction as the lowered synced_height.
  • Hand it back on load. Fill the four dashpay_backfill_* fields of the wallet restore entry.
  • Schema. The new stored fields are an additive SwiftData change, so schema-models.json and the schema snapshot have to follow.

The rewind itself needs no change: the handler already assigns syncedHeight as it is handed (wallet.syncedHeight = cs.chain.synced_height), so a lowered cursor is stored as written.

Acceptance

  • A wallet that ran the backfill once does not rewind again on the next launch.
  • A store written before this change opens and behaves as today until the first record is written.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions