Skip to content

fix(platform-wallet): bound the load-time history replay #5962

Open

Description

@Claudius-Maginificent

TL;DR: Opening a wallet replays its whole stored transaction history with no size limit, so a wallet that has received many transactions can take a lot of memory and time before it becomes usable.

User story

As a wallet user, I want my wallet to open in bounded time and memory however much history it has, to keep using the app after receiving many transactions.

Scenario

Base flow

A wallet built on the history replay of #5220 is reopened. Anyone can grow its history by sending small, valid transactions to its monitored addresses.

Actual behavior

On load, the Swift persistence handler fetches every PersistentTransaction, filters the full table for each wallet, and hands every matching body to Rust, which clones, plans and replays them all. There is no pagination, budget, checkpoint or eviction boundary (TODO(bound-load-history-replay) in rs-platform-wallet/src/manager/history_replay.rs). Memory and CPU at startup grow with history size.

Expected behavior

Load either stays within a fixed resource budget (bounded replay with durable spend claims for older history and a checkpoint), or fails closed with a typed error when the history exceeds that budget.

Detailed discussion

  • Swift: PlatformWalletPersistenceHandler.swift loads all history without a limit; the FFI decoder allocates with an unchecked Vec::with_capacity.
  • Options: a fail-closed count/byte budget with a typed restore error (smaller, about 100-150 lines in Swift and Rust), or a resumable, checkpointed replay (larger).
  • Raised as a blocking review finding on fix(platform-wallet)!: replay recorded transaction history on load for every persister #5220 and listed there as an unresolved resource blocker; kept out of that PR's scope.

Prior work

Attribution

🤖 Co-authored by Claudius the Magnificent AI Agent

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions