Skip to content

Conversation

@lklimek
Copy link
Contributor

@lklimek lklimek commented Jan 8, 2026

Issue being fixed or feature implemented

Identity creation with funds from platform addresses is confusing:
it's not clear how to create identity ID.

What was done?

Added Identity::new_with_input_addresses_and_keys() constructor that generated identity ID internally.

How Has This Been Tested?

With dash evo tool; WASM changes to be tested separately.

Breaking Changes

None, new feature

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

Summary by CodeRabbit

  • Bug Fixes

    • Stronger identity/address verification enabled for address-based identity creation.
  • New Features

    • Create identities from input addresses paired with public keys.
    • SDK helper to derive identity IDs from address+nonce inputs.
    • WASM helper to fetch and merge nonces into address inputs.
    • Address sync now reports both nonce and balance for found addresses.
  • Chores / Breaking Change

    • Public API now requires explicit nonces for identity submission; automatic nonce-fetching path removed.
    • FFI/address-provider callbacks updated to include nonce and a richer funds type.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions github-actions bot added this to the v3.0.0 milestone Jan 8, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 8, 2026

📝 Walkthrough

Walkthrough

Added an identity constructor that derives IDs from input addresses; extracted identity-ID derivation into a helper; switched two verification flags to true; required explicit address nonces across SDK/FFI; added nonce-fetching helper in WASM SDK and propagated AddressFunds (nonce+balance) through address-sync plumbing.

Changes

Cohort / File(s) Summary
Identity constructor
packages/rs-dpp/src/identity/identity.rs
Added pub fn new_with_input_addresses_and_keys(...) (feature: state-transitions) which derives an identity ID from input addresses and delegates to the existing creation path; added docs and imports.
Identity ID derivation helper
packages/rs-dpp/src/state_transition/traits/state_transition_identity_id_from_inputs.rs
Added pub(crate) fn identity_id_from_input_addresses(...) that encodes address→nonce map and double-hashes to produce an Identifier; updated identity_id_from_inputs to delegate to it and added Credits import and docs.
Verification toggles
packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
In IdentityCreateFromAddresses flow, set two boolean args to true for verify_full_identity_by_identity_id and verify_addresses_infos.
SDK API: explicit nonces
packages/rs-sdk/src/platform/transition/put_identity.rs
Removed automatic nonce-fetching API; put_with_address_funding now accepts inputs_with_nonce: BTreeMap<PlatformAddress,(AddressNonce,Credits)>; removed put_with_address_funding_with_nonce and related auto-nonce logic.
WASM SDK: nonce fetching helper
packages/wasm-sdk/src/state_transitions/addresses.rs
Added fetch_nonces_into_address_map(...) to fetch AddressInfo via fetch_many, validate and merge nonces into inputs, and updated identity creation paths to call it before put_with_address_funding.
AddressSync: internal type and API changes
packages/rs-sdk/src/platform/address_sync/...
Introduced AddressFunds (nonce + balance); changed AddressSyncResult::found to map to AddressFunds; updated conversions (TryFrom<&Element>), processing functions, docs, and tests to use funds.nonce and funds.balance.
AddressProvider trait (SDK)
packages/rs-sdk/src/platform/address_sync/provider.rs
Changed fn on_address_found(..., balance: u64)fn on_address_found(..., funds: AddressFunds) and updated docs/examples.
FFI: address sync vtable & types
packages/rs-sdk-ffi/src/address_sync/{mod.rs,provider.rs,types.rs}
Added nonce: u32 to DashSDKFoundAddress; updated OnAddressFoundFn vtable to include nonce before balance; CallbackAddressProvider::on_address_found now accepts AddressFunds; tests and call sites updated.
FFI: call sites & tests
packages/rs-sdk-ffi/src/address_sync/provider.rs, packages/rs-sdk/tests/fetch/address_sync.rs
Updated call-site signatures and tests to pass and assert AddressFunds (nonce + balance) instead of plain balances.
Misc (minor)
packages/wasm-dpp2/src/platform_address/input_output.rs
Added a non-functional comment adjacent to PlatformAddressOutputWasm (no API changes).

Sequence Diagram(s)

sequenceDiagram
    actor WASM as WASM_SDK
    participant RPC as Platform_RPC
    participant SDK as RS_SDK
    participant DPP as RS_DPP

    WASM->>RPC: fetch_many(addresses)             
    RPC-->>WASM: AddressInfo (nonce + balance)
    WASM->>WASM: merge nonces into inputs_map -> inputs_with_nonce
    WASM->>SDK: put_with_address_funding(inputs_with_nonce, keys, ...)
    SDK->>DPP: identity_id_from_input_addresses(inputs_with_nonce)
    DPP-->>SDK: Identity (via new_with_input_addresses_and_keys)
    SDK-->>WASM: result / broadcast state transition
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I found a nonce beneath each stone,

I stitched them to addresses, line by line.
IDs sprouted where counters were sown,
Balances and nonces now neatly align.
🥕 Hooray — the little map is mine.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(dpp): add Identity new_with_input_addresses_and_keys()' clearly and specifically describes the main change—adding a new constructor method to the Identity struct in the dpp package.
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

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
Copy link

github-actions bot commented Jan 8, 2026

✅ gRPC Query Coverage Report

================================================================================
gRPC Query Coverage Report - NEW QUERIES ONLY
================================================================================

Total queries in proto: 53
Previously known queries: 47
New queries found: 6

================================================================================

New Query Implementation Status:
--------------------------------------------------------------------------------
✓ getAddressInfo                                /home/runner/work/platform/platform/packages/rs-sdk/src/platform/query.rs
✓ getAddressesBranchState                       /home/runner/work/platform/platform/packages/rs-sdk/src/platform/address_sync/mod.rs
✓ getAddressesInfos                             /home/runner/work/platform/platform/packages/rs-sdk/src/platform/fetch_many.rs
✓ getAddressesTrunkState                        /home/runner/work/platform/platform/packages/rs-sdk/src/platform/query.rs
✓ getRecentAddressBalanceChanges                /home/runner/work/platform/platform/packages/rs-sdk/src/platform/query.rs
✓ getRecentCompactedAddressBalanceChanges       /home/runner/work/platform/platform/packages/rs-sdk/src/platform/query.rs

================================================================================
Summary:
--------------------------------------------------------------------------------
New queries implemented: 6 (100.0%)
New queries missing: 0 (0.0%)

Total known queries: 53
  - Implemented: 50
  - Not implemented: 2
  - Excluded: 1

Not implemented queries:
  - getConsensusParams
  - getTokenPreProgrammedDistributions

Copy link
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/rs-sdk/src/platform/transition/put_identity.rs (1)

49-54: Clarify the documentation phrasing.

The phrase "This is a preferred method" is ambiguous—it's unclear whether "this" refers to put_with_address_funding_with_nonce or to Identity::new_with_input_addresses_and_keys. Consider rephrasing for clarity.

📝 Suggested documentation improvement
 /// Creates an identity funded by Platform addresses using explicit nonces.
 ///
 /// Use [Identity::new_with_input_addresses_and_keys](dpp::identity::Identity::new_with_input_addresses_and_keys)
-/// to create an identity. Then use this method to put it to the platform.
+/// to create an identity with the same nonces provided to this method.
 ///
-/// This is a preferred method, as you need to use the same nonces when creating the identity.
+/// # Important
+/// 
+/// The `inputs_with_nonce` parameter must contain the same nonces used when 
+/// constructing the identity via `new_with_input_addresses_and_keys`, as the 
+/// identity ID is derived from these addresses and nonces.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18e25cd and d312169.

📒 Files selected for processing (1)
  • packages/rs-sdk/src/platform/transition/put_identity.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Rust code must pass cargo clippy --workspace linter checks
Rust code must be formatted using cargo fmt --all

**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants

Files:

  • packages/rs-sdk/src/platform/transition/put_identity.rs
🧠 Learnings (6)
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the `IdentityTransitionVersions` structure within `packages/rs-platform-version/src/version/v2.rs`, the field `credit_withdrawal` does not need the `identity_` prefix since it is already encompassed within identity state transitions.

Applied to files:

  • packages/rs-sdk/src/platform/transition/put_identity.rs
📚 Learning: 2024-10-06T16:11:34.946Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-06T16:11:34.946Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.

Applied to files:

  • packages/rs-sdk/src/platform/transition/put_identity.rs
📚 Learning: 2024-09-30T12:11:35.148Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2186
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs:48-54
Timestamp: 2024-09-30T12:11:35.148Z
Learning: In the identity credit withdrawal transition code, the field `platform_version.drive_abci.validation_and_processing.state_transitions.identity_credit_withdrawal_state_transition.transform_into_action` is not an `Option` type, so handling `None` cases is unnecessary.

Applied to files:

  • packages/rs-sdk/src/platform/transition/put_identity.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.

Applied to files:

  • packages/rs-sdk/src/platform/transition/put_identity.rs
📚 Learning: 2024-10-29T14:40:54.727Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/src/core/transaction.rs:0-0
Timestamp: 2024-10-29T14:40:54.727Z
Learning: In `packages/rs-sdk/src/platform/document_query.rs` and `packages/rs-sdk/src/core/transaction.rs`, certain places don't implement `IntoInner`, so direct error mappings cannot be simplified using `IntoInner`. A TODO comment has been added to address this in a future PR.

Applied to files:

  • packages/rs-sdk/src/platform/transition/put_identity.rs
📚 Learning: 2025-10-09T15:59:28.329Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2716
File: packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs:181-187
Timestamp: 2025-10-09T15:59:28.329Z
Learning: In `packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs`, the maintainer requires logging full state transition bytes (`tx_bytes = hex::encode(st_bytes)`) at debug level when a state transition passes CheckTx but is removed from the block by the proposer, to facilitate debugging of this rare edge case.

Applied to files:

  • packages/rs-sdk/src/platform/transition/put_identity.rs
🧬 Code graph analysis (1)
packages/rs-sdk/src/platform/transition/put_identity.rs (2)
packages/rs-sdk/src/platform/transition/address_inputs.rs (1)
  • collect_address_infos_from_proof (44-90)
packages/rs-sdk/src/platform/transition/broadcast.rs (2)
  • broadcast (23-23)
  • broadcast (38-93)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: Rust packages (dash-sdk) / Unused dependencies
  • GitHub Check: Rust packages (dash-sdk) / Formatting
  • GitHub Check: Rust packages (drive-abci) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Linting
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (dpp) / Linting
  • GitHub Check: Rust packages (drive) / Formatting
  • GitHub Check: Rust packages (wasm-sdk) / Tests
  • GitHub Check: Rust packages (wasm-dpp) / Tests
  • GitHub Check: Rust packages (drive) / Linting
  • GitHub Check: Rust packages (drive) / Unused dependencies
  • GitHub Check: Rust packages (drive) / Tests
  • GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci, SDK_TEST_DATA=true
    ) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
  • GitHub Check: Swift SDK and Example build (warnings as errors)
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios-sim)
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
🔇 Additional comments (4)
packages/rs-sdk/src/platform/transition/put_identity.rs (4)

3-3: LGTM: Import changes align with API simplification.

The import changes correctly reflect the removal of automatic nonce fetching functionality, keeping only the items needed for explicit nonce-based identity creation.


55-63: LGTM: Method signature is well-designed.

The explicit nonce-based API is clear and type-safe. The return of both the Identity and AddressInfos provides useful information to callers.


108-127: LGTM: Clean delegation pattern.

The implementation correctly delegates to the helper function with all parameters forwarded appropriately.


149-211: LGTM: Robust implementation with proper verification.

The helper function correctly:

  • Creates the state transition with explicit nonces
  • Validates the structure before broadcasting
  • Verifies the proved identity ID matches the expected ID
  • Collects and validates address information from the proof

The error handling is appropriate for all edge cases.

@lklimek lklimek changed the title feat(dpp): Identity::new_with_input_addresses_and_keys() feat(dpp): add Identity new_with_input_addresses_and_keys() Jan 9, 2026
Copy link
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 (2)
packages/wasm-sdk/src/state_transitions/addresses.rs (1)

1047-1059: Suggest more robust merge logic using key lookup instead of zip.

The current implementation uses zip to merge inputs_map and fetched_addresses, relying on BTreeMap's sorted iteration order. While both maps should have identical keys (validated at line 1041), using zip is fragile and requires the defensive address_left != address_right check.

Consider a more explicit approach that directly looks up each address:

♻️ Proposed refactor using key lookup
-    // merge nonces into inputs map
-    let inputs = inputs_map
-        .into_iter()
-        .zip(fetched_addresses)
-        .map(|((address_left, amount), (address_right, info))| {
-            if address_left != address_right {
-                Err(WasmSdkError::generic(
-                    "Address mismatch when merging nonces for identity creation; platform bug?",
-                ))?
-            }
-            let nonce = info.nonce;
-            Ok((address_left, (nonce, amount)))
-        })
-        .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?;
+    // merge nonces into inputs map
+    let inputs = inputs_map
+        .into_iter()
+        .map(|(address, amount)| {
+            let info = fetched_addresses.get(&address).ok_or_else(|| {
+                WasmSdkError::generic(format!(
+                    "Address {} not found in fetched addresses; platform bug?",
+                    address
+                ))
+            })?;
+            let nonce = info.nonce;
+            Ok((address, (nonce, amount)))
+        })
+        .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?;
packages/rs-sdk/src/platform/transition/put_identity.rs (1)

49-63: Consider clarifying nonce consistency requirement in documentation.

The documentation helpfully explains that new_with_input_addresses_and_keys should be used to create the identity and that "you need to use the same nonces when creating the identity." Consider adding a note about what happens if the nonces don't match (e.g., transaction failure, identity ID mismatch) to make the requirement more explicit.

Example addition:

/// Use [Identity::new_with_input_addresses_and_keys](dpp::identity::Identity::new_with_input_addresses_and_keys)
/// to create an identity. Then use this method to put it to the platform.
///
/// This is a preferred method, as you need to use the same nonces when creating the identity.
/// The identity ID is derived from the input addresses and their nonces, so using different
/// nonces will result in an identity ID mismatch and transaction failure.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d312169 and afe0e7d.

📒 Files selected for processing (2)
  • packages/rs-sdk/src/platform/transition/put_identity.rs
  • packages/wasm-sdk/src/state_transitions/addresses.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Rust code must pass cargo clippy --workspace linter checks
Rust code must be formatted using cargo fmt --all

**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants

Files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
  • packages/rs-sdk/src/platform/transition/put_identity.rs
🧠 Learnings (10)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
Learnt from: CR
Repo: dashpay/platform PR: 0
File: packages/swift-sdk/SwiftExampleApp/CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:38.019Z
Learning: Applies to packages/swift-sdk/SwiftExampleApp/**/{KeychainManager,*Key,*Identity}.swift : Store private keys separately from identities using iOS Keychain for secure storage; private keys belong to public keys, not identities
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the `IdentityTransitionVersions` structure within `packages/rs-platform-version/src/version/v2.rs`, the field `credit_withdrawal` does not need the `identity_` prefix since it is already encompassed within identity state transitions.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
  • packages/rs-sdk/src/platform/transition/put_identity.rs
📚 Learning: 2024-10-29T14:40:54.727Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/src/core/transaction.rs:0-0
Timestamp: 2024-10-29T14:40:54.727Z
Learning: In `packages/rs-sdk/src/platform/document_query.rs` and `packages/rs-sdk/src/core/transaction.rs`, certain places don't implement `IntoInner`, so direct error mappings cannot be simplified using `IntoInner`. A TODO comment has been added to address this in a future PR.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
  • packages/rs-sdk/src/platform/transition/put_identity.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Applies to **/swift-sdk/**/*.{swift,h,m,c} : iOS SDK must combine both Core (SPV wallet) and Platform (identity/documents) functionality in the unified SDK with proper function naming: `dash_core_sdk_*` prefix for Core functions, `dash_sdk_*` prefix for Platform functions, and `dash_unified_sdk_*` prefix for unified functions

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2186
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs:48-54
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the identity credit withdrawal transition code, the field `platform_version.drive_abci.validation_and_processing.state_transitions.identity_credit_withdrawal_state_transition.transform_into_action` is not an `Option` type, so handling `None` cases is unnecessary.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
  • packages/rs-sdk/src/platform/transition/put_identity.rs
📚 Learning: 2024-10-06T16:11:34.946Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-06T16:11:34.946Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.

Applied to files:

  • packages/rs-sdk/src/platform/transition/put_identity.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.

Applied to files:

  • packages/rs-sdk/src/platform/transition/put_identity.rs
📚 Learning: 2025-10-09T15:59:28.329Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2716
File: packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs:181-187
Timestamp: 2025-10-09T15:59:28.329Z
Learning: In `packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs`, the maintainer requires logging full state transition bytes (`tx_bytes = hex::encode(st_bytes)`) at debug level when a state transition passes CheckTx but is removed from the block by the proposer, to facilitate debugging of this rare edge case.

Applied to files:

  • packages/rs-sdk/src/platform/transition/put_identity.rs
🧬 Code graph analysis (2)
packages/wasm-sdk/src/state_transitions/addresses.rs (3)
packages/rs-sdk/src/platform/transition/put_identity.rs (1)
  • inputs (162-162)
packages/wasm-sdk/src/error.rs (1)
  • generic (71-73)
packages/wasm-sdk/src/queries/address.rs (1)
  • nonce (42-44)
packages/rs-sdk/src/platform/transition/put_identity.rs (2)
packages/rs-sdk/src/platform/transition/address_inputs.rs (1)
  • collect_address_infos_from_proof (44-90)
packages/rs-sdk/src/platform/transition/broadcast.rs (2)
  • broadcast (23-23)
  • broadcast (38-93)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (drive-abci) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (drive) / Tests
  • GitHub Check: Rust packages (drive) / Unused dependencies
  • GitHub Check: Rust packages (dpp) / Check each feature
  • GitHub Check: Rust packages (drive) / Linting
  • GitHub Check: Rust packages (dpp) / Unused dependencies
  • GitHub Check: Rust packages (wasm-dpp) / Tests
  • GitHub Check: Rust packages (dpp) / Linting
  • GitHub Check: Rust packages (wasm-sdk) / Linting
  • GitHub Check: Rust packages (rs-sdk-ffi) / Tests
  • GitHub Check: Rust packages (wasm-sdk) / Tests
  • GitHub Check: Rust packages (wasm-sdk) / Unused dependencies
  • GitHub Check: Build Docker images (Drive, drive, drive-abci, SDK_TEST_DATA=true
    ) / Build Drive image
  • GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios-sim)
  • GitHub Check: Swift SDK and Example build (warnings as errors)
🔇 Additional comments (7)
packages/wasm-sdk/src/state_transitions/addresses.rs (4)

5-5: LGTM: Import additions support new nonce-fetching functionality.

The new imports (BTreeMap, BTreeSet, FetchMany, Identity, Sdk, Credits, AddressNonce) are necessary for the fetch_nonces_into_address_map helper and updated type signatures.

Also applies to: 18-21


976-977: LGTM: Correct nonce fetching and passing.

The function correctly fetches nonces using the new fetch_nonces_into_address_map helper (line 977) and passes the nonce-enriched inputs to put_with_address_funding (line 996), aligning with the new API requirement for explicit nonces.

Also applies to: 996-996


171-201: No changes needed—the implementation is correct.

The transfer_address_funds method in the SDK already handles nonce fetching internally. At line 55 of packages/rs-sdk/src/platform/transition/transfer_address_funds.rs, the implementation calls fetch_inputs_with_nonce(self, &inputs).await? before delegating to transfer_address_funds_with_nonce. The comment at line 193 in the reviewed code correctly documents this behavior ("which handles nonces, building, and broadcasting").

The pattern differs from identity_create_from_addresses (which explicitly calls fetch_nonces_into_address_map before proceeding), but both approaches are valid. Nonces are properly fetched and incremented in either case.


303-341: Nonces are fetched internally by the underlying RS SDK method.

The top_up_from_addresses call delegates nonce fetching to the RS SDK's Identity::top_up_from_addresses implementation, which automatically fetches nonces via fetch_inputs_with_nonce before creating the transition. This is documented in the RS SDK method's comment: "nonces looked up automatically."

However, this differs from the pattern in address_funds_transfer and identity_create_from_addresses in the same file, which both explicitly call fetch_nonces_into_address_map at the WASM layer. Consider aligning the pattern here for consistency.

packages/rs-sdk/src/platform/transition/put_identity.rs (3)

3-3: LGTM: Removed unused imports.

The removal of fetch_inputs_with_nonce and nonce_inc is correct since the method now requires nonces to be provided by the caller rather than fetching them internally.


108-127: LGTM: Clean delegation to helper function.

The implementation correctly delegates to the helper function with all parameters passed through.


149-210: LGTM: Correct implementation with proper validation.

The function correctly:

  1. Uses caller-provided nonces (no internal fetching)
  2. Creates the state transition with try_from_inputs_with_signer
  3. Validates that the proved identity ID matches the expected identity ID (lines 192-199)
  4. Collects and returns address infos with proper validation

The identity ID validation is critical for preventing mismatches when the identity is derived from input addresses and nonces.

Copy link
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

🤖 Fix all issues with AI agents
In @packages/rs-dpp/src/identity/identity.rs:
- Around line 122-146: The doc comment for new_with_input_addresses_and_keys is
inaccurate: the inputs map value is (AddressNonce, Credits), not just
AddressNonce, and Credits are ignored when deriving the identity id; update the
function doc to state that inputs is a BTreeMap<PlatformAddress, (AddressNonce,
Credits)> and explicitly note that only the address and AddressNonce are used by
identity_id_from_input_addresses (Credits are not part of ID derivation). Keep
the existing call to crate::state_transition::identity_id_from_input_addresses
and ensure the docs mention that function as the derivation used.

In @packages/wasm-sdk/src/state_transitions/addresses.rs:
- Around line 1014-1062: The function fetch_nonces_into_address_map should first
validate that inputs_map is non-empty and return
WasmSdkError::invalid_argument(...) when empty; keep using
dash_sdk::query_types::AddressInfo::fetch_many to fetch infos but replace the
zip-based merge with a key-based join: iterate over inputs_map.keys(), look up
each key in fetched_addresses (the BTreeMap from fetch_many), and for any
missing key return WasmSdkError::invalid_argument(...) indicating which input
addresses were not found/are empty; when present, extract info.nonce and
preserve the Credits value to build the resulting BTreeMap<(PlatformAddress,
(AddressNonce, Credits))>; update all validation errors to use
WasmSdkError::invalid_argument instead of WasmSdkError::generic and remove the
address-left/address-right mismatch logic.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between afe0e7d and f24f6c3.

📒 Files selected for processing (2)
  • packages/rs-dpp/src/identity/identity.rs
  • packages/wasm-sdk/src/state_transitions/addresses.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Rust code must pass cargo clippy --workspace linter checks
Rust code must be formatted using cargo fmt --all

**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants

Files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
  • packages/rs-dpp/src/identity/identity.rs
🧠 Learnings (9)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/docs.html:2359-2383
Timestamp: 2025-07-28T20:00:24.323Z
Learning: In packages/wasm-sdk/docs.html, QuantumExplorer confirmed that placeholder private keys in documentation examples are acceptable as they are not real keys, though field name accuracy for the SDK API should still be maintained.
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2673
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs:1164-1197
Timestamp: 2025-06-18T03:44:14.385Z
Learning: QuantumExplorer determined that a CodeRabbit suggestion about fixing signable_bytes calculation in identity update tests with contract-bound keys was incorrect - the code flow is working as intended without the suggested changes.
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/tests/fetch/config.rs:233-233
Timestamp: 2024-10-30T11:19:59.163Z
Learning: In the Rust SDK's `rs-sdk/tests` integration tests (e.g., in `packages/rs-sdk/tests/fetch/config.rs`), we cannot create objects during tests because there is no support for object creation in this context. Therefore, hardcoded values for test identities must be used.
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-03T11:51:06.980Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-03T11:51:06.980Z
Learning: In the `IdentityTransitionVersions` structure within `packages/rs-platform-version/src/version/v2.rs`, the field `credit_withdrawal` does not need the `identity_` prefix since it is already encompassed within identity state transitions.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
  • packages/rs-dpp/src/identity/identity.rs
📚 Learning: 2024-10-29T14:40:54.727Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/src/core/transaction.rs:0-0
Timestamp: 2024-10-29T14:40:54.727Z
Learning: In `packages/rs-sdk/src/platform/document_query.rs` and `packages/rs-sdk/src/core/transaction.rs`, certain places don't implement `IntoInner`, so direct error mappings cannot be simplified using `IntoInner`. A TODO comment has been added to address this in a future PR.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WebAssembly as a bridge between Rust and JavaScript implementations

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.

Applied to files:

  • packages/rs-dpp/src/identity/identity.rs
📚 Learning: 2024-11-20T20:43:41.185Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/tests/strategy_tests/masternodes.rs:212-220
Timestamp: 2024-11-20T20:43:41.185Z
Learning: In `packages/rs-drive-abci/tests/strategy_tests/masternodes.rs`, the pattern of generating a `PrivateKey`, converting it to bytes, and reconstructing a `BlsPrivateKey` from those bytes is intentional. Avoid suggesting to simplify this code in future reviews.

Applied to files:

  • packages/rs-dpp/src/identity/identity.rs
🧬 Code graph analysis (2)
packages/wasm-sdk/src/state_transitions/addresses.rs (2)
packages/rs-sdk/src/platform/transition/put_identity.rs (1)
  • inputs (162-162)
packages/wasm-sdk/src/error.rs (1)
  • generic (71-73)
packages/rs-dpp/src/identity/identity.rs (1)
packages/rs-dpp/src/state_transition/traits/state_transition_identity_id_from_inputs.rs (1)
  • identity_id_from_input_addresses (25-44)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Rust packages (wasm-sdk) / Linting
  • GitHub Check: Rust packages (wasm-sdk) / Formatting
  • GitHub Check: Rust packages (wasm-sdk) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Unused dependencies
  • GitHub Check: Rust packages (drive-abci) / Tests
  • GitHub Check: Rust packages (rs-sdk-ffi) / Tests
  • GitHub Check: Rust packages (dpp) / Check each feature
  • GitHub Check: Rust packages (drive) / Tests
  • GitHub Check: Rust packages (dpp) / Linting
  • GitHub Check: Rust packages (dpp) / Unused dependencies
  • GitHub Check: Rust packages (dpp) / Tests
  • GitHub Check: Rust packages (drive) / Linting
  • GitHub Check: Build Docker images (Drive, drive, drive-abci, SDK_TEST_DATA=true
    ) / Build Drive image
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios-sim)
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
  • GitHub Check: Swift SDK and Example build (warnings as errors)
🔇 Additional comments (2)
packages/rs-dpp/src/identity/identity.rs (1)

1-4: Import additions look fine; ensure they’re feature-justified.
No issues here, assuming AddressNonce is only needed for the new constructor path.

packages/wasm-sdk/src/state_transitions/addresses.rs (1)

974-1012: Good flow change: nonce-enrich inputs before put_with_address_funding.
Fetching nonces here keeps the public JS API simpler and matches the “nonces fetched automatically” docs.

Copy link
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: 1

🤖 Fix all issues with AI agents
In @packages/wasm-sdk/src/state_transitions/addresses.rs:
- Line 1040: Fix the typo in the inline comment near the filter_map check in
addresses.rs: change "shouuld" to "should" in the comment that currently reads
"// sanity check - filter_map above shouuld have removed any non-existing
addresses" so the comment reads "... should have removed any non-existing
addresses".
🧹 Nitpick comments (2)
packages/wasm-sdk/src/state_transitions/addresses.rs (1)

1047-1069: Consider simplifying the merge logic to avoid relying on BTreeMap ordering.

The current zip approach works because both BTreeMaps have identical keys in the same order, and the address mismatch check (line 1052) validates this. However, this relies on a subtle ordering assumption that could be fragile during future refactoring.

A clearer approach would directly look up each input address in the fetched map:

♻️ Alternative implementation
-    // merge nonces into inputs map
-    let inputs = inputs_map
-        .into_iter()
-        .zip(fetched_addresses)
-        .map(
-            |((address_requested, amount), (address_received, info_received))| {
-                if address_requested != address_received {
-                    Err(WasmSdkError::invalid_argument(
-                        format!("Address mismatch when merging nonces for identity creation ({} vs {}); platform bug?",
-                            address_requested, address_received)
-                    ))?
-                }
-                if amount > info_received.balance {
-                    Err(WasmSdkError::invalid_argument(format!(
-                        "Input address {} has insufficient balance: requested {}, available {}",
-                        address_requested, amount, info_received.balance
-                    )))?
-                }
-                let nonce = info_received.nonce;
-                Ok((address_requested, (nonce, amount)))
-            },
-        )
-        .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?;
+    // merge nonces into inputs map
+    let inputs = inputs_map
+        .into_iter()
+        .map(|(address, amount)| {
+            let info = fetched_addresses.get(&address).ok_or_else(|| {
+                WasmSdkError::invalid_argument(format!(
+                    "Address {} not found when merging nonces; platform bug?",
+                    address
+                ))
+            })?;
+            if amount > info.balance {
+                return Err(WasmSdkError::invalid_argument(format!(
+                    "Input address {} has insufficient balance: requested {}, available {}",
+                    address, amount, info.balance
+                )));
+            }
+            Ok((address, (info.nonce, amount)))
+        })
+        .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?;

This approach is more explicit about the lookup relationship and doesn't depend on iterator ordering alignment.

packages/rs-dpp/src/identity/identity.rs (1)

122-147: Nonce semantics are well-documented; prioritize unit tests over implementation verification

The implementation correctly delegates to the validated identity_id_from_input_addresses helper and existing constructor. The nonce semantics concern is valid but already documented consistently across the codebase—the helper function (line 22 in state_transition_identity_id_from_inputs.rs) and SDK documentation both state that "nonces should represent state after creation of the identity (e.g., be incremented by 1)." This is an intentional design requiring callers to use post-transaction nonce values, and the wasm-sdk shows the proper usage pattern (fetching current nonces and incrementing them before passing to the constructor).

Focus on test coverage instead: The constructor lacks direct unit tests. Add tests demonstrating:

  • Correct identity ID generation from various input combinations
  • Proper error handling for empty inputs
  • The nonce increment requirement and its effect on derived identity ID
  • Consistency with existing identity creation flow
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f24f6c3 and 5d227d8.

📒 Files selected for processing (2)
  • packages/rs-dpp/src/identity/identity.rs
  • packages/wasm-sdk/src/state_transitions/addresses.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Rust code must pass cargo clippy --workspace linter checks
Rust code must be formatted using cargo fmt --all

**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants

Files:

  • packages/rs-dpp/src/identity/identity.rs
  • packages/wasm-sdk/src/state_transitions/addresses.rs
🧠 Learnings (12)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2673
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs:1164-1197
Timestamp: 2025-06-18T03:44:14.385Z
Learning: QuantumExplorer determined that a CodeRabbit suggestion about fixing signable_bytes calculation in identity update tests with contract-bound keys was incorrect - the code flow is working as intended without the suggested changes.
📚 Learning: 2024-10-06T16:11:34.946Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-06T16:11:34.946Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.

Applied to files:

  • packages/rs-dpp/src/identity/identity.rs
  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-03T11:51:06.980Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-03T11:51:06.980Z
Learning: In the `IdentityTransitionVersions` structure within `packages/rs-platform-version/src/version/v2.rs`, the field `credit_withdrawal` does not need the `identity_` prefix since it is already encompassed within identity state transitions.

Applied to files:

  • packages/rs-dpp/src/identity/identity.rs
  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-20T20:43:41.185Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/tests/strategy_tests/masternodes.rs:212-220
Timestamp: 2024-11-20T20:43:41.185Z
Learning: In `packages/rs-drive-abci/tests/strategy_tests/masternodes.rs`, the pattern of generating a `PrivateKey`, converting it to bytes, and reconstructing a `BlsPrivateKey` from those bytes is intentional. Avoid suggesting to simplify this code in future reviews.

Applied to files:

  • packages/rs-dpp/src/identity/identity.rs
  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2186
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_credit_withdrawal/mod.rs:48-54
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the identity credit withdrawal transition code, the field `platform_version.drive_abci.validation_and_processing.state_transitions.identity_credit_withdrawal_state_transition.transform_into_action` is not an `Option` type, so handling `None` cases is unnecessary.

Applied to files:

  • packages/rs-dpp/src/identity/identity.rs
📚 Learning: 2024-10-29T14:40:54.727Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/src/core/transaction.rs:0-0
Timestamp: 2024-10-29T14:40:54.727Z
Learning: In `packages/rs-sdk/src/platform/document_query.rs` and `packages/rs-sdk/src/core/transaction.rs`, certain places don't implement `IntoInner`, so direct error mappings cannot be simplified using `IntoInner`. A TODO comment has been added to address this in a future PR.

Applied to files:

  • packages/rs-dpp/src/identity/identity.rs
  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.

Applied to files:

  • packages/rs-dpp/src/identity/identity.rs
  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-20T16:05:40.200Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs:148-151
Timestamp: 2024-11-20T16:05:40.200Z
Learning: In `packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs`, when converting public keys from `QuorumForSavingV0` to `VerificationQuorum`, it's acceptable to use `.expect()` for public key conversion, as the conversion has been verified and panics are acceptable in this context.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-04T14:16:05.798Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2207
File: packages/rs-drive-proof-verifier/src/proof.rs:1646-1664
Timestamp: 2024-10-04T14:16:05.798Z
Learning: In the implementation of `FromProof<platform::GetContestedResourceIdentityVotesRequest>` in `packages/rs-drive-proof-verifier/src/proof.rs`, when matching `maybe_votes`, using `.expect()` on `v.into_iter().next()` is acceptable because the prior match arm `Some(v) if v.is_empty()` ensures that the map is not empty, preventing a panic.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WebAssembly as a bridge between Rust and JavaScript implementations

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
🧬 Code graph analysis (1)
packages/rs-dpp/src/identity/identity.rs (1)
packages/rs-dpp/src/state_transition/traits/state_transition_identity_id_from_inputs.rs (1)
  • identity_id_from_input_addresses (25-44)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Rust packages (drive-abci) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Linting
  • GitHub Check: Rust packages (rs-sdk-ffi) / Tests
  • GitHub Check: Rust packages (wasm-dpp2) / Tests
  • GitHub Check: Rust packages (wasm-sdk) / Linting
  • GitHub Check: Rust packages (wasm-sdk) / Tests
  • GitHub Check: Rust packages (dpp) / Unused dependencies
  • GitHub Check: Rust packages (dpp) / Linting
  • GitHub Check: Rust packages (dpp) / Check each feature
  • GitHub Check: Rust packages (drive) / Linting
  • GitHub Check: Rust packages (drive) / Tests
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci, SDK_TEST_DATA=true
    ) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios-sim)
  • GitHub Check: Swift SDK and Example build (warnings as errors)
🔇 Additional comments (8)
packages/wasm-sdk/src/state_transitions/addresses.rs (7)

5-5: LGTM! Import additions support the new nonce-fetching functionality.

The new imports are all necessary for the fetch_nonces_into_address_map helper function.

Also applies to: 13-13, 15-15, 20-21


171-201: Inconsistency between AI summary and actual changes.

The AI summary states that address_funds_transfer was updated to use fetch_nonces_into_address_map, but the provided code shows no such changes to this method. It continues to call transfer_address_funds directly without the new helper.

This might indicate:

  1. The changes were made elsewhere (in the SDK layer)
  2. The summary is incorrect
  3. Changes are missing from this file

Please verify whether address_funds_transfer should also be updated to fetch nonces explicitly, or if the SDK's transfer_address_funds method handles this internally.


976-977: LGTM! Correct integration of nonce-fetching logic.

The changes properly fetch nonces before creating the identity and pass the enriched inputs map (with nonces) to put_with_address_funding. The type transition from BTreeMap<PlatformAddress, Credits> to BTreeMap<PlatformAddress, (AddressNonce, Credits)> is handled correctly.

Also applies to: 996-996


1014-1022: LGTM! Clear documentation and signature.

The helper function is properly scoped as private, has clear documentation, and uses appropriate types.


1023-1038: LGTM! Clean address fetching logic.

The code efficiently fetches all input addresses in a single call and properly handles the conversion from IndexMap to BTreeMap.


1041-1045: LGTM! Proper validation of fetched addresses.

The length check ensures all requested addresses were successfully fetched from the platform.


1070-1071: LGTM! Clean return statement.

The function correctly returns the merged map with the expected type.

packages/rs-dpp/src/identity/identity.rs (1)

1-4: LGTM: Clean import additions

The new imports for PlatformAddress and AddressNonce are appropriately added to support the new constructor, and moving Revision to the prelude is a reasonable refactoring.

lklimek and others added 2 commits January 9, 2026 15:31
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
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: 1

🤖 Fix all issues with AI agents
In @packages/wasm-sdk/src/state_transitions/addresses.rs:
- Around line 1047-1068: The current use of zip() to pair inputs_map and
fetched_addresses is unsafe because it relies on positional alignment; instead
build an indexed lookup for fetched_addresses (e.g., convert fetched_addresses
into a map keyed by address_received) and then iterate inputs_map.into_iter(),
for each (address_requested, amount) perform an explicit lookup in that fetched
map, return an error if the address is missing, check amount <=
info_received.balance and extract nonce, and collect the results into the same
Result<BTreeMap<_, _>, WasmSdkError>() so order/pairing is guaranteed; update
the closure that previously matched |((address_requested, amount),
(address_received, info_received))| accordingly to use a lookup by
address_requested and preserve the same error messages (including address
mismatch/insufficient balance) and returned tuple shape (address_requested,
(nonce, amount)).
🧹 Nitpick comments (1)
packages/wasm-sdk/src/state_transitions/addresses.rs (1)

1024-1025: Consider using .copied() if PlatformAddress implements Copy.

If PlatformAddress implements Copy, using .copied().collect() is slightly more idiomatic than .cloned().collect().

♻️ Potential simplification
-    let input_addresses: BTreeSet<PlatformAddress> =
-        inputs_map.keys().cloned().collect::<BTreeSet<_>>();
+    let input_addresses: BTreeSet<PlatformAddress> =
+        inputs_map.keys().copied().collect::<BTreeSet<_>>();
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d227d8 and b25df8c.

📒 Files selected for processing (1)
  • packages/wasm-sdk/src/state_transitions/addresses.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Rust code must pass cargo clippy --workspace linter checks
Rust code must be formatted using cargo fmt --all

**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants

Files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
🧠 Learnings (13)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-03T11:51:06.980Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-03T11:51:06.980Z
Learning: In the `IdentityTransitionVersions` structure within `packages/rs-platform-version/src/version/v2.rs`, the field `credit_withdrawal` does not need the `identity_` prefix since it is already encompassed within identity state transitions.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-29T14:40:54.727Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/src/core/transaction.rs:0-0
Timestamp: 2024-10-29T14:40:54.727Z
Learning: In `packages/rs-sdk/src/platform/document_query.rs` and `packages/rs-sdk/src/core/transaction.rs`, certain places don't implement `IntoInner`, so direct error mappings cannot be simplified using `IntoInner`. A TODO comment has been added to address this in a future PR.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-20T16:05:40.200Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs:148-151
Timestamp: 2024-11-20T16:05:40.200Z
Learning: In `packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs`, when converting public keys from `QuorumForSavingV0` to `VerificationQuorum`, it's acceptable to use `.expect()` for public key conversion, as the conversion has been verified and panics are acceptable in this context.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-06T16:11:34.946Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-06T16:11:34.946Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-20T20:43:41.185Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/tests/strategy_tests/masternodes.rs:212-220
Timestamp: 2024-11-20T20:43:41.185Z
Learning: In `packages/rs-drive-abci/tests/strategy_tests/masternodes.rs`, the pattern of generating a `PrivateKey`, converting it to bytes, and reconstructing a `BlsPrivateKey` from those bytes is intentional. Avoid suggesting to simplify this code in future reviews.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-04T14:16:05.798Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2207
File: packages/rs-drive-proof-verifier/src/proof.rs:1646-1664
Timestamp: 2024-10-04T14:16:05.798Z
Learning: In the implementation of `FromProof<platform::GetContestedResourceIdentityVotesRequest>` in `packages/rs-drive-proof-verifier/src/proof.rs`, when matching `maybe_votes`, using `.expect()` on `v.into_iter().next()` is acceptable because the prior match arm `Some(v) if v.is_empty()` ensures that the map is not empty, preventing a panic.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-03T10:39:11.242Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2305
File: packages/rs-drive-abci/src/abci/handler/finalize_block.rs:81-0
Timestamp: 2024-11-03T10:39:11.242Z
Learning: In `packages/rs-drive-abci/src/abci/handler/finalize_block.rs`, the use of `.expect("commit transaction")` after `app.commit_transaction(platform_version)` is intentional due to the provided comment explaining its necessity. Do not flag this usage in future reviews.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-12-03T15:00:50.385Z
Learnt from: lklimek
Repo: dashpay/platform PR: 1924
File: packages/rs-sdk/src/sdk.rs:855-870
Timestamp: 2024-12-03T15:00:50.385Z
Learning: In `packages/rs-sdk/src/sdk.rs`, remember that `rustls_pemfile::certs` returns an iterator over `Result`, not a `Result` directly. Handle it accordingly in future code reviews.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WebAssembly as a bridge between Rust and JavaScript implementations

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
🧬 Code graph analysis (1)
packages/wasm-sdk/src/state_transitions/addresses.rs (2)
packages/rs-sdk/src/platform/transition/put_identity.rs (1)
  • inputs (162-162)
packages/wasm-sdk/src/error.rs (2)
  • generic (71-73)
  • invalid_argument (75-77)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Rust packages (drive-abci) / Tests
  • GitHub Check: Rust packages (wasm-sdk) / Tests
  • GitHub Check: Rust packages (rs-sdk-ffi) / Tests
  • GitHub Check: Rust packages (dpp) / Check each feature
  • GitHub Check: Rust packages (dash-sdk) / Linting
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (drive) / Tests
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios-sim)
  • GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-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, SDK_TEST_DATA=true
    ) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
🔇 Additional comments (2)
packages/wasm-sdk/src/state_transitions/addresses.rs (2)

5-21: LGTM! Imports are appropriate for the new functionality.

The added imports support the nonce fetching logic and are all utilized in the new helper function.


976-977: Integration with helper function looks correct.

The call to fetch_nonces_into_address_map properly enhances the inputs before passing them to the SDK method.

Copy link
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/wasm-sdk/src/state_transitions/addresses.rs (1)

1009-1031: Consider using BTreeMap::get for safer key matching.

The current zip-based approach relies on both BTreeMaps having identical key ordering. While this should hold given both are sorted and the length check passes, directly looking up by key would be more robust and clearer:

♻️ Safer alternative using direct key lookup
-    // merge nonces into inputs map
-    let inputs = inputs_map
-        .into_iter()
-        .zip(fetched_addresses)
-        .map(
-            |((address_requested, amount), (address_received, info_received))| {
-                if address_requested != address_received {
-                    Err(WasmSdkError::invalid_argument(
-                        format!("Address mismatch when merging nonces for identity creation ({} vs {}); platform bug?",
-                            address_requested, address_received)
-                    ))?
-                }
-                if amount > info_received.balance {
-                    Err(WasmSdkError::invalid_argument(format!(
-                        "Input address {} has insufficient balance: requested {}, available {}",
-                        address_requested, amount, info_received.balance
-                    )))?
-                }
-                let nonce = info_received.nonce;
-                Ok((address_requested, (nonce, amount)))
-            },
-        )
-        .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?;
+    // merge nonces into inputs map
+    let inputs = inputs_map
+        .into_iter()
+        .map(|(address, amount)| {
+            let info = fetched_addresses
+                .get(&address)
+                .ok_or_else(|| WasmSdkError::invalid_argument(
+                    format!("Address {} not found in fetched results", address)
+                ))?;
+            if amount > info.balance {
+                return Err(WasmSdkError::invalid_argument(format!(
+                    "Input address {} has insufficient balance: requested {}, available {}",
+                    address, amount, info.balance
+                )));
+            }
+            Ok((address, (info.nonce, amount)))
+        })
+        .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?;
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b25df8c and a7bc3d0.

📒 Files selected for processing (2)
  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
  • packages/wasm-sdk/src/state_transitions/addresses.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Rust code must pass cargo clippy --workspace linter checks
Rust code must be formatted using cargo fmt --all

**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants

Files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
🧠 Learnings (21)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
Learnt from: lklimek
Repo: dashpay/platform PR: 2405
File: packages/wasm-sdk/src/verify.rs:26-68
Timestamp: 2025-02-10T11:26:36.709Z
Learning: In the wasm-sdk package, empty vectors and placeholder values are intentionally used in verification functions during the proof-of-concept stage to ensure proper compilation and type checking.
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/docs.html:2359-2383
Timestamp: 2025-07-28T20:00:24.323Z
Learning: In packages/wasm-sdk/docs.html, QuantumExplorer confirmed that placeholder private keys in documentation examples are acceptable as they are not real keys, though field name accuracy for the SDK API should still be maintained.
📚 Learning: 2024-10-03T11:51:06.980Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-03T11:51:06.980Z
Learning: In the `IdentityTransitionVersions` structure within `packages/rs-platform-version/src/version/v2.rs`, the field `credit_withdrawal` does not need the `identity_` prefix since it is already encompassed within identity state transitions.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-29T14:40:54.727Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/src/core/transaction.rs:0-0
Timestamp: 2024-10-29T14:40:54.727Z
Learning: In `packages/rs-sdk/src/platform/document_query.rs` and `packages/rs-sdk/src/core/transaction.rs`, certain places don't implement `IntoInner`, so direct error mappings cannot be simplified using `IntoInner`. A TODO comment has been added to address this in a future PR.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-20T16:05:40.200Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs:148-151
Timestamp: 2024-11-20T16:05:40.200Z
Learning: In `packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs`, when converting public keys from `QuorumForSavingV0` to `VerificationQuorum`, it's acceptable to use `.expect()` for public key conversion, as the conversion has been verified and panics are acceptable in this context.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-20T20:43:41.185Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/tests/strategy_tests/masternodes.rs:212-220
Timestamp: 2024-11-20T20:43:41.185Z
Learning: In `packages/rs-drive-abci/tests/strategy_tests/masternodes.rs`, the pattern of generating a `PrivateKey`, converting it to bytes, and reconstructing a `BlsPrivateKey` from those bytes is intentional. Avoid suggesting to simplify this code in future reviews.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2207
File: packages/rs-drive-proof-verifier/src/proof.rs:1646-1664
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the implementation of `FromProof<platform::GetContestedResourceIdentityVotesRequest>` in `packages/rs-drive-proof-verifier/src/proof.rs`, when matching `maybe_votes`, using `.expect()` on `v.into_iter().next()` is acceptable because the prior match arm `Some(v) if v.is_empty()` ensures that the map is not empty, preventing a panic.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
📚 Learning: 2024-11-03T10:39:11.242Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2305
File: packages/rs-drive-abci/src/abci/handler/finalize_block.rs:81-0
Timestamp: 2024-11-03T10:39:11.242Z
Learning: In `packages/rs-drive-abci/src/abci/handler/finalize_block.rs`, the use of `.expect("commit transaction")` after `app.commit_transaction(platform_version)` is intentional due to the provided comment explaining its necessity. Do not flag this usage in future reviews.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-12-03T15:00:50.385Z
Learnt from: lklimek
Repo: dashpay/platform PR: 1924
File: packages/rs-sdk/src/sdk.rs:855-870
Timestamp: 2024-12-03T15:00:50.385Z
Learning: In `packages/rs-sdk/src/sdk.rs`, remember that `rustls_pemfile::certs` returns an iterator over `Result`, not a `Result` directly. Handle it accordingly in future code reviews.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-06-18T03:44:14.385Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2673
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs:1164-1197
Timestamp: 2025-06-18T03:44:14.385Z
Learning: QuantumExplorer determined that a CodeRabbit suggestion about fixing signable_bytes calculation in identity update tests with contract-bound keys was incorrect - the code flow is working as intended without the suggested changes.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-18T15:43:32.447Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2254
File: packages/rs-sdk/src/sdk.rs:654-658
Timestamp: 2024-10-18T15:43:32.447Z
Learning: In `packages/rs-sdk/src/sdk.rs`, within the `verify_metadata_height` function, when using `compare_exchange` on `last_seen_height`, it's acceptable to use `Ordering::Relaxed` for the failure ordering, as any inconsistency would only trigger an extra loop iteration without affecting correctness.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-28T14:08:53.428Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2351
File: packages/rs-dapi-client/src/address_list.rs:241-250
Timestamp: 2024-11-28T14:08:53.428Z
Learning: In the `IntoIterator` implementation for `AddressList` in `packages/rs-dapi-client/src/address_list.rs`, since `self` is consumed, holding a write lock while converting to an iterator does not block other operations.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WebAssembly as a bridge between Rust and JavaScript implementations

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-08T13:28:03.529Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2227
File: packages/rs-drive-abci/src/platform_types/platform_state/mod.rs:141-141
Timestamp: 2024-10-08T13:28:03.529Z
Learning: When converting `PlatformStateV0` to `PlatformStateForSavingV1` in `packages/rs-drive-abci/src/platform_types/platform_state/mod.rs`, only version `0` needs to be handled in the match on `platform_state_for_saving_structure_default` because the changes are retroactive.

Applied to files:

  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
📚 Learning: 2025-10-09T15:59:28.329Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2716
File: packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs:181-187
Timestamp: 2025-10-09T15:59:28.329Z
Learning: In `packages/rs-dapi/src/services/platform_service/broadcast_state_transition.rs`, the maintainer requires logging full state transition bytes (`tx_bytes = hex::encode(st_bytes)`) at debug level when a state transition passes CheckTx but is removed from the block by the proposer, to facilitate debugging of this rare edge case.

Applied to files:

  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
📚 Learning: 2025-08-05T13:55:39.147Z
Learnt from: thephez
Repo: dashpay/platform PR: 2718
File: packages/wasm-sdk/index.html:0-0
Timestamp: 2025-08-05T13:55:39.147Z
Learning: The get_identity_keys_with_proof_info function in the Rust WASM bindings does not support the "search" key request type and lacks the searchPurposeMap parameter. When proof mode is enabled with keyRequestType === 'search', the implementation falls back to the non-proof version (get_identity_keys) to maintain functionality.

Applied to files:

  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use `rs-drive-proof-verifier` for cryptographic proof verification

Applied to files:

  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
📚 Learning: 2024-11-03T10:38:00.762Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2305
File: packages/rs-drive-abci/src/abci/handler/info.rs:0-0
Timestamp: 2024-11-03T10:38:00.762Z
Learning: In this context, using `.unwrap()?` on the result of `root_hash` is acceptable and will not cause a panic.

Applied to files:

  • packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs
🧬 Code graph analysis (1)
packages/wasm-sdk/src/state_transitions/addresses.rs (1)
packages/rs-sdk/src/platform/transition/put_identity.rs (1)
  • inputs (162-162)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci, SDK_TEST_DATA=true
    ) / Build Drive image
  • GitHub Check: Rust crates security audit
  • GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios-sim)
🔇 Additional comments (4)
packages/rs-drive/src/verify/state_transition/verify_state_transition_was_executed_with_proof/v0/mod.rs (1)

999-1020: LGTM! Verification flags correctly updated for subset proof handling.

The boolean parameters for verify_full_identity_by_identity_id and verify_addresses_infos are now set to true, indicating these verifications expect subset proofs. This is consistent with the IdentityCreateFromAddresses flow where both identity and address info are verified from a combined proof, and the subsequent root hash comparison at lines 1022-1027 validates they share the same proof root.

packages/wasm-sdk/src/state_transitions/addresses.rs (3)

939-940: LGTM! Nonce fetching integrated correctly.

The integration properly fetches nonces before calling put_with_address_funding, aligning with the SDK's nonce-aware API requirements. The flow is clear: inputs are parsed, nonces are fetched and merged, then the combined data is passed to the SDK method.

Also applies to: 956-964


977-985: LGTM! Well-documented helper function.

The helper function has clear documentation explaining its purpose and error conditions. The signature is appropriate for the internal use case.


5-6: Remove the unused FetchMany import on line 20.

The FetchMany import is not used anywhere in this file. The Identity import is actually used multiple times (lines 259, 309, 517, 619, 865, 932, 933), so it should be kept.

⛔ Skipped due to learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/tests/strategy_tests/masternodes.rs:212-220
Timestamp: 2024-11-20T20:43:41.185Z
Learning: In `packages/rs-drive-abci/tests/strategy_tests/masternodes.rs`, the pattern of generating a `PrivateKey`, converting it to bytes, and reconstructing a `BlsPrivateKey` from those bytes is intentional. Avoid suggesting to simplify this code in future reviews.
Learnt from: shumkov
Repo: dashpay/platform PR: 2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-03T11:51:06.980Z
Learning: In the `IdentityTransitionVersions` structure within `packages/rs-platform-version/src/version/v2.rs`, the field `credit_withdrawal` does not need the `identity_` prefix since it is already encompassed within identity state transitions.
Learnt from: shumkov
Repo: dashpay/platform PR: 2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the `IdentityTransitionVersions` structure within `packages/rs-platform-version/src/version/v2.rs`, the field `credit_withdrawal` does not need the `identity_` prefix since it is already encompassed within identity state transitions.
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-06T16:11:34.946Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.
Learnt from: lklimek
Repo: dashpay/platform PR: 2207
File: packages/rs-drive-proof-verifier/Cargo.toml:46-46
Timestamp: 2024-10-04T10:07:23.863Z
Learning: Usages of `BTreeMap` in crates that are out of scope of a change should not be flagged for replacement.
Learnt from: lklimek
Repo: dashpay/platform PR: 2207
File: packages/rs-drive-proof-verifier/Cargo.toml:46-46
Timestamp: 2024-10-09T00:22:57.778Z
Learning: Usages of `BTreeMap` in crates that are out of scope of a change should not be flagged for replacement.

Copy link
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/rs-sdk/src/platform/address_sync/types.rs (1)

27-28: Minor formatting: missing blank line between struct definitions.

Consider adding a blank line after the AddressFunds struct closing brace for consistency with Rust formatting conventions.

Suggested fix
 pub struct AddressFunds {
     /// Address nonce used for anti-replay.
     pub nonce: AddressNonce,
     /// Credits balance held by the address.
     pub balance: Credits,
 }
+
 /// Configuration for address synchronization.
 #[derive(Debug, Clone)]
 pub struct AddressSyncConfig {
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7bc3d0 and 682e484.

📒 Files selected for processing (6)
  • packages/rs-sdk-ffi/src/address_sync/mod.rs
  • packages/rs-sdk-ffi/src/address_sync/provider.rs
  • packages/rs-sdk-ffi/src/address_sync/types.rs
  • packages/rs-sdk/src/platform/address_sync/mod.rs
  • packages/rs-sdk/src/platform/address_sync/provider.rs
  • packages/rs-sdk/src/platform/address_sync/types.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Rust code must pass cargo clippy --workspace linter checks
Rust code must be formatted using cargo fmt --all

**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants

Files:

  • packages/rs-sdk/src/platform/address_sync/provider.rs
  • packages/rs-sdk-ffi/src/address_sync/mod.rs
  • packages/rs-sdk/src/platform/address_sync/types.rs
  • packages/rs-sdk-ffi/src/address_sync/types.rs
  • packages/rs-sdk/src/platform/address_sync/mod.rs
  • packages/rs-sdk-ffi/src/address_sync/provider.rs
🧠 Learnings (8)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.

Applied to files:

  • packages/rs-sdk/src/platform/address_sync/provider.rs
  • packages/rs-sdk-ffi/src/address_sync/mod.rs
  • packages/rs-sdk/src/platform/address_sync/mod.rs
  • packages/rs-sdk-ffi/src/address_sync/provider.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the `IdentityTransitionVersions` structure within `packages/rs-platform-version/src/version/v2.rs`, the field `credit_withdrawal` does not need the `identity_` prefix since it is already encompassed within identity state transitions.

Applied to files:

  • packages/rs-sdk/src/platform/address_sync/provider.rs
  • packages/rs-sdk-ffi/src/address_sync/mod.rs
  • packages/rs-sdk/src/platform/address_sync/types.rs
📚 Learning: 2024-10-28T10:38:49.538Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2259
File: packages/rs-dapi-client/src/executor.rs:49-56
Timestamp: 2024-10-28T10:38:49.538Z
Learning: In `packages/rs-dapi-client/src/executor.rs`, the `ExecutionResponse` struct always has a non-optional `address` field of type `Address` because an address is always present when there's a successful response.

Applied to files:

  • packages/rs-sdk/src/platform/address_sync/types.rs
📚 Learning: 2024-10-22T10:53:12.111Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2259
File: packages/rs-dapi-client/src/dapi_client.rs:137-139
Timestamp: 2024-10-22T10:53:12.111Z
Learning: In `packages/rs-dapi-client/src/dapi_client.rs`, when passing data into asynchronous code, ensure that data structures are `Send + Sync`. Using `Arc<AtomicUsize>` is necessary for the retry counter.

Applied to files:

  • packages/rs-sdk/src/platform/address_sync/types.rs
📚 Learning: 2025-01-20T16:20:59.791Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2432
File: packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs:222-225
Timestamp: 2025-01-20T16:20:59.791Z
Learning: In the Dash Platform codebase, TokenAmount from crate::balances::credits is compatible with u64 when used for token base supply.

Applied to files:

  • packages/rs-sdk/src/platform/address_sync/types.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2182
File: packages/rs-dpp/src/withdrawal/daily_withdrawal_limit/v0/mod.rs:23-31
Timestamp: 2024-10-09T00:22:57.778Z
Learning: `Credits` is a `u64`, and division by 10 won't cause an overflow.

Applied to files:

  • packages/rs-sdk/src/platform/address_sync/types.rs
📚 Learning: 2024-10-29T14:40:54.727Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/src/core/transaction.rs:0-0
Timestamp: 2024-10-29T14:40:54.727Z
Learning: In `packages/rs-sdk/src/platform/document_query.rs` and `packages/rs-sdk/src/core/transaction.rs`, certain places don't implement `IntoInner`, so direct error mappings cannot be simplified using `IntoInner`. A TODO comment has been added to address this in a future PR.

Applied to files:

  • packages/rs-sdk/src/platform/address_sync/mod.rs
🧬 Code graph analysis (2)
packages/rs-sdk/src/platform/address_sync/provider.rs (1)
packages/rs-sdk-ffi/src/address_sync/provider.rs (1)
  • on_address_found (130-142)
packages/rs-sdk-ffi/src/address_sync/provider.rs (1)
packages/rs-sdk/src/platform/address_sync/provider.rs (1)
  • on_address_found (79-79)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: Rust packages (wasm-sdk) / Unused dependencies
  • GitHub Check: Rust packages (rs-sdk-ffi) / Tests
  • GitHub Check: Rust packages (drive-abci) / Tests
  • GitHub Check: Rust packages (drive) / Unused dependencies
  • GitHub Check: Rust packages (drive) / Formatting
  • GitHub Check: Rust packages (wasm-sdk) / Tests
  • GitHub Check: Rust packages (wasm-sdk) / Linting
  • GitHub Check: Rust packages (drive) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (dash-sdk) / Unused dependencies
  • GitHub Check: Rust packages (dpp) / Check each feature
  • GitHub Check: Rust packages (dpp) / Tests
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios-sim)
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Build Docker images (Drive, drive, drive-abci, SDK_TEST_DATA=true
    ) / Build Drive image
🔇 Additional comments (17)
packages/rs-sdk/src/platform/address_sync/types.rs (3)

20-27: LGTM! Well-structured composite type for address funds.

The AddressFunds struct cleanly encapsulates nonce and balance together, with appropriate derive traits (Copy, Clone, Debug, PartialEq, Eq) for a value type. The doc comments clearly explain each field's purpose.


74-77: LGTM! Map value type correctly updated to AddressFunds.

The found map now stores the composite AddressFunds type, enabling callers to access both nonce and balance for each discovered address.


112-122: LGTM! Helper methods correctly adapted to AddressFunds.

Both total_balance() and non_zero_count() properly access funds.balance from the new composite type. The logic remains unchanged, just adapted to the new data structure.

packages/rs-sdk-ffi/src/address_sync/types.rs (1)

66-84: LGTM! FFI struct correctly extended with nonce field.

The nonce: u32 field is properly placed and documented. The type u32 aligns with AddressNonce from the SDK core.

Note: This is an ABI-breaking change for FFI consumers. Ensure downstream Swift/iOS code is updated to account for the new field in the struct layout.

packages/rs-sdk-ffi/src/address_sync/mod.rs (1)

163-179: LGTM! Conversion correctly maps AddressFunds to FFI struct.

The iteration over result.found now properly destructures the AddressFunds value and assigns both nonce and balance fields to the FFI-compatible DashSDKFoundAddress struct.

packages/rs-sdk/src/platform/address_sync/provider.rs (3)

3-3: LGTM! Import correctly updated.

The import now includes AddressFunds alongside existing type aliases.


39-45: LGTM! Doc example correctly demonstrates new API.

The example shows proper usage of the AddressFunds parameter and accessing funds.balance for gap extension logic.


76-79: LGTM! Trait method signature correctly updated.

The on_address_found method now accepts funds: AddressFunds instead of a raw balance, enabling providers to access both nonce and balance. The doc comment accurately describes the new parameter.

Note: This is a breaking change for existing AddressProvider implementations.

packages/rs-sdk/src/platform/address_sync/mod.rs (5)

44-47: LGTM! Public export correctly added.

AddressFunds is now part of the public API surface, enabling consumers to use the composite type.


244-272: LGTM! Function correctly updated to return Result and propagate errors.

The process_trunk_result function now:

  1. Returns Result<(), Error> instead of ()
  2. Uses ? to propagate conversion errors from AddressFunds::try_from
  3. Passes funds to provider callback

470-505: LGTM! Branch result processing correctly updated.

The process_branch_result function mirrors the trunk result changes with proper error propagation and AddressFunds usage.


586-596: LGTM! Test updated for new API.

The test correctly validates that:

  1. Element::ItemWithSumItem with nonce bytes [0, 0, 0, 5] produces nonce 5
  2. Balance 1000 is correctly extracted
  3. Invalid element types (plain Element::Item) return InvalidProvedResponse error

507-530: LGTM! Well-implemented TryFrom conversion with proper error handling.

The implementation correctly:

  1. Pattern matches on Element::ItemWithSumItem
  2. Validates nonce is exactly 4 bytes before conversion
  3. Uses from_be_bytes for nonce deserialization, consistent with how the platform handles all nonce types (both AddressNonce as u32 and identity nonces as u64)
  4. Handles potential out-of-range balance values with try_into()
  5. Returns descriptive error messages for all failure cases
packages/rs-sdk-ffi/src/address_sync/provider.rs (4)

4-4: LGTM! Import correctly updated.

AddressFunds is now imported alongside other address sync types.


26-36: LGTM! FFI callback signature correctly extended.

The OnAddressFoundFn type now includes nonce: u32 parameter before balance: u64, maintaining a logical order matching the AddressFunds struct. The doc comment is updated to reflect that both balance and nonce are provided.


130-142: LGTM! Callback implementation correctly updated.

The on_address_found method now:

  1. Accepts funds: AddressFunds matching the trait signature
  2. Extracts funds.nonce and funds.balance when calling the vtable function
  3. Maintains correct parameter order in the FFI call

220-228: LGTM! Test callback updated for new signature.

The test_on_found function correctly includes the _nonce: u32 parameter to match the updated OnAddressFoundFn type.

Copy link
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: 1

🤖 Fix all issues with AI agents
In @packages/wasm-sdk/src/state_transitions/addresses.rs:
- Around line 916-923: Fix the typo in the documentation comment: replace
"aviod" with "avoid" in the TODO comment that references requiring address
nonces in the IdentityCreateFromAddressesOptionsJs and the note about
implementing the sync_address_balances mechanism; ensure the corrected sentence
reads clearly (e.g., "to avoid potential leak of address owner IP address")
while keeping the rest of the comment intact.
🧹 Nitpick comments (3)
packages/wasm-dpp2/src/platform_address/input_output.rs (1)

85-93: Acknowledged: TODO to add nonce to output struct.

The TODO comment clearly tracks the need to add a nonce field to PlatformAddressOutputWasm to achieve parity with PlatformAddressInputWasm. The reference to WasmSdk::identity_create_from_addresses provides good traceability.

Would you like me to open an issue to track this enhancement, or help implement the nonce field addition now?

packages/rs-sdk/tests/fetch/address_sync.rs (1)

63-65: Consider adopting "should..." naming convention for test functions.

As per coding guidelines, tests should be named descriptively starting with "should...". The docstring already describes the behavior well. Consider renaming to something like should_sync_found_and_absent_address_balances.

This is a minor suggestion and can be deferred if the codebase has an established test_ prefix convention.

packages/wasm-sdk/src/state_transitions/addresses.rs (1)

1017-1039: Consider using direct lookup instead of zip for clearer intent.

The current zip pattern relies on both BTreeMaps being sorted identically and having the exact same keys. While the equality check at lines 1023-1027 catches mismatches, iterating inputs_map and looking up in fetched_addresses directly would be clearer and more robust:

♻️ Suggested refactor using direct lookup
-    // merge nonces into inputs map
-    let inputs = inputs_map
-        .into_iter()
-        .zip(fetched_addresses)
-        .map(
-            |((address_requested, amount), (address_received, info_received))| {
-                if address_requested != address_received {
-                    Err(WasmSdkError::invalid_argument(
-                        format!("Address mismatch when merging nonces for identity creation ({} vs {}); platform bug?",
-                            address_requested, address_received)
-                    ))?
-                }
-                if amount > info_received.balance {
-                    Err(WasmSdkError::invalid_argument(format!(
-                        "Input address {} has insufficient balance: requested {}, available {}",
-                        address_requested, amount, info_received.balance
-                    )))?
-                }
-                let nonce = info_received.nonce;
-                Ok((address_requested, (nonce, amount)))
-            },
-        )
-        .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?;
+    // merge nonces into inputs map
+    let inputs = inputs_map
+        .into_iter()
+        .map(|(address, amount)| {
+            let info = fetched_addresses.get(&address).ok_or_else(|| {
+                WasmSdkError::invalid_argument(format!(
+                    "Input address {} not found when fetching nonces",
+                    address
+                ))
+            })?;
+            if amount > info.balance {
+                return Err(WasmSdkError::invalid_argument(format!(
+                    "Input address {} has insufficient balance: requested {}, available {}",
+                    address, amount, info.balance
+                )));
+            }
+            Ok((address, (info.nonce, amount)))
+        })
+        .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?;

This approach eliminates the need for the length check at lines 1011-1016 as well, since the lookup handles missing addresses directly.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 682e484 and 3608bb6.

📒 Files selected for processing (3)
  • packages/rs-sdk/tests/fetch/address_sync.rs
  • packages/wasm-dpp2/src/platform_address/input_output.rs
  • packages/wasm-sdk/src/state_transitions/addresses.rs
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Rust code must pass cargo clippy --workspace linter checks
Rust code must be formatted using cargo fmt --all

**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants

Files:

  • packages/wasm-dpp2/src/platform_address/input_output.rs
  • packages/wasm-sdk/src/state_transitions/addresses.rs
  • packages/rs-sdk/tests/fetch/address_sync.rs
**/tests/**/*.{js,jsx,ts,tsx,rs}

📄 CodeRabbit inference engine (AGENTS.md)

**/tests/**/*.{js,jsx,ts,tsx,rs}: Name tests descriptively, starting with 'should …'
Unit and integration tests should not perform network calls; mock dependencies

Files:

  • packages/rs-sdk/tests/fetch/address_sync.rs
🧠 Learnings (19)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
📚 Learning: 2024-09-29T13:13:54.230Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2182
File: packages/rs-platform-version/src/version/drive_abci_versions.rs:116-121
Timestamp: 2024-09-29T13:13:54.230Z
Learning: Adding Rust doc comments to structs and fields is recommended to enhance clarity and documentation.

Applied to files:

  • packages/wasm-dpp2/src/platform_address/input_output.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.

Applied to files:

  • packages/wasm-dpp2/src/platform_address/input_output.rs
  • packages/wasm-sdk/src/state_transitions/addresses.rs
  • packages/rs-sdk/tests/fetch/address_sync.rs
📚 Learning: 2024-10-03T11:51:06.980Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-03T11:51:06.980Z
Learning: In the `IdentityTransitionVersions` structure within `packages/rs-platform-version/src/version/v2.rs`, the field `credit_withdrawal` does not need the `identity_` prefix since it is already encompassed within identity state transitions.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
  • packages/rs-sdk/tests/fetch/address_sync.rs
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-30T11:19:59.163Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/tests/fetch/config.rs:233-233
Timestamp: 2024-10-30T11:19:59.163Z
Learning: In the Rust SDK's `rs-sdk/tests` integration tests (e.g., in `packages/rs-sdk/tests/fetch/config.rs`), we cannot create objects during tests because there is no support for object creation in this context. Therefore, hardcoded values for test identities must be used.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-29T14:40:54.727Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/src/core/transaction.rs:0-0
Timestamp: 2024-10-29T14:40:54.727Z
Learning: In `packages/rs-sdk/src/platform/document_query.rs` and `packages/rs-sdk/src/core/transaction.rs`, certain places don't implement `IntoInner`, so direct error mappings cannot be simplified using `IntoInner`. A TODO comment has been added to address this in a future PR.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-20T16:05:40.200Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs:148-151
Timestamp: 2024-11-20T16:05:40.200Z
Learning: In `packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs`, when converting public keys from `QuorumForSavingV0` to `VerificationQuorum`, it's acceptable to use `.expect()` for public key conversion, as the conversion has been verified and panics are acceptable in this context.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-20T20:43:41.185Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/tests/strategy_tests/masternodes.rs:212-220
Timestamp: 2024-11-20T20:43:41.185Z
Learning: In `packages/rs-drive-abci/tests/strategy_tests/masternodes.rs`, the pattern of generating a `PrivateKey`, converting it to bytes, and reconstructing a `BlsPrivateKey` from those bytes is intentional. Avoid suggesting to simplify this code in future reviews.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-09T00:22:57.778Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2207
File: packages/rs-drive-proof-verifier/src/proof.rs:1646-1664
Timestamp: 2024-10-09T00:22:57.778Z
Learning: In the implementation of `FromProof<platform::GetContestedResourceIdentityVotesRequest>` in `packages/rs-drive-proof-verifier/src/proof.rs`, when matching `maybe_votes`, using `.expect()` on `v.into_iter().next()` is acceptable because the prior match arm `Some(v) if v.is_empty()` ensures that the map is not empty, preventing a panic.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-03T10:39:11.242Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2305
File: packages/rs-drive-abci/src/abci/handler/finalize_block.rs:81-0
Timestamp: 2024-11-03T10:39:11.242Z
Learning: In `packages/rs-drive-abci/src/abci/handler/finalize_block.rs`, the use of `.expect("commit transaction")` after `app.commit_transaction(platform_version)` is intentional due to the provided comment explaining its necessity. Do not flag this usage in future reviews.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-12-03T15:00:50.385Z
Learnt from: lklimek
Repo: dashpay/platform PR: 1924
File: packages/rs-sdk/src/sdk.rs:855-870
Timestamp: 2024-12-03T15:00:50.385Z
Learning: In `packages/rs-sdk/src/sdk.rs`, remember that `rustls_pemfile::certs` returns an iterator over `Result`, not a `Result` directly. Handle it accordingly in future code reviews.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-06-18T03:44:14.385Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2673
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs:1164-1197
Timestamp: 2025-06-18T03:44:14.385Z
Learning: QuantumExplorer determined that a CodeRabbit suggestion about fixing signable_bytes calculation in identity update tests with contract-bound keys was incorrect - the code flow is working as intended without the suggested changes.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-18T15:43:32.447Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2254
File: packages/rs-sdk/src/sdk.rs:654-658
Timestamp: 2024-10-18T15:43:32.447Z
Learning: In `packages/rs-sdk/src/sdk.rs`, within the `verify_metadata_height` function, when using `compare_exchange` on `last_seen_height`, it's acceptable to use `Ordering::Relaxed` for the failure ordering, as any inconsistency would only trigger an extra loop iteration without affecting correctness.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-28T14:08:53.428Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2351
File: packages/rs-dapi-client/src/address_list.rs:241-250
Timestamp: 2024-11-28T14:08:53.428Z
Learning: In the `IntoIterator` implementation for `AddressList` in `packages/rs-dapi-client/src/address_list.rs`, since `self` is consumed, holding a write lock while converting to an iterator does not block other operations.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WebAssembly as a bridge between Rust and JavaScript implementations

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-10T10:30:19.883Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2232
File: packages/rs-sdk/src/mock/sdk.rs:90-95
Timestamp: 2024-10-10T10:30:19.883Z
Learning: In `packages/rs-sdk/src/mock/sdk.rs`, the `load_expectations` method in `MockDashPlatformSdk` remains asynchronous (`async`) for backward compatibility, even though it now delegates to the synchronous `load_expectations_sync` method.

Applied to files:

  • packages/rs-sdk/tests/fetch/address_sync.rs
🧬 Code graph analysis (1)
packages/wasm-sdk/src/state_transitions/addresses.rs (3)
packages/wasm-sdk/src/queries/utils.rs (1)
  • deserialize_required_query (11-28)
packages/rs-sdk/src/platform/transition/put_identity.rs (1)
  • inputs (162-162)
packages/wasm-sdk/src/error.rs (2)
  • generic (71-73)
  • invalid_argument (75-77)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Rust packages (wasm-dpp) / Tests
  • GitHub Check: Rust packages (dash-sdk) / Linting
  • GitHub Check: Rust packages (dash-sdk) / Check each feature
  • GitHub Check: Rust packages (drive-abci) / Tests
  • GitHub Check: Rust packages (dpp) / Linting
  • GitHub Check: Rust packages (dash-sdk) / Tests
  • GitHub Check: Rust packages (dpp) / Tests
  • GitHub Check: Rust packages (dpp) / Unused dependencies
  • GitHub Check: Rust packages (wasm-dpp2) / Formatting
  • GitHub Check: Rust packages (dpp) / Check each feature
  • GitHub Check: Rust packages (wasm-dpp2) / Linting
  • GitHub Check: Rust packages (wasm-dpp2) / Unused dependencies
  • GitHub Check: Rust packages (wasm-dpp2) / Tests
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
  • GitHub Check: Build Docker images (Drive, drive, drive-abci, SDK_TEST_DATA=true
    ) / Build Drive image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios-sim)
  • GitHub Check: Swift SDK and Example build (warnings as errors)
🔇 Additional comments (6)
packages/rs-sdk/tests/fetch/address_sync.rs (4)

1-3: LGTM!

Import correctly adds AddressFunds from the address_sync module, aligning with the new type used in the test harness.


15-21: LGTM!

The found field type correctly updated to store AddressFunds instead of raw u64 balance, consistent with the trait signature changes.


47-51: LGTM!

Method signature and implementation correctly updated to handle AddressFunds. The insertion logic properly stores the complete struct rather than just the balance.


88-103: LGTM!

Test assertions correctly updated to unwrap with .expect() (providing clear failure context) and access the .balance field from AddressFunds. The multi-line formatting improves readability.

packages/wasm-sdk/src/state_transitions/addresses.rs (2)

5-6: LGTM!

All new imports are used by the fetch_nonces_into_address_map helper function and are appropriate for the functionality being added.

Also applies to: 13-13, 15-15, 20-21


947-948: LGTM!

The integration properly fetches nonces before calling put_with_address_funding, ensuring the SDK method receives the required (AddressNonce, Credits) tuples.

Also applies to: 967-967

Copy link
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/wasm-sdk/src/state_transitions/addresses.rs (1)

990-1016: Consider using a lookup-based merge instead of zip for robustness.

The current implementation relies on both inputs_map and fetched_addresses having identical keys in the same order for the zip at line 1020 to produce correct pairings. While BTreeMap iterates in sorted order and the length check at line 1012 should catch mismatches, a lookup-based approach would be more explicit and safer against subtle ordering issues.

Also, the BTreeSet collection at lines 995-996 is unnecessary since FetchMany can accept any iterable of keys, and you could pass inputs_map.keys().cloned() directly.

♻️ Suggested refactor using lookup-based merge
 async fn fetch_nonces_into_address_map(
     sdk: &Sdk,
     inputs_map: BTreeMap<PlatformAddress, Credits>,
 ) -> Result<BTreeMap<PlatformAddress, (AddressNonce, Credits)>, WasmSdkError> {
-    // collect addresses
-    let input_addresses: BTreeSet<PlatformAddress> =
-        inputs_map.keys().cloned().collect::<BTreeSet<_>>();
-
     // fetch nonces
-    let fetched_addresses = dash_sdk::query_types::AddressInfo::fetch_many(sdk, input_addresses)
+    let fetched_addresses = dash_sdk::query_types::AddressInfo::fetch_many(
+        sdk,
+        inputs_map.keys().cloned().collect::<Vec<_>>(),
+    )
         .await
         .map_err(|e| {
             WasmSdkError::generic(format!(
                 "Failed to fetch address infos for identity creation: {}",
                 e
             ))
         })?
         .into_iter()
         .filter_map(|(k, v)| v.map(|info| (k, info)))
         .collect::<BTreeMap<_, _>>();

-    // sanity check - filter_map above should have removed any non-existing addresses
-    if inputs_map.len() != fetched_addresses.len() {
-        return Err(WasmSdkError::invalid_argument(
-            "Some input addresses were not found when fetching nonces",
-        ));
-    }
-    // merge nonces into inputs map
-    let inputs = inputs_map
+    // merge nonces into inputs map using lookup
+    inputs_map
         .into_iter()
-        .zip(fetched_addresses)
-        .map(
-            |((address_requested, amount), (address_received, info_received))| {
-                if address_requested != address_received {
-                    Err(WasmSdkError::invalid_argument(
-                        format!("Address mismatch when merging nonces for identity creation ({} vs {}); platform bug?",
-                            address_requested, address_received)
-                    ))?
-                }
-                if amount > info_received.balance {
+        .map(|(address, amount)| {
+            let info = fetched_addresses.get(&address).ok_or_else(|| {
+                WasmSdkError::invalid_argument(format!(
+                    "Input address {} was not found when fetching nonces",
+                    address
+                ))
+            })?;
+            if amount > info.balance {
+                return Err(WasmSdkError::invalid_argument(format!(
+                    "Input address {} has insufficient balance: requested {}, available {}",
+                    address, amount, info.balance
+                )));
+            }
-                    Err(WasmSdkError::invalid_argument(format!(
-                        "Input address {} has insufficient balance: requested {}, available {}",
-                        address_requested, amount, info_received.balance
-                    )))?
-                }
-                let nonce = info_received.nonce;
-                Ok((address_requested, (nonce, amount)))
-            },
-        )
-        .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?;
-
-    Ok(inputs)
+            Ok((address, (info.nonce, amount)))
+        })
+        .collect()
 }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3608bb6 and 8909a36.

📒 Files selected for processing (1)
  • packages/wasm-sdk/src/state_transitions/addresses.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.rs: Rust code must pass cargo clippy --workspace linter checks
Rust code must be formatted using cargo fmt --all

**/*.rs: Use 4-space indent for Rust files
Follow rustfmt defaults and keep code clippy-clean for Rust modules
Use snake_case for Rust module names
Use PascalCase for Rust type names
Use SCREAMING_SNAKE_CASE for Rust constants

Files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
🧠 Learnings (20)
📓 Common learnings
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.
📚 Learning: 2024-10-03T11:51:06.980Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2201
File: packages/rs-platform-version/src/version/v2.rs:1186-1188
Timestamp: 2024-10-03T11:51:06.980Z
Learning: In the `IdentityTransitionVersions` structure within `packages/rs-platform-version/src/version/v2.rs`, the field `credit_withdrawal` does not need the `identity_` prefix since it is already encompassed within identity state transitions.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-06T16:11:34.946Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2215
File: packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs:19-30
Timestamp: 2024-10-06T16:11:34.946Z
Learning: In the Rust file `packages/rs-drive-abci/src/execution/platform_events/core_based_updates/update_masternode_identities/create_owner_identity/v1/mod.rs`, within the `create_owner_identity_v1` function, the `add_public_keys` method of the `Identity` struct cannot fail and does not require explicit error handling.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-07-28T20:00:08.502Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/AI_REFERENCE.md:771-783
Timestamp: 2025-07-28T20:00:08.502Z
Learning: In packages/wasm-sdk/AI_REFERENCE.md, the documentation correctly shows the actual SDK method signatures (including identityCreate and identityTopUp with their full parameter lists), which may differ from the UI inputs shown in fixed_definitions.json. The UI may collect fewer parameters from users while handling additional requirements internally.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-28T13:49:17.301Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2317
File: packages/rs-dapi-client/src/address_list.rs:175-180
Timestamp: 2024-11-28T13:49:17.301Z
Learning: In Rust code in `packages/rs-dapi-client/src/address_list.rs`, do not change the interface of deprecated methods like `add_uri`, even to fix potential panics.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-29T14:40:54.727Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2277
File: packages/rs-sdk/src/core/transaction.rs:0-0
Timestamp: 2024-10-29T14:40:54.727Z
Learning: In `packages/rs-sdk/src/platform/document_query.rs` and `packages/rs-sdk/src/core/transaction.rs`, certain places don't implement `IntoInner`, so direct error mappings cannot be simplified using `IntoInner`. A TODO comment has been added to address this in a future PR.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-20T16:05:40.200Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs:148-151
Timestamp: 2024-11-20T16:05:40.200Z
Learning: In `packages/rs-drive-abci/src/platform_types/signature_verification_quorum_set/v0/for_saving.rs`, when converting public keys from `QuorumForSavingV0` to `VerificationQuorum`, it's acceptable to use `.expect()` for public key conversion, as the conversion has been verified and panics are acceptable in this context.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-20T20:43:41.185Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2257
File: packages/rs-drive-abci/tests/strategy_tests/masternodes.rs:212-220
Timestamp: 2024-11-20T20:43:41.185Z
Learning: In `packages/rs-drive-abci/tests/strategy_tests/masternodes.rs`, the pattern of generating a `PrivateKey`, converting it to bytes, and reconstructing a `BlsPrivateKey` from those bytes is intentional. Avoid suggesting to simplify this code in future reviews.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-04T14:16:05.798Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2207
File: packages/rs-drive-proof-verifier/src/proof.rs:1646-1664
Timestamp: 2024-10-04T14:16:05.798Z
Learning: In the implementation of `FromProof<platform::GetContestedResourceIdentityVotesRequest>` in `packages/rs-drive-proof-verifier/src/proof.rs`, when matching `maybe_votes`, using `.expect()` on `v.into_iter().next()` is acceptable because the prior match arm `Some(v) if v.is_empty()` ensures that the map is not empty, preventing a panic.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-03T10:39:11.242Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2305
File: packages/rs-drive-abci/src/abci/handler/finalize_block.rs:81-0
Timestamp: 2024-11-03T10:39:11.242Z
Learning: In `packages/rs-drive-abci/src/abci/handler/finalize_block.rs`, the use of `.expect("commit transaction")` after `app.commit_transaction(platform_version)` is intentional due to the provided comment explaining its necessity. Do not flag this usage in future reviews.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-12-03T15:00:50.385Z
Learnt from: lklimek
Repo: dashpay/platform PR: 1924
File: packages/rs-sdk/src/sdk.rs:855-870
Timestamp: 2024-12-03T15:00:50.385Z
Learning: In `packages/rs-sdk/src/sdk.rs`, remember that `rustls_pemfile::certs` returns an iterator over `Result`, not a `Result` directly. Handle it accordingly in future code reviews.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-06-18T03:44:14.385Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2673
File: packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs:1164-1197
Timestamp: 2025-06-18T03:44:14.385Z
Learning: QuantumExplorer determined that a CodeRabbit suggestion about fixing signable_bytes calculation in identity update tests with contract-bound keys was incorrect - the code flow is working as intended without the suggested changes.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-10-18T15:43:32.447Z
Learnt from: lklimek
Repo: dashpay/platform PR: 2254
File: packages/rs-sdk/src/sdk.rs:654-658
Timestamp: 2024-10-18T15:43:32.447Z
Learning: In `packages/rs-sdk/src/sdk.rs`, within the `verify_metadata_height` function, when using `compare_exchange` on `last_seen_height`, it's acceptable to use `Ordering::Relaxed` for the failure ordering, as any inconsistency would only trigger an extra loop iteration without affecting correctness.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-11-28T14:08:53.428Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2351
File: packages/rs-dapi-client/src/address_list.rs:241-250
Timestamp: 2024-11-28T14:08:53.428Z
Learning: In the `IntoIterator` implementation for `AddressList` in `packages/rs-dapi-client/src/address_list.rs`, since `self` is consumed, holding a write lock while converting to an iterator does not block other operations.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-09-03T15:44:33.889Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/docs.html:0-0
Timestamp: 2025-09-03T15:44:33.889Z
Learning: In packages/wasm-sdk/docs.html, thephez prefers to keep realistic-looking private key placeholders in documentation examples rather than using obvious fake placeholders, despite secret scanner warnings.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-07-28T20:00:24.323Z
Learnt from: QuantumExplorer
Repo: dashpay/platform PR: 2711
File: packages/wasm-sdk/docs.html:2359-2383
Timestamp: 2025-07-28T20:00:24.323Z
Learning: In packages/wasm-sdk/docs.html, QuantumExplorer confirmed that placeholder private keys in documentation examples are acceptable as they are not real keys, though field name accuracy for the SDK API should still be maintained.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-09-03T14:41:16.196Z
Learnt from: thephez
Repo: dashpay/platform PR: 2754
File: packages/wasm-sdk/AI_REFERENCE.md:766-766
Timestamp: 2025-09-03T14:41:16.196Z
Learning: In packages/wasm-sdk/, the AI_REFERENCE.md file is auto-generated from api-definitions.json. Any documentation fixes should be made in api-definitions.json rather than directly in AI_REFERENCE.md, as manual changes to AI_REFERENCE.md would be overwritten during regeneration.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2024-09-29T13:13:54.230Z
Learnt from: shumkov
Repo: dashpay/platform PR: 2182
File: packages/rs-platform-version/src/version/drive_abci_versions.rs:116-121
Timestamp: 2024-09-29T13:13:54.230Z
Learning: Adding Rust doc comments to structs and fields is recommended to enhance clarity and documentation.

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WASM bindings to connect Rust and JavaScript code

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
📚 Learning: 2025-11-25T13:10:23.481Z
Learnt from: CR
Repo: dashpay/platform PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T13:10:23.481Z
Learning: Use WebAssembly as a bridge between Rust and JavaScript implementations

Applied to files:

  • packages/wasm-sdk/src/state_transitions/addresses.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Rust packages (dpp) / Formatting
  • GitHub Check: Rust packages (drive) / Unused dependencies
  • GitHub Check: Rust packages (drive) / Linting
  • GitHub Check: Rust packages (drive-abci) / Tests
  • GitHub Check: Rust packages (rs-sdk-ffi) / Unused dependencies
  • GitHub Check: Rust packages (wasm-sdk) / Unused dependencies
  • GitHub Check: Rust packages (rs-sdk-ffi) / Linting
  • GitHub Check: Rust packages (rs-sdk-ffi) / Tests
  • GitHub Check: Rust packages (wasm-sdk) / Formatting
  • GitHub Check: Rust packages (wasm-sdk) / Linting
  • GitHub Check: Rust packages (wasm-dpp2) / Tests
  • GitHub Check: Rust packages (wasm-dpp2) / Unused dependencies
  • GitHub Check: Rust packages (wasm-dpp2) / Linting
  • GitHub Check: Build Docker images (Drive, drive, drive-abci, SDK_TEST_DATA=true
    ) / Build Drive image
  • GitHub Check: Build Docker images (Dashmate helper, dashmate-helper, dashmate-helper) / Build Dashmate helper image
  • GitHub Check: Build Docker images (RS-DAPI, rs-dapi, rs-dapi) / Build RS-DAPI image
  • GitHub Check: Build JS packages / Build JS
  • GitHub Check: Rust crates security audit
  • GitHub Check: Swift SDK and Example build (warnings as errors)
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios)
  • GitHub Check: Build rs-sdk-ffi for iOS targets (aarch64-apple-ios-sim)
🔇 Additional comments (4)
packages/wasm-sdk/src/state_transitions/addresses.rs (4)

916-923: Good documentation of unstable API and privacy concerns.

The documentation clearly warns users about the privacy implications and the planned changes. However, the crate path reference crate::platform::Platform::sync_address_balances in the TODO comment may be incorrect since this is in wasm-sdk, not the main SDK crate. Consider updating the path or using a more generic reference.


947-948: LGTM!

The integration of fetch_nonces_into_address_map into the identity creation flow is clean and maintains proper error propagation.


1029-1034: Balance comparison uses correct types.

The balance comparison amount > info_received.balance correctly compares Credits values. The error message is clear and helpful for debugging.


20-21: The Identity import from dash_sdk::platform at line 20 is actively used throughout the file (struct fields at lines 259, 619, and variable annotations at lines 309, 517, 940). It is the sole import source for Identity and is necessary. This import should not be questioned.

Likely an incorrect or invalid review comment.

@lklimek lklimek merged commit 4786a80 into v3.0-dev Jan 13, 2026
89 of 92 checks passed
@lklimek lklimek deleted the feat/identity-new-from-input-addresses branch January 13, 2026 12:30
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.

3 participants