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

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

    • Stricter identity and address verification enabled during identity creation for deeper validation.
  • New Features

    • Create identities from input addresses paired with public keys.
    • Added internal helper to derive identity IDs from input addresses/nonces.
    • WASM SDK adds a client helper to fetch and merge nonces into address inputs.
  • Chores / Breaking Change

    • Public API now requires explicit nonces for identity submissions; automatic nonce-fetching path removed and docs updated.

✏️ 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 a feature-gated Identity constructor that derives identity IDs from input addresses, extracted identity ID derivation into a reusable helper, flipped two verification flags to true, changed SDK APIs to require explicit address nonces, and added nonce-fetching logic in the WASM SDK.

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 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(...) to build address→nonce map, bincode-encode and double-hash it to produce an Identifier; identity_id_from_inputs now delegates to this helper; 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, switched two boolean args from false 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 path and put_with_address_funding_with_nonce; updated put_with_address_funding signature to accept inputs_with_nonce: BTreeMap<PlatformAddress,(AddressNonce,Credits)>; adjusted docs and imports.
WASM SDK: nonce fetching helper
packages/wasm-sdk/src/state_transitions/addresses.rs
Added private fetch_nonces_into_address_map(...) to fetch AddressInfo via fetch_many, validate results, and merge nonces into inputs; updated address_funds_transfer and identity_create_from_addresses to call this helper before put_with_address_funding.

Sequence Diagram(s)

sequenceDiagram
    actor Client as WASM_SDK
    participant RPC as Platform_RPC
    participant SDK as Platform_SDK
    participant DPP as rs-dpp

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

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I found each nonce beneath the leaf,

I stitched the map with careful brief.
Flags turned true, the checks now sing,
New paths sewn tight with a silver ring.
🥕 Hopping changes — neat as spring.

🚥 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()' directly and accurately describes the primary change in the PR - adding a new constructor method to the Identity type.
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.

Comment on lines +1047 to +1068
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>>()?;
Copy link
Contributor

@coderabbitai coderabbitai bot Jan 9, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Unsafe zip operation can cause address/nonce mismatches.

Using zip() to combine two BTreeMap iterators by position is unsafe. Even though BTreeMap maintains sorted order, after the filter_map operation on line 1037 that removes None values, there's no guarantee that inputs_map and fetched_addresses will have the same iteration order or even contain exactly the same keys.

If the ordering differs for any reason, address A could be paired with the nonce for address B, causing incorrect signature creation and transaction failures.

🔒 Proposed fix: Explicitly look up each address
     // 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)
-                    ))?
-                }
+        .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_received.balance {
+                if amount > info.balance {
                     Err(WasmSdkError::invalid_argument(format!(
-                        "Input address {} has insufficient balance: requested {}, available {}",
-                        address_requested, amount, info_received.balance
+                        "Input address {} has insufficient balance: requested {}, available {}",
+                        address, amount, info.balance
                     )))?
                 }
-                let nonce = info_received.nonce;
-                Ok((address_requested, (nonce, amount)))
+                let nonce = info.nonce;
+                Ok((address, (nonce, amount)))
             },
         )
         .collect::<Result<BTreeMap<_, _>, WasmSdkError>>()?;
🤖 Prompt for AI Agents
In @packages/wasm-sdk/src/state_transitions/addresses.rs around lines 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)).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have safety checks there (comparing length + comparing addresses), there is no reason for ordering to change, and even if there is we will detect it.

Lookup will be more expensive.

Copy link
Contributor

Choose a reason for hiding this comment

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

@lklimek, you're absolutely right. Since both inputs_map and fetched_addresses are BTreeMaps with the same keys (verified by the length check), they will iterate in the same sorted order, and the explicit address comparison check will catch any unexpected issues. The zip approach is both correct and more efficient here. Thank you for the clarification!


🧠 Learnings used
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: 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.

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.

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.

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

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants