Skip to content

apollo_network: migrate BootstrappingBehaviour to delegate dialling to DiallingBehaviour#13219

Merged
sirandreww-starkware merged 1 commit intomainfrom
03-12-apollo_network_migrate_bootstrappingbehaviour_to_delegate_dialling_to_diallingbehaviour
Mar 22, 2026
Merged

apollo_network: migrate BootstrappingBehaviour to delegate dialling to DiallingBehaviour#13219
sirandreww-starkware merged 1 commit intomainfrom
03-12-apollo_network_migrate_bootstrappingbehaviour_to_delegate_dialling_to_diallingbehaviour

Conversation

@sirandreww-starkware
Copy link
Copy Markdown
Contributor

@sirandreww-starkware sirandreww-starkware commented Mar 12, 2026

Note

Medium Risk
Changes bootstrapping connection lifecycle and shifts dial/retry responsibility to the shared DialingBehaviour, which could affect reconnect behavior and event ordering if routing is incorrect.

Overview
Bootstrapping no longer performs libp2p dials directly. BootstrappingBehaviour is rewritten to maintain a HashMap of bootstrap peers and emit queued ToOtherBehaviourEvent::RequestDial events (initially and on full disconnect), relying on the existing DialingBehaviour to execute dials and handle retry/backoff.

On successful outbound connection to a bootstrap peer, it now emits FoundListenAddresses and explicitly drops any queued stale RequestDial for that peer to handle rapid disconnect/reconnect ordering.

Tests are updated to assert RequestDial/routing behavior (including a new rapid reconnect case), Discovery test wiring simulates network-manager routing by forwarding RequestDial to DialingBehaviour, and the e2e broadcast test avoids early swarm polling that would otherwise drop initial RequestDial events.

Written by Cursor Bugbot for commit b9f5e9d. This will update automatically on new commits. Configure here.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

Copy link
Copy Markdown
Contributor Author

sirandreww-starkware commented Mar 12, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@sirandreww-starkware sirandreww-starkware self-assigned this Mar 12, 2026
@sirandreww-starkware sirandreww-starkware marked this pull request as ready for review March 12, 2026 08:22
Copy link
Copy Markdown
Contributor

@guy-starkware guy-starkware left a comment

Choose a reason for hiding this comment

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

@guy-starkware reviewed 6 files and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on ShahakShama and sirandreww-starkware).


crates/apollo_network/src/discovery/behaviours/bootstrapping/mod.rs line 47 at r1 (raw file):

        for (peer_id, address) in bootstrap_peers {
            if peer_id == local_peer_id {
                info!("Skipping bootstrap peer with same ID as local peer: {address}");

Is this going to trigger every time the node comes up? Or only for some of the nodes that happen to be on the list of bootstraps? If every time, I'm not sure it deserves a log.


crates/apollo_network/src/discovery/behaviours/bootstrapping/mod.rs line 58 at r1 (raw file):

        if peers_map.is_empty() {
            warn!("No bootstrap peers provided, bootstrapping will not be possible");

Not sure if we want a panic here or not. How bad is it to come up without bootstrap peers?

@sirandreww-starkware sirandreww-starkware force-pushed the 03-11-apollo_network_kadrequesting_emits_requestdial_events_via_diallingbehaviour branch from 8c0348d to b4df324 Compare March 12, 2026 14:38
@sirandreww-starkware sirandreww-starkware force-pushed the 03-12-apollo_network_migrate_bootstrappingbehaviour_to_delegate_dialling_to_diallingbehaviour branch from e0945f9 to a9a316a Compare March 12, 2026 14:38
@sirandreww-starkware sirandreww-starkware force-pushed the 03-11-apollo_network_kadrequesting_emits_requestdial_events_via_diallingbehaviour branch from b4df324 to edc724e Compare March 12, 2026 15:29
@sirandreww-starkware sirandreww-starkware force-pushed the 03-12-apollo_network_migrate_bootstrappingbehaviour_to_delegate_dialling_to_diallingbehaviour branch 2 times, most recently from bab9573 to 28626bc Compare March 15, 2026 07:29
@sirandreww-starkware sirandreww-starkware force-pushed the 03-11-apollo_network_kadrequesting_emits_requestdial_events_via_diallingbehaviour branch from edc724e to 12dac01 Compare March 15, 2026 07:30
@sirandreww-starkware sirandreww-starkware force-pushed the 03-11-apollo_network_kadrequesting_emits_requestdial_events_via_diallingbehaviour branch from 12dac01 to e3709c8 Compare March 15, 2026 11:08
@sirandreww-starkware sirandreww-starkware force-pushed the 03-12-apollo_network_migrate_bootstrappingbehaviour_to_delegate_dialling_to_diallingbehaviour branch from 28626bc to 7e89443 Compare March 15, 2026 11:08
@sirandreww-starkware sirandreww-starkware force-pushed the 03-11-apollo_network_kadrequesting_emits_requestdial_events_via_diallingbehaviour branch from e3709c8 to 32d641e Compare March 16, 2026 07:51
@sirandreww-starkware sirandreww-starkware force-pushed the 03-12-apollo_network_migrate_bootstrappingbehaviour_to_delegate_dialling_to_diallingbehaviour branch from 7e89443 to 477e6fa Compare March 16, 2026 07:51
@sirandreww-starkware sirandreww-starkware changed the base branch from 03-11-apollo_network_kadrequesting_emits_requestdial_events_via_diallingbehaviour to graphite-base/13219 March 16, 2026 10:38
@sirandreww-starkware sirandreww-starkware force-pushed the 03-12-apollo_network_migrate_bootstrappingbehaviour_to_delegate_dialling_to_diallingbehaviour branch from 477e6fa to 3d7c956 Compare March 16, 2026 12:20
@sirandreww-starkware sirandreww-starkware changed the base branch from graphite-base/13219 to 03-11-apollo_network_kadrequesting_emits_requestdial_events_via_diallingbehaviour March 16, 2026 12:21
@sirandreww-starkware sirandreww-starkware force-pushed the 03-12-apollo_network_migrate_bootstrappingbehaviour_to_delegate_dialling_to_diallingbehaviour branch from 3d7c956 to 963c8f1 Compare March 16, 2026 12:26
@sirandreww-starkware sirandreww-starkware force-pushed the 03-11-apollo_network_kadrequesting_emits_requestdial_events_via_diallingbehaviour branch from 9168c75 to f5f9ce7 Compare March 16, 2026 12:26
Copy link
Copy Markdown
Contributor Author

@sirandreww-starkware sirandreww-starkware left a comment

Choose a reason for hiding this comment

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

@sirandreww-starkware made 2 comments.
Reviewable status: 5 of 6 files reviewed, 2 unresolved discussions (waiting on guy-starkware and ShahakShama).


crates/apollo_network/src/discovery/behaviours/bootstrapping/mod.rs line 47 at r1 (raw file):

Previously, guy-starkware wrote…

Is this going to trigger every time the node comes up? Or only for some of the nodes that happen to be on the list of bootstraps? If every time, I'm not sure it deserves a log.

This code has been moved but not changed. If you'd like I can move it back to where it was?


crates/apollo_network/src/discovery/behaviours/bootstrapping/mod.rs line 58 at r1 (raw file):

Previously, guy-starkware wrote…

Not sure if we want a panic here or not. How bad is it to come up without bootstrap peers?

This code has been moved but not changed. If you'd like I can move it back to where it was?

Copy link
Copy Markdown
Contributor

@guy-starkware guy-starkware left a comment

Choose a reason for hiding this comment

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

@guy-starkware reviewed 1 file and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on ShahakShama and sirandreww-starkware).


crates/apollo_network/src/discovery/behaviours/bootstrapping/mod.rs line 47 at r1 (raw file):

Previously, sirandreww-starkware (Andrew Luka) wrote…

This code has been moved but not changed. If you'd like I can move it back to where it was?

No, I was just thinking about this info! log. You don't have to change it at this point but consider if this log gives me any additional information.


crates/apollo_network/src/discovery/behaviours/bootstrapping/mod.rs line 58 at r1 (raw file):

Previously, sirandreww-starkware (Andrew Luka) wrote…

This code has been moved but not changed. If you'd like I can move it back to where it was?

I don't mind where the code is. Just reading through it and suggesting what ever I see. If you don't want to make changes to the moved code just now at least think about modifying it later.

@sirandreww-starkware sirandreww-starkware force-pushed the 03-11-apollo_network_kadrequesting_emits_requestdial_events_via_diallingbehaviour branch from f5f9ce7 to 72feead Compare March 16, 2026 13:57
@sirandreww-starkware sirandreww-starkware force-pushed the 03-12-apollo_network_migrate_bootstrappingbehaviour_to_delegate_dialling_to_diallingbehaviour branch from 963c8f1 to 07836b1 Compare March 16, 2026 13:57
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread crates/apollo_network/src/discovery/behaviours/bootstrapping/mod.rs
@sirandreww-starkware sirandreww-starkware force-pushed the 03-12-apollo_network_migrate_bootstrappingbehaviour_to_delegate_dialling_to_diallingbehaviour branch from 07836b1 to b3f8e4d Compare March 16, 2026 15:13
@graphite-app graphite-app bot changed the base branch from 03-11-apollo_network_kadrequesting_emits_requestdial_events_via_diallingbehaviour to graphite-base/13219 March 17, 2026 08:26
@ShahakShama
Copy link
Copy Markdown
Collaborator

crates/apollo_network/src/discovery/behaviours/bootstrapping/mod.rs line 106 at r2 (raw file):

            }) => {
                if let Some(address) = self.bootstrap_peers.get(&peer_id) {
                    self.pending_events.push_back(ToOtherBehaviourEvent::FoundListenAddresses {

Was this here in the previous discovery? I think no. I think it only appears in identify

@sirandreww-starkware sirandreww-starkware force-pushed the 03-12-apollo_network_migrate_bootstrappingbehaviour_to_delegate_dialling_to_diallingbehaviour branch from b3f8e4d to 39760aa Compare March 19, 2026 15:04
@sirandreww-starkware sirandreww-starkware changed the base branch from graphite-base/13219 to main March 19, 2026 15:04
Copy link
Copy Markdown
Contributor Author

@sirandreww-starkware sirandreww-starkware left a comment

Choose a reason for hiding this comment

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

@sirandreww-starkware made 2 comments and resolved 2 discussions.
Reviewable status: 3 of 6 files reviewed, 2 unresolved discussions (waiting on guy-starkware and ShahakShama).


crates/apollo_network/src/discovery/behaviours/bootstrapping/mod.rs line 106 at r2 (raw file):

Previously, ShahakShama wrote…

Was this here in the previous discovery? I think no. I think it only appears in identify

It was, I tagged you in that location


crates/apollo_network/src/discovery/behaviours/bootstrapping/bootstrap_peer.rs line 146 at r3 (raw file):

                    self.should_add_peer_to_kad_routing_table = false;
                    Poll::Ready(Some(ToSwarm::GenerateEvent(
                        ToOtherBehaviourEvent::FoundListenAddresses {

@ShahakShama this shows what you asked about

@sirandreww-starkware sirandreww-starkware force-pushed the 03-12-apollo_network_migrate_bootstrappingbehaviour_to_delegate_dialling_to_diallingbehaviour branch from 39760aa to b9f5e9d Compare March 22, 2026 08:57
Copy link
Copy Markdown
Collaborator

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

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

:lgtm:

@ShahakShama reviewed 3 files and all commit messages, made 2 comments, and resolved 2 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on sirandreww-starkware).


crates/apollo_network/src/discovery/behaviours/bootstrapping/mod.rs line 106 at r2 (raw file):

Previously, sirandreww-starkware (Andrew Luka) wrote…

It was, I tagged you in that location

Ah ok, this is for peer manager

@sirandreww-starkware sirandreww-starkware added this pull request to the merge queue Mar 22, 2026
Merged via the queue into main with commit afa421e Mar 22, 2026
32 of 45 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants