Skip to content

refactor: relay router and mut relay reserver#392

Open
varex83 wants to merge 8 commits into
mainfrom
bohdan/refactor-relay
Open

refactor: relay router and mut relay reserver#392
varex83 wants to merge 8 commits into
mainfrom
bohdan/refactor-relay

Conversation

@varex83
Copy link
Copy Markdown
Collaborator

@varex83 varex83 commented May 11, 2026

No description provided.

Comment thread crates/p2p/src/relay.rs
match err {
DialError::LocalPeerId { .. } => Self::LocalPeerId,
DialError::NoAddresses => Self::NoAddresses,
DialError::DialPeerConditionFalse(_) => Self::Skipped,
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.

Will it be correctly handled in the on_dial_failure? It'll retry instead of skipping.

Comment thread crates/p2p/src/relay.rs
};
/// Builds circuit listen addresses for a relay from its transport
/// addresses: `/ip4/.../tcp/.../p2p/<relay-id>/p2p-circuit`.
fn circuit_addrs(relay_id: PeerId, addrs: &[Multiaddr]) -> Vec<Multiaddr> {
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.

Would be good to have some unit test for this function

Comment thread crates/p2p/src/relay.rs
/// Extracts the relay peer id from a circuit listen address of the form
/// `/.../p2p/<relay-id>/p2p-circuit`. Returns `None` if the address is not
/// a relay circuit address.
fn relay_id_from_circuit_addr(addr: &Multiaddr) -> Option<PeerId> {
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.

ditto

Comment thread crates/p2p/src/relay.rs
/// Builds circuit dial addresses for reaching `target` through every
/// currently reserved relay:
/// `/.../p2p/<relay-id>/p2p-circuit/p2p/<target>`.
fn peer_circuit_addrs(&self, target: &PeerId) -> Vec<Multiaddr> {
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.

ditto

Comment thread crates/p2p/src/relay.rs
listen_addr = %addr,
"Relay circuit listener expired; demoting to Established"
);
self.set_relay_state(relay_id, RelayConnectionState::Established);
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.

Do we need to update existing peer dial state?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, because our reservation is expired -> libp2p's relay will make a reservation -> we will handle this event properly in relay manager

Comment thread crates/p2p/src/relay.rs
/// Applies a relay address update from a [`MutablePeer`]: refreshes
/// tracked addresses and, if this is the first time we've seen this
/// relay, kicks off a new dial campaign.
pub fn queue_relay_update(&mut self, relay: Peer) {
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.

If a MutablePeer changes from one relay peer ID to another, the old relay can stay in the Reserved state and still be used for routing. Should we clear the old relay ID state when applying the update?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is matches charon implementation, we can keep old relays

@varex83 varex83 added this to the S1 milestone May 13, 2026
@varex83 varex83 self-assigned this May 13, 2026
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.

3 participants