Repository navigation
refactor(platform-wallet): share the masternode update helpers and use rust-dashcore's key and script types - #5997
Conversation
…'s keys into the wallet execute/prepare_masternode_update_registrar builds, owner-signs, funds, input-signs and (execute) broadcasts the provider update registrar transaction that rotates a masternode's operator and/or voting key to fresh wallet keys — Core's protx update_registrar — riding the same payload-finalizer seam as the update-service path. The owner's payload signature is the 65-byte compact recoverable ECDSA over base_payload_hash (Core's CHashSigner form, hash signed directly), pinned by the real testnet vector embedded in dashcore's payload tests: the vector's base_payload_hash is asserted byte-exact and the signing helper's output is recovered back to the owner key id. Preflights, before any signing or network work: the owner secret must hash to the ProRegTx's immutable keyIDOwner (fetched txid-bound); a chosen operator key must be unused across the whole masternode list under both serializations (consensus uniqueness); the payout address is always required and network-checked — the payload replaces the payout script on-chain; and rotating the operator key of a v3 extended-net-info entry is refused, since the mandatory reactivation would replace its endpoint map. Because a ProUpRegTx that changes the operator key resets the entry's service fields and PoSe-bans it until the new operator reactivates it, this commit also adds the reactivation half: the explicit-values update-service variant (prepare/execute_masternode_update_service_with_ values) re-asserts caller-captured service and platform values instead of copying the reset entry, and provider_key_candidates lists the wallet's operator/voting keys joined against the list so pickers can default to (and enforce) network-wide-unused keys. Shared registration-payload fetching is refactored out of the unban's reward rule rather than duplicated. Co-Authored-By: Claude Fable 5 <[email protected]>
…Swift wrappers Additive entry points mirroring the update-service families: - platform_wallet_manager_masternode_update_registrar and the tracked form (host-vaulted owner key text), each with a _prepare_ sibling that registers the signed transaction in the existing core signed-transaction storage for the review-before-broadcast step. - platform_wallet_manager_masternode_update_service_with_values (+ prepare): stage two of an operator rotation — no tracked form, since the post-rotation operator key is by definition a wallet key. - platform_wallet_manager_provider_key_candidates (+ free): the wallet's operator/voting keys by index with network-wide usage, keyed by the same account-type tags every provider-key FFI uses. The unban module's derive helper generalizes to any provider kind (owner keys included) instead of being copied, and its context resolver and secret parsers are shared. Out-params are zeroed before any other pointer check, per the crate contract, with tests. Swift: masternodeUpdateRegistrar / trackedMasternodeUpdateRegistrar (+ prepare), masternodeUpdateServiceWithValues (+ prepare), and providerKeyCandidates returning typed candidate rows. Co-Authored-By: Claude Fable 5 <[email protected]>
…ral's embedded indentation, repoint a renamed doc link - provider_key_candidates now refuses counts above a shared MAX_PROVIDER_KEY_CANDIDATES (256) before any allocation — an arbitrary external count fed Vec::with_capacity and could abort the process. The FFI re-exports the bound (asserted equal in tests) and the Swift wrapper guards against it up front. - The values-path extended-net-info error message had the source indentation baked into the literal (missing line continuations). - The registration-fetch doc pointed at a function renamed in this branch. Co-Authored-By: Claude Fable 5 <[email protected]>
…legacy-key handling, values-path semantics, NUL guards, candidate tests - Payout scripts are now gated to P2PKH/P2SH in both payout resolvers (consensus rejects every other type as bad-protx-payee), and the registrar refuses a P2PKH payout paid to the owner key or the payload's final voting key (bad-protx-payee-reuse) — both hashes are known before funding, so the doomed transaction never gets signed. - A kept operator key is normalized by the ENTRY VERSION, not the bytes: MasternodeListSummary gains operator_key_is_legacy (entry.version < 2, persisted leniently), and a legacy key re-entering a version-2 payload is parsed under Legacy and reserialized to basic. Byte-sniffing was proven unsound in tests — legacy bytes also parse under the basic scheme as a different flag reading. - The explicit-values service path takes pro_tx_hash and the payout address directly instead of MasternodeUpdateServiceParams, whose documented platform_p2p_port semantics contradicted the values API. - Swift wrappers guard every string parameter against embedded NUL before C-string marshalling, matching the existing wrappers — a truncated payout/key/service must never differ from what the caller supplied. - provider_key_candidates gains behavioral tests: modern- and legacy-serialization operator joins, voting key-id joins, unused retention, kind refusals, the zero count and the bound. Co-Authored-By: Claude Fable 5 <[email protected]>
The fully-qualified ProviderRegistrationPayload return type pushed both shared-helper signatures past rustfmt's max width, so the formatter was skipping the lines entirely and the missing space before the brace survived every fmt pass. Import the type instead so the signatures are short enough for rustfmt to own.
…service values before funding Review follow-ups on the ProUpRegTx / ProUpServTx orchestrators: - Resolve the masternode's collateral script from the txid-bound ProRegTx (internal collateral) or a txid-bound fetch of the external collateral transaction, and refuse a final voting key or owner key at the collateral's P2PKH destination (Core's bad-protx-collateral-reuse); for a v3 entry also refuse a payout equal to the collateral script (bad-protx-payee-reuse). Candidate discovery joins against DML voting fields only, so a key that once funded the collateral looked unused. - Validate explicit ProUpServTx values against MnNetInfo::ValidateService, CheckProviderNetworkFields and the network-wide uniqueness pass: IPv4 only, non-zero routable port with the mainnet-port rule, non-null platform node id, mainnet platform port defaults, no port collisions, and no service endpoint or platform node id already advertised by any other entry. MasternodeListSummary now carries every socket endpoint of an extended entry's map so the uniqueness check sees secondary addresses, with the snapshot format extended backward-compatibly. - Keep the typed dash_sdk::Error when a transaction fetch fails; the invalid-data shapes are reserved for responses that fail validation. - Split the registrar orchestrator so the whole wiring below the network fetches is exercised by a funded test that asserts the proTxHash, operator key, voting hash, payout script, inputs hash and recovered owner signature, plus the collateral preflight wired through it. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…, catch P2PK collateral reuse Review round three on the registrar path: - prepare_masternode_update_registrar ran the assembly (which derives wallet keys via tokio blocking read-locks) directly in its async body, and the candidates FFI ran provider_key_candidates inside block_on_worker's spawned task — both a documented blocking_read panic on an async worker, aborting across the C ABI. The orchestrator now assembles on the blocking pool (spawn_blocking, with a regression test driving the seam from a runtime worker), and the candidates extern awaits only the list read, deriving on the plain FFI thread like the per-index derive extern. - The collateral-reuse preflight only extracted P2PKH destinations; Core's ExtractDestination also converts a valid P2PK collateral to a PKHash over the key's original serialization, so a P2PK collateral at the voting or owner key slipped through to a deterministic consensus rejection. Both forms are extracted now, tested compressed and uncompressed. - The owner-key and voting-key collateral collisions report separate errors: re-choosing the voting key clears one, while the immutable owner key's collision cannot be fixed with a ProUpRegTx at all. Co-Authored-By: Claude Fable 5 <[email protected]>
…wn operator key Core's CheckProUpRegTx duplicate-key checks both exclude the node being updated (HasOperatorKeyUnderAnyScheme's self parameter, and the proTxHash != otherDmn->proTxHash guard on the unique-property lookup), so re-asserting the masternode's current operator key — a retry, or a voting-only change re-selecting the same operator index — is consensus valid. The wallet preflight refused it as a duplicate; it now skips the target entry while still rejecting clashes with every other masternode. Co-Authored-By: Claude Fable 5 <[email protected]>
… panicking in provider key derivation
resolve_context hands the FFI an Arc<PlatformWallet> whose underlying
key wallet the host can remove while the candidates extern awaits the
masternode list (Swift's providerKeyCandidates runs detached from the
deletion admission gate). derive_provider_key_at_index then hit the
read guard's expect("wallet exists in guard"), aborting at the
non-unwinding C boundary. The guard gains a fallible try_wallet(), and
the derivation resolves the wallet once through it, returning
WalletNotFound for the race — covering the registrar assembly path the
same way. Regression: removing the wallet after resolving the handle
makes provider_key_candidates return the error.
Co-Authored-By: Claude Fable 5 <[email protected]>
…t hygiene from review Three review suggestions, each verified against Core's develop sources: - Core's CNetAddr::IsValid runs before (and independent of) the routability requirement, so the unspecified and broadcast IPv4 addresses are invalid on every network — the values validator now rejects 0.0.0.0 and 255.255.255.255 even on regtest, keeping the regtest exemption for private-but-valid addresses only. - The temporary secp256k1 SecretKey locals in owner signing and owner verification are Copy with no erasing destructor; both are now scrubbed with non_secure_erase() right after use, matching the provider-key derivation code. - New test drives an ExtNetInfo entry with secondary IPv4 + IPv6 endpoints and domain/invalid entries through the summary conversion, asserting every socket endpoint is lifted and non-socket entries are skipped — then that a lifted secondary endpoint actually collides in the service-uniqueness preflight. Co-Authored-By: Claude Fable 5 <[email protected]>
…ardown, refuse zero platform ports The execute forms of the registrar and service updates signed and then broadcast directly, without the generation lifecycle protection the prepare-then-broadcast flow gets from core_wallet_broadcast_signed_transaction — so a wallet removed (or re-created) between signing and the send could still publish its transaction (#4185's shape). All three execute paths now broadcast through a shared helper that holds generation_payment_guard across the liveness check and the send, abandoning and refusing when the generation is no longer live, with a regression that removes the wallet after signing and asserts nothing reaches the broadcaster. The explicit-values validator also refuses Some(0) for either platform port before funding. Not a consensus mirror: Core's CheckProviderNetworkFields accepts a single zero platform port in a v2 payload off mainnet (only both-zero collides in its dup-ports equality) — but no node can serve on port 0, so a supplied zero is an input error caught before money moves. Co-Authored-By: Claude Fable 5 <[email protected]>
… window, unblock Swift's cooperative executor Three review suggestions: - Candidate discovery derives up to 256 indices, but the managed provider pool — and provider_masternode_txs_blocking's derive-and-compare ownership scan with it — tracks only through max(highest_generated + 1, 20). A rotation to a beyond-window index would broadcast a valid key the wallet could never attribute back to itself. The registrar assembly now refuses untracked indices before funding, via a shared PlatformWallet::provider_operator_tracked_window (the window constant is now shared with the ownership scan), with a beyond-window regression test. - Swift's providerKeyCandidates ran its synchronous FFI call in Task.detached, which still executes on the cooperative pool and parks a cooperative worker behind the wallet-manager lock. It now runs on a dedicated GCD queue and resumes through a continuation — the pattern pollQueue and the DPNS active-contests queue document. - provider_key_candidates documents its blocking-only contract: a Panics section for async-context callers and spawn_blocking guidance, matching wallet_masternodes_blocking's warning. Co-Authored-By: Claude Fable 5 <[email protected]>
…keep rotation externs off Swift's cooperative executor Voting-key ownership joins against the managed provider-voting pool's ACTUAL entries — key-wallet's voting matcher walks the pool's address index, and hosts join persisted address rows; there is no derive-and-compare scan like the operator side — so rotating to an unregistered index would sign and broadcast fine and then always show as an external voting key. The registrar assembly now refuses indices at or beyond PlatformWallet::provider_voting_tracked_window() before funding, with a beyond-pool regression test. The six registrar/service prepare and execute Swift wrappers also move off Task.detached (whose closures still run on the cooperative pool) onto a dedicated serial GCD queue behind a shared continuation helper, like providerKeyCandidates — kept on its own queue so a long-parked transaction never delays a picker refresh. Resolver and buffer lifetimes are unchanged: each body runs entirely on the queue. Co-Authored-By: Claude Fable 5 <[email protected]>
The rotation commits were written against v4.2-dev. Since then the update-service path learned Dash Core v24's version-3 payloads and rust-dashcore moved to secp256k1 0.33 and its own BLS types. The reactivation built from caller-supplied values now follows the same version rules as the entry-copy path: version 3 for an evonode once V24 is active and for an entry a registrar update left with an emptied version-3 address map, version 2 otherwise. An entry whose address map still lists addresses is refused, since the values name one address. The owner signature and the operator key re-encoding use the current secp256k1 and BLS APIs. A Dash address is now always P2PKH or P2SH, so the witness payout test checks the script rule directly. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The candidates query listed the first `count` provider keys, while a registrar update refuses an operator index outside the wallet's tracked window and a voting index outside its registered pool. A picker could therefore offer a key the rotation then refused. The query now stops at that window, so `count` only caps the listing. The Swift wrapper no longer picks a window size of its own: its default is the most one call returns. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…om the SPV coinbase, check every v3 endpoint A ProUpRegTx funded by a UTXO whose surplus is below the dust limit was built with no outputs, which Core refuses (bad-txns-vout-empty). The builder now adds the zero-value data output the update-service builder already carries, and the finalizer refuses an output-less transaction before signing, releasing the reservation. The pinned dash-spv exposes the coinbase of the newest validated masternode list diff, so both update-service paths now read V24 from it when the list alone cannot tell. Right after activation, while every entry is still legacy, a reactivation after an operator rotation is built at version 3 instead of a version 2 Core refuses. A version-3 evonode address map registers the Platform P2P and HTTPS endpoints next to the Core one. The values path now checks every endpoint of the map it built against the other masternodes, not only the Core address. Listing key candidates against the live masternode list is now a platform-wallet operation the FFI calls, and the legacy-BLS flag uses the upstream predicate. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…es, check a kept legacy operator key for duplicates A version-2 ProUpRegTx applied to a version-3 masternode replaces its DIP-0026 payout list with a single payout (Core: LegacyPayoutAsList). The masternode list carries no payouts, so the existing shares cannot be restated; every registrar update of a version-3 entry is now refused, not only the operator rotation. Keeping a version-1 entry's operator key re-encodes it to the basic BLS scheme. Core checks the re-encoded key against every other masternode on that migration (bad-protx-dup-key), so the same check now runs before funding. Co-Authored-By: Claude Fable 5.2 <[email protected]>
… rotations, check endpoints on the unban conversion A registrar update restates the entry's operator key, voting key and payout. Read from a list restored from disk while sync catches up, it could put a since-replaced operator key back, which Core treats as an operator change (reset and PoSe-ban), or miss that the entry is version 3 by now. The registrar update and the reactivation from values now read the list only while the SPV client reports it at the header tip, and fail with MasternodeListUnavailable otherwise. The plain unban converts a legacy evonode to version 3 once V24 is active, registering Platform endpoints for the first time. The finished map is now checked against the rest of the list before funding, as the values path already does (bad-protx-dup-netinfo-entry). Co-Authored-By: Claude Fable 5.2 <[email protected]>
… the unban, test the registrar fee against the collateral The plain unban restates the entry's own service values, so it now reads the masternode list only while SPV reports it at the header tip, as the rotation and the reactivation from values already do. While SPV is still syncing it fails with MasternodeListUnavailable instead of copying addresses from a list restored from disk. The registrar update funds through the same call as every other send, which the merged collateral lock keeps away from a masternode collateral the wallet holds. A test now checks that for the ProUpRegTx fee. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…e rust-dashcore's key and script types The masternode update code checked or converted the same things in several places. Each now has one definition: - an address-map entry's socket address (list.rs, record.rs) - binding a DAPI get-transaction reply to the requested txid (update_service.rs twice, tracked.rs); a registration transaction is bound once, when it is fetched - a payout address's script (operator payout, owner payout) - the list entry holding an operator key under either BLS serialization (registrar update, key candidates) Code that restated what rust-dashcore already has now calls it: the compact recoverable signature header and the owner key id (EcdsaRecSignature, EcdsaSecretKey, PublicKey::pubkey_hash), the P2PKH key hash (Script::p2pkh_public_key_hash_bytes), the display form of a hash (Txid) and the mainnet Core P2P port (Network::default_p2p_port). Refusal texts and accepted inputs are unchanged. The owner secret key now erases itself on drop instead of being erased by hand. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
🔍 Review in progress (commit 370fd59) · live progress |
…rt, export the guarded broadcast for prepared transactions The gated list reads checked readiness and then read the list as two separate accesses of the client. A host that stopped and restarted SPV between them handed the read a new client still catching up. The read is now dropped when the run session changed around it. The prepare functions told their caller to send the result through CoreWallet::broadcast_finalized_transaction, which leaves the wallet generation check to its caller. broadcast_special_transaction_guarded, which makes that check and already backs the execute paths, is now public and is what the prepare docs name. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…to claude/elated-sinoussi-74bb2d The base exported broadcast_special_transaction_guarded and imports it in update_registrar.rs; this branch renamed two imports in the same list. The list keeps both. Co-Authored-By: Claude Fable 5.2 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
The refactor preserves transaction binding, payout validation, and owner-key erasure. The blocking issue is that the shared BLS lookup treats a collision between serialized bytes as proof that another masternode holds the same key; key attribution and Dash Core’s collision preflight need separate checks. The Kotlin SDK build and tests passed, no code checks failed, and the PastaClaw review was pending.
🔴 1 blocking | 🟡 5 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: Bind decoded transactions to their request in the SDK
packages/rs-platform-wallet/src/masternode/update_service.rs:823-831
The shared wallet helper protects all affected masternode callers, but Sdk::get_transaction and Sdk::get_transaction_placement still return a decoded transaction without checking that its ID matches the request. DashPay invitation inspection already makes its own comparison. The coding conventions put client APIs in rs-sdk; its shared response-decoding path has both the exact request ID and the decoded transaction. Validate the match there and return an invalid-response error, not Ok(None), so invitations still retry a reversed ID only on a genuine miss. This check does not authenticate height or lock metadata. If the SDK relocation is deferred, link a tracking issue or follow-up PR.
source: gpt-6.2-astra (phase2-reviewer: general, architecture-layering, rust-quality, security-auditor)
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.2-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — This is a substantial refactor across masternode update flows that changes cryptographic key/signature handling and payout-script construction, both critical funds- and key-handling surfaces. - 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 quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/rs-platform-wallet/src/masternode/list.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/masternode/list.rs:136-139: Distinguish operator-key ownership from a serialized-byte collision
`operator_key_holder` compares both candidate encodings against each entry without checking `operator_key_is_legacy`. The sign-set vector in `locator.rs::CORE_RE_ENCODINGS` shows why that is incorrect: the same bytes encode one point under the legacy scheme and its negation under the basic scheme. The key picker can therefore report a masternode in `ProviderKeyCandidate.used_by` that holds a different key. For ownership, select the candidate encoding using the entry’s scheme and add a negative test with that vector; the current positive test leaves the supposed legacy entry’s scheme flag unset. Keep the registrar’s serialized-byte collision check separate: Dash Core v24’s `HasOperatorKeyUnderAnyScheme` probes both serialized hashes, so a byte collision can still make a rotation invalid even when no other masternode holds that point.
In `packages/rs-platform-wallet/src/masternode/update_service.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/masternode/update_service.rs:823-831: Bind decoded transactions to their request in the SDK
The shared wallet helper protects all affected masternode callers, but `Sdk::get_transaction` and `Sdk::get_transaction_placement` still return a decoded transaction without checking that its ID matches the request. DashPay invitation inspection already makes its own comparison. The coding conventions put client APIs in `rs-sdk`; its shared response-decoding path has both the exact request ID and the decoded transaction. Validate the match there and return an invalid-response error, not `Ok(None)`, so invitations still retry a reversed ID only on a genuine miss. This check does not authenticate height or lock metadata. If the SDK relocation is deferred, link a tracking issue or follow-up PR.
- [SUGGESTION] packages/rs-platform-wallet/src/masternode/update_service.rs:862-872: Extract the registration payload without rehashing or cloning the transaction
`fetch_transaction_checked` has already computed and checked the txid, but `registration_payload` serializes and hashes the transaction again on every successful read just to prepare an error message. Its by-value parameter also preserves the base branch’s full transaction clone in `prepare_masternode_update_registrar`, which still needs the original for collateral lookup. Borrow the transaction, return a reference to its registration payload, and compute the diagnostic txid only on the error branch. Callers that need an owned payload can clone just the payload.
- [SUGGESTION] packages/rs-platform-wallet/src/masternode/update_service.rs:616: Use the existing net-info port accessor in service preflight
The port extraction at `update_service.rs:1118–1121` duplicates the pinned `NetInfoEntry::port` exactly: service and domain entries return their port and invalid entries return `None`. Use `.filter_map(NetInfoEntry::port)` in `require_listed_platform_p2p_port`, as the nearby converted-map check already uses the accessor. Unlike socket-address conversion, this cleanup does not depend on new rust-dashcore API.
In `packages/rs-platform-wallet/src/masternode/update_registrar.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/masternode/update_registrar.rs:434-440: Share owner key-ID derivation with the masternode locator
`locator::ecdsa_key_id` performs the same scalar parsing, compression selection, and HASH160 calculation for `verify_masternode_key`, but it still creates a raw secp256k1 secret and allocates a `Vec` for the serialized public key. Move the `EcdsaSecretKey` and `PublicKey::pubkey_hash` implementation into that helper and have the registrar map an invalid scalar to its existing error. That gives key verification and rotation one implementation for both compression modes.
In `packages/rs-platform-wallet/src/wallet/provider_key_at_index.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/provider_key_at_index.rs:364-371: Use the shared operator-key extraction in the wallet ownership index
`manager/accessors.rs:1415–1425` still converts the same derived operator key’s basic and legacy bytes to 48-byte arrays by hand. That index feeds `wallet_masternodes_blocking`, so the wallet ownership view and the key picker still have separate extraction implementations. Keep the indexed lookup, but populate it from `operator_key_forms()`.
…orms and the net-info port accessor Review follow-ups, no behaviour change: - `locator::ecdsa_key_id` derives the key id through rust-dashcore's `EcdsaSecretKey` and `PublicKey::pubkey_hash`, so the scalar is erased on drop, and the registrar update's owner-key check calls it instead of deriving the same hash itself. - `registration_payload` borrows the transaction and returns a reference to its payload. The txid is computed only for the refusal message, and the registrar update clones the payload instead of the whole transaction. - `require_listed_platform_p2p_port` reads ports with `NetInfoEntry::port`. - The wallet ownership index takes both serializations of an operator key from `ProviderDerivedKey::operator_key_forms`, as the key picker and the registrar update do. - `operator_key_holder` documents that it matches serialized bytes under either scheme on purpose: the key picker reports as taken exactly the keys the registrar update refuses. Co-Authored-By: Claude Fable 5.2 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
This head adopts the existing port accessor and shared key helpers, and removes the registrar’s full-transaction clone and redundant hash. The service reward path now clones a registration payload to read one field; the pinned ECDSA dependency confirms that the owner scalar is still erased on drop. The Kotlin SDK build and tests passed, and the review check is pending.
🔴 1 blocking | 🟡 2 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: Bind decoded transactions to their request in the SDK
packages/rs-platform-wallet/src/masternode/update_service.rs:823-831
The wallet callers now share a txid check, but Sdk::get_transaction and Sdk::get_transaction_placement still return the decoded transaction without comparing it to the request. A direct SDK caller can therefore receive Ok(Some(..)) for a different transaction. Put the comparison in the shared SDK decode path, using the actual display-order ID sent on that request. Return an error on mismatch, not Ok(None), so the invitation flow retries with reversed bytes only on a genuine miss. This binds the transaction body to its ID; it does not verify the reported height, block hash, or lock status.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.2-astra (phase2-reviewer: architecture-layering, rust-quality)
Still open from earlier rounds (1)
- 🔴 Blocking: Distinguish operator-key ownership from a serialized-byte collision —
packages/rs-platform-wallet/src/masternode/list.rs:140-143(thread)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — This is a substantial refactor across masternode update flows that changes cryptographic key handling, signature construction, payout script derivation, and secret-key erasure inupdate_registrar.rsand related helpers. - 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 quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/rs-platform-wallet/src/masternode/update_service.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/masternode/update_service.rs:823-831: Bind decoded transactions to their request in the SDK
The wallet callers now share a txid check, but `Sdk::get_transaction` and `Sdk::get_transaction_placement` still return the decoded transaction without comparing it to the request. A direct SDK caller can therefore receive `Ok(Some(..))` for a different transaction. Put the comparison in the shared SDK decode path, using the actual display-order ID sent on that request. Return an error on mismatch, not `Ok(None)`, so the invitation flow retries with reversed bytes only on a genuine miss. This binds the transaction body to its ID; it does not verify the reported height, block hash, or lock status.
- [SUGGESTION] packages/rs-platform-wallet/src/masternode/update_service.rs:851-857: Read the operator reward without cloning the registration payload
`fetch_registration_payload` now clones the payload, including any payout scripts, signature, and extended address or payout entries. Its only caller, `fetch_operator_reward`, reads one `u16` and drops the clone; the previous service path moved the payload out of the transaction. Fetch the checked registration transaction in `fetch_operator_reward`, read `registration_payload(&transaction)?.operator_reward`, and remove the owned-payload helper.
In `packages/rs-platform-wallet/src/masternode/list.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/masternode/list.rs:140-143: Distinguish operator-key ownership from a serialized-byte collision
(carried; thread: https://github.com/dashpay/platform/pull/5997#discussion_r4635141786)
Out-of-scope follow-up suggestions (1)
These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.
- Make operator-secret verification scheme-aware — The unchanged BLS locator branch searches both byte forms without checking the entry’s scheme. The manual key verifier and service preflight likewise accept either form, so a byte collision can make the wallet report a match for a secret that does not control the listed key.
- Follow-up: In a separate PR, carry the entry or payload scheme into the locator and operator-secret verification paths, and test that a different point with matching bytes under the other scheme is rejected.
… registration payload `fetch_operator_reward` was the only caller of `fetch_registration_payload`, which cloned the whole payload so one `u16` could be read from it. It now fetches the checked registration transaction and reads the reward through `registration_payload`, and the owned-payload helper is gone. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
On the suggestion "Bind decoded transactions to their request in the SDK": deferring. Validating the txid inside |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
The latest commit reads the operator reward without cloning the registration payload. The full diff still has one blocker: the wallet ownership index can persist a BLS serialization collision as ownership of an operator key at the wrong wallet index. The Kotlin SDK build and tests passed; the automated review check is pending.
🟡 1 suggestion(s) | 💬 1 nitpick(s)
Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.
Follow-up candidates (optional) (2)
New non-blocking observations on code unchanged since the last full review. No inline threads are opened for them and later reviews do not repeat them: fix forward or track separately if they are worth it.
🟡 Suggestion: Pass only the owner key hash into registrar assembly
packages/rs-platform-wallet/src/masternode/update_registrar.rs:125-128
After collateral resolution, the blocking assembly task reads only registration.owner_key_hash. Cloning the payload copies the payout script, signature, and any extended address or payout vectors just to carry that hash across the task boundary. Keep the payload borrowed through resolve_collateral_script, then pass the Copy PubkeyHash to the task by value.
source: gpt-6.2-astra (phase2-reviewer: general, architecture-layering, rust-quality, security-auditor)
🟡 Suggestion: Keep the BLS scheme in the wallet ownership index
packages/rs-platform-wallet/src/manager/accessors.rs:1416-1420
This refactor still inserts both operator encodings into a map keyed only by bytes. In locator.rs::CORE_RE_ENCODINGS[1], the 91… legacy encoding belongs to a point whose basic encoding is b1…; read as basic, 91… denotes the negated point. A v2 ProRegTx retained because its owner or voting key belongs to the wallet can therefore resolve to an operator index whose derived key is not the registered one. wallet_masternodes_blocking returns that index as ownership, and MasternodeSync.swift persists it as operatorInWallet and operatorKeyIndex. Carry the scheme from the ProRegTx or ProUpRegTx that supplied the record’s operator key and match the corresponding wallet encoding. Add a negative test for the sign-set case, without changing the registrar’s two-form availability check.
source: gpt-6.2-astra (phase2-reviewer: general)
Review provenance
Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 8: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 9: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 10: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.2-sol(effort low) — This is a substantial refactor across masternode registration and service-update logic that changes cryptographic key handling, signature construction and recovery, operator-key matching, and payout-script derivation in files such as update_registrar.rs and update_service.rs. - 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 quota lookup failed),glm-5.3-flash(not used above high effort; tier asks max) - Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
- Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
- Code unchanged since the last final review (
cd1020ff): 1 new blocker(s) went to an independent confirmation pass (the final verifier's model in a fresh session, without its reasoning): 1 not confirmed (now follow-up candidates) (1 as an earlier confirmation decided, the file unchanged since); 1 new suggestion(s) listed as follow-up candidates, not posted inline - Fresh verifier:
gpt-6.2-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.
In `packages/rs-platform-wallet/src/masternode/update_service.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/masternode/update_service.rs:822-831: Bind decoded transactions to their request in the SDK
The shared wallet check covers registration, collateral, and tracked refresh. The check itself needs only the requested ID and the decoded response, which both `Sdk::get_transaction` and `Sdk::get_transaction_placement` already have. Neither method compares them, so consumers must know to repeat the check. The book’s “Where code goes” rule puts client API behavior in `rs-sdk`. Changing mismatch handling separately is reasonable; please link the issue or follow-up PR that will bind each successful decode to the ID sent on that request, preserve `Ok(None)` for not-found and the caller’s byte-order retry, and leave placement metadata explicitly unverified.
- [NITPICK] packages/rs-platform-wallet/src/masternode/update_service.rs:1326-1329: Use the shared txid formatter in the not-tracked error too
`tracked.rs::not_tracked` still reverses and hex-encodes a wire-order proTxHash solely to display it. Calling `display_hex(pro_tx_hash)` there produces the same error text without maintaining a second formatter. Keep the reversal in the refresh path, which also uses the display-order bytes for an identity lookup.
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
…oussi-74bb2d #5889 was squash-merged into v5.2-dev as 05efe75. Its four conflicted files (key_candidates.rs, list.rs, update_registrar.rs, update_service.rs) are byte-identical there to the branch tip this branch had already merged, so the conflicts resolve to this branch's refactored versions. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
… display_hex `tracked.rs::not_tracked` reversed and hex-encoded the wire-order proTxHash itself. It now calls `display_hex`, the formatter the other masternode refusals use; the error text is unchanged. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Your move: thepastaclaw left review threads unresolved; resolve them. |
|
/self-reviewed |
|
Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post |
Issue being fixed or feature implemented
Follow-up to #5889, from its review: audit the masternode key rotation code for repeated logic
and for logic that belongs in another crate. This PR removes the repetition that can be removed
inside this repository. It is stacked on #5889.
The parts that describe Dash Core's rules (ProTx version and address form, the legacy-to-v3
address map, service and port validation, V24 detection) need new API in rust-dashcore first and
are not changed here.
What was done?
One definition instead of several, in
packages/rs-platform-wallet/src/masternode/:list::socket_address: an address-map entry's socket address. Was inlist.rsandrecord.rs.update_service::require_requested_transaction: binds a DAPI get-transaction reply to therequested txid. Was in
update_service.rstwice and intracked.rs. A registrationtransaction is now bound once, when it is fetched;
registration_payloadonly reads it.update_service::payout_script_for_address: address string to payout script. Was in theoperator payout rule and the owner payout rule.
list::operator_key_holderandProviderDerivedKey::operator_key_forms: finding the list entrythat holds an operator key under either BLS serialization. Was in the registrar update and in
key candidates.
Calls into rust-dashcore instead of restating it:
EcdsaSecretKey,EcdsaRecSignatureand
PublicKey::pubkey_hash;p2pkh_script_hashusesScript::p2pkh_public_key_hash_bytes;display_hexusesTxid's display form;Network::Mainnet.default_p2p_port().Refusal texts and accepted inputs are unchanged. The owner secret key is now erased by its own
destructor instead of by hand.
How Has This Been Tested?
CARGO_INCREMENTAL=0 cargo test -p platform-wallet -p platform-wallet-ffi --all-featurescargo clippy -p platform-wallet -p platform-wallet-ffi --all-features --all-targets -- -D warningsNew tests: an uncompressed owner key (key id, signature header 27 + recovery id, recovery to the
uncompressed key),
socket_addresson malformed and non-IP entries,operator_key_holderunderboth serializations,
require_requested_transaction,payout_script_for_address,display_hex.Breaking Changes
None. No public API of
platform-walletchanges and no FFI symbol changes.Checklist:
🤖 Generated with Claude Code
PR Hygiene ·
370fd59/skip-botsproceeds without the ones not yet reportedWhen every merge requirement is met, the
PR Hygienecheck passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.