Skip to content

feat(platform-wallet): let a wallet tell when a timed-out document create can no longer land (surface its nonce) #5927

Open

Description

@romchornyi

Problem

A wallet that publishes a document and stops waiting for the result (a client-side timeout, or the app is killed) cannot tell when that publish can no longer land.

dashwallet-ios hits this with App Connect responses (dashpay/dashwallet-ios#1374, PR dashpay/dashwallet-ios#1414). The approval publishes a response document through platform_wallet_create_document_with_signer. When the call times out on the wallet side, the state transition may still be in a mempool. A disconnect that then finds no document cannot record the response as removed: the document may still appear.

The wallet now bounds this by time: 48 h of proved block time, twice dashmate's mainnet/testnet mempool ttlDuration: '24h'. That is a guess, not a guarantee:

  • the TTL is node configuration (base default '0s' means no TTL), and
  • a signed batch transition stays valid while its identity-contract nonce is unused and within the window of recent nonces (rs-dpp/src/identity/identity_nonce.rs, MAX_MISSING_IDENTITY_REVISIONS = 24). After every node dropped it, its bytes can still be broadcast again.

What actually ends the publish is its nonce being used (a failed batch transition uses its nonce too), or falling out of that window.

Asks

  1. Surface the nonce of a document create. create_document_with_signer (rs-platform-wallet → FFI → ManagedPlatformWallet.createDocument) should hand the caller the identity-contract nonce its transition carries, before broadcast. For example, a prepare step that returns the signed transition, its nonce and the document id, then a broadcast step. rs-sdk already separates the two (prepare_document_state_transition in put_document.rs).
  2. Answer "can nonce N still be accepted?" Expose a proved check, for an identity, a contract and a nonce N, that tells whether a transition with N can still be accepted. N is used, or N is more than the allowed distance below the current nonce. identityGetContractNonce returns one number. It is not clear whether the missing-revisions bits come with it, and without them a nonce that was skipped cannot be told apart from one that was used.
  3. (Optional) Use a nonce on purpose. A way to submit a cheap transition with an explicit nonce N on that contract, so a wallet can end a pending publish itself (cancel by superseding) instead of waiting.

With 1 and 2 the wallet replaces the time bound with one lookup. With 3 a disconnect can make "the app's response will not appear" true at once.

Context

  • The SDK already reports every failure after a possible broadcast as StateTransitionResultUnconfirmed (wait_after_broadcast in rs-sdk/src/platform/transition/broadcast.rs). The wallet uses that to clear the pending state on a failure for good. This issue is only about the unconfirmed or timed-out case.
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