Skip to content

DAPI: a non-blocking call to look up a state transition's status by hash (pending, committed, dropped or unknown) #5269

Open

Description

@PastaPastaPasta

A client that has broadcast a state transition and heard nothing back can't ask a node what happened to it. waitForStateTransitionResult answers at once only when the transition is already in a block. In every other case it blocks until a timeout, so "still pending in the mempool", "dropped" and "never seen" look the same. We'd like a unary DAPI call that reports a transition's status by hash without waiting and without re-broadcasting.

We hit this building Dash Forge, a git forge that runs on Platform.

Expected Behavior

A call such as getStateTransitionStatus(state_transition_hash) that answers straight away from the node it is sent to, with one of:

  • committed, with the block height and the result code (0, or the error that waitForStateTransitionResult returns today for a committed transition with a non-zero code);
  • pending: the transition is in this node's mempool;
  • seen, no longer pending: this node has the hash in its mempool cache, but the transition is neither in its mempool nor in a block. If the node knows why it was dropped (for example a failed recheck and its code), it would report that too;
  • unknown: none of the above.

The response would carry the usual ResponseMetadata, so the client knows which height the answer is from. The client would not need the transition's bytes, and nothing would be re-submitted.

Current Behavior

The committed case is already covered by waitForStateTransitionResult.

  • rs-dapi subscribes first, then looks the hash up with Tenderdash's tx. If the transition is found, rs-dapi returns at once, and that includes a committed transition with a non-zero code (wait_for_state_transition_result.rs L71-L93, L159-L180).
  • dashmate turns on Tenderdash's kv tx index (config.toml.dot L546), so this works for old hashes too.
  • The answer doesn't say which block included the transition. The response has only error, proof, success_with_owner_balance and metadata (platform.proto L2575-L2586). The transaction's height is used only internally (L182-L195). When metadata is set, it describes the Drive state that the proof or balance was read from.

Every other case blocks, then looks the same.

  • If the hash isn't in a block, the call waits for a result event until the server's timeout (L95-L140) or until the client's own deadline expires. The server's timeout is 30 s by default in rs-dapi (config/mod.rs L142) and 120 s in dashmate's config (getBaseConfigFactory.js L304).
  • The server timeout comes back as a successful gRPC response holding an error result with code 13 (Internal) and no consensus error (platform_service/mod.rs L286-L306, and the test at L545-L557).
  • A transition that is pending, one that was dropped and a hash the node never saw all give the same answer.
  • Polling with short waits only tells "committed yet or not". Each open wait also holds one of 1,024 slots on the node (mod.rs L32, L45-L53).

rs-dapi already has the lookups it would need, but only uses them internally.

Tenderdash has no RPC for "seen, no longer pending". Its mempool cache keeps only hashes (cache.go L35-L36), and none of its RPC routes reads the cache (routes.go L49-L60).

What we observed. We ran a bulk import of document batch creates on a devnet. Several times a transition was accepted, and the bounded wait that followed heard nothing. We could not ask whether the transition was still pending or had been dropped. Re-sending the same bytes was the only probe we had. Two runs died this way, one after 50 documents and one after 359: every re-send was answered "tx already exists in cache" by one node, and the transition never landed. In the run that completed (73,541 documents), 50 broadcasts got that answer, and 4 transitions never landed and had to be re-signed with a fresh nonce.

Possible Solution

Suggestions:

  • rs-dapi: add a unary call that runs tx(hash) and then unconfirmed_tx(hash). Both already exist in its Tenderdash client. For a committed transition, return the height and the result code. That alone gives "committed", "pending" and "unknown" without blocking. A prove flag for the committed case could reuse the proof path that waitForStateTransitionResult already uses.
  • Tenderdash: to tell "seen, no longer pending" apart from "unknown", expose whether a hash is in the mempool cache, for example in unconfirmed_tx's not-found answer or in a new RPC. If it is cheap, also keep the last CheckTx or recheck code next to the cached hash. We can't judge the memory cost of that.
  • SDKs: expose the call in rs-sdk, wasm-sdk and evo-sdk next to the existing waitForStateTransitionResult.

The answer is per node and unproved. Mempools differ, so "unknown" from one node does not prove the transition was never broadcast. Clients would still use proved reads (the result, or the nonce) for final decisions. The call's job is to tell them whether waiting longer makes sense.

Alternatives Considered

  • Re-broadcasting the same bytes and reading the answer. This is what we do today. It needs the bytes, it can put a dropped transition back into a mempool, and the answer can be ambiguous, as described above.
  • Short waitForStateTransitionResult calls as a poll. These only tell committed from not committed, and each one holds a wait slot on the node. A server-side timeout also looks like an error result without a cause; fix(rs-dapi,rs-sdk): generalize retryable post-broadcast result-wait errors #4137 covers that separately.
  • A proved identity-contract nonce read. This is our workaround (forge-core wait_settings and drive_write). After one bounded 20 s wait, a spent nonce means something landed. A free nonce still doesn't say whether our transition is pending or gone, so we re-send and, in the end, re-sign. It also doesn't apply to transitions that have no such nonce.
  • A "don't wait" flag on waitForStateTransitionResult. This would be a smaller change to the proto. A separate status call seemed clearer, because the existing response has no field for "pending" and no field for the block height.

Additional Context

Activity

  1. added
    enhancement
    dapi-endpoint
    on Oct 4, 2026
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

    dapi-endpointenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions