Skip to content

Add a read-only dry run for signed state transitions: verdict and fee breakdown without mempool admission #5264

Open

Description

@PastaPastaPasta

A client cannot ask a node what a signed state transition would cost, or whether it would be accepted, without broadcasting it and paying for it. We would like a read-only DAPI call that runs a signed transition against the latest committed state and returns the consensus verdict and a fee breakdown, without admitting it to the mempool.

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

Expected Behavior

A read-only call, for example simulateStateTransition(state_transition), that takes the same bytes as broadcastStateTransition and returns:

  • the verdict: success, or the first consensus error (code and message, encoded as broadcast errors are today);
  • the fee it would be charged: storage fee, processing fee, refunds (per identity), and fixed costs such as the contract registration cost or document action fees;
  • the admission requirement: what the identity's balance and the signing key's remaining budget must cover for Drive to accept it. Today this differs from the charge (see below).

It would never enter the mempool, never be gossiped, and leave the nonce untouched. It could be rate-limited like any other expensive read.

Cosmos SDK has the same thing in cosmos.tx.v1beta1.Service/Simulate (service.proto). It returns the gas used and the execution result of a transaction without broadcasting it.

Current Behavior

  • There is no such call. The Platform service's only write is broadcastStateTransition, and its response is empty (platform.proto L9-L12, L199-L201). The only fee estimate in the DAPI protos is Core's getEstimatedTransactionFee, which is for L1 transactions (core.proto L12).
  • Most of the machinery already exists, but it is not reachable by clients:
  • The CheckTx figure is an admission estimate, not the charge. Fee validation calls apply_drive_operations with apply = false, which "only estimate[s] costs" from estimated layer information (apply_drive_operations/mod.rs L18-L26, validate_fees_of_event/v0/mod.rs L118-L143, v1/mod.rs L229-L241). The v0 code also notes TODO: Should take into account refunds as well. The key-budget requirement is defined in v1/mod.rs L26-L48. So even with CheckTx exposed, the actual charge is only known after execution.

What this costs us in practice:

  • What-if questions cost real DASH. To decide whether two optional indexes were worth their per-write cost, we registered six probe contracts on a 5.0.0-beta.1 devnet and measured writes against them. The deployer's balance went from 599,868,517,600 to 494,309,793,700 credits, so the run cost 1.056 DASH; 1.019 DASH of that was the six registrations. The answer was that each index added about 14.4 M credits (+26.7 %) to every write, so we dropped both.
  • Admission differs from the charge, and we learn it from refusals. On an earlier 4.2 beta devnet (also protocol 14), Drive refused a 10-byte comment until the signing key had 79,623,000 credits of budget left and the identity had 193,644,600 credits of balance. The same write was charged about 52.2 M. We keep a table of these requirements read from refusal messages (cost.test.ts L143-L148, cost.ts L298-L316).
  • Our cost previews drift between betas. They come from hand-measured balance deltas (cost.ts L1-L80). For example, we measured a review at 35.9 M credits on a 4.2.0-beta.5 devnet and at 49.6 M to 49.9 M on a 4.2.0-beta.7 devnet. Some of that change is ours and some is Platform's, and we cannot tell which without measuring again.

Possible Solution

A suggestion; the maintainers will know the right shape better:

  1. A read-only Platform RPC, for example simulateStateTransition({ bytes state_transition }), returning { code, info, fee: { storage_fee, processing_fee, refunds[], fixed_fee }, admission: { required_balance, required_key_budget }, metadata }.
  2. In drive-abci, run the transition as block execution would, at the last committed block info, inside a GroveDB transaction that is always rolled back. Return the verdict, the actual FeeResult, and the admission figures from fee validation. The test-only execute_tx above already has this shape.
  3. Skip CheckTx's mempool bookkeeping. For example, the first-time check takes a shielded-proof nonce permit (check_tx/v0/mod.rs L200-L222). Bound the work as fix(drive-abci): bound CheckTx verification work #4164 did for CheckTx.
  4. The result is a quote from one node's state, not a proof. Clients would treat it as such.

A smaller first step would be to expose the existing CheckTx outcome through DAPI as a read-only call: the code, the info, and the estimated FeeResult split into storage, processing and refunds. That alone gives the verdict and the admission side, though not the exact charge.

An optional extension: accept an ordered list of transitions from one identity and run them in one discarded transaction. A contract create followed by writes against it could then be priced without registering anything, which would have covered our index question.

Alternatives Considered

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