Skip to content

fix(platform): repeat a failed wait lookup and settle the open review items of the before/after block proofs - #6240

Merged
QuantumExplorer merged 3 commits into
claude/state-transition-proof-b318cbfrom
fix/state-transition-proof-review-followups
Nov 24, 2026
Merged

QuantumExplorer merged 3 commits into
claude/state-transition-proof-b318cbfrom
fix/state-transition-proof-review-followups

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

Basic explanation

This follows up #6038 (the proofs of the state before and after a state transition's block) and is stacked on its branch. A code review of #6038 left four findings open after the fixes already pushed there. This PR handles them:

  1. A wait could time out for a transition that was already executed. Fixed in rs-dapi.
  2. Three new verifier functions took provider after platform_version. Reordered.
  3. The docs called a repeated lease release a no-op, which it is not. Docs corrected, behaviour pinned by a test.
  4. Any caller can use up a node's per-block proving budget with other people's transactions. Documented as a limit of a best-effort feature; no code change (reasons below).

Issue being fixed or feature implemented

1. A failed transaction lookup was read as "not in a block yet"

waitForStateTransitionResult subscribes to the transaction's event and then asks Tenderdash's tx whether the transaction is in a block already. It treated every failure of that lookup as "no", and waited for the event.

Before:

  • The transition is committed and indexed. The tx call fails with a transport error, a timeout, or tx (…) not found, err: database unavailable.
  • The wait logs "Transaction not found" and waits for an event that fired before it subscribed.
  • After state_transition_wait_timeout (120 s under dashmate) the client gets a timeout for an executed transition.

After:

  • Only Tenderdash's own answer that its index does not hold the hash (tx (<HASH>) not found, err: %!w(<nil>)) counts as "not in a block yet". This is the same check getRecentStateTransitionStatus already uses (is_missing_from_index), not a second copy of it.
  • After any other failure the wait keeps listening for the event and repeats the lookup: 500 ms later, then at doubling intervals up to 8 s.
  • The repeats stop at the first lookup Tenderdash answers: with the transaction (the wait answers with it), or that it holds no such hash (from then on only the event can end the wait, as before).

A wait whose first lookup is answered behaves exactly as before and makes no extra call. This problem predates #6038; it is fixed here because #6038 reworked the same function.

2. platform_version is the last parameter

verify_state_transition_result_around_block, verify_state_before_block and verify_state_transition_proof_outcome declared platform_version, provider. They now declare provider, platform_version.

3. Releasing a lease twice

Drive keeps nothing of a lease it no longer holds, so a release that finds no registration looks the same whether it came before its registration, a second time, or after the lease expired. All three are remembered as "a release that came first" (up to 1,024 of them, for 64 blocks), and a later registration with that lease is refused. The docs on unregister, RegistrationLease and the Drive proto said a repeated release changes nothing. They now say what happens and that a caller releases a lease once, which is what rs-dapi does.

Telling the cases apart would mean remembering every lease Drive has seen, for a case rs-dapi never produces, so the behaviour stays and the docs match it.

4. The proving budget is shared

A registration names a hash, and nothing ties it to whoever sent the transition. A client can register transitions other people sent, and those count against the node's 1,024 registrations and against a block's 64 decodes and 32 proofs like any other. A client whose transition is left out gets no pair, and its wait answers with the ordinary proof of current state.

No code change:

  • Reading a transition's kind without decoding it would stop unproved kinds from using the decode budget, but it leaves two cheaper routes to the same outcome open: filling the registry with 1,024 hashes, and registering other people's transfers, top-ups and withdrawals against the 32 proofs.
  • It needs a tag-to-type table in dpp that has to track the StateTransition enum order, and type-based twins of two versioned Drive predicates.
  • Nothing is lost but the extra proof, the public proto already tells callers the pair is conditional, and no SDK sets the flag yet.

The module docs and the docs of MAX_DECODED_STATE_TRANSITIONS_PER_BLOCK now state the limit.

What was done?

  • rs-dapi: wait_for_state_transition_result_impl tells a missing hash apart from a failed lookup and repeats a failed one while it waits (TX_LOOKUP_RETRY_DELAY, TX_LOOKUP_MAX_RETRY_DELAY). is_missing_from_index is now pub(super) so the wait can use it.
  • rs-dapi tests: the Tenderdash stand-in answers lookups from a script (missing, failed, found) in Tenderdash's real wording and counts them. Three new tests.
  • rs-drive-proof-verifier: parameter order of the three functions and their callers.
  • rs-drive-abci, dapi-grpc: doc corrections for the lease release and the shared budget, and one test that pins the repeated release.

Public interface changes

  • drive_proof_verifier::verify_state_transition_result_around_block(request, response, provider, platform_version): the last two parameters swapped. The function is new in feat(platform): prove the state before and after the block of a state transition #6038 and has no caller outside this repository's tests.
  • No wire change. drive.proto changes a comment only.
  • waitForStateTransitionResult answers the same things as before. The only visible difference is that a wait whose first lookup failed can now answer with a transaction that was already in a block, and makes repeated tx calls to Tenderdash until one is answered.

How Has This Been Tested?

  • cargo test -p rs-dapi --lib wait_for_state_transition_result: 34 passed, with the new
    • should_answer_with_a_transaction_a_repeated_lookup_finds_after_a_failed_one
    • should_stop_repeating_the_lookup_once_tenderdash_says_it_holds_no_such_hash
    • should_still_answer_with_the_event_while_the_lookup_keeps_failing
  • cargo test -p rs-dapi --lib get_recent_state_transition_status: 11 passed.
  • cargo test -p drive-abci --lib state_transition_execution_proofs: 31 passed, with the new should_remember_a_repeated_release_as_one_that_came_before_its_registration.
  • cargo test -p drive-abci --test state_before_block: 7 passed.
  • cargo test -p drive-proof-verifier --lib state_before_block: 5 passed.
  • cargo clippy -p rs-dapi -p drive-proof-verifier -p drive-abci --all-targets --all-features --locked -- --no-deps -D warnings: clean.

Not run: the full workspace suites and a live network.

Breaking Changes

None. The reordered verifier function has not been released.

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

QuantumExplorer and others added 3 commits November 24, 2026 23:33
…s result

A wait read every failure of Tenderdash's `tx` lookup as "in no block
yet" and went on to wait for the transaction's event. When the lookup
failed for another reason (a transport error, a timeout, an index read
that failed) and the transaction was in a block already, that event had
come before the wait subscribed, so the wait ran into its timeout for an
executed transition.

Only Tenderdash's own answer that its index does not hold the hash now
counts as "in no block yet". After any other failure the wait keeps
listening for the event and repeats the lookup, 500 ms later at first
and then at doubling intervals up to 8 s, until Tenderdash answers one:
with the transaction, which ends the wait, or that it holds no such
hash, after which only the event can.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…e-before-block verifiers

`verify_state_transition_result_around_block`, `verify_state_before_block`
and `verify_state_transition_proof_outcome` took `provider` after
`platform_version`. All three are new with the before/after block proofs,
so they follow the rule that `platform_version` closes a parameter list.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…dget do

- A release of a lease Drive does not hold is remembered as one that came
  before its registration, also when the lease was released already or
  has expired. The docs called a repeated release a no-op; they now say
  what it costs, and a test pins it.
- The registry and the per-block proving budgets are the node's, shared
  by every caller: a registration names only a hash, so a client can use
  them up with transitions others sent. The module docs now say so, and
  that a wait left out answers with a proof of current state.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@QuantumExplorer QuantumExplorer added this to the v5.2.0 milestone Nov 24, 2026
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@QuantumExplorer
QuantumExplorer merged commit c1f838c into claude/state-transition-proof-b318cb Nov 24, 2026
8 of 10 checks passed
@QuantumExplorer
QuantumExplorer deleted the fix/state-transition-proof-review-followups branch November 24, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant