Skip to content

fix(dpp): reduce max_shielded_transition_actions from 100 to 16 (#3411)#3498

Merged
QuantumExplorer merged 3 commits intov3.1-devfrom
fix/shielded-max-actions
Apr 21, 2026
Merged

fix(dpp): reduce max_shielded_transition_actions from 100 to 16 (#3411)#3498
QuantumExplorer merged 3 commits intov3.1-devfrom
fix/shielded-max-actions

Conversation

@lklimek
Copy link
Copy Markdown
Contributor

@lklimek lklimek commented Apr 15, 2026

Issue being fixed or feature implemented

Fixes #3411 — Shielded unshield rejected as "Tx too large" when spending many notes.

Related: #3399 (same root cause for asset lock transactions, fixed separately in #3491).

User Story

Imagine you are a user who has shielded credits in multiple small operations (e.g., 10× 0.1 DASH). When you try to unshield the full accumulated balance, the operation fails with a cryptic "Tx too large" error at the gRPC layer — leaving you wondering if your funds are stuck.

What was done?

Reduced max_shielded_transition_actions from 100 to 16 in SystemLimits.

Why the old limit was wrong

Each SerializedAction is 408 bytes (nullifier 32 + rk 32 + cmx 32 + encrypted_note 216 + cv_net 32 + spend_auth_sig 64). The bundle overhead (Halo 2 proof ~5,000 bytes, anchor 32, value_balance 8, flags 1, binding_sig 64, state transition envelope ~200) totals ~5,305 bytes.

Actions Payload Fits in 20 KiB?
100 (old) 100 × 408 + 5,305 = 46,105 bytes ❌ 2.25× over limit
16 (new) 16 × 408 + 5,305 = 11,833 bytes ✅ 42% margin

With the new limit, the validation layer (validate_actions_count + ShieldedTooManyActionsError) rejects oversized transitions early with a clear error, instead of letting them hit the gRPC transport limit.

Cross-reference: PR #3491 (asset locks)

PR #3491 separately limits asset lock transaction inputs to 100. That limit is correct for its context: each asset lock input is ~184 bytes, so 100 × 184 + 477 = 18,877 bytes (fits in 20 KiB with 8% margin). Different transaction type, different math, both correct.

How Has This Been Tested?

  • cargo test -p dpp --lib -- common_validation — 16 tests pass (existing validation tests)
  • Updated 5 drive-abci shielded test files to use 17 actions (one over new limit) instead of 101
  • Updated platform-version mock to match new value
  • All 90 shielded-related tests pass

Breaking Changes

Consensus-breaking: Transitions with 17–100 actions that were previously accepted will now be rejected. This is intentional — such transitions would have been rejected at the gRPC transport layer anyway with "Tx too large".

Checklist:

  • I have performed a self-review of my own code
  • 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

🤖 Co-authored by Claudius the Magnificent AI Agent

Summary by CodeRabbit

  • Chores
    • Reduced the maximum allowed shielded transition actions from 100 to 16 across system configuration.
    • Updated test fixtures and mocks to reflect and validate the new 16-action limit.

The previous limit of 100 actions allowed state transitions up to ~46 KB,
far exceeding the 20 KiB max_state_transition_size. Each SerializedAction
is 408 bytes; at 16 actions the total is ~12 KB with comfortable margin.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 18170339-2cd6-48b6-80fc-e8ad9345f2c8

📥 Commits

Reviewing files that changed from the base of the PR and between ab6aeea and 5de5f7a.

📒 Files selected for processing (5)
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shield/tests.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/shielded_transfer/tests.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shielded_withdrawal/tests.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/unshield/tests.rs
✅ Files skipped from review due to trivial changes (3)
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/unshield/tests.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/shielded_withdrawal/tests.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shield/tests.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shielded_transfer/tests.rs

📝 Walkthrough

Walkthrough

Updated the max_shielded_transition_actions limit from 100 to 16 in platform/system limits and adjusted unit tests to use 17 actions (instead of 101), with comments updated to target the validate_structure check for the new threshold.

Changes

Cohort / File(s) Summary
System limits
packages/rs-platform-version/src/version/mocks/v2_test.rs, packages/rs-platform-version/src/version/system_limits/v1.rs
Changed system_limits.max_shielded_transition_actions from 10016 in v1 constants and test mock.
Shielded operation tests
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shield/tests.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/shielded_transfer/tests.rs, packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shielded_withdrawal/tests.rs, packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/unshield/tests.rs
Reduced test dummy action counts from 101→17 and updated inline doc/comments to exercise max_shielded_transition_actions (16) via validate_structure; assertions unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hop, hop — I trimmed the list, so neat,

Seventeen carrots in a row to greet.
Limits tighter, tests now dance,
Validation sings at every chance.
A little hop makes code complete.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: reducing max_shielded_transition_actions from 100 to 16.
Linked Issues check ✅ Passed The PR successfully implements the primary objective from #3411: enforcing an explicit size limit for shielded transitions to prevent transport-layer failures.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the max_shielded_transition_actions limit reduction; no unrelated modifications present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/shielded-max-actions

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 and usage tips.

@github-actions github-actions Bot added this to the v3.1.0 milestone Apr 15, 2026
@lklimek lklimek requested a review from Copilot April 15, 2026 14:40
@lklimek lklimek marked this pull request as ready for review April 15, 2026 14:41
@thepastaclaw
Copy link
Copy Markdown
Collaborator

thepastaclaw commented Apr 15, 2026

⏳ Review in progress (commit 5de5f7a)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Reduces the maximum number of shielded Orchard actions permitted in shielded state transitions so transitions are rejected early with a deterministic consensus error rather than failing later due to state transition size limits.

Changes:

  • Lowered max_shielded_transition_actions in SystemLimits from 100 to 16 (with sizing rationale).
  • Updated the TEST_PLATFORM_V2 mock limits to match the new value.
  • Updated Drive ABCI shielded transition tests to exceed the new limit (17 actions) instead of the old one (101 actions), and refreshed related inline comments.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/rs-platform-version/src/version/system_limits/v1.rs Decreases the consensus limit for shielded actions to 16 and documents the size math.
packages/rs-platform-version/src/version/mocks/v2_test.rs Aligns the V2 test platform mock with the new shielded actions limit.
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/unshield/tests.rs Updates “too many actions” test to use 17 actions (over the new limit).
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shielded_withdrawal/tests.rs Updates “too many actions” test to use 17 actions (over the new limit).
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shielded_transfer/tests.rs Updates “too many actions” test to use 17 actions (over the new limit).
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shield_from_asset_lock/tests.rs Updates “too many actions” test to use 17 actions (over the new limit).
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/shield/tests.rs Updates “too many actions” test to use 17 actions (over the new limit).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.83%. Comparing base (bc21822) to head (5de5f7a).
⚠️ Report is 2 commits behind head on v3.1-dev.

Additional details and impacted files
@@             Coverage Diff              @@
##           v3.1-dev    #3498      +/-   ##
============================================
- Coverage     84.84%   84.83%   -0.01%     
============================================
  Files          2476     2476              
  Lines        267915   267733     -182     
============================================
- Hits         227303   227123     -180     
+ Misses        40612    40610       -2     
Components Coverage Δ
dpp 81.99% <ø> (-0.01%) ⬇️
drive 84.21% <ø> (ø)
drive-abci 87.46% <ø> (-0.03%) ⬇️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 92.10% <ø> (ø)
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 55.66% <ø> (ø)
🚀 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.

…ests

Replace the outdated "17 actions could exceed 20KB" explanation — per the
sizing math documented alongside max_shielded_transition_actions=16,
17 actions is ~12KB, well under the 20 KiB state transition size cap.
The real reason for calling validate_structure directly is to exercise
the action-count check in isolation from the full processing pipeline.

Addresses Copilot PR review on #3498.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lklimek lklimek added the ready for final review Ready for the final review. If AI was involved in producing this PR, it has already had a reviewer. label Apr 20, 2026
@QuantumExplorer QuantumExplorer merged commit 2e135bf into v3.1-dev Apr 21, 2026
44 checks passed
@QuantumExplorer QuantumExplorer deleted the fix/shielded-max-actions branch April 21, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for final review Ready for the final review. If AI was involved in producing this PR, it has already had a reviewer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(zk): Shielded unshield rejected as "Tx too large" when spending many notes

4 participants