Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
913b56b
feat: add tracing
varex83 Dec 5, 2025
51a691f
fix: linting, cargo-deny
varex83 Dec 5, 2025
e3ece2e
Merge remote-tracking branch 'origin/main' into bohdan/tracing
varex83 Dec 8, 2025
85a9b9c
feat: add p2p config
varex83 Dec 8, 2025
65d5ae7
fix: remove comment
varex83 Dec 9, 2025
a312796
Merge remote-tracking branch 'origin/main' into bohdan/p2p-config
varex83 Dec 9, 2025
1cc2a29
feat: add p2p metrics
varex83 Dec 9, 2025
c432d86
fix: rename label in example
varex83 Dec 9, 2025
aeaa971
fix: linting
varex83 Dec 9, 2025
65d3a49
Merge branch 'bohdan/p2p-config' into bohdan/p2p-create-node
varex83 Dec 10, 2025
a82bbc7
feat: [wip] add relay/ping
varex83 Dec 18, 2025
a2fe791
feat: add behaviours module, add relay client support
varex83 Dec 22, 2025
30a550b
fix: linter warnings
varex83 Dec 22, 2025
df9fdce
Merge remote-tracking branch 'origin/main' into bohdan/p2p-create-node
varex83 Dec 22, 2025
ddbb57b
fix: remove wildcard dependencies
varex83 Dec 22, 2025
3c5d3fe
feat: add connection gater
varex83 Dec 23, 2025
c663f61
fix: linter warnings
varex83 Dec 23, 2025
a244063
fix: linter warnings
varex83 Dec 23, 2025
adfc1ef
feat: create behaviour builder
varex83 Dec 24, 2025
31c4e27
feat: add relay server functionality
varex83 Dec 29, 2025
152fbcf
chore: fix linter, polish code
varex83 Dec 29, 2025
529d794
fix: cargo deny dependency issue
varex83 Dec 29, 2025
1eb752e
chore: add docs
varex83 Dec 30, 2025
7b72369
refactor: move relay-server to a different crate
varex83 Dec 30, 2025
90584d0
Merge remote-tracking branch 'origin/main' into bohdan/p2p-relay-server
varex83 Jan 12, 2026
b4a7be2
fix: remove unnecessary tick skip
varex83 Jan 12, 2026
c6ee116
fix: remove unused fn, drop lock after usage
varex83 Jan 12, 2026
8a0b118
fix: linter
varex83 Jan 12, 2026
5fd2e1b
fix: module visibility
varex83 Jan 12, 2026
a1ca920
feat: add bon support
varex83 Jan 12, 2026
f0a1830
feat: make ping config unconfigurable, use default ping config instead
varex83 Jan 12, 2026
281cc0e
fix: set ping timeout to 10 seconds
varex83 Jan 12, 2026
f7590f0
feat: add user agent support
varex83 Jan 12, 2026
efbaa5b
feat: make relay identify protocol const
varex83 Jan 13, 2026
231a80a
Merge remote-tracking branch 'origin/main' into bohdan/p2p-relay-server
varex83 Jan 13, 2026
42bfce4
Merge remote-tracking branch 'origin/main' into bohdan/p2p-relay-server
varex83 Jan 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 46 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"crates/charon-testutil",
"crates/tracing",
"crates/eth2api",
"crates/relay-server"
]
resolver = "3"

Expand All @@ -28,9 +29,10 @@ alloy = { version = "1.3", features = ["essentials"] }
built = { version = "0.8.0", features = ["git2", "chrono", "cargo-lock"] }
blst = "0.3"
anyhow = "1"
axum = "0.8.6"
cancellation = "0.1.0"
chrono = { version = "0.4", features = ["serde"] }
clap = { version = "4.5", features = ["derive", "env", "cargo"] }
clap = { version = "4.5.53", features = ["derive", "env", "cargo"] }
crossbeam = "0.8.4"
backon = "1.6.0"
hex = { version = "0.4.3" }
Expand All @@ -43,7 +45,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
thiserror = "2.0"
tokio = { version = "1", features = ["full"] }
tokio-util = { version = "0.7" }
tokio-util = "0.7.11"
libp2p = { version = "0.56", features = ["full", "secp256k1"] }
url = "2.5"
uuid = { version = "1.19", features = ["serde", "v4"] }
Expand Down Expand Up @@ -76,6 +78,7 @@ charon-k1util = { path = "crates/charon-k1util" }
charon-p2p = { path = "crates/charon-p2p" }
charon-testutil = { path = "crates/charon-testutil" }
charon-tracing = { path = "crates/tracing" }
charon-relay-server = { path = "crates/relay-server" }
eth2api = { path = "crates/eth2api" }

[workspace.lints.rust]
Expand Down
7 changes: 7 additions & 0 deletions crates/charon-p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ license.workspace = true
publish.workspace = true

[dependencies]
axum.workspace = true
chrono.workspace = true
libp2p.workspace = true
thiserror.workspace = true
Expand All @@ -15,8 +16,14 @@ charon-eth2.workspace = true
charon-k1util.workspace = true
vise.workspace = true
tokio.workspace = true
tokio-util.workspace = true
rand.workspace = true
tempfile.workspace = true
charon-tracing.workspace = true
tracing.workspace = true
serde.workspace = true
serde_json.workspace = true
charon-core.workspace = true

[dev-dependencies]
charon-testutil.workspace = true
Expand Down
2 changes: 0 additions & 2 deletions crates/charon-p2p/examples/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use charon_p2p::{
pluto_mdns::{PlutoMdnsBehaviour, PlutoMdnsBehaviourEvent},
},
config::P2PConfig,
gater::ConnGater,
p2p::{Node, NodeType},
};
use clap::Parser;
Expand Down Expand Up @@ -40,7 +39,6 @@ async fn main() -> Result<()> {
let mut p2p: Node<_> = Node::new(
P2PConfig::default(),
key.clone(),
ConnGater::new_open_gater(),
false,
NodeType::QUIC,
PlutoMdnsBehaviour::new,
Expand Down
85 changes: 73 additions & 12 deletions crates/charon-p2p/src/behaviours/pluto.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
//! Pluto behaviour.

use std::time::Duration;
use std::sync::LazyLock;

use libp2p::{identify, identity::Keypair, ping, relay, swarm::NetworkBehaviour};

use crate::gater::ConnGater;
use crate::{config::default_ping_config, gater::ConnGater};

/// Pluto network behaviour.
#[derive(NetworkBehaviour)]
pub struct PlutoBehaviour {
/// Connection gater behaviour.
Expand All @@ -19,20 +20,80 @@ pub struct PlutoBehaviour {
}

impl PlutoBehaviour {
/// Creates a new Pluto behaviour.
/// Creates a new Pluto behaviour with default configuration.
pub fn new(key: &Keypair, relay_client: relay::client::Behaviour) -> Self {
PlutoBehaviourBuilder::default().build(key, relay_client)
}

/// Returns a new builder for configuring a PlutoBehaviour.
pub fn builder() -> PlutoBehaviourBuilder {
PlutoBehaviourBuilder::default()
}
}

/// The default user agent for the Pluto network.
pub static DEFAULT_USER_AGENT: LazyLock<String> =
LazyLock::new(|| format!("pluto/{}", *charon_core::version::VERSION));

/// The default identify protocol for the Pluto network.
pub static DEFAULT_IDENTIFY_PROTOCOL: LazyLock<String> =
LazyLock::new(|| format!("/pluto/{}", *charon_core::version::VERSION));

/// Builder for [`PlutoBehaviour`].
#[derive(Debug, Clone)]
pub struct PlutoBehaviourBuilder {
gater: Option<ConnGater>,
identify_protocol: String,
Comment thread
emlautarom1 marked this conversation as resolved.
user_agent: String,
}

impl Default for PlutoBehaviourBuilder {
fn default() -> Self {
Self {
gater: None,
identify_protocol: DEFAULT_IDENTIFY_PROTOCOL.clone(),
user_agent: DEFAULT_USER_AGENT.clone(),
}
}
}

impl PlutoBehaviourBuilder {
/// Creates a new builder with default configuration.
pub fn new() -> Self {
Self::default()
}

/// Sets the connection gater.
pub fn with_gater(mut self, gater: ConnGater) -> Self {
self.gater = Some(gater);
self
}

/// Sets the identify protocol string.
pub fn with_identify_protocol(mut self, protocol: impl Into<String>) -> Self {
self.identify_protocol = protocol.into();
self
}

/// Sets the user agent string.
pub fn with_user_agent(mut self, user_agent: impl Into<String>) -> Self {
self.user_agent = user_agent.into();
self
}

/// Builds the [`PlutoBehaviour`] with the provided keypair and relay
/// client.
pub fn build(self, key: &Keypair, relay_client: relay::client::Behaviour) -> PlutoBehaviour {
PlutoBehaviour {
gater: self
.gater
.unwrap_or_else(|| ConnGater::new_conn_gater(vec![], vec![])),
relay: relay_client,
identify: identify::Behaviour::new(identify::Config::new(
"/pluto/1.0.0-alpha".into(),
key.public(),
)),
ping: ping::Behaviour::new(
ping::Config::new()
.with_interval(Duration::from_secs(1))
.with_timeout(Duration::from_secs(2)),
identify: identify::Behaviour::new(
identify::Config::new(self.identify_protocol, key.public())
.with_agent_version(self.user_agent),
),
gater: ConnGater::new_conn_gater(vec![], vec![]),
ping: ping::Behaviour::new(default_ping_config()),
}
}
}
Loading