Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Cherry Pick of PR #9676 + #9391 #9704

Merged
merged 3 commits into from
Sep 7, 2021
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
415 changes: 233 additions & 182 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,6 @@ members = [
#
# This list is ordered alphabetically.
[profile.dev.package]
aes-soft = { opt-level = 3 }
aesni = { opt-level = 3 }
blake2 = { opt-level = 3 }
blake2-rfc = { opt-level = 3 }
blake2b_simd = { opt-level = 3 }
Expand Down
2 changes: 1 addition & 1 deletion bin/node/browser-testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "Apache-2.0"

[dependencies]
futures-timer = "3.0.2"
libp2p = { version = "0.37.1", default-features = false }
libp2p = { version = "0.39.1", default-features = false }
jsonrpc-core = "15.0.0"
serde = "1.0.126"
serde_json = "1.0.48"
Expand Down
2 changes: 1 addition & 1 deletion bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ try-runtime-cli = { version = "0.10.0-dev", optional = true, path = "../../../ut
wasm-bindgen = { version = "0.2.73", optional = true }
wasm-bindgen-futures = { version = "0.4.18", optional = true }
browser-utils = { package = "substrate-browser-utils", path = "../../../utils/browser", optional = true, version = "0.10.0-dev"}
libp2p-wasm-ext = { version = "0.28", features = ["websocket"], optional = true }
libp2p-wasm-ext = { version = "0.29", features = ["websocket"], optional = true }

[target.'cfg(target_arch="x86_64")'.dependencies]
node-executor = { version = "3.0.0-dev", path = "../executor", features = [ "wasmtime" ] }
Expand Down
6 changes: 3 additions & 3 deletions client/authority-discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ readme = "README.md"
targets = ["x86_64-unknown-linux-gnu"]

[build-dependencies]
prost-build = "0.7"
prost-build = "0.8"

[dependencies]
async-trait = "0.1"
Expand All @@ -24,10 +24,10 @@ either = "1.5.3"
futures = "0.3.9"
futures-timer = "3.0.1"
ip_network = "0.3.4"
libp2p = { version = "0.37.1", default-features = false, features = ["kad"] }
libp2p = { version = "0.39.1", default-features = false, features = ["kad"] }
log = "0.4.8"
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.9.0"}
prost = "0.7"
prost = "0.8"
rand = "0.7.2"
sc-client-api = { version = "4.0.0-dev", path = "../api" }
sc-network = { version = "0.10.0-dev", path = "../network" }
Expand Down
2 changes: 1 addition & 1 deletion client/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ regex = "1.4.2"
tokio = { version = "0.2.21", features = [ "signal", "rt-core", "rt-threaded", "blocking" ] }
futures = "0.3.9"
fdlimit = "0.2.1"
libp2p = "0.37.1"
libp2p = "0.39.1"
parity-scale-codec = "2.0.0"
hex = "0.4.2"
rand = "0.7.3"
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
thiserror = "1.0.21"
libp2p = { version = "0.37.1", default-features = false }
libp2p = { version = "0.39.1", default-features = false }
log = "0.4.8"
futures = { version = "0.3.1", features = ["thread-pool"] }
futures-timer = "3.0.1"
Expand Down
2 changes: 1 addition & 1 deletion client/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sc-executor-wasmi = { version = "0.10.0-dev", path = "wasmi" }
sc-executor-wasmtime = { version = "0.10.0-dev", path = "wasmtime", optional = true }
parking_lot = "0.11.1"
log = "0.4.8"
libsecp256k1 = "0.3.4"
libsecp256k1 = "0.6"

[dev-dependencies]
assert_matches = "1.3.0"
Expand Down
2 changes: 1 addition & 1 deletion client/finality-grandpa-warp-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ futures = "0.3.8"
log = "0.4.11"
num-traits = "0.2.14"
parking_lot = "0.11.1"
prost = "0.7"
prost = "0.8"
sc-client-api = { version = "4.0.0-dev", path = "../api" }
sc-finality-grandpa = { version = "0.10.0-dev", path = "../finality-grandpa" }
sc-network = { version = "0.10.0-dev", path = "../network" }
Expand Down
2 changes: 1 addition & 1 deletion client/network-gossip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
futures = "0.3.9"
futures-timer = "3.0.1"
libp2p = { version = "0.37.1", default-features = false }
libp2p = { version = "0.39.1", default-features = false }
log = "0.4.8"
lru = "0.6.5"
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.9.0", path = "../../utils/prometheus" }
Expand Down
10 changes: 5 additions & 5 deletions client/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ readme = "README.md"
targets = ["x86_64-unknown-linux-gnu"]

[build-dependencies]
prost-build = "0.7"
prost-build = "0.8"

[dependencies]
async-trait = "0.1"
Expand Down Expand Up @@ -42,7 +42,7 @@ nohash-hasher = "0.2.0"
parking_lot = "0.11.1"
pin-project = "1.0.4"
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.9.0", path = "../../utils/prometheus" }
prost = "0.7"
prost = "0.8"
rand = "0.7.2"
sc-block-builder = { version = "0.10.0-dev", path = "../block-builder" }
sc-client-api = { version = "4.0.0-dev", path = "../api" }
Expand All @@ -65,17 +65,17 @@ wasm-timer = "0.2"
zeroize = "1.2.0"

[dependencies.libp2p]
version = "0.37.1"
version = "0.39.1"

[target.'cfg(target_os = "unknown")'.dependencies.libp2p]
version = "0.37.1"
version = "0.39.1"
default-features = false
features = ["identify", "kad", "mdns", "mplex", "noise", "ping", "request-response", "tcp-async-io", "websocket", "yamux"]


[dev-dependencies]
assert_matches = "1.3"
libp2p = { version = "0.37.1", default-features = false }
libp2p = { version = "0.39.1", default-features = false }
quickcheck = "1.0.3"
rand = "0.7.2"
sp-keyring = { version = "4.0.0-dev", path = "../../primitives/keyring" }
Expand Down
6 changes: 3 additions & 3 deletions client/network/src/bitswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ where

fn upgrade_inbound(self, mut socket: TSocket, _info: Self::Info) -> Self::Future {
Box::pin(async move {
let packet = upgrade::read_one(&mut socket, MAX_PACKET_SIZE).await?;
let packet = upgrade::read_length_prefixed(&mut socket, MAX_PACKET_SIZE).await?;
let message: BitswapMessage = Message::decode(packet.as_slice())?;
Ok(message)
})
Expand Down Expand Up @@ -122,7 +122,7 @@ where
Box::pin(async move {
let mut data = Vec::with_capacity(self.encoded_len());
self.encode(&mut data)?;
upgrade::write_one(&mut socket, data).await
upgrade::write_length_prefixed(&mut socket, data).await
})
}
}
Expand Down Expand Up @@ -328,7 +328,7 @@ pub enum BitswapError {
/// Error parsing CID
BadCid(cid::Error),
/// Packet read error.
Read(upgrade::ReadOneError),
Read(io::Error),
/// Error sending response.
#[display(fmt = "Failed to send response.")]
SendResponse,
Expand Down
79 changes: 50 additions & 29 deletions client/network/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ impl NetworkBehaviour for DiscoveryBehaviour {
KademliaEvent::PendingRoutablePeer { .. } => {
// We are not interested in this event at the moment.
},
KademliaEvent::QueryResult {
KademliaEvent::OutboundQueryCompleted {
result: QueryResult::GetClosestPeers(res),
..
} => match res {
Expand All @@ -741,7 +741,7 @@ impl NetworkBehaviour for DiscoveryBehaviour {
}
},
},
KademliaEvent::QueryResult {
KademliaEvent::OutboundQueryCompleted {
result: QueryResult::GetRecord(res),
stats,
..
Expand Down Expand Up @@ -778,7 +778,7 @@ impl NetworkBehaviour for DiscoveryBehaviour {
};
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev))
},
KademliaEvent::QueryResult {
KademliaEvent::OutboundQueryCompleted {
result: QueryResult::PutRecord(res),
stats,
..
Expand All @@ -799,7 +799,7 @@ impl NetworkBehaviour for DiscoveryBehaviour {
};
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev))
},
KademliaEvent::QueryResult {
KademliaEvent::OutboundQueryCompleted {
result: QueryResult::RepublishRecord(res),
..
} => match res {
Expand Down Expand Up @@ -830,6 +830,11 @@ impl NetworkBehaviour for DiscoveryBehaviour {
address,
score,
}),
NetworkBehaviourAction::CloseConnection { peer_id, connection } =>
return Poll::Ready(NetworkBehaviourAction::CloseConnection {
peer_id,
connection,
}),
}
}
}
Expand Down Expand Up @@ -862,6 +867,11 @@ impl NetworkBehaviour for DiscoveryBehaviour {
address,
score,
}),
NetworkBehaviourAction::CloseConnection { peer_id, connection } =>
return Poll::Ready(NetworkBehaviourAction::CloseConnection {
peer_id,
connection,
}),
}
}

Expand Down Expand Up @@ -931,7 +941,7 @@ mod tests {
},
identity::Keypair,
noise,
swarm::Swarm,
swarm::{Swarm, SwarmEvent},
yamux, Multiaddr, PeerId,
};
use std::{collections::HashSet, task::Poll};
Expand Down Expand Up @@ -1000,31 +1010,42 @@ mod tests {
match swarms[swarm_n].0.poll_next_unpin(cx) {
Poll::Ready(Some(e)) => {
match e {
DiscoveryOut::UnroutablePeer(other) |
DiscoveryOut::Discovered(other) => {
// Call `add_self_reported_address` to simulate identify happening.
let addr = swarms
.iter()
.find_map(|(s, a)| {
if s.behaviour().local_peer_id == other {
Some(a.clone())
} else {
None
}
})
.unwrap();
swarms[swarm_n].0.behaviour_mut().add_self_reported_address(
&other,
[protocol_name_from_protocol_id(&protocol_id)].iter(),
addr,
);

to_discover[swarm_n].remove(&other);
},
DiscoveryOut::RandomKademliaStarted(_) => {},
e => {
panic!("Unexpected event: {:?}", e)
SwarmEvent::Behaviour(behavior) => {
match behavior {
DiscoveryOut::UnroutablePeer(other) |
DiscoveryOut::Discovered(other) => {
// Call `add_self_reported_address` to simulate identify
// happening.
let addr = swarms
.iter()
.find_map(|(s, a)| {
if s.behaviour().local_peer_id == other {
Some(a.clone())
} else {
None
}
})
.unwrap();
swarms[swarm_n]
.0
.behaviour_mut()
.add_self_reported_address(
&other,
[protocol_name_from_protocol_id(&protocol_id)]
.iter(),
addr,
);

to_discover[swarm_n].remove(&other);
},
DiscoveryOut::RandomKademliaStarted(_) => {},
e => {
panic!("Unexpected event: {:?}", e)
},
}
},
// ignore non Behaviour events
_ => {},
}
continue 'polling
},
Expand Down
10 changes: 10 additions & 0 deletions client/network/src/peer_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ impl NetworkBehaviour for PeerInfoBehaviour {
address,
score,
}),
Poll::Ready(NetworkBehaviourAction::CloseConnection { peer_id, connection }) =>
return Poll::Ready(NetworkBehaviourAction::CloseConnection {
peer_id,
connection,
}),
}
}

Expand Down Expand Up @@ -372,6 +377,11 @@ impl NetworkBehaviour for PeerInfoBehaviour {
address,
score,
}),
Poll::Ready(NetworkBehaviourAction::CloseConnection { peer_id, connection }) =>
return Poll::Ready(NetworkBehaviourAction::CloseConnection {
peer_id,
connection,
}),
}
}

Expand Down
2 changes: 2 additions & 0 deletions client/network/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,8 @@ impl<B: BlockT> NetworkBehaviour for Protocol<B> {
}),
Poll::Ready(NetworkBehaviourAction::ReportObservedAddr { address, score }) =>
return Poll::Ready(NetworkBehaviourAction::ReportObservedAddr { address, score }),
Poll::Ready(NetworkBehaviourAction::CloseConnection { peer_id, connection }) =>
return Poll::Ready(NetworkBehaviourAction::CloseConnection { peer_id, connection }),
};

let outcome = match event {
Expand Down
Loading