Skip to content

primitives%feat(types): add new RFC predicates and use in is_reachable(), sync is_routable() with consensus definition#17

Merged
kwvg merged 4 commits into
dashpay:developfrom
kwvg:netroute
Jul 1, 2026
Merged

primitives%feat(types): add new RFC predicates and use in is_reachable(), sync is_routable() with consensus definition#17
kwvg merged 4 commits into
dashpay:developfrom
kwvg:netroute

Conversation

@kwvg

@kwvg kwvg commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Additional Information

Breaking Changes

None expected.

How Has This Been Tested?

cargo fmt --check
cargo test --features full,_internal
./contrib/lint_all.py

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 (note: N/A)
  • I have assigned this pull request to a milestone (for repository code-owners and collaborators only)

@kwvg kwvg added this to the 0.1 milestone Jun 28, 2026
@kwvg kwvg self-assigned this Jun 28, 2026
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kwvg, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 94a90a19-06b7-4ef3-8985-e0653fd4ebe3

📥 Commits

Reviewing files that changed from the base of the PR and between 03a62ff and 9aeeb7f.

📒 Files selected for processing (1)
  • pkgs/primitives/src/types/netaddr.rs
📝 Walkthrough

Walkthrough

This PR adds a From<[u8; 4]> conversion for AddrV1 to build IPv4-mapped addresses, reworks NetAddr's is_routable() exclusion logic and RFC classification helpers, introduces a new is_reachable() method, overhauls related tests, and fixes hex-prefix handling in a solver sample script.

Changes

NetAddr Classification Rework

Layer / File(s) Summary
AddrV1 IPv4-mapped constructor
pkgs/primitives/src/types/addrv1.rs
Adds From<[u8; 4]> for AddrV1 to build an IPv4-mapped 16-byte address from four octets.
RFC classification helpers
pkgs/primitives/src/types/netaddr.rs
Updates RFC6145 doc wording and adds/updates RFC classification helper methods (RFC4291, RFC4862, and others) used by routability logic.
is_routable() and is_reachable() logic
pkgs/primitives/src/types/netaddr.rs
Narrows IPv4 exclusion ranges, adds RFC5737 to exclusions, replaces rfc6052/rfc6145 IPv6 exclusions with rfc4862/rfc7343 in is_routable(), and adds a new is_reachable() method with multicast/reserved-range and distinct RFC-based exclusions.
Test suite overhaul
pkgs/primitives/src/types/netaddr.rs
Replaces custom NetAddr test adapters with AddrV1/AddrV2 string-parsing tests, adding coverage for RFC helpers, is_routable(), and is_reachable() including reachable_ipv4_mapped_v6.

Solver Sample Hex Parsing Fix

Layer / File(s) Summary
parseBits prefix stripping
contrib/samples/solver/index.js
Declares bitsInput as mutable so a leading 0x/0X prefix can be stripped before hex validation/parsing.

Sequence Diagram(s)

Not applicable — changes are classification logic and a script fix, without multi-component interaction flows.

Compact Metadata: 3 files changed across a Rust primitives package and a JS sample script; no exported entity signatures removed.

Related Issues: None specified.

Related PRs: None specified.

Suggested Labels: rust, primitives, networking, tests, javascript

Suggested Reviewers: None specified.

Poem:
A rabbit hopped through bytes so neat,
Mapped IPv4 addresses, quite the feat.
Routable or reachable, RFCs galore,
Hex prefixes stripped forevermore.
Tests rewritten, clean and bright—
This warren's code compiles just right. 🐰

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main feature work: new RFC predicates, is_reachable(), and is_routable() consensus sync.
Description check ✅ Passed The description clearly matches the implemented changes and testing notes, including the solver bug fix and routability/reachability updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jun 28, 2026

Copy link
Copy Markdown

@github-actions github-actions Bot added the needs-rebase This pull request needs to be rebased against the base branch label Jun 29, 2026
@github-actions github-actions Bot removed the needs-rebase This pull request needs to be rebased against the base branch label Jun 30, 2026
@kwvg kwvg changed the title sdk%feat: impl {Array,Encode}Buf to limit avoidable heap allocs, add PoW check, add RFCs, is_reachable(), sync is_routable() primitives%feat(types): add new RFC predicates and use in is_reachable(), sync is_routable() with consensus definition Jun 30, 2026
@kwvg kwvg marked this pull request as ready for review June 30, 2026 11:02
@kwvg

kwvg commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkgs/primitives/src/types/netaddr.rs`:
- Around line 469-499: `is_reachable` currently treats Tor/I2P/CJDNS as
reachable because it falls through for non-IPv4/IPv6 addresses, which conflicts
with the public-internet contract. Update `NetAddr::is_reachable` to explicitly
exclude privacy/overlay networks (or, if that behavior is intended, adjust the
rustdoc and tests accordingly) so `is_routable` does not imply public
reachability for those address types.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 173a9c7b-43b1-426e-b2f4-f9cdd3252ad9

📥 Commits

Reviewing files that changed from the base of the PR and between 8ae2896 and 03a62ff.

📒 Files selected for processing (3)
  • contrib/samples/solver/index.js
  • pkgs/primitives/src/types/addrv1.rs
  • pkgs/primitives/src/types/netaddr.rs

Comment thread pkgs/primitives/src/types/netaddr.rs Outdated
@kwvg kwvg merged commit cacdf8f into dashpay:develop Jul 1, 2026
19 checks passed
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.

1 participant