Skip to content

rs-platform-wallet: migrate AddressPool from platform_payment_managed_account to PlatformPaymentAddressProvider #3737

@Claudius-Maginificent

Description

@Claudius-Maginificent

Summary

Per @QuantumExplorer's review on PR #3648:

"We haven't been using the platform_payment_managed_account, and have plans to get rid of it entirely. Instead we use the thing in platform wallet."

key_wallet_manager::platform_payment_managed_account is on the removal path. The replacement is platform_wallet::PlatformPaymentAddressProvider. Today the public API in PlatformAddressWallet (next_unused_receive_address, etc.) is already on the modern layer, but the implementation still reaches into managed_account.addresses for the actual AddressPool (containing used_indices, highest_used, gap_limit, mark_index_used, etc.). The provider is currently a read-only sync-state mirror — it has a BiBTreeMap<AddressIndex, PlatformP2PKHAddress> but no pool semantics.

User Story

As a platform-wallet maintainer I want the AddressPool to live on the modern provider so that the deprecated platform_payment_managed_account type can be deleted without breaking the wallet's address-derivation, gap-limit, and Found-026 hand-out-reservation behaviour.

Scope

  1. Move AddressPool (or an equivalent stateful structure) onto PlatformPaymentAddressProvider::PerAccountPlatformAddressState, replacing the read-only BiBTreeMap<AddressIndex, PlatformP2PKHAddress> with a pool that owns used_indices, highest_used, highest_generated, gap_limit.
  2. Expose next_unused_with_info() and mark_index_used() as crate-public methods on the provider.
  3. Refactor PlatformAddressWallet::next_unused_receive_address (packages/rs-platform-wallet/src/wallet/platform_addresses/wallet.rs:232) to call the provider's methods instead of managed_account.addresses — closes the last deprecated-pool touch in the production hand-out path.
  4. Update sync paths (sync.rs, transfer.rs, withdrawal.rs) to read pool state from the provider, not from the managed account.
  5. Once production no longer touches the deprecated pool, delete platform_payment_managed_account (or whatever subset @QuantumExplorer's removal plan covers).

E2E test impact

The current e2e campaign (#3549) has 8 call sites across 6 files that touch the deprecated pool. Most likely covered by this issue:

File Line What it needs After this issue
tests/e2e/framework/cleanup.rs 251 highest_generated / highest_used for sweep-pool signer ceiling Reads via new accessor on PlatformAddressWallet (planned in #3549 stop-gap)
tests/e2e/framework/bank.rs 327 same same
tests/e2e/framework/gap_limit.rs 127 Batch derivation past pool watermark Needs new batch-derive API on provider
tests/e2e/cases/pa_005b_gap_limit_triplet.rs 172, 214 mark_index_used on boundary, gap_limit read Rewrite against provider pool, or retire if provider doesn't expose mutation
tests/e2e/framework/wallet_factory.rs 1151 Inspect used_indices for Found-026 guard Rewrite against provider pool

PR #3549 ships with two new wrapper accessors (platform_payment_account_max_derived_index, platform_payment_account_gap_limit) and #[allow(deprecated)] annotations on the un-migratable test sites — see PR for stop-gap details. Once this issue lands, those #[allow(deprecated)] sites can be cleaned up and PA-005b can be rewritten or retired.

Related

Acceptance criteria

Out of scope

🤖 Co-authored by Claudius the Magnificent AI Agent

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions