Repository navigation
feat(sdk): persist the owner balance a document write's proof carries - #5409
Conversation
…put and a DPNS registration From protocol version 14 a document batch's proof carries the owner's credit balance next to the document. Add `PutDocument::put_to_platform_and_wait_for_response_with_owner_balance_and_metadata` and `Sdk::register_dpns_name_with_owner_balance_and_metadata`, which hand that balance out together with the verified response metadata, whose height is the block the balance is a snapshot at. Both check the proof as strictly as `put_to_platform_and_wait_for_response`: the write must be proved executed unless the document type is indexOnly. The step from a verified outcome to the document and the balance becomes a pure function with unit tests. Existing signatures and behaviour are unchanged; `register_dpns_name` delegates to the new call. Refs #4897 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…roof carries DPNS registration, document create, DashPay profile create and update and contactInfo publish now keep the owner's balance their proof carries from protocol version 14 on. It goes through `persist_confirmed_balance` with the proof's block as the balance watermark, like the balance a transfer or a withdrawal proves, and only for identities owned by the wallet. A proof made at an earlier version carries no balance and leaves it as before, so the apps' balance refresh after a registration still applies until the activation. Refs #4897 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 54 minutes. View limit details
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. Comment |
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-10-13T11:28:53.178Z |
|
Waiting for bot review — coderabbitai not yet · thepastaclaw ✓. Wait for the missing reviews, or a writer can post |
|
✅ Final review complete — no blockers (commit 20f6d08) · triage: normal |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Static verification of the complete PR range found no actionable in-scope defects. The additive SDK APIs preserve existing proof guarantees and return the authenticated balance and metadata; wallet updates reuse ownership checks, height-ordered persistence, and failure-retry behavior without changing consensus or historical version tables. No local builds or tests were run: the supplied CI snapshot reports successful Rust workspace and Swift/Kotlin checks, while dedicated Rust wallet tests and E2E checks were skipped and PR Hygiene remained pending.
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
normalbygpt-6.1-sol(effort low) — The diff adds SDK proof-result plumbing and wallet balance-cache persistence across document-write paths, but does not itself change funds movement, consensus, cryptography, or storage migrations. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-3.8-flash-high(antigravity below 15% reserve: weekly 14% left, 5h 100% left),glm-5.3-flash(not used above high effort; tier asks max) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort high); agentphase2-reviewer
|
/self-reviewed |
|
Ready for review — files with no dedicated owner: QuantumExplorer or shumkov. |
Brings 5.0.0-rc.5, rc.6 and rc.7 (v5.0-dev 79693ec) into v5.1-dev. Conflict resolutions: - Cargo.toml: GroveDB moves to 6.1.1 (2128ea18, dashpay#5499; fast-forward of fc7028d8). rust-dashcore stays on dev aca02026; v5.0-dev's v0.45.0 pin (d631aaca) is not taken. - Cargo.lock: v5.1-dev's lockfile, re-resolved for GroveDB 6.1.1, with dashpay#5499's RUSTSEC bumps replayed via cargo update --precise (h2 0.4.20, rustls 0.23.46, rustls-webpki 0.103.15, quinn-proto 0.11.19, crossbeam-epoch 0.9.21, rust_decimal 1.43.0, anyhow 1.0.104, event-listener 5.4.2, chacha20 0.10.2, spin 0.9.9). - CHANGELOG.md: [Unreleased] on top, then the rc.7, rc.6 and rc.5 entries. - rs-dpp serialization/mod.rs: keeps v5.1's dashcore module gate and takes dashpay#5498's serde-conversion gate for the json module. - rs-sdk dpns_usernames, put_document: dashpay#5409's ResponseMetadata import with v5.1's dpp::secp256k1 rand imports. - platform-wallet masternode/update_service.rs (dashpay#5408, dashpay#5497): v5.0's file ported to dpp::bls. rust-dashcore dev does not expose the coinbase of applied masternode list diffs, so the coinbase source is optional: with none, V24 is read from the list alone (any version-3 entry), as dashpay#5408 did, instead of refusing every legacy evonode update. - platform-wallet spv/runtime.rs: masternode_list_entries reads through DashSpvClient::latest_masternode_list (the engine is crate-private on dev); latest_coinbase is not carried over. - platform-wallet platform_wallet_traits.rs: both branches forwarded unrecorded_spend_heights and note_chain_lock_height; one forward each is kept, and the tests of both branches. - platform-wallet identity/network/profile.rs: v5.1's rs-sdk profile path (dashpay#5470). dashpay#5409's proven-balance persistence for profile writes follows in a separate commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…carries dashpay#5409 (v5.0-dev) made the platform wallet keep the owner balance a document write's proof carries, including DashPay profile create and update, which on v5.0-dev go through SdkWriter::put_document. On v5.1-dev dashpay#5470 moved profile create and update into rs-sdk (Sdk::create_profile / Sdk::update_profile over the document builders), which return only the document, so after the forward merge profile writes dropped the balance. This carries dashpay#5409's behaviour onto that path. rs-sdk (additive): - Sdk::create_profile_with_owner_balance_and_metadata and Sdk::update_profile_with_owner_balance_and_metadata return the confirmed document, the owner's balance after the write (None for a proof made before protocol version 14) and the verified response metadata. create_profile and update_profile delegate to them and keep their signatures. - The write is signed by the same builders, then broadcast and verified by dashpay#5409's wait_for_document_and_owner_balance_with_metadata, which requires an execution proof unless the document type is indexOnly (profile is not), as document_create/document_replace did. rs-platform-wallet: - create_profile_with_external_signer and update_profile_with_external_signer call the new variants. record_own_profile_write (the former cache_own_profile) keeps the proven balance through persist_proven_owner_balance, then caches the profile. Book: the put-operations chapter names the two calls. Test: should_keep_the_proven_owner_balance_of_a_profile_write. With the persist_proven_owner_balance call removed from record_own_profile_write it fails (left: 2818262560, right: 2743797100); with it, it passes. The network half (sign, broadcast, proof) is not unit-testable without a proof-producing mock; it reuses dashpay#5409's tested document_and_owner_balance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Issue being fixed or feature implemented
Prepares the platform wallet for #4897.
From protocol version 14 (#4887) the proof of a document batch carries the owner's credit balance next to the document. The platform wallet ignores it, so after a DPNS registration the apps still query the balance again (
refresh_identity_balance, #4799).This PR makes the wallet take the balance from the proof whenever the proof carries one:
Refs #4897. The issue stays open, because two steps still wait for the activation:
What was done?
rs-sdk (additive; no existing signature or behaviour changes)
PutDocument::put_to_platform_and_wait_for_response_with_owner_balance_and_metadata. It returns three things:Nonefor a proof made before protocol version 14);put_to_platform_and_wait_for_response: the write must be proved executed unless the document type is indexOnly. By contrast,put_to_platform_and_wait_for_response_with_owner_balanceaccepts an affected-state snapshot for any document type; it is left as is.Sdk::register_dpns_name_with_owner_balance_and_metadata. It returns the registration result together with the balance and metadata of the domain's proof. The domain is the registration's last write, so that balance already includes the preorder's cost.register_dpns_namedelegates to it and is unchanged for its callers (rs-sdk-ffi, wasm-sdk).wait_for_document_and_owner_balanceruns through it with unchanged behaviour.rs-platform-wallet
IdentityWallet::persist_proven_owner_balance. It keeps a proof-carried balance through the existingpersist_confirmed_balance, using the proof's block as the balance watermark. This is the same path that transfers, withdrawals and top-ups use since fix(sdk): fetch and persist managed identity credit balances #4799:Noneleaves the balance untouched.PutDocument:register_name_with_external_signer, the variant the FFI and JNI expose);create_document_with_signer;SdkWriter::put_document).There is no FFI, Swift, Kotlin, network or consensus change.
Follow-ups, not in this PR
Sdk::send_contact_request).How Has This Been Tested?
cargo test -p dash-sdk --lib platform::transition::waitable: 6 new tests pass. They cover an execution proof with and without the balance, the strict and lenient handling of an affected-state outcome, an outcome missing the sent document, and a non-document result.cargo test -p platform-wallet --lib wallet::identity::network::balance: 26 tests pass, 4 of them new:Nonewrites nothing;cargo clippy -p dash-sdk -p platform-wallet -p platform-wallet-ffi --all-targets --all-features --locked -- --no-deps -D warningspasses, and so doescargo check -p dash-sdk --no-default-features --locked.Nonepath, which is the current behaviour. TheSomepath is covered by the unit tests above.Breaking Changes
None. The new APIs are additive, and
SdkWriter::put_documentis crate-private.Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code
PR Hygiene ·
20f6d08book/src/sdk/put-operations.md) — QuantumExplorer or shumkovrs-platform-wallet— you own itrust-sdk(packages/rs-sdk/src/platform/dpns_usernames/mod.rs,packages/rs-sdk/src/platform/transition/put_document.rs,packages/rs-sdk/src/platform/transition/waitable.rs) — approved by lklimekWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.