Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
- Add network metrics for peer identification and tracking
- Add transport level connection limits
- Limit the number of peers that can connect from same IP address
- Update `libp2p-scatter` to v0.4.0-rc.1 ([#1473](https://github.com/circlefin/malachite/pull/1473))

### `signing`
- Implement `SigningProvider` for `Arc<T>` where `T: SigningProvider`
Expand Down
9 changes: 2 additions & 7 deletions code/Cargo.lock

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

2 changes: 1 addition & 1 deletion code/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ itertools = "0.14"
itf = "0.2.3"
libp2p = { version = "0.56.0", features = ["macros", "identify", "tokio", "ed25519", "ecdsa", "tcp", "quic", "noise", "yamux", "gossipsub", "dns", "ping", "metrics", "request-response", "cbor", "serde", "kad"] }
libp2p-identity = "0.2.12"
libp2p-broadcast = { version = "0.4.0-rc.1", features = ["metrics"], package = "libp2p-scatter" }
libp2p-broadcast = { version = "0.3.0", package = "libp2p-scatter" }
libp2p-gossipsub = { version = "0.49.0", features = ["metrics"] }
multiaddr = "0.18.2"
multihash = { version = "0.19.3", default-features = false }
Expand Down
1 change: 0 additions & 1 deletion code/crates/app/src/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ fn make_network_config(cfg: &ConsensusConfig, value_sync_cfg: &ValueSyncConfig)
discovery_kad: cfg.p2p.protocol_names.discovery_kad.clone(),
discovery_regres: cfg.p2p.protocol_names.discovery_regres.clone(),
sync: cfg.p2p.protocol_names.sync.clone(),
broadcast: cfg.p2p.protocol_names.broadcast.clone(),
},
}
}
12 changes: 3 additions & 9 deletions code/crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ mod utils;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ProtocolNames {
pub consensus: String,

pub discovery_kad: String,

pub discovery_regres: String,

pub sync: String,
pub broadcast: String,
}

impl Default for ProtocolNames {
Expand All @@ -25,7 +27,6 @@ impl Default for ProtocolNames {
discovery_kad: "/malachitebft-discovery/kad/v1beta1".to_string(),
discovery_regres: "/malachitebft-discovery/reqres/v1beta1".to_string(),
sync: "/malachitebft-sync/v1beta1".to_string(),
broadcast: "/malachitebft-broadcast/v1beta1".to_string(),
}
}
}
Expand Down Expand Up @@ -867,7 +868,6 @@ mod tests {
discovery_kad: "/custom-discovery/kad/v1".to_string(),
discovery_regres: "/custom-discovery/reqres/v1".to_string(),
sync: "/custom-sync/v1".to_string(),
broadcast: "/custom-broadcast/v1".to_string(),
};

let json = serde_json::to_string(&protocol_names).unwrap();
Expand All @@ -890,7 +890,6 @@ mod tests {
discovery_kad: "/test-network/discovery/kad/v1".to_string(),
discovery_regres: "/test-network/discovery/reqres/v1".to_string(),
sync: "/test-network/sync/v1".to_string(),
broadcast: "/test-network/broadcast/v1".to_string(),
};

let config_with_custom = P2pConfig {
Expand Down Expand Up @@ -924,7 +923,6 @@ mod tests {
discovery_kad = "/custom-network/discovery/kad/v2"
discovery_regres = "/custom-network/discovery/reqres/v2"
sync = "/custom-network/sync/v2"
broadcast = "/custom-network/broadcast/v2"

[p2p.protocol]
type = "gossipsub"
Expand All @@ -945,10 +943,6 @@ mod tests {
"/custom-network/discovery/reqres/v2"
);
assert_eq!(config.p2p.protocol_names.sync, "/custom-network/sync/v2");
assert_eq!(
config.p2p.protocol_names.broadcast,
"/custom-network/broadcast/v2"
);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion code/crates/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ either = { workspace = true }
eyre = { workspace = true }
futures = { workspace = true }
libp2p = { workspace = true }
libp2p-broadcast = { workspace = true, features = ["metrics"] }
libp2p-broadcast = { workspace = true }
libp2p-gossipsub = { workspace = true, features = ["metrics"] }
seahash = { workspace = true }
serde = { workspace = true }
Expand Down
19 changes: 6 additions & 13 deletions code/crates/network/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ use std::convert::Infallible;
use std::time::Duration;

use eyre::Result;
use libp2p::connection_limits;
pub use libp2p::identity::Keypair;
use libp2p::kad::{Addresses, KBucketKey, KBucketRef};
use libp2p::request_response::{OutboundRequestId, ResponseChannel};
use libp2p::swarm::behaviour::toggle::Toggle;
use libp2p::swarm::NetworkBehaviour;
use libp2p::{connection_limits, StreamProtocol};
use libp2p::{gossipsub, identify, ping};
use libp2p_broadcast as broadcast;

pub use libp2p::identity::Keypair;
pub use libp2p::{Multiaddr, PeerId};
use libp2p_broadcast as broadcast;

use malachitebft_discovery as discovery;
use malachitebft_metrics::Registry;
Expand Down Expand Up @@ -241,17 +240,11 @@ impl Behaviour {

let enable_broadcast = (config.pubsub_protocol.is_broadcast() && config.enable_consensus)
|| config.enable_sync;

let broadcast = enable_broadcast.then(|| {
let protocol = StreamProtocol::try_from_owned(config.protocol_names.broadcast.clone())
.expect("Invalid protocol name for broadcast");

let config = broadcast::Config::default()
.protocol_name(protocol)
.max_message_size(config.pubsub_max_size);

broadcast::Behaviour::new_with_metrics(
config,
broadcast::Config {
max_buf_size: config.pubsub_max_size,
},
registry.sub_registry_with_prefix("broadcast"),
)
});
Expand Down
2 changes: 0 additions & 2 deletions code/crates/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ pub struct ProtocolNames {
pub discovery_kad: String,
pub discovery_regres: String,
pub sync: String,
pub broadcast: String,
}

impl Default for ProtocolNames {
Expand All @@ -70,7 +69,6 @@ impl Default for ProtocolNames {
discovery_kad: "/malachitebft-discovery/kad/v1beta1".to_string(),
discovery_regres: "/malachitebft-discovery/reqres/v1beta1".to_string(),
sync: "/malachitebft-sync/v1beta1".to_string(),
broadcast: "/malachitebft-broadcast/v1beta1".to_string(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion code/crates/network/src/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn publish(
}
PubSubProtocol::Broadcast => {
if let Some(broadcast) = swarm.behaviour_mut().broadcast.as_mut() {
broadcast.broadcast(channel.to_broadcast_topic(channel_names), data);
broadcast.broadcast(&channel.to_broadcast_topic(channel_names), data);
} else {
return Err(eyre::eyre!("Broadcast not enabled"));
}
Expand Down
1 change: 0 additions & 1 deletion code/crates/starknet/host/src/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ async fn spawn_network_actor(
discovery_kad: cfg.consensus.p2p.protocol_names.discovery_kad.clone(),
discovery_regres: cfg.consensus.p2p.protocol_names.discovery_regres.clone(),
sync: cfg.consensus.p2p.protocol_names.sync.clone(),
broadcast: cfg.consensus.p2p.protocol_names.broadcast.clone(),
},
};

Expand Down