Skip to content

fix(drive-abci): bound CheckTx verification work - #4164

Merged
QuantumExplorer merged 2 commits into
v4.1-devfrom
codex/fix-checktx-validation-bounds
Jul 22, 2026
Merged

QuantumExplorer merged 2 commits into
v4.1-devfrom
codex/fix-checktx-validation-bounds

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

Summary

  • perform current-state admission before shielded cryptographic validation in CheckTx
  • add a small action-weighted CheckTx verification budget isolated from proposal and block processing
  • return transient backpressure when local verification capacity is occupied

Addresses security review findings DS-CAND-207 through DS-CAND-211.

Verification

  • cargo test -p drive-abci --lib check_tx_verification -- --nocapture
  • focused proof-budget and transport-status regression tests
  • cargo clippy -p drive-abci --lib --no-deps -- -D warnings
  • cargo fmt --all -- --check
  • git diff --check

@github-actions github-actions Bot added this to the v4.1.0 milestone Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@QuantumExplorer, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 54 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 36aaf62b-f78e-4e3c-8293-9e1c95ee7b36

📥 Commits

Reviewing files that changed from the base of the PR and between fc05d62 and f7a8843.

📒 Files selected for processing (17)
  • packages/rs-drive-abci/src/abci/app/check_tx.rs
  • packages/rs-drive-abci/src/abci/app/mod.rs
  • packages/rs-drive-abci/src/abci/handler/check_tx.rs
  • packages/rs-drive-abci/src/error/execution.rs
  • packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/processor/traits/shielded_proof.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/document/replacement.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shield_from_asset_lock/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shield_from_asset_lock/tests.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shield_from_asset_lock/transform_into_action/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/transformer/mod.rs
  • packages/rs-drive-abci/src/platform_types/check_tx_proof_verifier.rs
  • packages/rs-drive-abci/src/platform_types/mod.rs
  • packages/rs-drive-abci/src/platform_types/platform/mod.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-checktx-validation-bounds

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

Comment @coderabbitai help to get the list of available commands.

@QuantumExplorer
QuantumExplorer marked this pull request as ready for review July 21, 2026 02:04
@thepastaclaw

thepastaclaw commented Jul 21, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit f7a8843)

@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.

Preliminary review — Codex only

Verified the full PR delta at exact head 0d5219e. The limiter correctly protects the shielded proofs routed through validate_shielded_proof, and the focused tests pass, but ShieldFromAssetLock still performs Halo2 verification before the permit and CheckTx discards its penalty action on failure. This leaves a repeatable CPU-exhaustion path, so changes are required; two non-blocking regression-test gaps are also noted.

Validated blockers were found in the Codex precheck. Sonnet is deferred until a fresh Codex revalidation clears the blocker gate.

Review provenance

  • Codex reviewers: gpt-5.6-sol — general (failed), gpt-5.6-sol — security-auditor (failed), gpt-5.6-sol — rust-quality (failed), gpt-5.6-sol — general (failed), gpt-5.6-sol — security-auditor (failed), gpt-5.6-sol — rust-quality (failed), gpt-5.6-sol — general (failed), gpt-5.6-sol — security-auditor (failed), gpt-5.6-sol — rust-quality (failed), gpt-5.6-sol — general (failed), gpt-5.6-sol — security-auditor (failed), gpt-5.6-sol — rust-quality (failed), gpt-5.6-sol — general (failed), gpt-5.6-sol — security-auditor (failed), gpt-5.6-sol — rust-quality (failed), gpt-5.6-sol — general (failed), gpt-5.6-sol — security-auditor (failed), gpt-5.6-sol — rust-quality (failed), gpt-5.6-sol — general (completed), gpt-5.6-sol — security-auditor (completed), gpt-5.6-sol — rust-quality (completed)
  • Verifier: gpt-5.6-sol — verifier
  • Sonnet: not run (deferred by blocker gate)

🔴 1 blocking | 🟡 2 suggestion(s)

🤖 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-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs`:
- [BLOCKING] packages/rs-drive-abci/src/execution/validation/state_transition/check_tx_verification/v0/mod.rs:331-337: ShieldFromAssetLock bypasses the CheckTx proof-verification budget
  The permit is conditional on has_shielded_proof_validation(), which explicitly excludes ShieldFromAssetLock. That transition's earlier transform_into_action call instead invokes reconstruct_and_verify_bundle directly at shield_from_asset_lock/transform_into_action/v0/mod.rs:298. A bad proof returns a PartiallyUseAssetLockAction together with a consensus error, but this CheckTx path converts the result to errors only at lines 318-323, and check_tx_v0 rejects it without executing or persisting the penalty action. The asset-lock owner can therefore mutate a canonical proof, re-sign each transition, and repeatedly run Halo2 verification against the same funded lock outside the new action-weighted limit. Acquire the CheckTx permit around ShieldFromAssetLock proof verification after its cheap asset-lock and state admission checks, while preserving the transformer's penalty action for proposal and block processing, and add a regression test covering this path.

In `packages/rs-drive-abci/src/platform_types/check_tx_proof_verifier.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/platform_types/check_tx_proof_verifier.rs:87-98: Exercise the limiter under concurrent contention
  The current test acquires permits sequentially and never sends competing callers through the compare-exchange retry path. Add a barrier-based multithreaded test that holds admitted permits, records the maximum simultaneous weight, verifies it never exceeds the configured limit, and confirms all capacity is released afterward. This directly protects the concurrency property the limiter was introduced to enforce.

In `packages/rs-drive-abci/src/abci/handler/check_tx.rs`:
- [SUGGESTION] packages/rs-drive-abci/src/abci/handler/check_tx.rs:150-156: Cover backpressure through the complete CheckTx error path
  Retryable backpressure depends on the validator producing CheckTxProofVerificationBusy, this handler propagating it instead of converting it into an in-band ABCI response, and the application mapping it to tonic ResourceExhausted. Existing tests cover the validator and status mapper independently, so removing this special case would still leave them green. Add a handler/application-level test that occupies the permit, submits a state-admissible shielded transition, and asserts the resulting tonic status is ResourceExhausted.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.09594% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.45%. Comparing base (fc05d62) to head (f7a8843).
⚠️ Report is 5 commits behind head on v4.1-dev.

Files with missing lines Patch % Lines
...n/state_transition/check_tx_verification/v0/mod.rs 94.39% 6 Missing ⚠️
...tate_transition/processor/traits/shielded_proof.rs 71.42% 6 Missing ⚠️
...ackages/rs-drive-abci/src/abci/handler/check_tx.rs 94.44% 2 Missing ⚠️
...abci/src/platform_types/check_tx_proof_verifier.rs 98.79% 1 Missing ⚠️
...s/rs-drive-abci/src/platform_types/platform/mod.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           v4.1-dev    #4164      +/-   ##
============================================
+ Coverage     87.43%   87.45%   +0.02%     
============================================
  Files          2646     2649       +3     
  Lines        333981   334578     +597     
============================================
+ Hits         292023   292616     +593     
- Misses        41958    41962       +4     
Components Coverage Δ
dpp 88.44% <ø> (ø)
drive 86.13% <ø> (-0.02%) ⬇️
drive-abci 89.60% <94.09%> (+0.08%) ⬆️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 92.90% <ø> (+0.01%) ⬆️
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 49.66% <ø> (+0.11%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@QuantumExplorer
QuantumExplorer merged commit 127c29f into v4.1-dev Jul 22, 2026
20 of 22 checks passed
@QuantumExplorer
QuantumExplorer deleted the codex/fix-checktx-validation-bounds branch July 22, 2026 08:20
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.

2 participants