Modifying `extend` to return adopted orphan beads by Sansh2356 · Pull Request #474 · braidpool/braidpool · GitHub
Skip to content

Modifying extend to return adopted orphan beads #474

Merged
mcelrath merged 2 commits into
braidpool:devfrom
Sansh2356:ibd/braid-add-bead-outcome
Jun 12, 2026
Merged

Modifying extend to return adopted orphan beads #474
mcelrath merged 2 commits into
braidpool:devfrom
Sansh2356:ibd/braid-add-bead-outcome

Conversation

@Sansh2356

@Sansh2356 Sansh2356 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor
  • Changing the extend function signatures to return promoted_orphan_beads adopted_orphan_beads .
  • Updating the caller sites, the update of the usage of returned beads will be update in coming PRs .

Copilot AI review requested due to automatic review settings June 6, 2026 16:05
@Sansh2356 Sansh2356 requested a review from zaidmstrr as a code owner June 6, 2026 16:06

Copilot AI 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.

Pull request overview

This PR updates the braid extension flow so Braid::extend() reports which previously-parked orphan beads were promoted (i.e., became connectable) as a result of adding a bead. This fits into the node’s DAG (“braid”) maintenance by making orphan promotion observable to callers.

Changes:

  • Extend AddBeadStatus::BeadAdded into BeadAdded { promoted_orphans: Vec<Bead> } and plumb through process_orphan_beads() to return the promoted set.
  • Update call sites to match the new BeadAdded { .. } shape.
  • Add tests covering: no orphan promotion, single orphan promotion, and transitive orphan-chain promotion.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
node/src/braid/mod.rs Changes BeadAdded to carry promoted_orphans and returns them from orphan processing.
node/src/braid/tests.rs Adds unit tests validating promoted orphan reporting behavior.
node/src/lib.rs Updates pattern matching for the new BeadAdded { .. } variant.
node/src/main.rs Updates pattern matching for the new BeadAdded { .. } variant in networking/IBD flows.
node/src/rpc_server.rs Updates RPC handling to match the new BeadAdded { .. } variant.

Comment thread node/src/braid/mod.rs
Comment thread node/src/braid/tests.rs
@Sansh2356 Sansh2356 force-pushed the ibd/braid-add-bead-outcome branch from e48e658 to 48deb1d Compare June 6, 2026 16:22
@Sansh2356 Sansh2356 changed the title Modifying extend to return promoted orphan beads Modifying extend to return ~~promoted~~ adopted orphan beads Jun 6, 2026
@Sansh2356 Sansh2356 changed the title Modifying extend to return ~~promoted~~ adopted orphan beads Modifying extend to return adopted orphan beads Jun 6, 2026

@nkatha23 nkatha23 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.

ACK 48deb1d

The change is clean. process_orphan_beads() now returns the promoted set and the recursive promoted.extend(self.process_orphan_beads()) correctly handles transitive chains in a single extend call, the transitive test confirms this.

One observation: the call sites in main.rs, lib.rs, and rpc_server.rs all use { .. } to ignore promoted_orphans for now. That's fine given the PR description says usage comes in a followup, but it's worth noting that promoted orphans are currently not being persisted to DB or forwarded to peers at those sites, so during IBD, orphans that get promoted through extend won't trigger the downstream DB write path. Assuming that's intentional and the followup PR will wire that up.

Also noting: test_invalid_json fails due to a pre-existing port 5050 leak in server_start_test unrelated to this PR.

nkatha23 added a commit to nkatha23/braidpool that referenced this pull request Jun 8, 2026
Tests binding fixed ports (3353, 3356, 3357, 3358, 5050) caused AddrInUse failures when tests ran concurrently or a previous test left a server listening. This was a known flake documented across multiple PRs (braidpool#309, braidpool#474).

Add bound_addr_tx: Option<oneshot::Sender<SocketAddr>> to run_stratum_service. After binding, the actual address is sent
through the channel so tests can connect to the real port.

All 5 tests now use port 0 (OS-assigned) and await the oneshot receiver before connecting, no sleep needed, no race window.
Production call in main.rs passes None.
@Sansh2356 Sansh2356 force-pushed the ibd/braid-add-bead-outcome branch from 48deb1d to 565c377 Compare June 9, 2026 15:09
nkatha23 added a commit to nkatha23/braidpool that referenced this pull request Jun 10, 2026
Tests binding fixed ports (3353, 3356, 3357, 3358, 5050) caused AddrInUse failures when tests ran concurrently or a previous test left a server listening. This was a known flake documented across multiple PRs (braidpool#309, braidpool#474).

Add bound_addr_tx: Option<oneshot::Sender<SocketAddr>> to run_stratum_service. After binding, the actual address is sent
through the channel so tests can connect to the real port.

All 5 tests now use port 0 (OS-assigned) and await the oneshot receiver before connecting, no sleep needed, no race window.
Production call in main.rs passes None.
zaidmstrr pushed a commit that referenced this pull request Jun 11, 2026
…477)

* fix(tests): replace hardcoded stratum ports with OS-assigned port 0

Tests binding fixed ports (3353, 3356, 3357, 3358, 5050) caused AddrInUse failures when tests ran concurrently or a previous test left a server listening. This was a known flake documented across multiple PRs (#309, #474).

Add bound_addr_tx: Option<oneshot::Sender<SocketAddr>> to run_stratum_service. After binding, the actual address is sent
through the channel so tests can connect to the real port.

All 5 tests now use port 0 (OS-assigned) and await the oneshot receiver before connecting, no sleep needed, no race window.
Production call in main.rs passes None.

* fix: use actual bound port in stratum endpoint logging

server_endpoints and the warning log were using self.stratum_config.port which shows 0 when OS port assignment is used. Switch to bound_addr.port()
so logs always show the real listening port.
@Sansh2356 Sansh2356 force-pushed the ibd/braid-add-bead-outcome branch 2 times, most recently from d6c9716 to 2b9c914 Compare June 12, 2026 15:39

@mcelrath mcelrath 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.

Looks good to me. Just a note on terminology, I'd prefer if it was called adopted rather than promoted_orphans.

… bead to return promoted orphans

Instead of fetching promoted orphans upon receiving their parents and being successfully
validated and extended the orphan beads that are dependent on these to be received and
are then promoted from the orphan set.

I have modified the functions to directly return the promoted orphans instead that will be
used for orphan persistance in db .
@Sansh2356 Sansh2356 force-pushed the ibd/braid-add-bead-outcome branch from 2b9c914 to 5ac2442 Compare June 12, 2026 16:57
@mcelrath mcelrath merged commit 2a3b963 into braidpool:dev Jun 12, 2026
13 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.

4 participants