Skip to content

Commit

Permalink
deps(network): sync with upstream yamux (#2030)
Browse files Browse the repository at this point in the history
* libp2p-yamux now uses yamux v0.13 (new version) by default and fall back to yamux v0.12 (old version) when setting any configuration options.
* Additionally, this commit increases the backpressure buffer cap from 25 to 256.
* Use new protocol version (Version2) for peer exchange and request-response behaviours.
  • Loading branch information
onur-ozkan authored Dec 14, 2023
1 parent c66afb3 commit da8a23b
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 30 deletions.
71 changes: 45 additions & 26 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions mm2src/mm2_p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ void = "1.0"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
instant = "0.1.12"
libp2p = { git = "https://github.com/KomodoPlatform/rust-libp2p.git", tag = "k-0.52.1", default-features = false, features = ["dns", "identify", "floodsub", "gossipsub", "noise", "ping", "request-response", "secp256k1", "tcp", "tokio", "websocket", "macros", "yamux"] }
libp2p = { git = "https://github.com/KomodoPlatform/rust-libp2p.git", tag = "k-0.52.2", default-features = false, features = ["dns", "identify", "floodsub", "gossipsub", "noise", "ping", "request-response", "secp256k1", "tcp", "tokio", "websocket", "macros", "yamux"] }
tokio = { version = "1.20", default-features = false }

[target.'cfg(target_arch = "wasm32")'.dependencies]
instant = { version = "0.1.12", features = ["wasm-bindgen"] }
libp2p = { git = "https://github.com/KomodoPlatform/rust-libp2p.git", tag = "k-0.52.1", default-features = false, features = ["identify", "floodsub", "noise", "gossipsub", "ping", "request-response", "secp256k1", "wasm-ext", "wasm-ext-websocket", "macros", "yamux"] }
libp2p = { git = "https://github.com/KomodoPlatform/rust-libp2p.git", tag = "k-0.52.2", default-features = false, features = ["identify", "floodsub", "noise", "gossipsub", "ping", "request-response", "secp256k1", "wasm-ext", "wasm-ext-websocket", "macros", "yamux"] }

[dev-dependencies]
async-std = "1.6.2"
Expand Down
5 changes: 4 additions & 1 deletion mm2src/mm2_p2p/src/behaviours/peers_exchange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ impl<'de> Deserialize<'de> for PeerIdSerde {
#[derive(Debug, Clone)]
pub enum PeersExchangeProtocol {
Version1,
Version2,
}

impl AsRef<str> for PeersExchangeProtocol {
fn as_ref(&self) -> &str {
match self {
PeersExchangeProtocol::Version1 => "/peers-exchange/1",
PeersExchangeProtocol::Version2 => "/peers-exchange/2",
}
}
}
Expand Down Expand Up @@ -205,7 +207,8 @@ impl NetworkBehaviour for PeersExchange {
#[allow(clippy::new_without_default)]
impl PeersExchange {
pub fn new(network_info: NetworkInfo) -> Self {
let protocol = iter::once((PeersExchangeProtocol::Version1, ProtocolSupport::Full));
// We don't want to support V1 since it was only used in 7777 old layer.
let protocol = iter::once((PeersExchangeProtocol::Version2, ProtocolSupport::Full));
let config = RequestResponseConfig::default();
let request_response = RequestResponse::new(protocol, config);
PeersExchange {
Expand Down
5 changes: 4 additions & 1 deletion mm2src/mm2_p2p/src/behaviours/request_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ struct PendingRequest {
#[derive(Debug, Clone)]
pub enum Protocol {
Version1,
Version2,
}

impl AsRef<str> for Protocol {
fn as_ref(&self) -> &str {
match self {
Protocol::Version1 => "/request-response/1",
Protocol::Version2 => "/request-response/2",
}
}
}
Expand Down Expand Up @@ -393,7 +395,8 @@ impl From<libp2p::request_response::Event<PeerRequest, PeerResponse>> for Reques
/// Build a request-response network behaviour.
pub fn build_request_response_behaviour() -> RequestResponseBehaviour {
let config = RequestResponseConfig::default();
let protocol = core::iter::once((Protocol::Version1, ProtocolSupport::Full));
// We don't want to support V1 since it was only used in 7777 old layer.
let protocol = core::iter::once((Protocol::Version2, ProtocolSupport::Full));
let inner = RequestResponse::new(protocol, config);

let (tx, rx) = mpsc::unbounded();
Expand Down

0 comments on commit da8a23b

Please sign in to comment.