Repository navigation
Description
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
waitForStateTransitionResultreturns 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
kvtx 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_balanceandmetadata(platform.proto L2575-L2586). The transaction's height is used only internally (L182-L195). Whenmetadatais 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.
- Its Tenderdash client has
unconfirmed_tx(hash)andtx(hash)(tenderdash_client.rs L493-L509).handle_duplicate_transactionuses both when a broadcast is a duplicate (broadcast_state_transition.rs L178-L216). - Tenderdash's
unconfirmed_txlooks a hash up in the mempool (rpc/core/mempool.go L206-L217). - Clients can't call Tenderdash themselves, because dashmate binds its RPC to
127.0.0.1(getBaseConfigFactory.js L392-L394). - So today a client can only learn "in the mempool" by re-broadcasting the bytes and reading the
AlreadyExistsmessage. When the hash is still in Tenderdash's mempool cache, that message is a bare "tx already exists in cache" that doesn't say which case applies (filed separately as rs-dapi: "tx already exists in cache" skips the duplicate check, so a dropped state transition looks the same as a pending one #5266).
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 thenunconfirmed_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. Aproveflag for the committed case could reuse the proof path thatwaitForStateTransitionResultalready 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
waitForStateTransitionResultcalls 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_settingsanddrive_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
- Version used: Platform 5.0.0-beta.1 on a devnet (sakura) set up with dashmate defaults. Tenderdash is dashmate's default
dashpay/tenderdash:1.8image; we read the v1.8.1 source. - Client: rs-sdk (
dash-sdk) at git tagv5.0.0-beta.1, in a Rust CLI. - Project: https://github.com/PastaPastaPasta/dash-forge
- Related: rs-dapi: "tx already exists in cache" skips the duplicate check, so a dropped state transition looks the same as a pending one #5266 (re-broadcast answered "tx already exists in cache" without saying which case applies), IdentityCreditTransfer to a non-existent recipientId passes check_tx and stays in the mempool, blocking the sender's nonce slot #4624 (a transition that stays in the mempool while
waitForStateTransitionResulttimes out; a status call would show it as pending), rs-sdk: put_to_platform_and_wait_* fails with AlreadyExists when a timed-out broadcast was already accepted #4998 (AlreadyExistsafter a broadcast that was accepted) and fix(rs-dapi,rs-sdk): generalize retryable post-broadcast result-wait errors #4137 (separating wait failures from rejections).
Activity