Repository navigation
refactor: build Platform types with their upstream constructors - #1126
Conversation
Pin dash-sdk, rs-sdk-trusted-context-provider, platform-wallet and platform-wallet-storage to dashpay/platform v5.1-dev 063589bf (5.0.0-rc.8). The lockfile moves only the Platform packages. The upstream V019 wallet-storage migration adds a nullable asset-lock operation id; V001-V018 are unchanged. The compatibility bridge gets the 033ecae destination snapshot it compares against, and the pin guard records the new revision with an unchanged migration fingerprint. BREAKING CHANGE: the wallet storage upgrade to V019 is forward only. An older build cannot open upgraded storage; going back needs a copy of the data directory taken before the upgrade. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The new rust-dashcore wraps secp256k1 keys in EcdsaSecretKey and EcdsaPublicKey, returns secret bytes as Zeroizing, and drops the Secp256k1 context argument. Signers, single-key wallets, DashPay derivation, address and QR handling, migrations and their tests follow the new types. Signing stays on the non-grinding dpp::secp256k1 path, and a parity test pins the BLS signature bytes the previous SDK made. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Handle the dpp and SDK types the new pin adds, keeping today's behaviour: - Document replace keeps moderated_at and moderated_by; new documents start without them. - The document editor refuses typed-array fields instead of dropping their contents, and keeps referenced key ids as numbers. - Shielded token events show read-only in group actions, and the shielded pool token settings are refused before anything is signed. - Contested document creation states the protocol's base contest fund, so the SDK never auto-quotes a larger one. - Masternode vote reads use ResourceVoteWithCount, the SDK's new vote type; the vote count is not used yet. - New query fields, wallet events, wallet error variants and asset-lock funding modes are handled where the SDK now requires them. - Entropy-only document ids are documented as placeholders from protocol 14, and deferred upstream features link to their issues. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The SDK was pinned to the protocol 13 table, so it could not build any protocol 14 transition or follow the versioned identity lookup. It now starts at upstream's per-network minimum and ratchets to what proven responses report. - System contracts are cached per protocol version and served through accessors. The context provider serves them at the version the proof verifier asks for and fails rather than serve another version's. - A proved epoch sets the fee multiplier and raises the protocol version. An older epoch than the adopted one is ignored. - Rebuilding the connection resets the protocol version, fee multiplier and adopted epoch under one lock before the new SDK is published, and drops reads begun on the old connection. - Capabilities read the network's version through a helper that stays closed for a version this build does not define. - Contest timing reads the live version; retired vote schedules keep the protocol 13 notice window they were created under. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Compare the protocol 13 client tables with a recorded snapshot, so an upstream change to them is reviewed, and check that keys and documents DET builds on a protocol 13 network use encodings protocol 13 decodes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Map the refusals the new protocol adds to flows DET already offers to dedicated TaskError variants: a full username contest, a vote choice the contest does not allow, a name someone else asked for first, a token that cannot be moved, a changed immutable document field, a reference to a document type that cannot be deleted, and a moderators' fee on a contract without moderation. Names supplied by the node stay in the typed source only, never in the message. Token operations that fail inside the wallet runtime keep their SDK cause, so they are classified like any SDK error; an unclassified one names the operation that did not complete. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Add a dated design note for the pin, the protocol version sources, the connection state rules and the protocol 13 guards, and point AGENTS.md at From<SdkError> for TaskError as the SDK error reference. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…it refusals Protocol version 14 refusals that flows already in DET can hit get dedicated, actionable messages, each keeping the SDK error as its source: - an identity banned or suspended (until when) on a moderated contract; - a gas sponsor short of credits, a gas payer the document type does not offer, and mixed gas payers in one batch; - pre-programmed token distributions of one time over the limit. An overflowing shielded note total is logged at warn: it means corrupt or hostile sync data, not routine noise. Tests cover contracts saved at protocol 12 loading unchanged at 13 and 14, and contracts saved at 14 decoding at 13 and in full again at 14. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
A lookup at another version, as the proof verifier makes at a response's version, swapped out the app's set, so each such lookup reloaded the system contracts and the next app read reloaded them again. Each version now keeps its own set; the app's reads keep the set they last got for a failed reload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…poch When the epoch cannot be read, the proved DPNS fallback confirmed the SDK's version, which starts at the network's upstream minimum (14 on devnet), as the network's. It now confirms the version of the responses the SDK verified, and nothing before any. Restores the completed-withdrawal status list with the reason sending FAILED to a protocol 13 network is safe, and its test, now comparing the protocol 13 schema with the latest one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The derived key DET signs with is copied into secp256k1's own type, which keeps its bytes after use. Wrap it so it is erased on drop, as the derived key it comes from would be; signatures stay byte-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
… protocol 13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The new refusals sent users to another document editor or token client. They now say the app cannot edit this field type, sign this action or change this token setting yet, in one wording, and the shielded setting refusal sits with the token contract errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Also corrects the platform compatibility fixtures README: no code reads e3cd7cf.sql any more; it is the V001-V018 checksum reference. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The protocol version fallback takes only a version the SDK verified, and a mock expectation's metadata is never recorded as verified, so the three headless refresh tests saw the version stay unconfirmed. The mock now has the SDK accept the version from metadata treated as proved, as after a live network's signed response, and a new test pins that a response the SDK never verified leaves the version unconfirmed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The SDK picks each transition's encoding from the platform version DET passes in, so these tests checked dpp's version tables rather than DET. The mainnet start version and the contest fund cap stay covered by the platform_info and fee_estimation tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The SDK at this pin already tracks the version the network has proven: it records the version of every response whose proof and quorum signature it verified, and a rebuilt connection is a new SDK that starts from nothing. DET's own copy, raised from proved epochs and DPNS reads and reset on every rebuild, duplicated that state. The app now reads the current SDK's verified version; capabilities still stay closed before a version is proven and for one this build does not define, and network info shows the proven number or says none is confirmed. Proved epochs still set the fee multiplier, in epoch order and only on the current connection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
A connection rebuild never changes the chain, the multiplier changes once per epoch and feeds only fee estimates, so ordering epoch reads and dropping those begun before a rebuild guarded against nothing worth the machinery. A proved epoch read sets the multiplier directly again; an unavailable epoch still keeps the last known value and labels it as such. A rebuild still reads the epoch, so the new SDK proves the network's version again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
A released protocol's tables and each network's minimum version are upstream's to keep fixed; DET's start is covered by platform_version_starts_at_the_network_minimum. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Replace hand-written `PublicKey { compressed, inner }` literals with
`PrivateKey::public_key()` where the literal copied the private key's
compression flag, and with `PublicKey::new` where it forced a compressed
key. Both produce the same value as the literals they replace.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Use `QualifiedIdentityPublicKey::from` and `from_identity_public_key_in_wallet` instead of struct literals, and build the v0.9.3 upgrade test's identity with `Identity::new_with_id_and_keys` at the network's starting protocol version, so the identity structure follows the platform version instead of being fixed to V0 by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…tory DashPay contact requests, contact info and the generic document screen built new documents as hand-written `DocumentV0` literals. They now go through `model::document::new_document_for_creation`, which derives the placeholder id from the entropy as before and calls the document type's `create_document_with_prevalidated_properties`, so the document structure follows the platform version. Properties are kept exactly as given. The factory also fills required `$createdAt`-style fields and leaves an immutable document without a revision. The create transition carries neither, so the transition is unchanged; a test proves it for `contactRequest` and `contactInfo` at protocol versions 13 and 14. Document replacement clones the original and uses the document setters instead of rebuilding it field by field, with the same result. A failure to build the document now surfaces as the dedicated `TaskError::DocumentPreparationFailed`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…factory Identity public keys that are not bound to a contract are now built with `IdentityPublicKey::default_versioned` plus the key setters instead of hand-written `IdentityPublicKeyV0` literals, so the key structure follows the platform version. - Production: `IdentityKeySpecs` builds its master key this way. `to_public_keys_map` and `to_key_storage` take the platform version their caller already uses (`AppContext::platform_version()` on the asset-lock path, `sdk.version()` on the platform-address path), and `to_key_storage` now reports a failure as `TaskError::IdentityCreationError`. - Unit tests: one `test_support::identity_public_key` fixture. - Integration tests (kittest, backend-e2e): the factory and setters inline. Keys that may be bound to a contract stay `IdentityPublicKeyV0` literals: the key setters cannot set contract bounds. A test proves the specs' keys are the same V0 keys as before at protocol versions 13 and 14. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…ctors Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Document factory and task integration src/model/document.rs, src/model/mod.rs, src/backend_task/dashpay/contact_info.rs, src/backend_task/dashpay/contact_requests.rs, src/backend_task/error.rs |
A shared factory creates documents with the supplied document type, owner, properties, entropy, and platform version. DashPay contact document tasks use it and map preparation failures to DocumentPreparationFailed. |
Document UI validation and replacement src/ui/helpers.rs, src/ui/contracts_documents/document_action_screen.rs |
Contract selection clears an incompatible document type. Document creation reports foreign document types, uses the shared factory, and replaces documents while retaining fields not explicitly reset. |
Sequence Diagram(s)
sequenceDiagram
participant ContractChooser
participant DocumentActionScreen
participant DocumentFactory
ContractChooser->>DocumentActionScreen: selected contract and document type
DocumentActionScreen->>DocumentActionScreen: validate contract ID match
DocumentActionScreen->>DocumentFactory: create with type, owner, properties, entropy, and platform version
DocumentFactory-->>DocumentActionScreen: document or protocol error
Version-aware identity keys
| Layer / File(s) | Summary |
|---|---|
Versioned key conversion and registration src/backend_task/identity/mod.rs, src/backend_task/error.rs, src/backend_task/identity/register_identity.rs, tests/backend-e2e/register_dpns.rs, src/context/wallet_lifecycle/tests.rs |
Key storage and public-key map conversion accept a platform version and return typed errors. Registration paths and related callers pass the active version. |
Shared identity-key fixtures and call sites src/context/test_support.rs, src/backend_task/identity/*, src/model/derived_identity_key.rs, src/model/legacy_recovery.rs, src/model/qualified_identity/*, src/ui/identity/keys/*, src/ui/masternodes/*, src/ui/tokens/claim_tokens_screen.rs, src/backend_task/wallet/mod.rs, src/wallet_backend/dashpay.rs, tests/backend-e2e/*, tests/kittest/* |
A shared helper and versioned setters replace direct V0 key construction in test fixtures. Wallet-backed qualified keys use their constructor, and the add-key UI converts keys through From. |
Public-key construction updates
| Layer / File(s) | Summary |
|---|---|
Wallet and migration public-key construction src/backend_task/migration/*, src/model/single_key.rs, src/wallet_backend/secret_access.rs, src/wallet_backend/single_key.rs, src/context/wallet_lifecycle/tests.rs |
Wallet and migration code derives public keys with PrivateKey::public_key() or creates them with PublicKey::new() instead of assembling their fields. |
Token transition signing versions
| Layer / File(s) | Summary |
|---|---|
Use the SDK version for signing src/backend_task/tokens/destroy_frozen_funds.rs, src/backend_task/tokens/pause_tokens.rs, src/backend_task/tokens/resume_tokens.rs, src/backend_task/tokens/update_token_config.rs |
The four token operations pass sdk.version() to transition signing. |
Priority:
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Refactor
Suggested reviewers: lklimek, thepastaclaw
Merge Risk: 
Minimal · up to 37b77
-
No concrete issue requiring a change before merge is established by the available evidence. Normal checks and owner review can proceed.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 inconclusive Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "refactor: build Platform types with their upstream constructors" matches the main change. The PR replaces hand-built Platform values (identity public keys, qualified keys, documents, and identity keys) with upstream constructors and factories, such as
new_document_for_creation,identity_public_key,from_identity_public_key_in_wallet, anddefault_versioned. The title is concise and conveys the primary intent. The conventional-commit prefix is consistent with a behavior-preserving refactor. It does not mention the protocol 14 adaptation or the token signing change tosdk.version(), but those are secondary.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 80 functions across 42 files. (5 skipped: 5 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
|
⛔ Final review complete — 1 blocking finding(s) (commit 37b7720) |
Pause, resume, destroy-frozen-funds and token-config-update signed with `AppContext::platform_version()` but broadcast through the task's `sdk`. After a connection rebuild the two SDKs can differ, so sign with `sdk.version()`, the version of the SDK that broadcasts, as the rest of the backend does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The proof verifier asks for contracts at the version it verifies with, which can be newer than the SDK's. System contracts were already served at that version; a saved user contract was decoded at the SDK's version instead, dropping newer-protocol settings such as action fees. The fallback now decodes it at the version asked for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Resolve the contact_requests test-module import conflict by keeping both sides: DppDocument (this branch's fixtures) and ContactInfoField (v1.0-dev's new contactInfo tests). Build the new claim-tokens test key with the shared versioned-factory fixture instead of an IdentityPublicKeyV0 literal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
IdentityKeySpecs::to_public_keys_map stringified the ProtocolError from IdentityPublicKey::default_versioned into PublicKeyMapBuildFailed's detail, dropping the source chain. It now returns TaskError directly and maps that failure to the new IdentityKeysPreparationFailed variant, which keeps the error as a typed Box<SdkError> source (SdkError::Protocol). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The tokens_screen fixture still built its unbound key as an IdentityPublicKeyV0 literal; it now uses IdentityPublicKey::default_versioned plus the key setters, like the other kittest fixtures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The contract/document-type chooser keeps the selected type when the contract changes. The document factory derives the new document's id from the type's contract, so a stale type produced an id for one contract inside a transition for another. Creating now stops with a message asking the user to pick a type from the selected contract. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The contract/document-type chooser kept the selected type after the user picked another contract, so every document action could pair one contract with another contract's type. Selecting a contract now clears a type that belongs to a different contract. The create guard stays as a backstop, and its message now reaches the banner instead of hiding behind the generic "check its fields" text: try_build_document returns a DocumentBuildError that tells the leftover type apart from invalid fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
to_public_keys_map built its key-type and security-level failures as format! strings stored in PublicKeyMapBuildFailed's detail field. They are now IdentityKeySpecError variants carrying the key id, purpose, level and type, and PublicKeyMapBuildFailed holds that error as its source. The banner text is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
|
Waiting for bot review — coderabbitai ✓ · thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
There was a problem hiding this comment.
Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)
Updated after discussion: 1 finding(s) of this review were settled in the inline threads; 1 blocking finding(s) still stand.
- ✅ Withdrawn: 🔴 Match the tuple-shaped PublicKeyMapBuildFailed variant without moving the error
The refactor has a introduced test-compilation blocker: the new regression test matches a tuple-shaped error variant with struct syntax and then risks moving the error before inspecting its source. The document selector also leaves mutation state and in-flight fetch results associated with the previous contract/type usable after a selection change, which can enable or submit an operation using stale data. The previously reported platform-version mismatch remains a valid suggestion; Test Suite and Clippy were still queued in the supplied CI snapshot.
🔴 2 1 blocking | 🟡 1 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🔴 Blocking: Invalidate fetched mutation state when the contract or document type changes
src/ui/contracts_documents/document_action_screen.rs:279-282
This branch clears only fetched_documents, leaving original_doc, field_inputs, fetched_price, and broadcast_status intact. A user can fetch a document or price for contract A, switch to contract B, select a document type, and still have Replace or Purchase enabled with the old document or price while the new contract/type is submitted. The replacement path does not verify that the fetched document belongs to the current contract/type. In addition, display_task_result accepts every Documents result without associating it with the query that produced it, so a late response from the old selection can repopulate this stale state after it was cleared. Selection changes must invalidate all mutation-specific state, and fetch results must be ignored or tagged with the selection that initiated them.
source: gpt-6.1-sol (phase2-reviewer: general)
1 carried-forward finding(s) already raised on this PR; not re-posting as new inline comments.
Review provenance
Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This is a large, cross-cutting refactor that changes cryptographic key construction, identity key handling, document creation, and transaction-signing platform-version selection across production paths such as src/backend_task/identity/mod.rs and src/backend_task/tokens/*.rs. - Phase 1 reviewers: not run (disabled for this repository)
- Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort xhigh); agentphase2-reviewer,gpt-6.1-sol— rust-quality (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `src/backend_task/identity/mod.rs`:
- [BLOCKING → WITHDRAWN in discussion; do not fix] src/backend_task/identity/mod.rs:1576-1582: Match the tuple-shaped PublicKeyMapBuildFailed variant without moving the error
`TaskError::PublicKeyMapBuildFailed` is declared as a tuple variant in `src/backend_task/error.rs`, but this regression test uses struct-variant syntax (`{ .. }`), so the test does not compile. After correcting the pattern, matching the owned `error` would move it before the subsequent `error.source()` call; the assertion must borrow the error.
In `src/ui/contracts_documents/document_action_screen.rs`:
- [BLOCKING] src/ui/contracts_documents/document_action_screen.rs:279-282: Invalidate fetched mutation state when the contract or document type changes
This branch clears only `fetched_documents`, leaving `original_doc`, `field_inputs`, `fetched_price`, and `broadcast_status` intact. A user can fetch a document or price for contract A, switch to contract B, select a document type, and still have Replace or Purchase enabled with the old document or price while the new contract/type is submitted. The replacement path does not verify that the fetched document belongs to the current contract/type. In addition, `display_task_result` accepts every `Documents` result without associating it with the query that produced it, so a late response from the old selection can repopulate this stale state after it was cleared. Selection changes must invalidate all mutation-specific state, and fetch results must be ignored or tagged with the selection that initiated them.
- [SUGGESTION] src/ui/contracts_documents/document_action_screen.rs:1451-1457: Use the same Platform version for document construction and broadcast
(existing thread: https://github.com/dashpay/dash-evo-tool/pull/1126#discussion_r4382488150)
The document factory is called with `self.app_context.platform_version()`, while the later `BroadcastDocument` task snapshots the SDK when it runs and uses that SDK's `version()` for contest-fund calculation and transition construction. A reconnect can replace the SDK between these operations, allowing the document to be prepared under one protocol version and broadcast under another. Construct the document in the backend from task inputs and the same SDK snapshot, or carry and compare one version snapshot through both stages. The protocol update being infrequent does not remove this ordering mismatch.
|
Real issue, but it predates this PR and is outside its diff (as the review notes,
The fix is tracked in a separate PR: #1155. That PR clears all fetched mutation state on a contract or document-type change and ignores fetch results and errors from a selection the screen no longer waits for. 🤖 Co-authored by Claudius the Magnificent AI Agent |
|
/self-reviewed |
|
Ready for review — files with no dedicated owner: nobody may approve. |
TL;DR
DET built several Platform types by hand as struct literals. Where the upstream crates (dpp, dash-sdk and dashcore at Platform
575d961f) offer a constructor or factory, DET now uses it. This is a pure refactor: nothing changes on the wire and nothing changes for the user.PublicKey { compressed, inner }becomesPrivateKey::public_key()orPublicKey::new(...).QualifiedIdentityPublicKey { .. }becomes DET's ownFromandfrom_identity_public_key_in_walletconstructors.create_document_with_prevalidated_properties, wrapped in one helper,model::document::new_document_for_creation.Identity::new_with_id_and_keys.IdentityPublicKey::default_versionedplus the key setters instead ofIdentityPublicKeyV0literals. That covers the registration master key inIdentityKeySpecsand 37 test keys. The unit tests share onetest_support::identity_public_keyfixture; the kittest and backend-e2e tests call the factory directly.User story / Scenario
Not applicable. This is a refactor with no change a user can see.
Detailed discussion
The wire stays the same
DocumentCreateTransitionV0::from_documenttakes only the base (id, nonce, type, contract), the entropy and the properties from the document. The factory differs from the old literal in two ways, and neither reaches the transition:$createdAt.contactRequest) without a revision.model::document::tests::factory_document_yields_the_hand_built_create_transitionbuilds the create transition from the old hand-built document and from the factory document forcontactRequestandcontactInfoat protocol versions 13 and 14, and checks that the two are equal.The factory keeps the properties exactly as given.
create_document_from_datawould have rewritten identifier values, and properties go on the wire, which is why the helper doesn't use it.The replacement path produces exactly the document the old literal did.
replacing_document_keeps_identity_and_drops_platform_set_fieldschecks this.Which platform version each site uses
sdk.version(), the version their transition builder already uses.AppContext::platform_version().IdentityKeySpecs::to_public_keys_mapandto_key_storagenow take a platform version. Registration passes the one each path already uses:AppContext::platform_version()on the asset-lock path andsdk.version()on the platform-address path.sdk.version(), the version of the SDK that broadcasts the transition. Before, they usedAppContext::platform_version(), which can differ from the task's SDK after a connection rebuild.Identity keys stay V0
In every platform version up to 14,
identity_key_structure_versionis 0, so the factory yieldsIdentityPublicKey::V0.identity_key_specs_build_v0_keys_at_protocols_13_and_14checks that, at protocols 13 and 14, the specs' master key in both the public key map and the key storage equals the old hand-built V0 key. The identity-create encoding on mainnet (protocol 13) is therefore unchanged.New error paths
TaskError::DocumentPreparationFailedwith a typedProtocolErrorsource.TaskError::IdentityKeysPreparationFailed. Its typed source isSdkError::Protocol, wrapping dpp's own error.unknown_key_structure_keeps_the_typed_protocol_errorchecks both the variant and the source.TaskError::IdentityCreationError.Before, nothing could fail at any of these steps. In practice they only fail on a protocol version this build doesn't know.
The public keys map's existing validation failures (an unsupported key type, a purpose that doesn't allow the security level) were strings. They are now
IdentityKeySpecErrorvariants, held as the typed source ofTaskError::PublicKeyMapBuildFailed, and the banner text is unchanged.a_disallowed_security_level_is_a_typed_key_spec_errorchecks this.The factory derives a new document's id from its document type's contract, so the type must belong to the selected contract. The contract/document-type chooser kept the selected type when the user picked another contract. It now drops a type that belongs to a different contract, which covers every document action;
selecting_a_contract_drops_another_contracts_document_typechecks this. As a backstop, creating a document with a type from another contract stops with its own banner: "This document type belongs to another contract. Select a document type from the selected contract and try again."creating_refuses_a_document_type_from_another_contractandthe_create_banner_explains_a_document_type_from_another_contractcheck this.Left as literals, because upstream has no suitable constructor
IdentityPublicKeyV0keys that may be bound to a contract: no upstream setter exists forcontract_bounds. There are four sites: the two in the Add Key screen and the non-master keys inIdentityKeySpecs::to_public_keys_mapandto_key_storage. Each carries a comment saying why.DataContractV1:DataContractFactorygoes through serialization format V0, which has no fields for tokens, groups, keywords or description.DocumentV0::default()placeholder in the replace path:Documenthas noDefault.ResourceVoteV0,ExtendedEpochInfoV0,ContenderWithSerializedDocumentV0,TokenPaymentInfoV0: no constructors exist.tests/migration-fixtures/v0.9.3-public-identities/fixture-writer.rs: it is compiled inside the v0.9.3 tag, so it has to keep that version's API.Verification
cargo clippy --all-features --all-targets -- -D warningsis clean.cargo test --all-features --lib -- backend_task::identity::tests:: ui::contracts_documents::document_action_screen::tests:: ui::helpers::tests::: 21 passed.cargo test --all-features --lib ui::tokens::claim_tokens_screen::tests::: 4 passed.cargo test --all-features --test kittest tokens_screen::: 4 passed.--all-targets.🤖 Co-authored by Claudius the Magnificent AI Agent
🤖 Generated with Claude Code
https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
PR Hygiene ·
37b7720src/backend_task/dashpay/contact_info.rs,src/backend_task/dashpay/contact_requests.rs,src/backend_task/dashpay/encryption.rsand 44 more) — nobody may approve: everyone who could attested to itWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.Summary by CodeRabbit