Skip to content

fix(platform): correct burn identity in group actions#2615

Merged
QuantumExplorer merged 8 commits into
v2.0-devfrom
branch-fixgroup-action-burn-identity
May 19, 2025
Merged

fix(platform): correct burn identity in group actions#2615
QuantumExplorer merged 8 commits into
v2.0-devfrom
branch-fixgroup-action-burn-identity

Conversation

@QuantumExplorer
Copy link
Copy Markdown
Member

@QuantumExplorer QuantumExplorer commented May 18, 2025

Issue being fixed or feature implemented

Group action burns were incorrectly using the last person who approved the group action as the burn identity instead of the originator.

What was done?

  • Updated the BurnEvent message to include burn_from_id as a required field.
  • Modified the TokenEvent::Burn to accept burn_from_identifier and adjusted related methods and structures accordingly.
  • Changed the logic in the TokenBurnTransitionAction to set the correct burn_from_identifier based on the group action originator.
  • Updated tests to ensure the correct behavior during token burns in group actions.

How Has This Been Tested?

  • Added new unit tests to cover the updated behavior for group action token burns.
  • Existing tests were run and passed to ensure no other functionality was broken.

Breaking Changes

None

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

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features
    • Added tracking of the identity from which tokens are burned in token burn events and related records.
    • Included proposer identity in group action events for better traceability.
    • Introduced a new searchable field and index for "burnFromId" in token burn history documents, allowing more detailed queries.
  • Bug Fixes
    • Corrected the description of the "recipientId" field in mint event history.
  • Tests
    • Added comprehensive tests for group-authorized token burns, including scenarios with token transfers before burn completion.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2025

Walkthrough

This update introduces explicit tracking of the identity from which tokens are burned across the token platform. It adds a burn_from_id field to protocol buffers, Rust structures, and token event representations, and updates serialization, accessors, and schema definitions accordingly. Related test cases and validation logic are also extended. Additionally, a proposer_id field is added to group actions to track the identity proposing the action.

Changes

File(s) Change Summary
packages/dapi-grpc/protos/platform/v0/platform.proto Modified BurnEvent in GetGroupActionsResponse: replaced public_note at field 2 with required bytes burn_from_id, moved public_note to field 3.
packages/token-history-contract/schema/v1/token-history-contract-documents.json Added burnFromId property and index to burn document; updated property positions; clarified recipientId description in mint document.
packages/rs-dpp/src/tokens/token_event.rs Introduced BurnFromIdentifier alias; updated TokenEvent::Burn to include BurnFromIdentifier; updated related methods and serialization.
packages/rs-dpp/src/group/group_action/mod.rs,
packages/rs-dpp/src/group/group_action/v0/mod.rs
Added proposer_id field and accessor to GroupActionV0 and related trait implementations.
packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_burn_transition_action/v0/mod.rs Added burn_from_identifier field to TokenBurnTransitionActionV0; changed burn_amount type to TokenAmount; updated accessors.
packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_burn_transition_action/mod.rs Added getter/setter for burn_from_identifier in TokenBurnTransitionActionAccessorsV0.
packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_burn_transition_action/v0/transformer.rs Extracted/validated burn_from_identifier from group action or defaulted to owner_id when constructing TokenBurnTransitionActionV0.
packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_burn_transition.rs Updated TokenEvent::Burn construction to include burn_from_identifier; updated group action and operation initializations.
packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_base_transition_action/v0/transformer.rs Renamed local variable for clarity; no logic changes.
packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_transition.rs Modified associated_token_event for BurnAction to include burn_from_identifier.
packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_config_update_transition.rs,
token_destroy_frozen_funds_transition.rs,
token_emergency_action_transition.rs,
token_freeze_transition.rs,
token_mint_transition.rs,
token_set_price_for_direct_purchase_transition.rs,
token_unfreeze_transition.rs
Added proposer_id field to GroupActionV0 initialization when action is proposer.
packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs Updated test data: added proposer_id to GroupActionV0; updated TokenEvent::Burn to include burn_from_identifier.
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/token/token_burn_transition_action/state_v0/mod.rs Updated pattern matching for TokenEvent::Burn to include new field; used burn_from_identifier in balance validation.
packages/rs-drive-abci/src/query/group_queries/group_actions/v0/mod.rs Updated mapping of TokenEvent::Burn to gRPC response to include burn_from_id.
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/burn/mod.rs Added two tests covering group burn with intermediate token transfers and insufficient balances.
packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_transition.rs Updated construction of TokenEvent::Burn to include owner_id as burn_from_identifier.
packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs Added match arm for TokenTransition::Burn(_) to ignore burnFromId and note fields in historical doc comparison.
packages/rs-drive/src/drive/group/prove/prove_action_infos/v0/mod.rs,
packages/rs-drive/src/drive/group/prove/prove_action_signers/v0/mod.rs
Updated tests to include proposer_id in GroupActionV0 and burn_from_identifier in TokenEvent::Burn.
packages/rs-sdk/tests/fetch/group_actions.rs Updated test assertions to include proposer_id and burn_from_identifier in GroupActionV0 and TokenEvent::Burn.
packages/rs-sdk/tests/vectors/test_fetch_all_group_actions/quorum_pubkey-106-0acdeecd6241d2cdec7ff61f91adb6f84188c97ff5d6f33f2225522b6f666be8.json,
packages/rs-sdk/tests/vectors/test_fetch_one_group_action_since_existing_one_with_limit/quorum_pubkey-106-0acdeecd6241d2cdec7ff61f91adb6f84188c97ff5d6f33f2225522b6f666be8.json
Added new test vector files with cryptographic data for group action fetch tests.
packages/rs-sdk/tests/vectors/test_fetch_all_group_actions/quorum_pubkey-106-4308e13f7335a56c12a2fd4a2e64670383282934865ccc3241c0f7fedf218853.json,
packages/rs-sdk/tests/vectors/test_fetch_one_group_action_since_existing_one_with_limit/quorum_pubkey-106-101a4299cad9e06288ea7a290a730a1c696ab53d03e0b241f35f9d002eee3233.json
Removed obsolete test vector files.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Platform
    participant GroupAction
    participant TokenEvent
    participant StateValidation
    participant HistoryContract

    Client->>Platform: Propose token burn (specify burn_from_id)
    Platform->>GroupAction: Create GroupActionV0 (with proposer_id)
    GroupAction->>TokenEvent: Create Burn event (amount, burn_from_id, note)
    Platform->>StateValidation: Validate burn (uses burn_from_id)
    StateValidation->>HistoryContract: Record burn (burnFromId in document)
    Platform->>Client: Respond with burn result (includes burn_from_id)
Loading

Poem

A rabbit with tokens, so clever and spry,
Now tracks every burn, not letting one fly.
With burn_from_id hopping into the code,
Each burn’s true source is carefully showed.
Proposers and notes, all fields in a row—
The ledger’s more clear, as all rabbits now know!
🐇✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🔭 Outside diff range comments (2)
packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_burn_transition_action/v0/mod.rs (2)

31-41: ⚠️ Potential issue

Accessor signatures still use u64 – type mismatch with TokenAmount

burn_amount is now TokenAmount, yet the trait exposes u64.
This will not compile unless TokenAmount is a type-alias. Even then, the API is misleading.

-    fn burn_amount(&self) -> u64;
+    fn burn_amount(&self) -> TokenAmount;

-    fn set_burn_amount(&mut self, amount: u64);
+    fn set_burn_amount(&mut self, amount: TokenAmount);

92-106: ⚠️ Potential issue

Implementation must mirror the trait change

-    fn burn_amount(&self) -> u64 {
+    fn burn_amount(&self) -> TokenAmount {
         self.burn_amount
     }

-    fn set_burn_amount(&mut self, amount: u64) {
+    fn set_burn_amount(&mut self, amount: TokenAmount) {
         self.burn_amount = amount;
     }
🧹 Nitpick comments (6)
packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_burn_transition_action/v0/transformer.rs (2)

115-118: Pattern match is brittle – use an exhaustive match or explicit guard

At runtime corruption is turned into a ProtocolError, but the pattern only matches one exact variant shape.
If the enum later gains additional fields (e.g. TokenEvent::Burn { … } style) this line will silently break at compile-time.
Consider an exhaustive match or if let TokenEvent::Burn { burn_from_id, .. } to make the intent future-proof.


231-238: Duplicate extraction logic – extract into a small helper

The burn_from_identifier extraction is duplicated in both constructors. A tiny private function would remove the repetition and the risk of future divergence.

fn derive_burn_from(base: &TokenBaseTransitionAction, fallback: Identifier) -> Result<Identifier, Error> {}
packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_burn_transition_action/v0/mod.rs (1)

15-19: Field order: put new, small fields before large ones

Identifier (32 bytes) before TokenAmount (8 bytes) avoids padding and maintains the previous struct size layout. This is a minor but free optimisation.

packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/burn/mod.rs (3)

516-517: Incorrect comment in the assertion section

The comment on line 516 indicates "Original identity should have no tokens" but the assertion checks for Some(98663) tokens remaining. This comment appears to be misleading.

-        assert_eq!(balance1, Some(98663));       // Original identity should have no tokens
+        assert_eq!(balance1, Some(98663));       // Original identity should have reduced balance (100000 - 1337)

517-518: Inconsistent comment in assertion section

The comment on line 517 incorrectly states "Recipient should not keep transferred tokens if burn was enforced" but the test is actually verifying that the recipient keeps the transferred tokens (which is the expected behavior).

-        assert_eq!(balance2, Some(1337));       // Recipient should not keep transferred tokens if burn was enforced
+        assert_eq!(balance2, Some(1337));       // Recipient should keep transferred tokens even after burn is enforced

746-747: Misleading comment in validation section

The comment "Validate the burn still succeeded even though tokens were transferred" is incorrect since the burn actually failed with an error, as expected in this test case.

-        // Validate the burn still succeeded even though tokens were transferred
+        // Validate balances remain unchanged after burn failed due to insufficient tokens
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 64f0c69 and 23fae7d.

📒 Files selected for processing (24)
  • packages/dapi-grpc/protos/platform/v0/platform.proto (1 hunks)
  • packages/rs-dpp/src/group/group_action/mod.rs (2 hunks)
  • packages/rs-dpp/src/group/group_action/v0/mod.rs (2 hunks)
  • packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_transition.rs (1 hunks)
  • packages/rs-dpp/src/tokens/token_event.rs (5 hunks)
  • packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs (1 hunks)
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/token/token_burn_transition_action/state_v0/mod.rs (3 hunks)
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/burn/mod.rs (2 hunks)
  • packages/rs-drive-abci/src/query/group_queries/group_actions/v0/mod.rs (1 hunks)
  • packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_burn_transition.rs (3 hunks)
  • packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_config_update_transition.rs (1 hunks)
  • packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition.rs (1 hunks)
  • packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_emergency_action_transition.rs (1 hunks)
  • packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_freeze_transition.rs (1 hunks)
  • packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_mint_transition.rs (1 hunks)
  • packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_set_price_for_direct_purchase_transition.rs (1 hunks)
  • packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_transition.rs (1 hunks)
  • packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_unfreeze_transition.rs (1 hunks)
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_base_transition_action/v0/transformer.rs (2 hunks)
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_burn_transition_action/mod.rs (2 hunks)
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_burn_transition_action/v0/mod.rs (4 hunks)
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_burn_transition_action/v0/transformer.rs (3 hunks)
  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs (1 hunks)
  • packages/token-history-contract/schema/v1/token-history-contract-documents.json (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (6)
packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/token/token_burn_transition_action/state_v0/mod.rs (1)
packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts (2)
  • GroupActionEvent (8224-8249)
  • TokenEvent (8366-8416)
packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs (1)
packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts (2)
  • GroupActionEvent (8224-8249)
  • TokenEvent (8366-8416)
packages/rs-dpp/src/group/group_action/mod.rs (1)
packages/rs-dpp/src/group/group_action/v0/mod.rs (1)
  • proposer_id (25-27)
packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_burn_transition_action/mod.rs (1)
packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_burn_transition_action/v0/mod.rs (4)
  • burn_from_identifier (32-32)
  • burn_from_identifier (92-94)
  • set_burn_from_identifier (35-35)
  • set_burn_from_identifier (96-98)
packages/rs-dpp/src/group/group_action/v0/mod.rs (1)
packages/rs-dpp/src/group/group_action/mod.rs (2)
  • proposer_id (22-22)
  • proposer_id (33-37)
packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_burn_transition.rs (3)
packages/rs-dpp/src/group/group_action/v0/mod.rs (1)
  • event (33-35)
packages/rs-dpp/src/group/group_action/mod.rs (2)
  • event (24-24)
  • event (45-49)
packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts (1)
  • TokenEvent (8366-8416)
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: Rust packages (drive-abci) / Detect immutable structure changes
  • GitHub Check: Rust packages (dpp) / Linting
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (rs-dapi-client) / Detect immutable structure changes
  • GitHub Check: Rust packages (dash-sdk) / Linting
  • GitHub Check: Rust packages (rs-dapi-client) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Formatting
  • GitHub Check: Rust packages (token-history-contract) / Unused dependencies
  • GitHub Check: Rust packages (rs-dapi-client) / Unused dependencies
  • GitHub Check: Rust packages (dapi-grpc) / Linting
  • GitHub Check: Rust packages (dapi-grpc) / Check each feature
  • GitHub Check: Rust packages (token-history-contract) / Linting
  • GitHub Check: Rust packages (dapi-grpc) / Formatting
  • GitHub Check: Rust packages (dapi-grpc) / Unused dependencies
  • GitHub Check: Rust packages (wasm-dpp) / Tests
  • GitHub Check: Rust packages (wasm-dpp) / Linting
  • GitHub Check: Build Docker images (DAPI, dapi, dapi) / Build DAPI image
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
🔇 Additional comments (37)
packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_freeze_transition.rs (1)

59-67: Correctly tracks proposer identity in group actions

The addition of proposer_id: owner_id in the GroupActionV0 initialization ensures that the identity of the action proposer is explicitly tracked in group actions, which aligns with the broader changes introduced in this PR to fix identity attribution in token events.

packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_mint_transition.rs (1)

59-67: Properly associates group actions with their proposers

The addition of proposer_id: owner_id correctly tracks which identity initiated the token mint action in a group context, enabling proper attribution in event history and ensuring consistency with other token-related operations.

packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_destroy_frozen_funds_transition.rs (1)

59-66: Correctly tracks proposer identity in destroy frozen funds event

Adding proposer_id: owner_id ensures proper attribution of the identity that initiated the action to destroy frozen funds, maintaining consistency with other token operations and supporting accurate historical tracking of token-related events.

packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_emergency_action_transition.rs (1)

59-66: Ensures proper proposer tracking for emergency actions

The addition of proposer_id: owner_id guarantees that emergency token actions correctly identify their initiator, which is particularly important for accountability in these sensitive operations and aligns with the PR's goal of fixing identity attribution.

packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_set_price_for_direct_purchase_transition.rs (1)

60-69: Correctly adds proposer_id for tracking burn identity origin

This change adds the proposer_id field to the GroupActionV0 struct when initializing the group action, which properly identifies the original proposer of the action rather than the last approver.

packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_unfreeze_transition.rs (1)

60-69: Consistent implementation of proposer_id tracking

This change correctly adds the proposer_id field to GroupActionV0, maintaining consistency with the pattern established in other token operations and properly supporting the fix for burn identity attribution.

packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_config_update_transition.rs (1)

61-70: Properly adds proposer identity tracking

The addition of proposer_id: owner_id to the GroupActionV0 struct maintains consistency with the changes in other token operations and ensures that the group action correctly tracks the identity of the proposing user.

packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs (1)

368-370: Correctly updates burn verification to handle new identity field

This change adds a case to ignore the new burnFromId and note fields when comparing historical documents during burn token transition verification. This is necessary to maintain compatibility with the updated burn event structure that now tracks the identity from which tokens are burned.

packages/rs-drive-abci/src/query/group_queries/group_actions/v0/mod.rs (1)

146-151: Updated TokenEvent::Burn to include burn_from_id parameter

The pattern matching for TokenEvent::Burn now correctly includes the burn_from_id parameter, which is properly serialized to the response. This change ensures that the identity of the token burner is properly tracked and exposed in the API response.

packages/rs-drive-abci/src/execution/platform_events/initialization/create_genesis_state/test/tokens.rs (1)

90-95: Added proposer_id and updated burn event parameters

The GroupActionV0 struct now properly includes the proposer_id field and the TokenEvent::Burn has been updated to include the burn_from_id parameter (IDENTITY_ID_1). This ensures that test data correctly reflects the new structure for tracking the identity from which tokens are burned.

packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_base_transition_action/v0/transformer.rs (2)

88-88: Variable name improved for clarity

The variable has been renamed from current_group_action_event to current_group_action, which better reflects that it contains the entire group action object, not just the event.


192-192: Consistent variable renaming

The tuple return value has been updated to use the renamed variable, maintaining consistency with the earlier change.

packages/rs-dpp/src/group/group_action/mod.rs (2)

21-23: Added proposer_id accessor to GroupActionAccessors trait

This new accessor method properly extends the trait interface to provide access to the proposer_id field, which is necessary for tracking the identity that originated the group action.


33-37: Implemented proposer_id accessor for GroupAction

The implementation follows the established pattern for accessor methods in this enum, properly delegating to the inner variant's implementation. This ensures consistent access to the proposer_id across the codebase.

packages/rs-dpp/src/group/group_action/v0/mod.rs (2)

15-15: Adding the proposer_id field improves clarity and tracking.

The addition of this field explicitly tracks who initiated a group action, rather than just tracking approvers. This is particularly important for token burns to ensure the identity is correctly attributed.


25-27: Accessor method implementation for the new field follows proper patterns.

The implementation correctly returns the field by reference, maintaining consistent accessor patterns with the rest of the struct.

packages/dapi-grpc/protos/platform/v0/platform.proto (1)

663-664: Schema update correctly adds burn identity tracking.

The BurnEvent message now includes a required burn_from_id field to explicitly track which identity's tokens are being burned, fixing the attribution issue in group actions. The public_note field is appropriately maintained but moved to field #3.

packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/action_validation/token/token_burn_transition_action/state_v0/mod.rs (3)

78-79: Updated pattern matching handles new event structure.

The pattern match correctly updates to handle the additional burn_from_id field in the TokenEvent::Burn variant. The underscore pattern appropriately ignores this field since it's not used in the validation logic at this point.


114-114: Token balance validation now checks against the correct identity.

The balance check now uses self.burn_from_identifier() instead of owner_id, ensuring token balances are verified against the actual identity from which tokens are being burned, not just the action initiator.


126-126: Error reporting correctly references burn source identity.

Error message construction is updated to use self.burn_from_identifier(), ensuring error messages accurately identify which identity has insufficient tokens.

packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_transition.rs (1)

402-404: Token burn event construction includes burn source identity.

The TokenEvent::Burn constructor now includes owner_id as a parameter to track which identity's tokens are being burned. The comments helpfully explain that this might need correction during group actions.

This change is essential for proper tracking of token burning in the context of group actions, ensuring the burn is attributed to the right identity.

packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_transition.rs (1)

77-77: Good implementation of burn action attribution.

The added parameter burn_from_identifier() properly ensures that the token burn event now tracks the identity from which tokens are burned. This aligns with the PR objective to correctly attribute burn actions to their originator rather than the last approver.

packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_burn_transition_action/mod.rs (3)

2-2: LGTM - necessary import for the burn identifier.

Adding the Identifier import is needed for the new burn_from_identifier accessor methods.


32-36: LGTM - proper accessor implementation for burn identifier.

This getter method correctly retrieves the burn_from_identifier from the underlying TokenBurnTransitionActionV0 struct. The implementation matches the accessors already defined in the v0 module.


38-42: LGTM - proper setter implementation for burn identifier.

This setter method correctly updates the burn_from_identifier on the underlying TokenBurnTransitionActionV0 struct. The implementation matches the accessors already defined in the v0 module.

packages/rs-drive/src/state_transition_action/action_convert_to_operations/batch/token/token_burn_transition.rs (4)

56-56: LGTM - correctly constructs burn event with burn_from identifier.

This change correctly adds the burn_from_identifier to the TokenEvent::Burn construction for group actions, which is in line with the PR objective to properly track the identity from which tokens are burned.


61-61: Good addition of proposer_id to group action.

Setting the proposer_id to owner_id in the GroupActionV0 initialization ensures proper tracking of who proposed the group action. This is essential for the correct attribution of burn actions.


83-83: Critical fix for burn attribution.

Changed identity_balance_holder_id from owner_id to burn_from_identifier, which is the core fix for the issue. This ensures that tokens are burned from the correct identity as indicated by burn_from_identifier rather than the owner_id.


93-93: LGTM - consistent use of burn_from_identifier.

This change correctly updates the TokenEvent::Burn constructor in the TokenHistory operation to include burn_from_identifier, maintaining consistency with the rest of the changes.

packages/rs-dpp/src/tokens/token_event.rs (5)

36-37: Good semantic type alias for clarity.

The introduction of the BurnFromIdentifier type alias provides clear semantic meaning when used in the context of a token burn, improving code readability and maintainability.


71-73: LGTM - proper signature update for Burn event.

The TokenEvent::Burn variant signature now correctly includes BurnFromIdentifier as the second parameter, which is essential for tracking the identity from which tokens are burned.


151-152: LGTM - updated Display implementation.

The Display implementation for TokenEvent::Burn has been properly updated to include the burn_from_identifier in the formatted output.


226-226: LGTM - updated pattern matching for public note.

Pattern matching in the public_note method has been correctly updated to accommodate the new burn_from_identifier parameter.


273-283: LGTM - comprehensive historical document update.

The historical document creation for burn events now properly includes the burnFromId property, ensuring it's stored and queryable in the token history. All related handling is consistent with the updated TokenEvent::Burn signature.

packages/token-history-contract/schema/v1/token-history-contract-documents.json (1)

69-77: Position shift – verify compatibility with existing data

burnFromId inserted at position 1 pushes subsequent fields. Make sure any client relying on positional ordering (e.g. sparse binary layouts or older SDKs) is updated simultaneously; otherwise decoding will be wrong.

packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/batch/tests/token/burn/mod.rs (2)

282-518: Well-structured test for token burn with group actions!

This test thoroughly validates that token burn actions properly track the identity originating the burn even when tokens are transferred between the proposal and confirmation stages of a group action. The test correctly:

  1. Sets up a contract with group-based authorization
  2. Mints tokens to the first identity
  3. Initiates a burn as the proposer
  4. Transfers some tokens to a recipient
  5. Confirms the burn as the second group member
  6. Validates final balances reflect the correct burn attribution

This effectively tests the fix for ensuring burn identity is correctly attributed to the originator rather than the last approver.


521-759: Good edge case test for insufficient balance scenarios!

This complementary test properly validates the error handling when a burn can't be completed due to insufficient balance after token transfers. It correctly:

  1. Initiates a burn as the proposer without first minting tokens
  2. Transfers tokens away, reducing available balance
  3. Attempts to confirm the burn, which appropriately fails with IdentityDoesNotHaveEnoughTokenBalanceError
  4. Verifies balances remain unchanged after the failed confirmation

The test ensures the system correctly handles cases where tokens are transferred between proposal and confirmation, causing the burn to fail due to insufficient balance.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 94c898b and d10cd19.

📒 Files selected for processing (4)
  • packages/rs-sdk/tests/vectors/test_fetch_all_group_actions/quorum_pubkey-106-0acdeecd6241d2cdec7ff61f91adb6f84188c97ff5d6f33f2225522b6f666be8.json (1 hunks)
  • packages/rs-sdk/tests/vectors/test_fetch_all_group_actions/quorum_pubkey-106-4308e13f7335a56c12a2fd4a2e64670383282934865ccc3241c0f7fedf218853.json (0 hunks)
  • packages/rs-sdk/tests/vectors/test_fetch_one_group_action_since_existing_one_with_limit/quorum_pubkey-106-0acdeecd6241d2cdec7ff61f91adb6f84188c97ff5d6f33f2225522b6f666be8.json (1 hunks)
  • packages/rs-sdk/tests/vectors/test_fetch_one_group_action_since_existing_one_with_limit/quorum_pubkey-106-101a4299cad9e06288ea7a290a730a1c696ab53d03e0b241f35f9d002eee3233.json (0 hunks)
💤 Files with no reviewable changes (2)
  • packages/rs-sdk/tests/vectors/test_fetch_all_group_actions/quorum_pubkey-106-4308e13f7335a56c12a2fd4a2e64670383282934865ccc3241c0f7fedf218853.json
  • packages/rs-sdk/tests/vectors/test_fetch_one_group_action_since_existing_one_with_limit/quorum_pubkey-106-101a4299cad9e06288ea7a290a730a1c696ab53d03e0b241f35f9d002eee3233.json
🧰 Additional context used
🪛 Biome (1.9.4)
packages/rs-sdk/tests/vectors/test_fetch_all_group_actions/quorum_pubkey-106-0acdeecd6241d2cdec7ff61f91adb6f84188c97ff5d6f33f2225522b6f666be8.json

[error] 1-1: String values must be double quoted.

(parse)

packages/rs-sdk/tests/vectors/test_fetch_one_group_action_since_existing_one_with_limit/quorum_pubkey-106-0acdeecd6241d2cdec7ff61f91adb6f84188c97ff5d6f33f2225522b6f666be8.json

[error] 1-1: String values must be double quoted.

(parse)

⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: Rust packages (dapi-grpc) / Check each feature
  • GitHub Check: Rust packages (drive-abci) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Unused dependencies
  • GitHub Check: Rust packages (dash-sdk) / Linting
  • GitHub Check: Rust packages (drive) / Linting
  • GitHub Check: Rust packages (drive) / Tests
  • GitHub Check: Rust packages (drive-abci) / Linting
  • GitHub Check: Rust packages (drive) / Formatting
  • GitHub Check: Rust packages (drive-abci) / Unused dependencies
  • GitHub Check: Rust packages (dpp) / Check each feature
  • GitHub Check: Rust packages (wasm-dpp) / Tests
  • GitHub Check: Rust packages (wasm-dpp) / Linting
  • GitHub Check: Rust packages (dpp) / Tests
  • GitHub Check: Rust packages (dpp) / Linting
  • GitHub Check: Rust packages (dpp) / Unused dependencies
  • GitHub Check: Build Docker images (DAPI, dapi, dapi) / Build DAPI image
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
@QuantumExplorer QuantumExplorer changed the title fix: correct burn identity in group actions fix(platform): correct burn identity in group actions May 19, 2025
@QuantumExplorer QuantumExplorer added this to the v2.0.0 milestone May 19, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/token-history-contract/test/unit/tokenHistoryContract.spec.js (1)

47-56: Consider adding specific validation tests for burnFromId field.

The test suite includes validation tests for other required fields like tokenId and amount, but is missing similar tests for the newly added burnFromId field. Adding dedicated tests would ensure the field is properly validated.

You could add a new test section like:

describe('burnFromId', () => {
  it('should be defined', async () => {
    delete rawBurnDocument.burnFromId;
    const document = dpp.document.create(dataContract, identityId, 'burn', rawBurnDocument);
    const validationResult = document.validate(dpp.protocolVersion);
    const error = expectJsonSchemaError(validationResult);
    expect(error.keyword).to.equal('required');
    expect(error.params.missingProperty).to.equal('burnFromId');
  });
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between d6fca74 and 5926cd1.

📒 Files selected for processing (3)
  • packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_transition.rs (1 hunks)
  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs (2 hunks)
  • packages/token-history-contract/test/unit/tokenHistoryContract.spec.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_transition.rs
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: Rust packages (drive-abci) / Detect immutable structure changes
  • GitHub Check: Rust packages (drive-abci) / Linting
  • GitHub Check: Rust packages (drive) / Formatting
  • GitHub Check: Rust packages (drive) / Linting
  • GitHub Check: Rust packages (drive) / Tests
  • GitHub Check: Rust packages (drive) / Unused dependencies
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (dpp) / Unused dependencies
  • GitHub Check: Rust packages (dash-sdk) / Formatting
  • GitHub Check: Rust packages (dash-sdk) / Unused dependencies
  • GitHub Check: Rust packages (dash-sdk) / Linting
  • GitHub Check: Rust packages (dpp) / Tests
  • GitHub Check: Rust packages (dpp) / Linting
  • GitHub Check: Rust packages (dpp) / Check each feature
  • GitHub Check: Rust packages (wasm-dpp) / Unused dependencies
  • GitHub Check: Rust packages (wasm-dpp) / Linting
  • GitHub Check: Rust packages (wasm-dpp) / Tests
  • GitHub Check: Rust packages (token-history-contract) / Unused dependencies
  • GitHub Check: Build JS packages / Build JS
🔇 Additional comments (2)
packages/token-history-contract/test/unit/tokenHistoryContract.spec.js (2)

52-52: Addition of burnFromId field aligns with the PR objectives.

This change correctly adds the burnFromId field to the test document, which is now required according to the updated schema. This addition supports the fix for group action burns to correctly track the identity from which tokens are burned, rather than using the last person who approved the action.


100-104: Verify existing test effectiveness with new field requirement.

This test now implicitly validates that a document with the burnFromId field is valid, which is good. The test passes with the new field added, confirming the schema update is working correctly.

Copy link
Copy Markdown
Member Author

@QuantumExplorer QuantumExplorer left a comment

Choose a reason for hiding this comment

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

Self Reviewed

@QuantumExplorer QuantumExplorer merged commit 3d61b1d into v2.0-dev May 19, 2025
167 of 168 checks passed
@QuantumExplorer QuantumExplorer deleted the branch-fixgroup-action-burn-identity branch May 19, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants