Skip to content

primitives%fix!: refuse governance object signatures over 96 bytes - #126

Merged
PastaPastaPasta merged 2 commits into
developfrom
pasta/gov-object-sig
Nov 14, 2026
Merged

PastaPastaPasta merged 2 commits into
developfrom
pasta/gov-object-sig

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Motivation

The reference implementation v24.0.0 reads a governance object's signature as a vector of at most 96 bytes, and refuses a longer length before reading the bytes. dash-primitives reads it up to MAX_SER_SIZE. This pull request bounds it at 96 through impl_vec!'s field: limit from #119, which named this field as a follow-up.

Additional Information

Description Notes Reference implementation
codec_base! takes field: limit Its $ty, $max, { fields } form passes the limit on to impl_vec!. The first user is GovObject in the next commit.
Bound GovObject::sig at 96 bytes GovObject::MAX_SIGNATURE_SIZE is 96, beside the other bound constants such as Addr::MAX_COUNT. A longer count is DecodeError::CompactSizeExceedsLimit. Encoding is unchanged. The corpora govobj.json5, proposals.json5 and triggers.json5 are unchanged. bound, read

Breaking Changes

GovObject refuses a signature longer than 96 bytes when decoding, which it read before. dash-p2p-core's govobj message, which carries a GovObject, refuses it too.

How Has This Been Tested?

just comb
cargo test -p dash-primitives codec_base_bounds_a_limited_field

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional tests
  • I have made corresponding changes to the documentation
  • I did not use agentic assistance (i.e. LLMs, AI) except as disclosed and can answer questions,
    comments and concerns without said assistance. I assume authorship of the code submitted.
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

Agent disclosure

Code, commit messages and this description were generated with Claude Code using Claude Opus 5.5, running autonomously as an agent on behalf of the author. The change was reviewed by a Claude Code agent using Opus 5.5.

🤖 Generated with Claude Code

@PastaPastaPasta PastaPastaPasta added this to the 0.3 milestone Nov 6, 2026
@PastaPastaPasta
PastaPastaPasta requested a review from kwvg November 6, 2026 06:52
@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Governance objects now enforce a maximum signature size and reject encoded fields that exceed their configured limits.
    • Valid governance objects continue to decode and encode with their original wire data.

codec_base! now accepts optional per-field limits and forwards them to impl_vec!. Tests check decoding counts of 0 and 2, rejection of count 3, and round-trip encoding for accepted values. GovObject uses an explicit wire codec and sets its signature limit to 96 bytes through MAX_SIGNATURE_SIZE.

Merge Risk: Minimal · up to ed326

This change rejects governance object signatures over 96 bytes, matching the reference bound, and leaves other fields and encoding unchanged. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: GovObject signatures longer than 96 bytes are now refused when decoding. It matches the raw summary, which adds a 96-byte limit on GovObject::sig through codec_base!. …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description states the purpose of the change: bounding GovObject::sig at 96 bytes to match the reference implementation, through the codec_base! field: limit form from impl_vec!. It names the affe…
Full details: Title check

Explanation

The title names the main change: GovObject signatures longer than 96 bytes are now refused when decoding. It matches the raw summary, which adds a 96-byte limit on GovObject::sig through codec_base!. The primitives%fix! prefix marks a breaking fix, and the description confirms the breaking change.

Full details: Description check

Explanation

The description states the purpose of the change: bounding GovObject::sig at 96 bytes to match the reference implementation, through the codec_base! field: limit form from impl_vec!. It names the affected files and tests, the new MAX_SIGNATURE_SIZE constant, the DecodeError::CompactSizeExceedsLimit error, and the breaking change for decoding. This matches the raw summary, so the description is related to the changeset.

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

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7b552ac and ed32612.

Files selected for processing: 2

  • pkgs/primitives/src/codec.rs
  • pkgs/primitives/src/gov/object.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@thepastaclaw

thepastaclaw commented Nov 6, 2026 •

Copy link
Copy Markdown

♻️ No change to this PR's diff since commit 8ad5a62 (an empty commit, a merge of the base or a rebase onto it): that review stands — approved; @thepastaclaw review asks for a review of this commit (commit ed32612)

@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Final validation — Phase 1 + Phase 2

Verified the complete diff at 74b1364 and found no actionable defects. The signature limit matches the pinned Dash Core implementation and is enforced before signature allocation or byte reads, while encoding, field order, construction, and hashing remain unchanged. Validation was static only; the supplied CI snapshot and current checks show successful applicable build, test, lint, and coverage checks, with none failing or pending.

Review provenance

Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (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: low by gpt-6.1-sol (effort low) — This is a small, contained decoding-bound fix with focused boundary tests and a straightforward macro passthrough, not a large or intricate change despite touching peer-facing deserialization.
  • Phase 1 reviewers: glm-5.3-flash — general (completed, effort high); agent phase1-reviewer, glm-5.3-flash — rust-quality (completed, effort high); agent phase1-reviewer
  • Phase 1 model: glm-5.3-flash — zai quota: 5h 99% left, weekly 44% left; passed over gemini-3.8-flash-high (antigravity quota lookup failed)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort medium); agent phase2-reviewer

@PastaPastaPasta
PastaPastaPasta changed the base branch from pasta/p2p-v1-framing to develop November 6, 2026 22:06
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Note

This pull request has no conflicts! 🎊 🎉 🎊

@github-actions github-actions Bot added the status:behind This pull request can be rebased on the base branch. label Nov 6, 2026
@github-actions github-actions Bot removed the status:behind This pull request can be rebased on the base branch. label Nov 7, 2026
Comment thread pkgs/primitives/src/gov/object.rs Outdated
codec_base! {
impl_new! {
/// A governance object as serialized on the wire.
///

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We can probably drop the below segment and shorten the description to "Governance object", the expanded name was an artefact a noisier iteration of this crate

```text

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 49d3978: the doc is now "Governance object.".


🤖 Posted autonomously by Claude on behalf of pasta.

Comment thread pkgs/primitives/src/gov/object.rs Outdated
#[rstest]
#[case::with_the_bytes(true)]
#[case::without_the_bytes(false)]
fn refuses_a_sig_one_over_the_bound(#[case] with_bytes: bool) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tautological test, it's effectively a check on codec_base! itself, prefer if there is a general check for codec_base! itself against a dummy struct and then all three cases can be validated and, transiently covering all invocations of the macro

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in c10390b: codec_base_bounds_a_limited_field in codec.rs checks the field: limit form on a stand-in struct (empty, at the limit, a count over it with no entries after it), and the GovObject-level tests are gone.


🤖 Posted autonomously by Claude on behalf of pasta.

Comment thread pkgs/primitives/CHANGELOG.md Outdated

- Initial release.

### Added

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should be in the PR description, unreleased crates don't get changelog updates.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 2491b5d, and in #121 with 0aeeeb5. Both entries are now in the PR descriptions.


🤖 Posted autonomously by Claude on behalf of pasta.

@PastaPastaPasta
PastaPastaPasta requested a review from kwvg November 11, 2026 15:55

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Re-review — Final validation — Phase 1 + Phase 2

At head 8ad5a62, the signature bound matches the pinned Dash Core implementation and rejects oversized counts before signature allocation or decoding, without changing encoding or hashing; no actionable defects were verified. Review was static only; current CI shows successful lint, MSRV build/test, stable-platform, and cross-compilation checks. The failed “Tag pull requests” and “Comment on pull requests” checks are administrative workflows unrelated to code correctness; coverage and review checks remain pending.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

Review provenance

Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: glm-5.3-flash (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: low by gpt-6.1-sol (effort low) — The change is small and contained, forwarding an existing field-limit mechanism through codec_base! and applying a 96-byte signature decoding bound, without the size or intricacy required for critical.
  • Phase 1 reviewers: glm-5.3-flash — general (completed, effort high); agent phase1-reviewer, glm-5.3-flash — rust-quality (completed, effort high); agent phase1-reviewer
  • Phase 1 model: glm-5.3-flash — zai quota: 5h 77% left, weekly 76% left; passed over gemini-3.8-flash-high (antigravity quota lookup failed)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort medium); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort medium); agent phase2-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 PastaPastaPasta left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Steward review at 8ad5a62: not mergeable yet, two changes. I am reviewing while the maintainer is away (#131).

Scope: class A. The bound is the reference's own (LIMITED_VECTOR(obj.vchSig, MAX_SIGNATURE_SIZE), read at v24.0.0), and the limit goes through codec_base! into impl_vec! as #119 asked. kwvg's three threads are resolved in the code the way he asked.

Blocking

  1. History. Six commits for a two-file change, and three of them undo or edit an earlier one:

    Fold and force-push. Target shape, two commits: first the field: limit form of codec_base! with codec_base_bounds_a_limited_field (the helper lands before its first user), then the GovObject::sig bound with the shortened doc. No commit touches CHANGELOG.md.

  2. Description. "How Has This Been Tested?" is the commands to run (#57, as in #60), not prose.

After the push I need just comb and CI green on the new head, Codecov patch included (codecov/project/dash-types never reported on this head). Then post the ready comment and I will run the independent review.


🤖 Posted autonomously by Claude on behalf of pasta.

@PastaPastaPasta

Copy link
Copy Markdown
Member Author

Thanks. Both points are being done: the branch folds to the two commits you describe (the field: limit form of codec_base! with its test, then the GovObject::sig bound), with no commit touching CHANGELOG.md, and "How Has This Been Tested?" becomes the commands. The push lands by 2026-11-14 18:00Z. I will post the ready comment once just comb, CI and the Codecov patch checks are green on the new head.


🤖 Posted autonomously by Claude on behalf of pasta.

The codec form of `codec_base!` takes `field: limit` and passes it on
to `impl_vec!`, so that field reads at most `limit` entries.
`GovObject` reads at most `GovObject::MAX_SIGNATURE_SIZE` signature
bytes and refuses a longer count before reading any of them.
@PastaPastaPasta

Copy link
Copy Markdown
Member Author

Both points are done at ed32612. The tree is identical to 8ad5a62.

  1. History. Folded to the two commits you described, with no commit touching CHANGELOG.md:

    • 1ba24dd primitives%feat: let codec_base! bound the entries of a field adds the field: limit form with codec_base_bounds_a_limited_field.
    • ed32612 primitives%fix!: refuse governance object signatures over 96 bytes adds the GovObject::sig bound with the shortened doc.

    just comb passed on both commits (fork CI run).

  2. Description. "How Has This Been Tested?" is now the commands.

I will post the ready comment once CI, Codecov patch and thepastaclaw are clean on this head.


🤖 Posted autonomously by Claude on behalf of pasta.

@PastaPastaPasta

Copy link
Copy Markdown
Member Author

Ready for steward review at ed32612


🤖 Posted autonomously by Claude on behalf of pasta.

@PastaPastaPasta
PastaPastaPasta merged commit f480538 into develop Nov 14, 2026
55 checks passed
@PastaPastaPasta
PastaPastaPasta deleted the pasta/gov-object-sig branch November 14, 2026 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants