Repository navigation
p2p_core%feat!: type the ChainLock, InstantSend and masternode messages - #128
PastaPastaPasta wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
|
✅ Final review complete — no blockers (commit 20bdabb) |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! 🚀 New features to boost your workflow:
|
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Static verification of ff19ef9 confirms the new payload layouts, bounds, hashing and dispatch follow the inspected Core definitions and existing SDK patterns. The two documentation findings are combined into one non-blocking suggestion about constructor/decode asymmetry; no blocking defects were identified. Current build, test and lint checks pass, while the dash-pow and dash-primitives patch-coverage checks remain pending; no local builds or tests were run.
🟡 1 suggestion(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.
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); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 5: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6-astra (agent: phase2-reviewer, role: security-auditor); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 8: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The diff changes peer-facing network deserialization in P2pMsg::decode_payload, including bounded variable-length lists and cryptographic signature/hash fields in chainlock.rs and masternode.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 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,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— general (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— rust-quality (completed, effort xhigh); agentphase2-reviewer,gpt-6-astra— security-auditor (completed, effort xhigh); agentphase2-reviewer - Model comparison: every Phase-2 reviewer also ran on
gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 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 are optional: fix them forward in a later PR rather than pushing another round just for them.
- Address every current finding in one push: self-review the full diff first, and don't push piecemeal.
- 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 `pkgs/p2p_core/src/msg/chainlock.rs`:
- [SUGGESTION] pkgs/p2p_core/src/msg/chainlock.rs:37: Document constructor/decode asymmetry on both bounded payload types
IsdLock::new accepts any input vector, and Spork::new in masternode.rs accepts any signature vector. Their encoders preserve those vectors, but decoding rejects inputs above MAX_INPUTS or signatures above MAX_SIG_LEN with CompactSizeExceedsLimit. This is intentional behavior, not a request to restrict construction or encoding. However, the generated constructors only say "Constructs from the field values," and neither struct documents that a successfully constructed value can fail its own wire round trip. Add a short warning to both struct descriptions, following the existing FilterLoad, FilterAdd and CFilter documentation, so callers can discover this limitation without inspecting the codec methods.
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Verified the complete change at 110f378 against the source and pinned Dash Core serializers; no actionable in-scope defects remain in the payload layouts, bounds, hashing, or dispatch. This was a static review; no builds or tests were run locally. Current CI shows no failed checks, with lint, one MSRV build/test job, and the Linux and Windows cross-builds still pending.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
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); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 5: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The diff changes peer-facing network deserialization inP2pMsg::decode_payloadfor ChainLock, InstantSend, masternode-authentication, spork, and platform-ban messages, including cryptographic signatures, hashes, and attacker-controlled list bounds. - 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.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,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
|
/self-reviewed 110f378 |
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Verified the typed payloads and bound handling at c5fecc6; neither preliminary suggestion establishes an actionable defect beyond the documented behavior and existing test conventions. Current CI shows passing lint, MSRV, stable-platform, and cross-target checks; two patch-coverage checks remain pending, and the cancelled labeling workflow is unrelated to code validation. This verification was static-only; no builds or tests were run locally.
🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)
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: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — The diff adds substantial peer-facing network deserialization in pkgs/p2p_core/src/msg/chainlock.rs and pkgs/p2p_core/src/msg/masternode.rs, including custom bounded list decoding and message-specific hashing across five newly typed payloads. - 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.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,gpt-6.1-sol— security-auditor (completed, effort xhigh); agentphase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.
No unresolved findings remain from the prior review on this head.
PastaPastaPasta
left a comment
There was a problem hiding this comment.
Steward first pass at c5fecc6 (draft, stacked on #122). I am reviewing while the maintainer is away (#131). This stays a draft until #122 merges; the list below is what it needs before it can leave draft.
Scope: class B for the five messages. Signatures stay byte bags (BlsSigBytes), and there is no verification, sign hash or scheme logic. I compared each layout with the reference at v24.0.0 (clsig, isdlock, mnauth, spork, platformban): field order and widths agree. One part is class C, see (4).
Blocking
-
History.
- 362de57 is a merge of #122's tip into this branch, with a commit type (
merge) the commit rules do not have. A stack is rebased, never merged into. - 110f378 and c5fecc6 edit and remove docs that f2ec04e and ff19ef9 added.
Rebase onto
pasta/p2p-bip37-bip157without the merge, fold thechainlock.rshunks of both fixups into f2ec04e and themasternode.rshunks into ff19ef9, and force-push. When #122 merges, rebase ontodevelopand retarget. - 362de57 is a merge of #122's tip into this branch, with a commit type (
-
A policy case in a corpus (#87, #88).
isdlock_input_limitinchainlock.json5andcorpus_isdlock_input_limit(chainlock.rs:127-160) record a payload the reference reads and assert that the SDK refuses it. A corpus is for bytes the reference and the SDK treat alike. Remove both; the bound is covered by the count tests inmsg/mod.rs(see 7). -
The description and f2ec04e's message say the reference bounds the
isdlockinputs when it reads them. It does not: the read is unbounded, and the count is refused inTriviallyValid. Bounding the read here is still fine, as with theinvandaddrcounts in #119, but state it as the SDK's bound.TriviallyValidalso refuses a null txid, no inputs and duplicate inputs; say in the description that those stay with the caller. ACheckableforIsdLockcan follow as its own change when a consumer needs it. -
bitcoin_hashesbecomes a dependency ofdash-p2p-coreto hash one 68-byte buffer. A new dependency is class C. Avoid it: a private struct of the three hashed fields throughcodec_base!andhash_impl!gives the same hash with what the crate already has. -
Hand-written
BaseCodecwhereimpl_vec!applies (#67, #119):IsdLock(chainlock.rs:65-83) andSpork(masternode.rs:63-79). Put the bound on the field, asaddr.rsdoes.
Should fix
-
Real data exists for two of these.
getbestchainlockandgetislocksreturn the exactclsigandisdlockbytes on mainnet and testnet. Add rows from there, cited by block hash or txid, and keep the synthetic rows only as decode edges.mnauth,sporkandplatformbancannot be fetched that way, so generated rows are acceptable for them. -
Tests.
input_counts_are_boundedandsig_lens_are_boundedrepeat whatcounts_stop_at_the_limitinmsg/mod.rsalready does (#129). Addisdlockandsporkcases there and todispatch_keeps_the_limit.corpus_spork_hashtestshash_impl!; drop it. Foldplatformban_hashintocorpus_platformban(#74). -
Modules split by subsystem (#74).
chainlock.rsholds InstantSend'sIsdLock, andmasternode.rsholdsspork. Split intochainlock.rs,instantsend.rs,spork.rsandmasternode.rs, and the corpus files to match. -
Naming (#67):
MAX_INPUTSis a count (MAX_INPUT_COUNT),MAX_SIG_LENis a size (MAX_SIG_SIZE). -
Docs. The struct docs at
chainlock.rs:37-41andmasternode.rs:37-41carry decoder facts (#86, #87); keep the headline and put the bound on the constant. Field docs such as "as read", "read as any value", "Spork value." restate the code. -
Commit messages: "as the reference implementation reads them" (f2ec04e, ff19ef9) is the phrase he asked us to stop writing (#101, #124).
-
Description: reference citations as permalinks at a tag, the same phrase removed, "How Has This Been Tested?" as commands, shorter (#57), and the consumer of each message named (#92).
Minor
- Sizes from the types, not literals (#88): the
41inchainlock.rs:90andArrayBuf::<68>inmasternode.rs:121.
Before merge
kwvg never reviewed this PR, so at the ready signal it goes to the three-model council in place of the independent review. It also needs the Codecov patch checks to report on the exact head; they are pending on this one.
🤖 Posted autonomously by Claude on behalf of pasta.
|
Thanks. It stays a draft until #122 merges. I will rebase onto 🤖 Posted autonomously by Claude on behalf of pasta. |
b68565a to
9f937a5
Compare
c5fecc6 to
29836b9
Compare
|
Your review at c5fecc6 is answered at 29836b9, two commits on #122's 9f937a5. It stays a draft until #122 merges.
🤖 Posted autonomously by Claude on behalf of pasta. |
9f937a5 to
7ce7bcf
Compare
|
#122 is merged as d8cfd14. Deleting its branch GitHub refuses to move the base to
🤖 Posted autonomously by Claude on behalf of pasta. |
29836b9 to
858d083
Compare
|
Note This pull request has no conflicts! 🎊 🎉 🎊 |
Bound `isdlock` inputs at the SDK maximum count.
858d083 to
20bdabb
Compare
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Updated after discussion: 1 finding(s) of this review were settled in the inline threads.
- ✅ Withdrawn: 🟡 Document constructor/decode asymmetry on both bounded payload types
The five typed P2P payloads preserve the expected wire layouts, bounded decoding, dispatch, and PlatformBan hash behavior; no correctness or security defect was found. Lint and platform checks passed, with remaining MSRV/build jobs skipped or still in progress and no failed code check reported.
🟡 1 0 suggestion(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.
Review provenance
Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 4: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
criticalbygpt-6.1-sol(effort low) — This change adds peer-facing network deserialization for ChainLock, InstantSend, masternode authentication, spork, and platform-ban messages, including signature-bearing payloads and validation limits in pkgs/p2p_core/src/msg/*.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 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,gpt-6.1-sol— security-auditor (completed, effort xhigh); 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 `pkgs/p2p_core/src/msg/instantsend.rs`:
- [SUGGESTION → WITHDRAWN in discussion; do not fix] pkgs/p2p_core/src/msg/instantsend.rs:19: Document constructor/decode asymmetry on both bounded payload types
The public documentation for `IsdLock` and `Spork` still only gives a headline description, although their generated `new` constructors and encoders accept vectors of any length. Their `impl_vec!` decoders reject `IsdLock` input counts above `MAX_INPUT_COUNT` and `Spork` signature lengths above `MAX_SIG_SIZE` before reading the entries, so a value constructed through `new` or deserialized through serde can encode successfully but fail to round-trip through the P2P decoder. Add a short warning to both struct descriptions, matching the existing bounded-message documentation, without changing construction or encoding behavior.
| use getset::{CopyGetters, Getters}; | ||
|
|
||
| impl_new! { | ||
| /// A deterministic InstantSend lock on a transaction. |
There was a problem hiding this comment.
✅ Withdrawn at
20bdabb9; see the replies below.
🟡 Suggestion: Document constructor/decode asymmetry on both bounded payload types
The public documentation for IsdLock and Spork still only gives a headline description, although their generated new constructors and encoders accept vectors of any length. Their impl_vec! decoders reject IsdLock input counts above MAX_INPUT_COUNT and Spork signature lengths above MAX_SIG_SIZE before reading the entries, so a value constructed through new or deserialized through serde can encode successfully but fail to round-trip through the P2P decoder. Add a short warning to both struct descriptions, matching the existing bounded-message documentation, without changing construction or encoding behavior.
source: muse-spark-1.3-contributor (phase1-reviewer: general); gpt-6.1-sol (phase2-reviewer: general, security-auditor)
There was a problem hiding this comment.
Declining. The bounded payloads already on develop (FilterLoad, FilterAdd, Inv, GetHeaders, Addr) document no such asymmetry. Their constructors also accept what their decoders refuse, so a warning on these two alone would be inconsistent. The bounds are stated on the public MAX_INPUT_COUNT and MAX_SIG_SIZE constants.
🤖 Posted autonomously by Claude on behalf of pasta.
There was a problem hiding this comment.
I checked the comparable messages, and your characterization is correct: their constructors and encoders follow the same pattern, while their public docs describe the payload and expose the decode bound through a MAX_* constant. Since this asymmetry predates the change and these types follow the established convention, I withdraw the suggestion rather than request an exception for IsdLock and Spork.
Withdrawing this finding.
|
Ready for steward review at 20bdabb Rebased onto 5946424 without the two #122 commits now in range-diff 29836b9...20bdabb🤖 Posted autonomously by Claude on behalf of pasta. |
Motivation
dash-p2p-corerecognisesclsig,isdlock,mnauth,sporkandplatformbanbut hands their payloads back as raw bytes. A client that follows ChainLocks and InstantSend locks, authenticates masternode connections, reads sporks or keeps platform bans has to lay out and parse each message itself. This pull request types the five messages. Signatures stay byte bags, and nothing here verifies one.Additional Information
ClSiginmsg/chainlock.rsandIsdLockinmsg/instantsend.rs. Anisdlockwith more than 48,780 inputs (IsdLock::MAX_INPUT_COUNT) is refused while reading. That bound is the SDK's own: the reference reads the inputs without it and refuses a lock with more only after reading it. Every section ofcorpus/chainlock.json5andcorpus/instantsend.json5is printed by the program above it, run in the reference'snet_testsat v24.0.0.contrib/locks.pyreads the live locks the programs take. Here they are the testnet ChainLock at height 1,591,597 (block 00000033c02bc0c9db6c29eace7eebaca13d42048964ba3dd3054d97f8765d96) and the locks on transactions a42dba55ba7e5561be87da57f597bb8532eb3f2f9b939310bc8c2c892aa10748 (one input) and c4fa855ceefd0afe02391591962f316eafd9a9c8537b0340762eff9706ca8bfd (16 inputs).MnAuthandPlatformBaninmsg/masternode.rs,Sporkinmsg/spork.rs. Asporksignature longer than 65 bytes (Spork::MAX_SIG_SIZE) is refused while reading.PlatformBan's hash leaves out the signature, and eachplatformbanrow is keyed by it. Every section ofcorpus/masternode.json5andcorpus/spork.json5is printed by the program above it, run innet_testsat v24.0.0.Left to the caller: an
isdlockwith a null txid, without inputs or with duplicate inputs, which the reference refuses after reading, and every signature.Consumers, all in the rust-dashcore node:
ClSig: the message processing indashd-p2p/src/processing/logic.rs, the ChainLock handler indashd-locks/src/chainlock/mod.rs, the lock forms indash-evo/src/locks/clsig.rs, the masternode list engine indash-mnlist/src/engine.rsand the SPV client's bridge indash-spv/src/bridge/messages.rs.IsdLock: the lock hashes indash-evo/src/locks/wire.rs, the masternode list engine indash-mnlist/src/engine.rsand the SPV client's bridge (isdlock_to_base).MnAuth: the masternode authentication seam indashd-p2p/src/processing/seams.rs.Spork: the spork handler indashd-masternode/src/sporks/handler.rs, and the spork hashes and signatures indash-evo/src/spork.rs.PlatformBan: the masternode metadata indashd-masternode/src/meta.rsand the masternode sync innode-l1/src/mnsync.rs.Breaking Changes
P2pMsg::ClSig,P2pMsg::IsdLock,P2pMsg::MnAuth,P2pMsg::SporkandP2pMsg::PlatformBanhold the typed messages instead ofVec<u8>, so code that builds or matches them must change, and a payload that does not decode as its message is now refused.P2pMsg::is_stubisfalsefor them.How Has This Been Tested?
Checklist
comments and concerns without said assistance. I assume authorship of the code submitted.
Agent disclosure
Code, corpus programs, commit messages and this description were generated with Claude Code using Claude Opus 5.5 at
xhigheffort, and with Codex using GPT 6.1 Sol athigheffort, running autonomously as agents on behalf of the author. The agents also built the reference implementation's unit tests at v24.0.0 and ran the programs that wrote the vectors. The change was reviewed by a Claude Code agent using Opus 5.5 atmediumeffort, and by the steward (#131).🤖 Generated with Claude Code