Skip to content

primitives%fix: read a BIP155 IPv6 address in fc00::/8 as IPv6 - #110

Merged
kwvg merged 2 commits into
developfrom
pasta/addrv2-ipv6-net
Nov 3, 2026
Merged

kwvg merged 2 commits into
developfrom
pasta/addrv2-ipv6-net

Conversation

@PastaPastaPasta

@PastaPastaPasta PastaPastaPasta commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Motivation

AddrV2::decode read a BIP155 address of network 2 (IPv6) whose first byte is 0xfc as AddrV2::Cjdns, so it was written back with network 6, as different bytes. The reference implementation keeps such an address IPv6. Only network 6 is CJDNS. A net info entry in a provider transaction, read in the same format, keeps it IPv6 too.

Additional Information

Description Notes Reference implementation
Read network 2 as IPv6 AddrV2::decode gives Ipv6 for network 2, so an address is written back with the network it was read with. A Cjdns address is read from network 6 only. network 2, net info entry
Accept it in the check AddrV2::check no longer refuses an Ipv6 address in fc00::/8. A Cjdns address still needs the 0xfc prefix. validity
Keep the text and serde forms The text is unchanged: "[fc00::1]" still parses as Cjdns. An Ipv6 address in fc00::/8 displays as the same text, so it does not read back from its text. The serde form tags the network, so JSON and CBOR keep either address as it was. CJDNS text
Keep the duplicate rule Within a net info group, an Ipv6 and a Cjdns address with the same bytes count as one address, as their text is the same. Before this change both were read as Cjdns, so the group was already refused. Across groups, entries are compared with their network, so the two are not a duplicate there. in a group, across groups

The new net info vector comes from the reference implementation at v24.0.0-rc.4 (0e7382df80), the revision the corpus names, with the corpus's own program for that section. The program reproduces the other 27 vectors of the section unchanged.

Breaking Changes

No API change. For an address in fc00::/8 read with network 2, decode now gives Ipv6 where it gave Cjdns, and check accepts it. Text in fc00::/8 still parses as Cjdns. A net info group holding it and a Cjdns address with the same bytes is still refused as a duplicate. In two groups, on the same port, the two are no longer a duplicate, as in the reference implementation.

How Has This Been Tested?

  • New cases: decoding keeps the network (IPv6 and CJDNS, written back byte for byte), the check of an IPv6 address in fc00::/8, the text of such an address reading back as CJDNS, a JSON round trip keeping either network, a net info entry check, the duplicate in a group and the same pair across groups, and the net info vector. Reverting the read, the check, the text rule or the duplicate rule fails 2, 3, 2 and 1 cases.
  • Serde round trips through JSON and CBOR keep Ipv6 and Cjdns for an address in fc00::/8, a net info entry, a net info and a whole provider registration payload, which then writes network 2 or 6 respectively.
  • The reference implementation refuses the same group as a duplicate, checked with a test build at the corpus revision.
  • cargo test -p dash-primitives -p dash-p2p-core --all-features passes, and cargo clippy --workspace --all-features --all-targets is clean with -D warnings.
  • CI (just test lint fuzz::test, CodeQL included) is green.

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

Network 2 starting with 0xfc was read as CJDNS and written back as
network 6. It now stays IPv6 when read, in the check and from text,
and in one group still duplicates a CJDNS address with its bytes.
@PastaPastaPasta
PastaPastaPasta requested a review from kwvg November 2, 2026 00:46
@PastaPastaPasta PastaPastaPasta added this to the 0.3 milestone Nov 2, 2026
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 310c7d4 and f984c73.

Files selected for processing: 1
  • pkgs/primitives/src/types/addrv2.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.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • IPv6 addresses beginning with fc are now accepted and remain identified as IPv6 when decoded with the IPv6 network identifier; CJDNS addresses remain recognized when identified as CJDNS.
    • Service address validation accepts these IPv6 addresses, and duplicate detection recognizes IPv6 and CJDNS service addresses with matching address data.
    • Bracketed fc address text is still classified as CJDNS, so an IPv6 address in this range may not retain its type when converted to text and parsed again.

IPv6 wire decoding now preserves the IPv6 variant for addresses beginning with 0xfc, while the CJDNS wire network ID continues to produce the CJDNS variant. Validation accepts these IPv6 addresses. Text parsing still classifies bracketed addresses in this range as CJDNS, so an IPv6 value in this range does not round-trip through its display text. Service address comparison treats IPv6 and CJDNS addresses with matching bytes as the same address.

Suggested reviewers: kwvg

Merge Risk: Minimal · up to f984c

Wire decoding now keeps the IPv6 and CJDNS variants separate for identical bytes, and the binary and serde paths preserve each variant. Text parsing of bracketed fc00::/8 addresses intentionally remains CJDNS, and this is documented and tested. No merge-blocking risk remains.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly identifies the main change: decoding BIP155 IPv6 addresses in fc00::/8 as IPv6.
Description check Passed The description directly explains the decoding, validation, serialization, duplicate-handling changes, and related tests.
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.
  • 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

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Note

This pull request has no conflicts! 🎊 🎉 🎊

@thepastaclaw

thepastaclaw commented Nov 2, 2026 •

Copy link
Copy Markdown

✅ Final review complete — no blockers (commit f984c73) · triage: low

@codecov

codecov Bot commented Nov 2, 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.

@github-actions github-actions Bot added the status:behind This pull request can be rebased on the base branch. label Nov 2, 2026

@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 head 310c7d4 against the cited Dash Core revisions and surrounding address consumers. The network-preservation fix and distinct within-group versus cross-group duplicate rules match the reference implementation; neither supplied in-scope suggestion identifies an actionable issue. Validation was static only, and current PR checks confirm all applicable checks succeeded, with none pending or failing.

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 diff makes a small, well-contained correction to address classification and duplicate comparison with focused regression tests, rather than 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 100% left, weekly 56% 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
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.

  • NetInfo checks do not enforce Core's chain-dependent routability requirement — At Dash Core revision 8163290aa0307ed4bc2fc0ba15b78c20d61dfa88, ExtNetInfo::ValidateService in src/evo/netinfo.cpp:448-458 rejects non-routable services when RequireRoutableExternalIP() is enabled. In contrast, pkgs/primitives/src/types/netinfo.rs:261-270 checks address validity and ports without chain context, so its success does not establish mainnet acceptance—for example, an IPv6 fd00::1 service passes these SDK checks but fails Core's routability requirement. This is a concrete, pre-existing validation limitation, not a defect introduced by preserving BIP155 network identity.
    • Follow-up: Track a separate clarification or chain-aware validation API, with mainnet-versus-regtest reference vectors, so callers can distinguish context-free checks from full provider-service acceptance.

Comment thread pkgs/primitives/src/types/netinfo.rs Resolved
Text in fc00::/8 reads as CJDNS, as before, while the wire read keeps
network 2 as IPv6. The serde form keeps either network.

@kwvg kwvg left a comment

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.

See comment

@PastaPastaPasta
PastaPastaPasta requested a review from kwvg November 2, 2026 16:52

@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

Independently reviewed the complete diff at f984c73 and found no actionable in-scope defects: network preservation, tagged serde representations, and within-group versus across-group duplicate handling match the relevant Dash Core semantics. Verification was static only; no builds or tests were run locally. Current CI reports successful lint, stable-platform builds, and applicable MSRV checks, with the x86_64 Windows cross-build still pending and no failed checks.

🔴 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); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 8: 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 a small, contained correction to address decoding and validation with focused regression tests, 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 99% left; passed over gemini-3.8-flash-high (antigravity quota lookup failed)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • 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, 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.
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.

  • AddrV2::decode does not reclassify INTERNAL/TORV2/IPV4-in-IPv6 network-2 addresses as Core does — Verified as a separate, pre-existing decoder-parity difference. Dash Core's netaddress.h:454-481 recognizes the internal prefix and invalidates IPv4/TorV2 embeddings, while both the SDK base and head retain those bytes as IPv6. Those prefixes are outside fc00::/8 and their behavior is unchanged by removing the fc-prefix conversion; NIEntry also retains its existing explicit rejection of these embeddings. Correcting this PR's network-2 fc00 behavior does not require expanding it into a general address-normalization change.
    • Follow-up: Consider creating a separate issue or author/maintainer-requested PR for this.

@kwvg kwvg left a comment

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.

utACK f984c73

Comment thread pkgs/primitives/corpus/netinfo.json5 Resolved
@kwvg
kwvg merged commit 02ba9c2 into develop Nov 3, 2026
52 checks passed
@kwvg
kwvg deleted the pasta/addrv2-ipv6-net branch November 3, 2026 11:51
PastaPastaPasta added a commit that referenced this pull request Nov 3, 2026
* [d91c63a] sdk%test: check special-transaction vectors against allowed refusals (pasta)
* [f0c656d] primitives%fix!: refuse special-use addresses in network info (pasta)

Description:

`````
## Motivation

The reference implementation refuses a network info service whose address is in a special-use range, local addresses among them, except on regtest. The network info checks accepted such addresses. They now refuse them with `NIError::SpecialUse` on every network, as asked in #110 (comment). The regtest allowance aids debugging in the reference implementation and is not mirrored here.

## Additional Information

| Description | Notes | Reference implementation |
| ----------- | ----- | ------------------------ |
| Refuse special-use addresses | A service is refused for an IPv4 address in 0/8, 127/8 or the RFC 1918, 2544, 3927, 5737 or 6598 ranges, or an IPv6 address that is ::1 or in the RFC 4193, 4843, 4862 or 7343 ranges. This covers the legacy and the extended network info, using the existing `NetAddr` classification. Tor, I2P, CJDNS and domain entries are unaffected. | [legacy service](https://github.com/dashpay/dash/blob/8163290aa0307ed4bc2fc0ba15b78c20d61dfa88/src/evo/netinfo.cpp#L294-L295), [extended service](https://github.com/dashpay/dash/blob/8163290aa0307ed4bc2fc0ba15b78c20d61dfa88/src/evo/netinfo.cpp#L456-L457), [special-use ranges](https://github.com/dashpay/dash/blob/8163290aa0307ed4bc2fc0ba15b78c20d61dfa88/src/netaddress.cpp#L464-L471), [local addresses](https://github.com/dashpay/dash/blob/8163290aa0307ed4bc2fc0ba15b78c20d61dfa88/src/netaddress.cpp#L400-L411) |
| On every network | The reference implementation accepts these addresses on regtest alone. The check takes no network and refuses them on all of them. | [regtest allowance](https://github.com/dashpay/dash/blob/8163290aa0307ed4bc2fc0ba15b78c20d61dfa88/src/chainparams.cpp#L899) |
| Order of the checks | The range is checked before the service port rules, so a special-use service with a refused port now fails for its range, as in the reference implementation. A zero port is still refused before the range, as it was before this change: both orders refuse the same inputs, and only the reported error differs. | [extended service](https://github.com/dashpay/dash/blob/8163290aa0307ed4bc2fc0ba15b78c20d61dfa88/src/evo/netinfo.cpp#L449-L473) |
| IPv6 in fc00::/8 | Since #110 a BIP155 IPv6 address in fc00::/8 reads as IPv6. It is in the RFC 4193 range, so it is now refused. A CJDNS address with the same bytes is unaffected. | |
| Regtest vectors are allowed refusals | The ProRegTx and ProUpServTx vectors from regtest carry services on local addresses, so their tests allow the check to refuse them with `SpecialUse` (`check_sptx_except` in `dash-dev`, which takes the allowed errors). Tests that read a payload's fields or verify its signature decode it without the check (`decode_sptx`). The fixture that the rule tests edit moves its service to a public address first, so each edit stays the only failure. | |
| Breaking | `NIError` gains `SpecialUse`. | |

🤖 Generated with [Claude Code](https://claude.com/claude-code)
`````
PastaPastaPasta added a commit to PastaPastaPasta/base-sdk that referenced this pull request Nov 4, 2026
Takes dashpay#100 dashpay#88 dashpay#108 dashpay#107 dashpay#111 dashpay#110 dashpay#112 dashpay#115 dashpay#114 dashpay#101. ChainSetup keeps
the DEC-1043 policy fields; the BS11 BLS wrappers, i64 TxOut values and
MAX_SER_SIZE payload bound stay for Core parity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:behind This pull request can be rebased on the base branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants