mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 04:07:57 +00:00
*: Update to libp2p v0.33.0 (#7759)
* *: Update to libp2p v0.33.0 * client/network: Consistently track request arrival time With https://github.com/libp2p/rust-libp2p/pull/1886/ one is guaranteed to receive either a `ResponseSent` or a `InboundFailure` event for each received inbound request via `RequestResponseEvent::Message`. Given this guarantee there is no need to track arrival times in a best-effort manner and thus there is no need to use a LRU cache for arrival times. * client/offchain: Adjust to PeerId API changes
This commit is contained in:
Generated
+55
-48
@@ -716,6 +716,15 @@ dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cipher"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801"
|
||||
dependencies = [
|
||||
"generic-array 0.14.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ckb-merkle-mountain-range"
|
||||
version = "0.3.1"
|
||||
@@ -2819,9 +2828,9 @@ checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a"
|
||||
|
||||
[[package]]
|
||||
name = "libp2p"
|
||||
version = "0.32.2"
|
||||
version = "0.33.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "022cdac4ab124be12de581e591796d4dfb7d1f1eef94669d2c1eaa0e98dd2f0e"
|
||||
checksum = "2e17c636b5fe5ff900ccc2840b643074bfac321551d821243a781d0d46f06588"
|
||||
dependencies = [
|
||||
"atomic",
|
||||
"bytes 0.5.6",
|
||||
@@ -2857,13 +2866,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-core"
|
||||
version = "0.25.2"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc9c96d3a606a696a3a6c0ad3c3352c57bda2082ec9090930f1bd9daf787039f"
|
||||
checksum = "e1cb706da14c064dce54d8864ade6836b3486b51689300da74eeb7053aa4551e"
|
||||
dependencies = [
|
||||
"asn1_der",
|
||||
"bs58",
|
||||
"bytes 0.5.6",
|
||||
"ed25519-dalek",
|
||||
"either",
|
||||
"fnv",
|
||||
@@ -2902,9 +2910,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-deflate"
|
||||
version = "0.25.0"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a579d7dd506d0620ba88ccc1754436b7de35ed6c884234f9a226bbfce382640"
|
||||
checksum = "e3257a41f376aa23f237231971fee7e350e4d8353cfcf233aef34d6d6b638f0c"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"futures 0.3.8",
|
||||
@@ -2913,9 +2921,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-dns"
|
||||
version = "0.25.0"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "15dea5933f570844d7b5222b12b58f7bd52e9ca38cd65a1bd4f35341f053f012"
|
||||
checksum = "2e09bab25af01326b4ed9486d31325911437448edda30bc57681502542d49f20"
|
||||
dependencies = [
|
||||
"futures 0.3.8",
|
||||
"libp2p-core",
|
||||
@@ -2924,9 +2932,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-floodsub"
|
||||
version = "0.25.0"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23070a0838bd9a8adb27e6eba477eeb650c498f9d139383dd0135d20a8170253"
|
||||
checksum = "6fd8cdd5ef1dd0b7346975477216d752de976b92e43051bc8bd808c372ea6cec"
|
||||
dependencies = [
|
||||
"cuckoofilter",
|
||||
"fnv",
|
||||
@@ -2942,9 +2950,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-gossipsub"
|
||||
version = "0.25.0"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65e8f3aa0906fbad435dac23c177eef3cdfaaf62609791bd7f54f8553edcfdf9"
|
||||
checksum = "d489531aa9d4ba8726a08b3b74e21c2e10a518ad266ebca98d79040123ab0036"
|
||||
dependencies = [
|
||||
"base64 0.13.0",
|
||||
"byteorder",
|
||||
@@ -2968,9 +2976,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-identify"
|
||||
version = "0.25.0"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "802fb973a7e0dde3fb9a2113a62bad90338ebe01983b706e1d576d0c2af93cda"
|
||||
checksum = "c43bc51a9bc3780288c526615ba0f5f8216820ea6dcc02b89e8daee526c5fccb"
|
||||
dependencies = [
|
||||
"futures 0.3.8",
|
||||
"libp2p-core",
|
||||
@@ -2984,9 +2992,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-kad"
|
||||
version = "0.26.0"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6506b7b7982f7626fc96a91bc61be4b1fe7ae9ac23824f0ecefcce21cb39238c"
|
||||
checksum = "a226956b49438a10f3206480b8faf5e61fc445c349ea9d9cc37766a83745fa9a"
|
||||
dependencies = [
|
||||
"arrayvec 0.5.2",
|
||||
"bytes 0.5.6",
|
||||
@@ -3010,9 +3018,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-mdns"
|
||||
version = "0.26.0"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b934ee03a361f317df7d75defa4177b285534c58f49d5e6e240278e13ef3f65"
|
||||
checksum = "8a9e12688e8f14008c950c1efde587cb44dbf316fa805f419cd4e524991236f5"
|
||||
dependencies = [
|
||||
"async-io",
|
||||
"data-encoding",
|
||||
@@ -3031,9 +3039,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-mplex"
|
||||
version = "0.25.0"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae2132b14045009b0f8e577a06e1459592ef0a89dedc58f3d4baf4eac956837b"
|
||||
checksum = "ce3200fbe6608e623bd9efa459cc8bafa0e4efbb0a2dfcdd0e1387ff4181264b"
|
||||
dependencies = [
|
||||
"bytes 0.5.6",
|
||||
"futures 0.3.8",
|
||||
@@ -3049,9 +3057,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-noise"
|
||||
version = "0.27.0"
|
||||
version = "0.28.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9610a524bef4db383cd96b4ec3ec4722eafa72c7242fa89990b74166760583d"
|
||||
checksum = "0580e0d18019d254c9c349c03ff7b22e564b6f2ada70c045fc39738e144f2139"
|
||||
dependencies = [
|
||||
"bytes 0.5.6",
|
||||
"curve25519-dalek 3.0.0",
|
||||
@@ -3071,9 +3079,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-ping"
|
||||
version = "0.25.0"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "659adf89356e04f65398bb74ee791b269e63da9e41b37f8dc19eaacd12487bfe"
|
||||
checksum = "50b2ec86a18cbf09d7df440e7786a2409640c774e476e9a3b4d031382c3d7588"
|
||||
dependencies = [
|
||||
"futures 0.3.8",
|
||||
"libp2p-core",
|
||||
@@ -3086,9 +3094,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-plaintext"
|
||||
version = "0.25.0"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96dfe26270c91d4ff095030d1fcadd602f3fd84968ebd592829916d0715798a6"
|
||||
checksum = "6a7b1bdcbe46a3a2159c231601ed29645282653c0a96ce3a2ad8352c9fbe6800"
|
||||
dependencies = [
|
||||
"bytes 0.5.6",
|
||||
"futures 0.3.8",
|
||||
@@ -3103,13 +3111,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-pnet"
|
||||
version = "0.19.2"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96b3c2d5d26a9500e959a0e19743897239a6c4be78dadf99b70414301a70c006"
|
||||
checksum = "6ce3374f3b28162db9d3442c9347c4f14cb01e8290052615c7d341d40eae0599"
|
||||
dependencies = [
|
||||
"futures 0.3.8",
|
||||
"log",
|
||||
"pin-project 0.4.27",
|
||||
"pin-project 1.0.2",
|
||||
"rand 0.7.3",
|
||||
"salsa20",
|
||||
"sha3",
|
||||
@@ -3117,9 +3125,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-request-response"
|
||||
version = "0.7.0"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd96c3580fe59a9379ac7906c2f61c7f5ad3b7515362af0e72153a7cc9a45550"
|
||||
checksum = "620e2950decbf77554b5aed3824f7d0e2c04923f28c70f9bff1a402c47ef6b1e"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes 0.5.6",
|
||||
@@ -3137,9 +3145,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-swarm"
|
||||
version = "0.25.0"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "de333c483f27d02ecf7b6cef814a36f5e1876f15139eefb00225c405350e1c22"
|
||||
checksum = "fdf5894ee1ee63a38aa58d58a16e3dcf7ede6b59ea7b22302c00c1a41d7aec41"
|
||||
dependencies = [
|
||||
"either",
|
||||
"futures 0.3.8",
|
||||
@@ -3153,9 +3161,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-tcp"
|
||||
version = "0.25.1"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc28c9ad6dc43f4c3950411cf808639d90307a076330e7996e5e94e70279bde0"
|
||||
checksum = "1d2113a7dab2b502c55fe290910cd7399a2aa04fe70a2f5a415a87a1db600c0e"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"futures 0.3.8",
|
||||
@@ -3169,9 +3177,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-uds"
|
||||
version = "0.25.0"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d821208d4b9af4b293a56dde470edd9f9fac8bb94a51f4f5327cc29a471b3f3"
|
||||
checksum = "af05fe92c2a3aa320bc82a308ddb7b33bef3b060154c5a4b9fb0b01f15385fc0"
|
||||
dependencies = [
|
||||
"async-std",
|
||||
"futures 0.3.8",
|
||||
@@ -3181,9 +3189,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-wasm-ext"
|
||||
version = "0.25.0"
|
||||
version = "0.26.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e6ef400b231ba78e866b860445480ca21ee447e03034138c6d57cf2969d6bf4"
|
||||
checksum = "37cd44ea05a4523f40183f60ab6e6a80e400a5ddfc98b0df1c55edeb85576cd9"
|
||||
dependencies = [
|
||||
"futures 0.3.8",
|
||||
"js-sys",
|
||||
@@ -3195,9 +3203,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-websocket"
|
||||
version = "0.26.3"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "522a877ce42ededf1f5dd011dbc40ea116f1776818f09dacb3d7a206f3ad6305"
|
||||
checksum = "270c80528e21089ea25b41dd1ab8fd834bdf093ebee422fed3b68699a857a083"
|
||||
dependencies = [
|
||||
"async-tls",
|
||||
"either",
|
||||
@@ -3215,9 +3223,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-yamux"
|
||||
version = "0.28.0"
|
||||
version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3be7ac000fa3e42ac09a6e658e48de34ac8ef9fff64a4e6e6b08dcc8f4b0e5f6"
|
||||
checksum = "36799de9092c35782f080032eddbc8de870f94a0def87cf9f8883efccd5cacf0"
|
||||
dependencies = [
|
||||
"futures 0.3.8",
|
||||
"libp2p-core",
|
||||
@@ -6372,11 +6380,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "salsa20"
|
||||
version = "0.6.0"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c7f47b10fa80f6969bbbd9c8e7cc998f082979d402a9e10579e2303a87955395"
|
||||
checksum = "399f290ffc409596022fce5ea5d4138184be4784f2b28c62c59f0d8389059a15"
|
||||
dependencies = [
|
||||
"stream-cipher",
|
||||
"cipher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -7101,7 +7109,6 @@ dependencies = [
|
||||
"linked-hash-map",
|
||||
"linked_hash_set",
|
||||
"log",
|
||||
"lru",
|
||||
"nohash-hasher",
|
||||
"parity-scale-codec",
|
||||
"parking_lot 0.11.1",
|
||||
|
||||
@@ -8,7 +8,7 @@ license = "Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
futures-timer = "3.0.2"
|
||||
libp2p = { version = "0.32.2", default-features = false }
|
||||
libp2p = { version = "0.33.0", default-features = false }
|
||||
jsonrpc-core = "15.0.0"
|
||||
serde = "1.0.106"
|
||||
serde_json = "1.0.48"
|
||||
|
||||
@@ -23,7 +23,7 @@ derive_more = "0.99.2"
|
||||
either = "1.5.3"
|
||||
futures = "0.3.4"
|
||||
futures-timer = "3.0.1"
|
||||
libp2p = { version = "0.32.2", default-features = false, features = ["kad"] }
|
||||
libp2p = { version = "0.33.0", default-features = false, features = ["kad"] }
|
||||
log = "0.4.8"
|
||||
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus", version = "0.8.0"}
|
||||
prost = "0.6.1"
|
||||
|
||||
@@ -19,7 +19,7 @@ regex = "1.4.2"
|
||||
tokio = { version = "0.2.21", features = [ "signal", "rt-core", "rt-threaded", "blocking" ] }
|
||||
futures = "0.3.4"
|
||||
fdlimit = "0.2.1"
|
||||
libp2p = "0.32.2"
|
||||
libp2p = "0.33.0"
|
||||
parity-scale-codec = "1.3.0"
|
||||
hex = "0.4.2"
|
||||
rand = "0.7.3"
|
||||
|
||||
@@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
[dependencies]
|
||||
futures = "0.3.4"
|
||||
futures-timer = "3.0.1"
|
||||
libp2p = { version = "0.32.2", default-features = false }
|
||||
libp2p = { version = "0.33.0", default-features = false }
|
||||
log = "0.4.8"
|
||||
lru = "0.6.1"
|
||||
sc-network = { version = "0.8.0", path = "../network" }
|
||||
|
||||
@@ -36,7 +36,6 @@ ip_network = "0.3.4"
|
||||
linked-hash-map = "0.5.2"
|
||||
linked_hash_set = "0.1.3"
|
||||
log = "0.4.8"
|
||||
lru = "0.6.1"
|
||||
nohash-hasher = "0.2.0"
|
||||
parking_lot = "0.11.1"
|
||||
pin-project = "0.4.6"
|
||||
@@ -64,13 +63,13 @@ wasm-timer = "0.2"
|
||||
zeroize = "1.2.0"
|
||||
|
||||
[dependencies.libp2p]
|
||||
version = "0.32.2"
|
||||
version = "0.33.0"
|
||||
default-features = false
|
||||
features = ["identify", "kad", "mdns", "mplex", "noise", "ping", "request-response", "tcp-async-std", "websocket", "yamux"]
|
||||
|
||||
[dev-dependencies]
|
||||
assert_matches = "1.3"
|
||||
libp2p = { version = "0.32.2", default-features = false }
|
||||
libp2p = { version = "0.33.0", default-features = false }
|
||||
quickcheck = "0.9.0"
|
||||
rand = "0.7.2"
|
||||
sp-keyring = { version = "2.0.0", path = "../../primitives/keyring" }
|
||||
|
||||
@@ -90,7 +90,7 @@ pub enum BehaviourOut<B: BlockT> {
|
||||
protocol: Cow<'static, str>,
|
||||
/// If `Ok`, contains the time elapsed between when we received the request and when we
|
||||
/// sent back the response. If `Err`, the error that happened.
|
||||
result: Result<Option<Duration>, ResponseFailure>,
|
||||
result: Result<Duration, ResponseFailure>,
|
||||
},
|
||||
|
||||
/// A request initiated using [`Behaviour::send_request`] has succeeded or failed.
|
||||
@@ -419,7 +419,7 @@ impl<B: BlockT, H: ExHashT> NetworkBehaviourEventProcess<block_requests::Event<B
|
||||
self.events.push_back(BehaviourOut::InboundRequest {
|
||||
peer,
|
||||
protocol: self.block_requests.protocol_name().to_owned().into(),
|
||||
result: Ok(Some(total_handling_time)),
|
||||
result: Ok(total_handling_time),
|
||||
});
|
||||
},
|
||||
block_requests::Event::Response { peer, response, request_duration } => {
|
||||
|
||||
@@ -50,7 +50,6 @@ use libp2p::{
|
||||
PollParameters, ProtocolsHandler,
|
||||
},
|
||||
};
|
||||
use lru::LruCache;
|
||||
use std::{
|
||||
borrow::Cow, collections::{hash_map::Entry, HashMap}, convert::TryFrom as _, io, iter,
|
||||
pin::Pin, task::{Context, Poll}, time::{Duration, Instant},
|
||||
@@ -129,12 +128,11 @@ pub enum Event {
|
||||
peer: PeerId,
|
||||
/// Name of the protocol in question.
|
||||
protocol: Cow<'static, str>,
|
||||
/// If `Ok`, contains the time elapsed between when we received the request and when we
|
||||
/// sent back the response. If `Err`, the error that happened.
|
||||
/// Whether handling the request was successful or unsuccessful.
|
||||
///
|
||||
/// Note: Given that response time is tracked on a best-effort basis only, `Ok(time)` can be
|
||||
/// `None`.
|
||||
result: Result<Option<Duration>, ResponseFailure>,
|
||||
/// When successful contains the time elapsed between when we received the request and when
|
||||
/// we sent back the response. When unsuccessful contains the failure reason.
|
||||
result: Result<Duration, ResponseFailure>,
|
||||
},
|
||||
|
||||
/// A request initiated using [`RequestResponsesBehaviour::send_request`] has succeeded or
|
||||
@@ -164,7 +162,7 @@ pub struct RequestResponsesBehaviour {
|
||||
>,
|
||||
|
||||
/// Whenever an incoming request arrives, the arrival [`Instant`] is recorded here.
|
||||
pending_responses_arrival_time: LruCache<RequestId, Instant>,
|
||||
pending_responses_arrival_time: HashMap<RequestId, Instant>,
|
||||
}
|
||||
|
||||
/// Generated by the response builder and waiting to be processed.
|
||||
@@ -206,7 +204,7 @@ impl RequestResponsesBehaviour {
|
||||
Ok(Self {
|
||||
protocols,
|
||||
pending_responses: Default::default(),
|
||||
pending_responses_arrival_time: LruCache::new(1_000),
|
||||
pending_responses_arrival_time: Default::default(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -367,9 +365,8 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
|
||||
|
||||
if let Some((protocol, _)) = self.protocols.get_mut(&*protocol_name) {
|
||||
if let Err(_) = protocol.send_response(inner_channel, Ok(response)) {
|
||||
// Note: In case this happened due to a timeout, the corresponding
|
||||
// `RequestResponse` behaviour will emit an `InboundFailure::Timeout` event.
|
||||
self.pending_responses_arrival_time.pop(&request_id);
|
||||
// Note: Failure is handled further below when receiving `InboundFailure`
|
||||
// event from `RequestResponse` behaviour.
|
||||
log::debug!(
|
||||
target: "sub-libp2p",
|
||||
"Failed to send response for {:?} on protocol {:?} due to a \
|
||||
@@ -425,7 +422,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
|
||||
peer,
|
||||
message: RequestResponseMessage::Request { request_id, request, channel, .. },
|
||||
} => {
|
||||
self.pending_responses_arrival_time.put(
|
||||
self.pending_responses_arrival_time.insert(
|
||||
request_id.clone(),
|
||||
Instant::now(),
|
||||
);
|
||||
@@ -495,7 +492,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
|
||||
// An inbound request failed, either while reading the request or due to failing
|
||||
// to send a response.
|
||||
RequestResponseEvent::InboundFailure { request_id, peer, error, .. } => {
|
||||
self.pending_responses_arrival_time.pop(&request_id);
|
||||
self.pending_responses_arrival_time.remove(&request_id);
|
||||
let out = Event::InboundRequest {
|
||||
peer,
|
||||
protocol: protocol.clone(),
|
||||
@@ -504,14 +501,9 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
|
||||
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(out));
|
||||
}
|
||||
RequestResponseEvent::ResponseSent { request_id, peer } => {
|
||||
let arrival_time = self.pending_responses_arrival_time.pop(&request_id)
|
||||
.map(|t| t.elapsed());
|
||||
if arrival_time.is_none() {
|
||||
log::debug!(
|
||||
"Expected to find arrival time for sent response. Is the LRU \
|
||||
cache size set too small?",
|
||||
);
|
||||
}
|
||||
let arrival_time = self.pending_responses_arrival_time.remove(&request_id)
|
||||
.map(|t| t.elapsed())
|
||||
.expect("To find request arrival time for answered request.");
|
||||
|
||||
let out = Event::InboundRequest {
|
||||
peer,
|
||||
|
||||
@@ -1373,14 +1373,11 @@ impl<B: BlockT + 'static, H: ExHashT> Future for NetworkWorker<B, H> {
|
||||
Poll::Ready(SwarmEvent::Behaviour(BehaviourOut::InboundRequest { protocol, result, .. })) => {
|
||||
if let Some(metrics) = this.metrics.as_ref() {
|
||||
match result {
|
||||
Ok(Some(serve_time)) => {
|
||||
Ok(serve_time) => {
|
||||
metrics.requests_in_success_total
|
||||
.with_label_values(&[&protocol])
|
||||
.observe(serve_time.as_secs_f64());
|
||||
}
|
||||
// Response time tracking is happening on a best-effort basis. Ignore
|
||||
// the event in case response time could not be provided.
|
||||
Ok(None) => {},
|
||||
Err(err) => {
|
||||
let reason = match err {
|
||||
ResponseFailure::Network(InboundFailure::Timeout) => "timeout",
|
||||
@@ -1388,6 +1385,8 @@ impl<B: BlockT + 'static, H: ExHashT> Future for NetworkWorker<B, H> {
|
||||
"unsupported",
|
||||
ResponseFailure::Network(InboundFailure::ResponseOmission) =>
|
||||
"busy-omitted",
|
||||
ResponseFailure::Network(InboundFailure::ConnectionClosed) =>
|
||||
"connection-closed",
|
||||
};
|
||||
|
||||
metrics.requests_in_failure_total
|
||||
|
||||
@@ -19,7 +19,7 @@ parking_lot = "0.10.0"
|
||||
futures = "0.3.4"
|
||||
futures-timer = "3.0.1"
|
||||
rand = "0.7.2"
|
||||
libp2p = { version = "0.32.2", default-features = false }
|
||||
libp2p = { version = "0.33.0", default-features = false }
|
||||
sp-consensus = { version = "0.8.0", path = "../../../primitives/consensus/common" }
|
||||
sc-consensus = { version = "0.8.0", path = "../../consensus/common" }
|
||||
sc-client-api = { version = "2.0.0", path = "../../api" }
|
||||
|
||||
@@ -187,9 +187,9 @@ impl<Storage: OffchainStorage> OffchainExt for Api<Storage> {
|
||||
|
||||
fn set_authorized_nodes(&mut self, nodes: Vec<OpaquePeerId>, authorized_only: bool) {
|
||||
let peer_ids: HashSet<PeerId> = nodes.into_iter()
|
||||
.filter_map(|node| PeerId::from_bytes(node.0).ok())
|
||||
.filter_map(|node| PeerId::from_bytes(&node.0).ok())
|
||||
.collect();
|
||||
|
||||
|
||||
self.network_provider.set_authorized_peers(peer_ids);
|
||||
self.network_provider.set_authorized_only(authorized_only);
|
||||
}
|
||||
@@ -213,7 +213,7 @@ impl NetworkState {
|
||||
|
||||
impl From<NetworkState> for OpaqueNetworkState {
|
||||
fn from(state: NetworkState) -> OpaqueNetworkState {
|
||||
let enc = Encode::encode(&state.peer_id.into_bytes());
|
||||
let enc = Encode::encode(&state.peer_id.to_bytes());
|
||||
let peer_id = OpaquePeerId::new(enc);
|
||||
|
||||
let external_addresses: Vec<OpaqueMultiaddr> = state
|
||||
@@ -239,7 +239,7 @@ impl TryFrom<OpaqueNetworkState> for NetworkState {
|
||||
let inner_vec = state.peer_id.0;
|
||||
|
||||
let bytes: Vec<u8> = Decode::decode(&mut &inner_vec[..]).map_err(|_| ())?;
|
||||
let peer_id = PeerId::from_bytes(bytes).map_err(|_| ())?;
|
||||
let peer_id = PeerId::from_bytes(&bytes).map_err(|_| ())?;
|
||||
|
||||
let external_addresses: Result<Vec<Multiaddr>, Self::Error> = state.external_addresses
|
||||
.iter()
|
||||
|
||||
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
futures = "0.3.4"
|
||||
libp2p = { version = "0.32.2", default-features = false }
|
||||
libp2p = { version = "0.33.0", default-features = false }
|
||||
sp-utils = { version = "2.0.0", path = "../../primitives/utils"}
|
||||
log = "0.4.8"
|
||||
serde_json = "1.0.41"
|
||||
|
||||
@@ -19,7 +19,7 @@ parking_lot = "0.10.0"
|
||||
futures = "0.3.4"
|
||||
futures-timer = "3.0.1"
|
||||
wasm-timer = "0.2.5"
|
||||
libp2p = { version = "0.32.2", default-features = false, features = ["dns", "tcp-async-std", "wasm-ext", "websocket"] }
|
||||
libp2p = { version = "0.33.0", default-features = false, features = ["dns", "tcp-async-std", "wasm-ext", "websocket"] }
|
||||
log = "0.4.8"
|
||||
pin-project = "0.4.6"
|
||||
rand = "0.7.2"
|
||||
|
||||
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
thiserror = "1.0.21"
|
||||
libp2p = { version = "0.32.2", default-features = false }
|
||||
libp2p = { version = "0.33.0", default-features = false }
|
||||
log = "0.4.8"
|
||||
sp-core = { path= "../../core", version = "2.0.0"}
|
||||
sp-inherents = { version = "2.0.0", path = "../../inherents" }
|
||||
|
||||
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
futures = { version = "0.3", features = ["compat"] }
|
||||
futures01 = { package = "futures", version = "0.1.29" }
|
||||
log = "0.4.8"
|
||||
libp2p-wasm-ext = { version = "0.25", features = ["websocket"] }
|
||||
libp2p-wasm-ext = { version = "0.26", features = ["websocket"] }
|
||||
console_error_panic_hook = "0.1.6"
|
||||
console_log = "0.2.0"
|
||||
js-sys = "0.3.34"
|
||||
|
||||
Reference in New Issue
Block a user