You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(dapi): check the state transition size pre-filter against the active protocol version - #5659
Follow-up to #5460 (review thread #5460 (comment)): DAPI's state transition size pre-filter in broadcastStateTransition checks against PlatformVersion::latest(), not the version the network runs. If a later protocol version lowered max_state_transition_size, DAPI would refuse transitions the network still accepts until that version activates.
What was done?
rs-dapibroadcast_state_transition.rs: the pre-filter checks against the limit of the protocol version the network runs now, Drive's current from the cached getStatus (cleared on every block), still through validate_state_transition_size. The lookup waits at most 2 s, as getRecentStateTransitionStatus does since feat(sdk): prove a state transition's outcome, and add getRecentStateTransitionStatus #5823. When the status does not answer in time or names a version this build does not know, it checks against MOST_PERMISSIVE_SIZE_VERSION, the known version with the largest max_state_transition_size, so DAPI never refuses what the network could accept. Drive enforces the active version's limit when it decodes.
shielded_proof_failure_budget.rs: the proof-failure budget clamps a broadcast's Orchard action count, and caps actions in flight, at MAX_SHIELDED_ACTIONS, the largest max_shielded_transition_actions across PLATFORM_VERSIONS (a const fn, asserted non-zero at compile time), instead of latest()'s. A smaller bound would charge a bundle the active version still verifies for fewer actions than Drive checks.
The proof-failure budget keeps the largest known action limit: it only sizes a reservation and refuses nothing, and it is synchronous.
How Has This Been Tested?
cargo test -p rs-dapi --lib: 449 passed. should_check_the_size_against_the_given_version_limit checks max accepted and max + 1 refused for a version's limit; should_take_the_current_drive_version_from_the_status and should_have_no_active_version_without_a_known_current_version cover reading the version from the status and the fallback cases (no status, version 0, unknown version); should_pick_the_version_with_the_largest_size_limit covers the fallback's selection; the budget test checks an oversized bundle is reserved as MAX_SHIELDED_ACTIONS.
cargo clippy -p rs-dapi --all-targets: clean.
The limits are the same today: every known version allows 20480 bytes and 16 shielded actions. A broadcast now reads the cached status first; after each block the first one waits for a fresh status, at most 2 s.
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
State transition size validation now uses the largest limit across known platform versions, avoiding rejection of transactions allowed by an older supported version.
The in-flight shielded action limit now reflects the largest limit across known platform versions. Reservations above that bound are capped, keeping the budget consistent across supported versions.
PR Hygiene · 0fc5537
Bots — thepastaclaw ✓
Self-review — posted; again after any push
Build green
Approvals
rust-dapi (packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs, packages/rs-dapi/src/services/platform_service/shielded_proof_failure_budget.rs) — QuantumExplorer or lklimek or shumkov
shumkov requested changes — waiting for them to re-review or dismiss
When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.
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.
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
No actionable comments were generated in the recent review.
Walkthrough
State-transition size validation and the shielded-proof in-flight action budget now use the greatest corresponding limit among known platform versions, rather than the latest version’s limit. Tests cover maximum selection, tie handling, validation, and reservation clamping.
Changes: Platform-version bounds
Layer / File(s)
Summary
Select the state-transition size bound packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs
Size validation now uses the greatest state-transition size limit among known platform versions. Tests cover maximum selection, ties, and validation.
Set the shielded-action budget bound packages/rs-dapi/src/services/platform_service/shielded_proof_failure_budget.rs
The default in-flight action limit now uses the greatest action limit among known platform versions. A compile-time assertion rejects a zero bound. Tests cover maximum selection and clamping.
dashpay/platform#5460: Adds the state-transition size validation whose platform-version limit selection this change updates.
Suggested reviewers:quantumexplorer
Merge Risk: Minimal · previous review ed9e6
The size pre-filter remains compatible with known network versions. No merge-blocking regression was identified.
Pre-merge checks: 3 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Title check
The title names the rs-dapi state transition size pre-filter and says the check now uses the active protocol version. The changeset does something different. Both files now take the largest max_state_…
Rewrite the title to match the change. For example: "fix(dapi): bound the state transition size pre-filter by the largest known limit". Use the same wording as the PR objectives.
Passed checks: 3 passed
Check name
Status
Explanation
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check
Explanation
The title names the rs-dapi state transition size pre-filter and says the check now uses the active protocol version. The changeset does something different. Both files now take the largest max_state_transition_size and max_shielded_transition_actions across all known platform versions, not the active version. The PR objectives say the same thing, so the title contradicts the change. The title is also misleading in the way it describes the approach.
Resolution
Rewrite the title to match the change. For example: "fix(dapi): bound the state transition size pre-filter by the largest known limit". Use the same wording as the PR objectives.
Finishing Touches
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
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.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Final validation — Phase 1 + Phase 2
The PR correctly changes DAPI's state-transition size pre-filter to use the largest limit across the compiled production protocol-version registry. Drive still applies the active protocol version's authoritative limit during decoding, and the helper and boundary tests are consistent with that design. The changed files are narrowly scoped, and the available CI checks completed successfully.
Triage: normal by gpt-6.1-sol (effort low) — This is a contained DAPI validation-logic change with compile-time protocol-version selection and boundary tests, but it affects peer-facing state-transition admission behavior rather than being merely cosmetic.
…known limit
DAPI does not track the network's protocol version, so checking against
PlatformVersion::latest() would refuse a transition the network still
accepts if a later version lowered the limit before activating. Check
against the known version with the largest max_state_transition_size
instead, still through validate_state_transition_size; Drive enforces
the active version's limit when it decodes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.
The reason will be displayed to describe this comment to others. Learn more.
Re-review — Final validation — Phase 1 + Phase 2
The state-transition size pre-filter correctly uses the largest known size limit while Drive continues to enforce the active protocol version. However, the adjacent shielded proof-failure budget still clamps action counts using only PlatformVersion::latest(), so an older active version with a larger action limit could cause invalid proof work to be charged below its actual cost. The Rust workspace test failure is unrelated to this PR because it occurs in unchanged rs-sdk test callers.
🔴 1 blocking
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Use the largest known shielded-action limit for failure-budget accounting packages/rs-dapi/src/services/platform_service/shielded_proof_failure_budget.rs:173-181
The budget still initializes max_in_flight_actions from PlatformVersion::latest(), and try_reserve_at clamps every decoded action count to that value. If a newer protocol version lowers max_shielded_transition_actions while the network is still running an older version with a larger limit, a valid larger bundle can reach Drive and incur proof-verification work, but the DAPI budget records only the newer, smaller action count. Failed-action debt and drain timing are therefore understated, allowing a source to submit more invalid Orchard proof work than the intended budget permits. This is the same latest-versus-active-version boundary that the PR fixes for state-transition bytes; derive the action cap from the largest known platform-version limit and add a regression test using differing action limits.
Triage: normal by gpt-6.1-sol (effort low) — This is a focused but behavior-changing protocol-version-aware validation fix in DAPI, and while it affects a peer-facing input boundary, the diff is not large or intricate enough to meet the critical tier.
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/rs-dapi/src/services/platform_service/shielded_proof_failure_budget.rs`:
- [BLOCKING] packages/rs-dapi/src/services/platform_service/shielded_proof_failure_budget.rs:173-181: Use the largest known shielded-action limit for failure-budget accounting
The budget still initializes `max_in_flight_actions` from `PlatformVersion::latest()`, and `try_reserve_at` clamps every decoded action count to that value. If a newer protocol version lowers `max_shielded_transition_actions` while the network is still running an older version with a larger limit, a valid larger bundle can reach Drive and incur proof-verification work, but the DAPI budget records only the newer, smaller action count. Failed-action debt and drain timing are therefore understated, allowing a source to submit more invalid Orchard proof work than the intended budget permits. This is the same latest-versus-active-version boundary that the PR fixes for state-transition bytes; derive the action cap from the largest known platform-version limit and add a regression test using differing action limits.
…wn action limit
The budget clamped a broadcast's Orchard action count, and capped actions in
flight, at `PlatformVersion::latest()`'s `max_shielded_transition_actions`.
If a newer version lowered that limit while the network still ran an older
one, a bundle Drive verifies would be charged for fewer actions than it
checks. Take the largest limit across `PLATFORM_VERSIONS` instead, as the
state transition size pre-filter now does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.
The reason will be displayed to describe this comment to others. Learn more.
Re-review — Final validation — Phase 1 + Phase 2
The largest-known-limit changes correctly resolve the prior version-bound issue, and the size pre-filter remains conservative while Drive enforces the active version. However, the DAPI failure budget still does not account for every shielded proof path: token, batch, and ShieldFromAssetLock V1 transitions can perform proof verification while orchard_action_count returns zero, and token transitions can contain two bundles while the reservation cap only allows one bundle's action limit. The Rust workspace check is marked failed, but its completed steps passed and the log ends while shielded tests were still running, with no changed-code failure shown.
🔴 1 blocking
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Count every transition type that performs shielded proof verification packages/rs-dapi/src/services/platform_service/shielded_proof_failure_budget.rs:119-145
orchard_action_count returns zero for TokenShieldedTransferWithShieldedFee, TokenUnshieldWithShieldedFee, TokenPurchaseFromShieldedPool, and Batch, and it omits ShieldFromAssetLockTransition::V1. Drive's authoritative shielded_proof_action_count counts these paths: the token transitions sum both token_actions and fee_actions, batch token/document payments contribute their shielded actions, and ShieldFromAssetLock::V1 contributes its actions. These transitions can therefore reach Drive's Orchard proof verification and return InvalidShieldedProofError (code 40902) without creating a DAPI reservation, allowing repeated invalid-proof submissions to bypass this DoS budget. Additionally, even if the token variants were added to this match, try_reserve clamps their combined action count to MAX_SHIELDED_ACTIONS, although each token transition contains two independently validated bundles and Drive counts both; the reservation must reflect the actual total proof work. Use a shared pure action-counting helper or otherwise keep this counter synchronized with Drive, and add coverage for standalone token, batch, and both ShieldFromAssetLock versions.
source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.1-sol (phase2-reviewer: general, architecture-layering, platform-versioning, rust-quality, security-auditor)
Triage: normal by gpt-6.1-sol (effort low) — This is a contained but behavior-changing Rust fix in DAPI admission and resource-budget logic, and it does not directly modify consensus, cryptography, funds handling, or persistent storage.
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `packages/rs-dapi/src/services/platform_service/shielded_proof_failure_budget.rs`:
- [BLOCKING] packages/rs-dapi/src/services/platform_service/shielded_proof_failure_budget.rs:119-145: Count every transition type that performs shielded proof verification
`orchard_action_count` returns zero for `TokenShieldedTransferWithShieldedFee`, `TokenUnshieldWithShieldedFee`, `TokenPurchaseFromShieldedPool`, and `Batch`, and it omits `ShieldFromAssetLockTransition::V1`. Drive's authoritative `shielded_proof_action_count` counts these paths: the token transitions sum both `token_actions` and `fee_actions`, batch token/document payments contribute their shielded actions, and `ShieldFromAssetLock::V1` contributes its actions. These transitions can therefore reach Drive's Orchard proof verification and return `InvalidShieldedProofError` (code 40902) without creating a DAPI reservation, allowing repeated invalid-proof submissions to bypass this DoS budget. Additionally, even if the token variants were added to this match, `try_reserve` clamps their combined action count to `MAX_SHIELDED_ACTIONS`, although each token transition contains two independently validated bundles and Drive counts both; the reservation must reflect the actual total proof work. Use a shared pure action-counting helper or otherwise keep this counter synchronized with Drive, and add coverage for standalone token, batch, and both ShieldFromAssetLock versions.
On the blocking finding in review 5703227769 (DAPI's orchard_action_count returns 0 for the token shielded transitions, shielded batches and ShieldFromAssetLock::V1): the gap is real, but this PR did not create it and does not touch the counter. DAPI's counter came with #5001, and #4760 later extended Drive's shielded_proof_action_count without updating DAPI's copy. The fix also changes the budget's model: the counter moves into dpp so both crates share it, and the clamp becomes per bundle, since a token transition verifies two. That is its own change and needs the maintainer's call on the approach, so it is tracked in #5676 and will land in a separate PR. This PR stays scoped to bounding the size pre-filter and the clamp by the largest known protocol limit.
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.
…l version
The size pre-filter now reads the network's current protocol version from
the cached getStatus, with a 2 s timeout, and checks against its
max_state_transition_size. When the status does not answer in time or names
a version this build does not know, it falls back to the most permissive
known version, so DAPI never refuses what the network could accept.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
romchornyi
changed the title
fix(dapi): bound the state transition size pre-filter by the largest known limit
fix(dapi): check the state transition size pre-filter against the active protocol version
Nov 12, 2026
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.
At head 0fc5537, the size pre-filter uses Drive's reported active protocol version with a bounded, permissive fallback. One non-blocking performance issue remains: concurrent cold-cache broadcasts independently refresh the same status. Validation was static only; current CI shows Rust workspace tests still pending and no failed code checks.
🟡 1 0 suggestion(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
Triage: normal by gpt-6.1-sol (effort low) — This is a substantial but contained DAPI validation and resource-budget change involving protocol-version fallback behavior, without directly changing consensus rules, cryptography, funds movement, or storage.
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs`:
- [SUGGESTION → DEFERRED by a maintainer; not blocking, do not fix in this PR] packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs:280-283: Coalesce concurrent active-version cache misses
Every broadcast now awaits this lookup, but get_status_impl caches only completed responses. On a cache miss, get_status.rs immediately calls build_status_response_with_health, which starts Drive getStatus and Tenderdash status/net_info RPCs without sharing an in-progress refresh. Concurrent broadcasts arriving after block-driven cache invalidation therefore each start another three-RPC refresh until a response is cached. The two-second timeout bounds each caller's wait, not the duplicate upstream work. Share the in-progress lookup across callers while retaining generation-checked cache insertion, and add a concurrent cold-cache test asserting that callers share one refresh.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ready-for-humanBots have reported, the author has self-reviewed, and the build is green: this needs a human.
4 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue being fixed or feature implemented
Follow-up to #5460 (review thread #5460 (comment)): DAPI's state transition size pre-filter in
broadcastStateTransitionchecks againstPlatformVersion::latest(), not the version the network runs. If a later protocol version loweredmax_state_transition_size, DAPI would refuse transitions the network still accepts until that version activates.What was done?
rs-dapibroadcast_state_transition.rs: the pre-filter checks against the limit of the protocol version the network runs now, Drive'scurrentfrom the cachedgetStatus(cleared on every block), still throughvalidate_state_transition_size. The lookup waits at most 2 s, asgetRecentStateTransitionStatusdoes since feat(sdk): prove a state transition's outcome, and add getRecentStateTransitionStatus #5823. When the status does not answer in time or names a version this build does not know, it checks againstMOST_PERMISSIVE_SIZE_VERSION, the known version with the largestmax_state_transition_size, so DAPI never refuses what the network could accept. Drive enforces the active version's limit when it decodes.shielded_proof_failure_budget.rs: the proof-failure budget clamps a broadcast's Orchard action count, and caps actions in flight, atMAX_SHIELDED_ACTIONS, the largestmax_shielded_transition_actionsacrossPLATFORM_VERSIONS(aconst fn, asserted non-zero at compile time), instead oflatest()'s. A smaller bound would charge a bundle the active version still verifies for fewer actions than Drive checks.The proof-failure budget keeps the largest known action limit: it only sizes a reservation and refuses nothing, and it is synchronous.
How Has This Been Tested?
cargo test -p rs-dapi --lib: 449 passed.should_check_the_size_against_the_given_version_limitchecks max accepted and max + 1 refused for a version's limit;should_take_the_current_drive_version_from_the_statusandshould_have_no_active_version_without_a_known_current_versioncover reading the version from the status and the fallback cases (no status, version 0, unknown version);should_pick_the_version_with_the_largest_size_limitcovers the fallback's selection; the budget test checks an oversized bundle is reserved asMAX_SHIELDED_ACTIONS.cargo clippy -p rs-dapi --all-targets: clean.The limits are the same today: every known version allows 20480 bytes and 16 shielded actions. A broadcast now reads the cached status first; after each block the first one waits for a fresh status, at most 2 s.
Breaking Changes
None.
Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code
Summary by CodeRabbit
PR Hygiene ·
0fc5537rust-dapi(packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs,packages/rs-dapi/src/services/platform_service/shielded_proof_failure_budget.rs) — QuantumExplorer or lklimek or shumkovWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.