Skip to content

feat(dpp): add getters and setters for new shielded state transitions#3879

Merged
QuantumExplorer merged 1 commit into
v3.1-devfrom
claude/blissful-carson-2ad6cc
Jun 13, 2026
Merged

feat(dpp): add getters and setters for new shielded state transitions#3879
QuantumExplorer merged 1 commit into
v3.1-devfrom
claude/blissful-carson-2ad6cc

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Jun 13, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Resolves #3871.

rs-dpp 4.0.0-rc.2 ships the new shielded state transitions with public fields on their V0 structs, but the enum wrappers had no accessors for most fields. As the issue reports, you could reach inputs / input_witnesses on ShieldTransition (via StateTransitionWitnessSigned) but could not get/set actions, amount, anchor, proof, etc. through the enum:

let mut transition = ShieldTransition::V0(ShieldTransitionV0 { .. });
transition.set_actions(vec![..]); // <- did not exist
transition.set_amount(11111111);  // <- did not exist

What was done?

Added complete getters and setters for every field of all six new shielded transitions, following the existing *AccessorsV0 trait pattern (trait defined in accessors/v0/mod.rs, implemented on the enum in accessors/mod.rs):

Transition Change
ShieldTransition new ShieldTransitionAccessorsV0: actions, amount, anchor, proof, binding_signature, fee_strategy (+ setters)
ShieldFromAssetLockTransition new ShieldFromAssetLockTransitionAccessorsV0: actions, value_balance, anchor, proof, binding_signature, surplus_output (+ setters)
UnshieldTransition added setters for all fields + getters for unshielding_amount, anchor, proof, binding_signature
ShieldedTransferTransition added setters for all fields + getters for value_balance, anchor, proof, binding_signature
ShieldedWithdrawalTransition added setters for all fields + getters for unshielding_amount, anchor, proof, binding_signature, core_fee_per_byte, pooling
IdentityCreateFromShieldedPoolTransition added setters for all fields + getters for anchor, proof, binding_signature

Fields already exposed through shared traits are intentionally not duplicated, to avoid method-call ambiguity on the enum:

  • inputs / input_witnessesStateTransitionWitnessSigned
  • user_fee_increaseStateTransitionHasUserFeeIncrease
  • asset_lock_proofAssetLockProved
  • ECDSA signatureStateTransitionSingleSigned

How Has This Been Tested?

  • Added a test_getters_and_setters round-trip test to each transition's accessors/mod.rs (6 tests) — asserts each getter reads the constructed value and each setter mutates it.
  • cargo test -p dpp --all-features accessors::tests::test_getters_and_setters — all 6 pass.
  • cargo check -p dpp --all-features --tests — clean.
  • cargo clippy -p dpp --all-features --tests — clean.
  • cargo fmt --all applied.

Breaking Changes

None. The changes are purely additive — new methods on the *AccessorsV0 traits whose only implementors are the enum wrappers in this crate. Downstream crates that call these accessors are unaffected.

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

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests

    • Added comprehensive unit tests for shielded transition accessor methods across multiple transition types, validating getter and setter functionality.
  • Refactor

    • Enhanced shielded transition components with mutable accessor methods, enabling read-write operations on transition fields for IdentityCreateFromShieldedPool, ShieldFromAssetLock, Shield, ShieldedTransfer, ShieldedWithdrawal, and Unshield transitions.

The new shielded state-transition enums (ShieldTransition,
UnshieldTransition, ShieldedTransferTransition, ShieldedWithdrawalTransition,
ShieldFromAssetLockTransition and IdentityCreateFromShieldedPoolTransition)
exposed their V0 struct fields publicly but the enum wrappers had no
getters/setters for most of them, so callers could not mutate a transition
through the enum (e.g. `transition.set_actions(..)` / `set_amount(..)`).

Add full getters and setters for every field of all six transitions via their
`*AccessorsV0` traits (creating the missing accessor modules for
ShieldTransition and ShieldFromAssetLockTransition). Fields already exposed
through shared traits are intentionally not duplicated to avoid method-call
ambiguity on the enum: inputs/input_witnesses via StateTransitionWitnessSigned,
user_fee_increase via StateTransitionHasUserFeeIncrease, asset_lock_proof via
AssetLockProved and the ECDSA signature via StateTransitionSingleSigned.

Add a getter/setter round-trip test for each transition.

Closes #3871

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d3a291ef-9858-4857-b396-d8aae47bb6e3

📥 Commits

Reviewing files that changed from the base of the PR and between 65042eb and a005f7c.

📒 Files selected for processing (14)
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/identity_create_from_shielded_pool_transition/accessors/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/identity_create_from_shielded_pool_transition/accessors/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/shield_from_asset_lock_transition/accessors/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/shield_from_asset_lock_transition/accessors/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/shield_from_asset_lock_transition/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/shield_transition/accessors/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/shield_transition/accessors/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/shield_transition/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/shielded_transfer_transition/accessors/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/shielded_transfer_transition/accessors/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/shielded_withdrawal_transition/accessors/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/shielded_withdrawal_transition/accessors/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/unshield_transition/accessors/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/unshield_transition/accessors/v0/mod.rs

📝 Walkthrough

Walkthrough

This PR implements getter and setter accessor methods across six shielded transition types (IdentityCreateFromShieldedPool, ShieldFromAssetLock, Shield, ShieldedTransfer, ShieldedWithdrawal, Unshield), following a consistent trait-based pattern. Each transition gains immutable and mutable access to Orchard proofs, serialized actions, anchors, and balance/fee parameters, with comprehensive unit tests validating field mutation behavior.

Changes

Shielded transition getter and setter accessors

Layer / File(s) Summary
Identity creation transition accessors
packages/rs-dpp/src/state_transition/state_transitions/shielded/identity_create_from_shielded_pool_transition/accessors/v0/mod.rs, packages/rs-dpp/src/state_transition/state_transitions/shielded/identity_create_from_shielded_pool_transition/accessors/mod.rs
IdentityCreateFromShieldedPoolTransitionAccessorsV0 trait gains 8 setter methods (set_actions, set_public_keys, set_denomination, set_anchor, set_proof, set_binding_signature, set_send_to_address_on_creation_failure, set_identity_id); implementation delegates to V0 variant; tests verify getter/setter round-trip behavior.
Shield-from-asset-lock transition accessors
packages/rs-dpp/src/state_transition/state_transitions/shielded/shield_from_asset_lock_transition/mod.rs, packages/rs-dpp/src/state_transition/state_transitions/shielded/shield_from_asset_lock_transition/accessors/v0/mod.rs, packages/rs-dpp/src/state_transition/state_transitions/shielded/shield_from_asset_lock_transition/accessors/mod.rs
New accessors submodule exposes ShieldFromAssetLockTransitionAccessorsV0 trait with 12 getter/setter methods (actions, value_balance, anchor, proof, binding_signature, surplus_output) plus default nullifiers helper; implementation pattern matches on V0 variant; comprehensive test coverage validates all field accessors.
Shield transition accessors
packages/rs-dpp/src/state_transition/state_transitions/shielded/shield_transition/mod.rs, packages/rs-dpp/src/state_transition/state_transitions/shielded/shield_transition/accessors/v0/mod.rs, packages/rs-dpp/src/state_transition/state_transitions/shielded/shield_transition/accessors/mod.rs
New accessors submodule exposes ShieldTransitionAccessorsV0 trait with 12 getter/setter methods (actions, amount, anchor, proof, binding_signature, fee_strategy) plus default nullifiers helper; implementation dispatches on V0 enum variant; comprehensive tests exercise all field accessors.
Shielded transfer transition accessors
packages/rs-dpp/src/state_transition/state_transitions/shielded/shielded_transfer_transition/accessors/v0/mod.rs, packages/rs-dpp/src/state_transition/state_transitions/shielded/shielded_transfer_transition/accessors/mod.rs
ShieldedTransferTransitionAccessorsV0 trait expanded with 5 new setter methods (set_actions, set_value_balance, set_anchor, set_proof, set_binding_signature); each setter mutates the V0 backing fields via pattern match; tests construct sample transition and verify getter correctness before and after setter mutations.
Shielded withdrawal transition accessors
packages/rs-dpp/src/state_transition/state_transitions/shielded/shielded_withdrawal_transition/accessors/v0/mod.rs, packages/rs-dpp/src/state_transition/state_transitions/shielded/shielded_withdrawal_transition/accessors/mod.rs
ShieldedWithdrawalTransitionAccessorsV0 trait expanded from 2 minimal accessors to 17 methods including setters for actions, unshielding_amount, anchor, proof, binding_signature, core_fee_per_byte, pooling, and output_script; implementation replaces prior minimal accessor pattern with full variant-dispatched access; tests validate all new getter/setter pairs and Pooling enum handling.
Unshield transition accessors
packages/rs-dpp/src/state_transition/state_transitions/shielded/unshield_transition/accessors/v0/mod.rs, packages/rs-dpp/src/state_transition/state_transitions/shielded/unshield_transition/accessors/mod.rs
UnshieldTransitionAccessorsV0 trait extended from 2 read-only accessors to 12 getter/setter methods covering actions, output_address, unshielding_amount, anchor, proof, binding_signature; each setter implements V0 variant dispatch pattern; tests build sample transition and verify getter/setter consistency.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • dashpay/platform#3816: Introduces initial IdentityCreateFromShieldedPoolTransition accessors (v0 trait and read-only getters), which this PR extends with complete setter implementations and tests.

Suggested labels

ready for final review

Suggested reviewers

  • shumkov
  • thepastaclaw

Poem

🐰 Six transitions now speak in getters and setters true,
Accessors unlock the shielded cryptographic brew,
Actions, anchors, proofs aligned in harmony,
Orchard fields dance with v0 consistency! 🌾

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.10% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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: adding getters and setters for shielded state transitions.
Linked Issues check ✅ Passed All coding requirements from #3871 are met: getters and setters implemented for ShieldTransition, ShieldFromAssetLockTransition, UnshieldTransition, ShieldedTransferTransition, ShieldedWithdrawalTransition, and IdentityCreateFromShieldedPoolTransition.
Out of Scope Changes check ✅ Passed All changes are in-scope: new accessor modules and trait implementations for shielded transitions. No extraneous modifications found.

✏️ 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 claude/blissful-carson-2ad6cc

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.

@thepastaclaw

thepastaclaw commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

✅ Review complete (commit a005f7c)

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

Code Review

Purely additive PR adding getters and setters for six new shielded state-transition enum wrappers, following the existing *AccessorsV0 trait pattern. Both agent reviewers and CodeRabbit found no actionable issues. No consensus-critical paths, validation, or serialization touched.

@codecov

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.20%. Comparing base (65042eb) to head (a005f7c).

Additional details and impacted files
@@              Coverage Diff              @@
##           v3.1-dev    #3879       +/-   ##
=============================================
- Coverage     87.22%   71.20%   -16.03%     
=============================================
  Files          2641       20     -2621     
  Lines        328569     2837   -325732     
=============================================
- Hits         286597     2020   -284577     
+ Misses        41972      817    -41155     
Components Coverage Δ
dpp ∅ <ø> (∅)
drive ∅ <ø> (∅)
drive-abci ∅ <ø> (∅)
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value ∅ <ø> (∅)
platform-wallet ∅ <ø> (∅)
drive-proof-verifier ∅ <ø> (∅)
🚀 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.

@github-actions

Copy link
Copy Markdown
Contributor

✅ DashSDKFFI.xcframework built for this PR.

SwiftPM (host the zip at a stable URL, then use):

.binaryTarget(
  name: "DashSDKFFI",
  url: "https://your.cdn.example/DashSDKFFI.xcframework.zip",
  checksum: "cef79a9c53d7af301aac7af5a0bf80deef569a9bc755f3290f9d3927527d1754"
)

Xcode manual integration:

  • Download 'DashSDKFFI.xcframework' artifact from the run link above.
  • Drag it into your app target (Frameworks, Libraries & Embedded Content) and set Embed & Sign.
  • If using the Swift wrapper package, point its binaryTarget to the xcframework location or add the package and place the xcframework at the expected path.

@QuantumExplorer QuantumExplorer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Reviewed

@QuantumExplorer QuantumExplorer merged commit 09b2c90 into v3.1-dev Jun 13, 2026
33 of 35 checks passed
@QuantumExplorer QuantumExplorer deleted the claude/blissful-carson-2ad6cc branch June 13, 2026 19:03
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.

New transitions doesn't have getter/setter methods

2 participants