Skip to content

rs-sdk: a proven state transition outcome (executed, cannot execute, or still possible until a height) #5822

Closed

Description

@QuantumExplorer

A client that broadcast a state transition and got no clear answer has no way to learn, with proof, whether that transition executed, can never execute, or may still execute, and until when. #5269 asks for a node's unproved view of a transition: pending, committed, dropped or unknown. This issue asks for the proven half next to it. Only proven answers may drive decisions that move or release funds.

We hit this in the platform wallet's private payments (#5810). After a broadcast that may have reached the network, the wallet keeps the payment's notes reserved and, for a DashPay private contact request, the contact pair locked. It does this until the payment provably landed or provably can't land, so it never pays twice or exposes a relationship. Today the only provable "can't land" signal it has is waiting for the spend's anchor to age out, so it can't tell the user how long the wait is.

Expected Behavior

An SDK function, for example Sdk::state_transition_outcome(&transition), takes the full transition (not just its hash, since it needs its inputs) and returns one of the following, each backed by proofs the client verifies:

Outcome Meaning Proven by
Executed In a block, with its effect present Affected-state proof: for a shielded spend, its nullifiers spent; for a private document create, its entry in the type's store
ExecutedWithError Included but failed with a paid error Fee or balance proof, only for types with a paid failure path (type 29 has none)
CannotExecute(AnchorExpired) A shielded spend whose anchor is no longer among the anchors Platform keeps getShieldedAnchors. Anchors are kept for shielded_anchor_retention_blocks (1000) and pruned every shielded_anchor_pruning_interval (100), so this holds at the latest from about anchor height + 1100
CannotExecute(InputUsed) A nullifier spent by another transition, or an identity or contract nonce or asset lock already consumed, with this transition's effect absent getShieldedNullifiers, getIdentityNonce, getIdentityContractNonce or the asset lock proof, plus the absence of the effect
CannotExecute(Invalid) Fails the state-independent checks (signature, structure) Checked locally and deterministically
StillPossible { until_height } None of the above; it may still execute, but no later than until_height Anchor still kept, nullifiers unspent and nonce free, with the deadline taken from the anchor's height

It may attach the node's unproved view from #5269 as a separate, clearly typed hint (for example "in this node's mempool"), for display only.

Why the two must stay separate

  • A node's "not in my mempool" proves nothing. Mempools differ between nodes, anyone who saw the signed transition can rebroadcast it, and a node's answer is unverified.
  • Releasing reserved notes, retrying a payment, or unlocking a held pair must only follow Executed or CannotExecute. Otherwise a client can pay twice, or reveal something it meant to keep private.
  • Separate types (a proven TransitionOutcome and an unproved NodeTransitionStatus) make that hard to get wrong.

Possible Solution

  • rs-sdk: compose the outcome from the proved queries that already exist (getShieldedAnchors, getShieldedNullifiers, getIdentityNonce, getIdentityContractNonce, getPrivateDocumentEntries, waitForStateTransitionResult with prove). This needs no Drive or consensus change. Per-type rules decide which inputs to check.
  • DAPI: a non-blocking call to look up a state transition's status by hash (pending, committed, dropped or unknown) #5269's call: name it getRecentStateTransitionStatus, in line with getRecentAddressBalanceChanges. "Recent" fits because a node's view covers only its mempool, its recently seen hashes and its transaction index. The proven outcome is not "recent": Executed and CannotExecute(AnchorExpired) stay provable indefinitely.
  • platform-wallet: once this exists, the shielded coordinator's stranded-release pass and the private payment journal can use CannotExecute to free reservations and pairs, and StillPossible { until_height } to show the user a deadline instead of "pending".
  • wasm-sdk, evo-sdk, Swift and Kotlin: expose the outcome where they already expose waitForStateTransitionResult.

Notes

  • Privacy. For shielded and private document transitions, a client should only ask the node it broadcast to: asking several nodes about the same transition spreads the link between the client's network address and the transition. The proven queries leak less when they are batched with the client's ordinary sync reads.
  • Ordering. A CannotExecute(AnchorExpired) decision must use an anchor set fetched before the read that shows the effect absent. Otherwise a spend that executed just before pruning could be missed. The wallet's stranded-release pass already follows this order and documents why.

Related

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

    Client Onlyenhancementrs-sdk

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions