Skip to content

fix(dapi): check the state transition size pre-filter against the active protocol version - #5659

Merged
romchornyi merged 10 commits into
v5.2-devfrom
fix/dapi-state-transition-size-bound
Nov 20, 2026
Merged

romchornyi merged 10 commits into
v5.2-devfrom
fix/dapi-state-transition-size-bound

Conversation

@romchornyi

@romchornyi romchornyi commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

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-dapi broadcast_state_transition.rs: a broadcast first refuses bytes above MOST_PERMISSIVE_SIZE_VERSION's max_state_transition_size (the largest of any compiled version), without any lookup. It then checks the size against the protocol version the network runs now, Drive's current from the cached getStatus (cleared on every block), waiting 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, the largest compiled limit applies. Drive enforces the active version's limits when it decodes.
  • While every compiled version has the same size and shielded action limits (KNOWN_LIMITS_ARE_UNIFORM, a const fn over PLATFORM_VERSIONS), the active version cannot change either decision, so the broadcast skips the status lookup.
  • shielded_proof_failure_budget.rs: the proof-failure budget clamps each Orchard bundle of a broadcast to the same active version's max_shielded_transition_actions (bundle_action_limit), falling back to MAX_SHIELDED_ACTIONS, the largest across PLATFORM_VERSIONS (asserted non-zero at compile time), instead of latest()'s. The in-flight cap stays at MAX_SHIELDED_ACTIONS.

The fallbacks cover the versions compiled into this DAPI build. A newer protocol version this build does not know may raise either limit past them until DAPI is upgraded.

How Has This Been Tested?

  • cargo test -p rs-dapi: 451 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_see_whether_the_known_limits_differ covers the fast path's condition; should_bound_a_bundle_by_the_active_version_or_the_largest_known_limit covers the per-bundle clamp; should_pick_the_version_with_the_largest_size_limit covers the size fallback's selection.
  • cargo clippy -p rs-dapi --all-targets -- -D warnings: clean.

The limits are the same today (20480 bytes and 16 shielded actions in every known version), so broadcasts do not wait for the status.

Breaking Changes

None.

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

Summary by CodeRabbit

  • Bug Fixes
    • 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 · 679abd4

  • 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) — approved by lklimek

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.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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

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.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

Possibly related PRs

  • 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: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Title check Warning 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 Passed checks: 3 passed

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed 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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 45d925b and ed9e65e.

Files selected for processing: 1

  • packages/rs-dapi/src/services/platform_service/shielded_proof_failure_budget.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@thepastaclaw

thepastaclaw commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 679abd4)

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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.

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • 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.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer

@romchornyi
romchornyi added this pull request to stack #5662 October 29, 2026 10:54
Base automatically changed from fix/asset-lock-proof-size-chain-fallback to v5.1-dev October 29, 2026 13:26
…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 <[email protected]>
@romchornyi
romchornyi force-pushed the fix/dapi-state-transition-size-bound branch from e109823 to 45d925b Compare October 29, 2026 13:26
@github-actions github-actions Bot added this to the v5.1.0 milestone Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Oct 29, 2026
@romchornyi

Copy link
Copy Markdown
Contributor Author

/skip-bots

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. and removed waiting-bots Waiting for the review bots to report on this head labels Oct 29, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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.

source: gpt-6.1-sol (phase2-reviewer: general)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 9: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 10: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 11: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 12: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • 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.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
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.

@github-actions github-actions Bot removed the bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. label Oct 29, 2026
…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 <[email protected]>
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Oct 29, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • 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.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
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.

@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Oct 29, 2026
@romchornyi

Copy link
Copy Markdown
Contributor Author

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.

…ansition-size-bound

# Conflicts:
#	packages/rs-dapi/src/services/platform_service/shielded_proof_failure_budget.rs
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

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.

…ame limits

While all compiled protocol versions share the state transition size and
shielded action limits, the active version cannot change either check,
so a broadcast no longer waits for getStatus. The fallback docs now say
they cover only the versions compiled into this build, and the in-flight
cap test follows MAX_SHIELDED_ACTIONS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@romchornyi

Copy link
Copy Markdown
Contributor Author

Not-inline suggestion (in-flight boundary test hard-coding 16): fixed in 27bcc34, the test now reserves and re-admits MAX_SHIELDED_ACTIONS.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 19, 2026
@romchornyi

Copy link
Copy Markdown
Contributor Author

Summary of the changes since the last human review (0fc5537 → 27bcc34):

  • Active version for the proof-failure budget too (lklimek's thread): the budget clamps each Orchard bundle to the active version's max_shielded_transition_actions, from the same cached getStatus lookup the size check uses, and falls back to the largest limit across compiled versions when the status doesn't answer or names an unknown version (c419ecc).
  • No wait for oversized bytes: bytes above every compiled version's size limit are refused before the status lookup (2f8dfa5).
  • No wait while limits are uniform: while every compiled version has the same size and action limits (true today: 20480 bytes, 16 actions), KNOWN_LIMITS_ARE_UNIFORM skips the status lookup, since the active version can't change either decision. Once a version changes a limit, the lookup comes back on its own (27bcc34).
  • Docs now say the fallbacks cover only versions compiled into this build; tests no longer hard-code 16.

cargo test -p rs-dapi (451), clippy -D warnings and fmt are green. The Dashmate local-network E2E failure on 2f8dfa5 was Core block sync timing out at network start, before any broadcast. Out of scope and tracked separately: getStatus refresh coalescing (#5900), CI nextest filter skipping the budget tests (#5985), shared bundle enumeration with Drive (#5676).

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The final head correctly adds the uniform-limit fast path and documents compiled-version fallback behavior; CI reports the Rust workspace and relevant package checks passing. One cache-versus-CheckTx activation race and one future-branch wiring test gap remain suggestions, and the remaining largest-bundle tests still hard-code 16; the reported local-network E2E failure occurred during network startup before broadcast processing.

🟡 3 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.

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Use MAX_SHIELDED_ACTIONS in the remaining largest-bundle tests
packages/rs-dapi/src/services/platform_service/shielded_proof_failure_budget.rs:568-582

should_make_a_failed_largest_bundle_wait_for_a_clean_slate and should_charge_a_reservation_dropped_unsettled still use literal 16, even though the neighboring in-flight-cap test now derives its reservation from MAX_SHIELDED_ACTIONS. If the compiled action limit changes, these tests will continue passing while no longer exercising the largest-bundle boundary. Derive the bundle size and drain duration from MAX_SHIELDED_ACTIONS in both tests.

source: muse-spark-1.3-contributor (phase1-reviewer: general)

Still open from earlier rounds (2)

  • 🟡 Suggestion: Test which size limit the broadcast handler actually applies — packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs:65-73 (thread)
  • 🟡 Suggestion: Keep exact admission limits on the CheckTx state snapshot — packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs:65-84 (thread)
Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — This is a substantial but contained DAPI validation and resource-budget change involving protocol-version limit selection, without changing consensus rules, cryptographic correctness, or peer-facing deserialization.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
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/shielded_proof_failure_budget.rs`:
- [SUGGESTION] packages/rs-dapi/src/services/platform_service/shielded_proof_failure_budget.rs:568-582: Use MAX_SHIELDED_ACTIONS in the remaining largest-bundle tests
  `should_make_a_failed_largest_bundle_wait_for_a_clean_slate` and `should_charge_a_reservation_dropped_unsettled` still use literal `16`, even though the neighboring in-flight-cap test now derives its reservation from `MAX_SHIELDED_ACTIONS`. If the compiled action limit changes, these tests will continue passing while no longer exercising the largest-bundle boundary. Derive the bundle size and drain duration from `MAX_SHIELDED_ACTIONS` in both tests.

In `packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs`:
- [SUGGESTION] packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs:65-73: Test which size limit the broadcast handler actually applies
  (carried; thread: https://github.com/dashpay/platform/pull/5659#discussion_r4619900971)
- [SUGGESTION] packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs:65-84: Keep exact admission limits on the CheckTx state snapshot
  (carried; thread: https://github.com/dashpay/platform/pull/5659#discussion_r4618858113)
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Share shielded action enumeration with Drive — DAPI still maintains a separate shielded-transition and bundle enumeration from Drive's shielded_proof_action_count. The current mappings match, but future transition or bundle additions can make the local proof-failure budget undercount work again.
    • Follow-up: Implement the shared protocol-owned enumeration tracked in #5676.

@github-actions

Copy link
Copy Markdown
Contributor

Bots are done — your move: address shumkov requested changes; lklimek requested changes, then post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 19, 2026
…TIONS

The clean-slate, dropped-reservation, verified-source and eviction tests
hard-coded 16 actions. They now use the compiled cap, so they keep
exercising the largest bundle if the action limit changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@romchornyi

Copy link
Copy Markdown
Contributor Author

Re "Use MAX_SHIELDED_ACTIONS in the remaining largest-bundle tests" (shielded_proof_failure_budget.rs:568-582): fixed in 679abd4: tests that reserve a largest bundle derive its size from MAX_SHIELDED_ACTIONS. Applied at should_make_a_failed_largest_bundle_wait_for_a_clean_slate (bundle size and drain time), should_charge_a_reservation_dropped_unsettled, and the two other sites that hard-coded 16 and would hit the in-flight cap if the limit dropped: should_never_refuse_a_source_whose_proofs_verify and should_evict_the_least_indebted_idle_source_when_full.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 20, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

The latest commit makes the remaining largest-bundle fixtures use the configured cap. No blocking issues were found; the new suggestion is to test that an above-cap reservation runs alone. On the reviewed head, the Rust workspace tests, RS-DAPI image build, local-network E2E, and both browser shards and the main platform suite passed; the workspace filter still excludes the shielded budget tests, and only review and hygiene checks were pending.

🟡 3 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.

Still open from earlier rounds (2)

  • 🟡 Suggestion: Keep exact admission limits on the CheckTx state snapshot — packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs:65-84 (thread)
  • 🟡 Suggestion: Test which size limit the broadcast handler actually applies — packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs:59-73 (thread)
Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The change adds version-aware admission and resource-budget logic to DAPI's broadcast path without changing consensus rules, proof verification, or network deserialization.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
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/shielded_proof_failure_budget.rs`:
- [SUGGESTION] packages/rs-dapi/src/services/platform_service/shielded_proof_failure_budget.rs:713-719: Test that an above-cap reservation runs alone
  The multi-bundle test proves that an idle source can reserve more than the in-flight cap, but it settles the reservation before making another request. The separate cap test checks only a cap-sized reservation, so neither test pins the above-cap exception to an idle source. For the same source, hold a small reservation and assert that the above-cap request is refused; then settle the small reservation, hold the above-cap reservation, and assert that a new small request is refused before any failure is charged.

In `packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs`:
- [SUGGESTION] packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs:65-84: Keep exact admission limits on the CheckTx state snapshot
  (carried; thread: https://github.com/dashpay/platform/pull/5659#discussion_r4618858113)
- [SUGGESTION] packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs:59-73: Test which size limit the broadcast handler actually applies
  (carried; thread: https://github.com/dashpay/platform/pull/5659#discussion_r4619900971)
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Share Orchard bundle enumeration between DAPI and Drive — The counters cover the same transition types at this head, but separate lists have already drifted once. Sharing the enumeration would prevent that from recurring while leaving the rate-limit policy in DAPI.
    • Follow-up: Use #5676 for a separate PR that moves the shared enumeration into DPP.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Bots are done — your move: address shumkov requested changes; lklimek left a review thread unresolved, then post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 20, 2026
@romchornyi

Copy link
Copy Markdown
Contributor Author

/self-reviewed

@github-actions

Copy link
Copy Markdown
Contributor

Ready for review — re-review or resolve: shumkov · resolve every review thread lklimek left open (their approval counts).
Full checklist in the description.

@github-actions github-actions Bot added ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 20, 2026
@github-actions
github-actions Bot requested a review from lklimek November 20, 2026 17:38
@romchornyi
romchornyi dismissed shumkov’s stale review November 20, 2026 17:45

Addressed: since 0fc5537 the size pre-filter and (c419ecc) the proof failure budget use the active protocol version's limits, falling back to the largest known. See r4616155223.

@github-actions

Copy link
Copy Markdown
Contributor

Policy satisfied — this can merge.
Full checklist in the description.

@github-actions github-actions Bot removed the ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. label Nov 20, 2026
@romchornyi
romchornyi merged commit 66bdfa7 into v5.2-dev Nov 20, 2026
36 checks passed
@romchornyi
romchornyi deleted the fix/dapi-state-transition-size-bound branch November 20, 2026 18:01
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.

5 participants