Skip to content

feat: add relay server functionality#101

Merged
varex83 merged 36 commits into
mainfrom
bohdan/p2p-relay-server
Jan 13, 2026
Merged

feat: add relay server functionality#101
varex83 merged 36 commits into
mainfrom
bohdan/p2p-relay-server

Conversation

@varex83
Copy link
Copy Markdown
Collaborator

@varex83 varex83 commented Dec 29, 2025

No description provided.

@varex83 varex83 changed the title feat: create behaviour builder feat: add relay server functionality Dec 29, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 29, 2025

Coverage (base → head): 35.4% → 34.53% ⬇️ 0.87 pp
Only posts when PR coverage is lower than the base branch's latest push (or freshly computed base).

Copy link
Copy Markdown
Collaborator

@emlautarom1 emlautarom1 left a comment

Choose a reason for hiding this comment

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

A couple of questions and comments based on the extension of the PR.

Comment thread crates/charon-p2p/src/behaviours/pluto.rs
Comment thread crates/charon-p2p/src/behaviours/pluto.rs Outdated
Comment thread crates/relay-server/src/web.rs Outdated

/// Shared application state for HTTP handlers.
#[derive(Clone)]
pub struct AppState {
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.

AppState can be private to the module

Copy link
Copy Markdown
Collaborator Author

@varex83 varex83 Jan 12, 2026

Choose a reason for hiding this comment

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

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.

Not sure I follow the change? We can remove the pub modifier here, follow the warnings and remove the associated pub modifiers since there are no usages outside this module.

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.

I just made a whole module accessible only on crate level

/// Web.
pub(crate) mod web;

Comment thread crates/relay-server/src/web.rs Outdated
Comment thread crates/relay-server/src/behaviour.rs Outdated
Comment thread crates/relay-server/src/behaviour.rs
Comment thread crates/relay-server/examples/relay_server.rs
Comment thread crates/relay-server/examples/relay_server.rs
Comment thread crates/relay-server/src/p2p.rs
Base automatically changed from bohdan/p2p-conn-gater to main January 12, 2026 09:47
Copy link
Copy Markdown
Collaborator

@emlautarom1 emlautarom1 left a comment

Choose a reason for hiding this comment

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

LGTM, some small details only.


/// Shared application state for HTTP handlers.
#[derive(Clone)]
pub struct AppState {
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.

Not sure I follow the change? We can remove the pub modifier here, follow the warnings and remove the associated pub modifiers since there are no usages outside this module.

Comment thread crates/relay-server/src/behaviour.rs Outdated
fn default() -> Self {
Self {
gater: None,
identify_protocol: "/pluto/relay/1.0.0-alpha".into(),
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.

Just for consistency, the same way that we have defaults in PlutoBehaviourBuilder we should have them in RelayServerBehaviourBuilder (extract the identify_protocol into a lazy static)

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.

return Err(error);
}
},
event = node.swarm.select_next_some() => {
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.

Mostly due to code structuring: this block that handles events will grow larger (according to the TODO) and having everything inside this function might get complicated in the long run, that's why I mentioned that this will need to be revisited in a future PR (we might not even need to do anything).

Comment on lines +143 to +145
// todo(varex83): check if this is correct, since it's aligned with the original
// implementation, but I'm not sure if it's the correct way to do it.
// Would it be better to use max_res_per_peer * max_conns?
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.

A couple of things:

  • The Go implementation does not have an equivalent of max_circuits_per_peer
  • max_circuits matches the Go MaxCircuit (based on default values and docs), and in the original implementation this is set to config.MaxResPerPeer. This means that max_circuits: config.max_res_per_peer is correct.

Due to the confusion, I'd leave it as a TODO and revisit it later. We might need to ask someone with a bit more experience in libp2p about it.

@varex83 varex83 merged commit 0a4b2f6 into main Jan 13, 2026
7 checks passed
@varex83 varex83 deleted the bohdan/p2p-relay-server branch January 13, 2026 15:43
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.

2 participants