Skip to content

apollo_network: KadRequesting emits RequestDial events via DiallingBehaviour#13218

Merged
sirandreww-starkware merged 1 commit intomainfrom
03-11-apollo_network_kadrequesting_emits_requestdial_events_via_diallingbehaviour
Mar 17, 2026
Merged

apollo_network: KadRequesting emits RequestDial events via DiallingBehaviour#13218
sirandreww-starkware merged 1 commit intomainfrom
03-11-apollo_network_kadrequesting_emits_requestdial_events_via_diallingbehaviour

Conversation

@sirandreww-starkware
Copy link
Copy Markdown
Contributor

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

Note

Medium Risk
Changes peer dialing flow in the discovery subsystem by replacing direct swarm dial requests with delegated dial events and new de-duplication state; this can affect connectivity/retry behavior if the new state handling is incorrect.

Overview
Discovery dialing is now delegated via events instead of direct swarm dials. KadRequestingBehaviour now queues Kademlia results as (PeerId, Vec<Multiaddr>) and emits ToOtherBehaviourEvent::RequestDial (with addresses) rather than ToSwarm::Dial.

It adds tracking for peers with an active dial request to avoid repeated dial dispatches, and cleans up pending_dials/active tracking on connection establishment and when set_target_peers resets the target set. discovery::Behaviour is updated to pass the full Kademlia (peer_id, addresses) tuples through and forward RequestDial to DialingBehaviour.

Written by Cursor Bugbot for commit 0912f23. 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.

Comment thread crates/apollo_network/src/discovery/behaviours/kad_requesting.rs Outdated
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 2 files and all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on ShahakShama and sirandreww-starkware).

@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-11-apollo_network_wire_diallingbehaviour_into_discovery_with_requestdial_event branch from 13aac61 to 25d474d 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-11-apollo_network_wire_diallingbehaviour_into_discovery_with_requestdial_event branch from 25d474d to 3ce8c4d Compare March 12, 2026 15:29
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/kad_requesting.rs Outdated
@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_wire_diallingbehaviour_into_discovery_with_requestdial_event branch from 3ce8c4d to af4bcfb Compare March 15, 2026 07:30
@sirandreww-starkware sirandreww-starkware changed the base branch from 03-11-apollo_network_wire_diallingbehaviour_into_discovery_with_requestdial_event to graphite-base/13218 March 15, 2026 09:54
@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
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 1 comment.
Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on guy-starkware and ShahakShama).

Comment thread crates/apollo_network/src/discovery/behaviours/kad_requesting.rs Outdated
@sirandreww-starkware sirandreww-starkware force-pushed the 03-11-apollo_network_kadrequesting_emits_requestdial_events_via_diallingbehaviour branch from 32d641e to 9168c75 Compare March 16, 2026 10:39
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.

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


crates/apollo_network/src/discovery/behaviours/kad_requesting.rs line 40 at r4 (raw file):

    pending_dials: VecDeque<(PeerId, Vec<Multiaddr>)>,
    /// Peers for which a `RequestDial` event has been dispatched to `DiallingBehaviour` but no
    /// connection has been established yet.

This is incorrect. Peers that a connection has been established with are in this list as well

Comment thread crates/apollo_network/src/discovery/behaviours/kad_requesting.rs Outdated
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 3 comments.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on guy-starkware and ShahakShama).


crates/apollo_network/src/discovery/behaviours/kad_requesting.rs line 40 at r4 (raw file):

Previously, ShahakShama wrote…

This is incorrect. Peers that a connection has been established with are in this list as well

That's not true, we remove the peer once a ConnectionEstablished event is emitted


crates/apollo_network/src/discovery/behaviours/kad_requesting.rs line 150 at r3 (raw file):

    // TODO(AndrewL): When target peers change, cancel DialPeerStreams in DiallingBehaviour
    // for peers no longer in the target set. Currently those streams retry indefinitely.

@ShahakShama here

Code quote:

    // TODO(AndrewL): When target peers change, cancel DialPeerStreams in DiallingBehaviour
    // for peers no longer in the target set. Currently those streams retry indefinitely.

Comment thread crates/apollo_network/src/discovery/behaviours/kad_requesting.rs Outdated
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 1 comment.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on guy-starkware and ShahakShama).


crates/apollo_network/src/discovery/behaviours/kad_requesting.rs line 150 at r3 (raw file):

Previously, sirandreww-starkware (Andrew Luka) wrote…

@ShahakShama here

solved in #13282

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.

@ShahakShama made 1 comment and resolved 2 discussions.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on guy-starkware and sirandreww-starkware).


crates/apollo_network/src/discovery/behaviours/kad_requesting.rs line 40 at r4 (raw file):

Previously, sirandreww-starkware (Andrew Luka) wrote…

That's not true, we remove the peer once a ConnectionEstablished event is emitted

So you can return to dialing_peers 😅

@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
@sirandreww-starkware sirandreww-starkware force-pushed the 03-11-apollo_network_wire_diallingbehaviour_into_discovery_with_requestdial_event branch from 734c3f6 to 01d86d9 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 1 comment.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on guy-starkware and ShahakShama).


crates/apollo_network/src/discovery/behaviours/kad_requesting.rs line 40 at r4 (raw file):

Previously, ShahakShama wrote…

So you can return to dialing_peers 😅

I don't know, I kind of like it better now (more descriptive)

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 resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on guy-starkware).

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 all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on sirandreww-starkware).

@graphite-app graphite-app bot changed the base branch from 03-11-apollo_network_wire_diallingbehaviour_into_discovery_with_requestdial_event to graphite-base/13218 March 16, 2026 13:34
@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-11-apollo_network_kadrequesting_emits_requestdial_events_via_diallingbehaviour branch from 72feead to 71c761a Compare March 16, 2026 15:13
@sirandreww-starkware sirandreww-starkware force-pushed the 03-11-apollo_network_kadrequesting_emits_requestdial_events_via_diallingbehaviour branch from 71c761a to 0912f23 Compare March 17, 2026 08:26
@graphite-app graphite-app bot changed the base branch from graphite-base/13218 to main March 17, 2026 08:27
@graphite-app
Copy link
Copy Markdown

graphite-app bot commented Mar 17, 2026

Merge activity

  • Mar 17, 8:27 AM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.

@sirandreww-starkware sirandreww-starkware added this pull request to the merge queue Mar 17, 2026
Merged via the queue into main with commit 0ead473 Mar 17, 2026
61 of 153 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 19, 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