Skip to content

fix(dash-spv): fix dashd process port assignation - #923

Open
ZocoLini wants to merge 1 commit into
devfrom
fix/dashd-sync-903
Open

fix(dash-spv): fix dashd process port assignation#923
ZocoLini wants to merge 1 commit into
devfrom
fix/dashd-sync-903

Conversation

@ZocoLini

@ZocoLini ZocoLini commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Closes #903

Summary by CodeRabbit

  • Chores
    • Improved internal test environment port allocation to reduce conflicts during parallel test runs.
    • Added safeguards to keep automatically assigned ports within a valid operating-system range.
    • No user-facing product changes.

@ZocoLini
ZocoLini requested a review from xdustinface August 4, 2026 14:40
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

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

Next review available in: 5 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2f817d69-e35d-4f87-85d1-a92957775091

📥 Commits

Reviewing files that changed from the base of the PR and between aca426f and d80600c.

📒 Files selected for processing (1)
  • dash-spv/src/test_utils/node.rs
📝 Walkthrough

Walkthrough

The test utility now allocates ports from process-specific lanes beginning at port 20000. Compile-time validation constrains the range below Linux’s ephemeral ports. Allocation wraps within the range and continues availability probing.

Changes

Test port allocation

Layer / File(s) Summary
Bounded PID-based port allocation
dash-spv/src/test_utils/node.rs
The utility defines the port range and per-process lanes, validates the upper bound at compile time, seeds the atomic counter from the process ID, wraps allocations within the range, and probes candidate ports.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: xdustinface

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.
Title check ✅ Passed The title clearly identifies the main change: fixing dashd process port assignment in dash-spv.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dashd-sync-903

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 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 `@dash-spv/src/test_utils/node.rs`:
- Around line 42-55: Add comprehensive unit tests in the node module and
integration tests under dash-spv/tests for find_available_port, covering range
boundaries, process IDs above u16::MAX, counter wrapping, occupied ports, and
concurrent allocation. Refactor the allocator to inject the seed/range or expose
a pure mapping helper so tests avoid real process IDs and shared global state,
while preserving production behavior.
- Around line 42-55: Update find_available_port and the DashCoreNode startup
flow so the selected p2p and RPC ports remain reserved until DashCoreNode::start
launches dashd with those ports. Preserve the reservation by carrying the bound
TcpListener or equivalent handle through DashCoreConfig, or bind the ports
directly during startup, and release it only after dashd has successfully
claimed them.
- Around line 19-34: Move PORT_RANGE_BASE, PORT_LANE_WIDTH, and PORT_LANE_COUNT
out of node.rs into test configuration, loading their values when the test
allocator initializes and validating the configured range before allocating
ports. Remove the hardcoded 32768 limit and use the configured or OS-provided
ephemeral-port boundary, while preserving the existing lane allocation behavior.
- Around line 44-49: Update the NEXT_PORT initialization to compute the process
ID modulo PORT_LANE_COUNT while it is still a u32, then cast the bounded
remainder to u16 before multiplying by PORT_LANE_WIDTH and adding
PORT_RANGE_BASE.
🪄 Autofix

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b168e1c6-6614-4e74-b34a-4d18a28272c4

📥 Commits

Reviewing files that changed from the base of the PR and between 9cbe4e7 and aca426f.

📒 Files selected for processing (1)
  • dash-spv/src/test_utils/node.rs

Comment thread dash-spv/src/test_utils/node.rs
Comment thread dash-spv/src/test_utils/node.rs
Comment thread dash-spv/src/test_utils/node.rs
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.74%. Comparing base (9cbe4e7) to head (d80600c).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #923      +/-   ##
==========================================
- Coverage   74.76%   74.74%   -0.03%     
==========================================
  Files         328      328              
  Lines       76593    76593              
==========================================
- Hits        57267    57251      -16     
- Misses      19326    19342      +16     
Flag Coverage Δ
core 77.29% <ø> (ø)
ffi 49.32% <ø> (-0.40%) ⬇️
rpc 20.00% <ø> (ø)
spv 91.08% <ø> (+0.13%) ⬆️
wallet 75.69% <ø> (ø)
see 18 files with indirect coverage changes

@ZocoLini
ZocoLini force-pushed the fix/dashd-sync-903 branch from aca426f to d80600c Compare August 4, 2026 15:34
@github-actions github-actions Bot added the ready-for-review CodeRabbit has approved this PR label Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review CodeRabbit has approved this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: Windows dashd_sync tests intermittently fail during node startup

1 participant