From c8c97226ddcf2b2f87bdab1015bc306f734304aa Mon Sep 17 00:00:00 2001 From: Dmitry Lavrenov <39522748+dmitrylavrenov@users.noreply.github.com> Date: Tue, 25 Jun 2024 11:01:20 +0300 Subject: [PATCH] Update deps to have `curve25519-dalek` v4.1.3 (to fix `RUSTSEC-2024-0344`) (#104) * Bump ed25519-zebra to 4.0.3 * Update Update schnorrkel to 0.11.4 and related to it deps * Bump ed25519-dalek to 2.0 * Upgrade to libp2p 0.51.3 (#13587) * client/network: upgrade to libp2p 0.51.0 * make discovery.rs compile * make peer_info.rs compile * changes to notifications and request-response proto * make service.rs compile * towards making request_responses.rs compile * make request_responses.rs compile * make request_responses.rs compile * fix notifications/behaviour.rs tests * fix warnings * remove old code * allow deprecated code (temporary) * upgrade to libp2p 0.51.1 * add TODO for behaviour tests * return empty vec if peer_id is absent https://github.com/paritytech/substrate/pull/13587#discussion_r1141695167 fyi: I don't really know what the old behaviour was. * update comment to reflect new defaults Closes #13338 * Revert "update comment to reflect new defaults" This reverts commit 7a981abd69308e9d522ec94905f181439a1b1dba. * remove config.rs (from wrong merge) * upgrade to libp2p 0.51.2 * fix formatting * use handle_pending_outbound_connection in networt_state RPC * update deps * use re-exports when we use other libp2p packages * Apply suggestions from code review Co-authored-by: Dmitry Markin * format code * handle potential errors in network_state RPC * only update libp2p crate * update libp2p-core * fix docs * use libp2p-identity instead of libp2p where it's possible. libp2p-identity is much smaller, hence makes sense to use it instead of larger libp2p crate. * Update client/network/src/discovery.rs Co-authored-by: Aaro Altonen <48052676+altonen@users.noreply.github.com> * update Cargo.lock * add comment for per_connection_event_buffer_size current value is somewhat arbitrary and needs to be tweaked depending on memory usage and network worker sleep stats. * fix link format * update Cargo.lock * upgrade to libp2p 0.51.3 * deprecate mplex * Revert "deprecate mplex" This reverts commit 9e25820e706e464a0e962a8604861fcb2a7641eb. * Revert "upgrade to libp2p 0.51.3" This reverts commit 6544dd4138e2f89517bd7c7281fc78a638ec7040. * use new libp2p version in `statement` crate * pin version temporarily * libp2p 0.51.3 * deprecate mplex * deprecate legacy noise handshake * fix build error * update libp2p-identity * enable libp2p-identity:ed25519 feature in sc-consensus * enable ed25519 for peerset as well --------- Co-authored-by: Dmitry Markin Co-authored-by: Aaro Altonen <48052676+altonen@users.noreply.github.com> Co-authored-by: parity-processbot <> * chore: update libp2p to 0.52.1 (#14429) * update libp2p to 0.52.0 * proto name now must implement `AsRef` * update libp2p version everywhere * ToSwarm, FromBehaviour, ToBehaviour also LocalProtocolsChange and RemoteProtocolsChange * new NetworkBehaviour invariants * replace `Vec` with `StreamProtocol` * rename ConnectionHandlerEvent::Custom to NotifyBehaviour * remove DialError & ListenError invariants also fix pending_events * use connection_limits::Behaviour See https://github.com/libp2p/rust-libp2p/pull/3885 * impl `void::Void` for `BehaviourOut` also use `Behaviour::with_codec` * KademliaHandler no longer public * fix StreamProtocol construction * update libp2p-identify to 0.2.0 * remove non-existing methods from PollParameters rename ConnectionHandlerUpgrErr to StreamUpgradeError * `P2p` now contains `PeerId`, not `Multihash` * use multihash-codetable crate * update Cargo.lock * reformat text * comment out tests for now * remove `.into()` from P2p * confirm observed addr manually See https://github.com/libp2p/rust-libp2p/blob/master/protocols/identify/CHANGELOG.md#0430 * remove SwarmEvent::Banned since we're not using `ban_peer_id`, this can be safely removed. we may want to introduce `libp2p::allow_block_list` module in the future. * fix imports * replace `libp2p` with smaller deps in network-gossip * bring back tests * finish rewriting tests * uncomment handler tests * Revert "uncomment handler tests" This reverts commit 720a06815887f4e10767c62b58864a7ec3a48e50. * add a fixme * update Cargo.lock * remove extra From * make void uninhabited * fix discovery test * use autonat protocols confirming external addresses manually is unsafe in open networks * fix SyncNotificationsClogged invariant * only set server mode manually in tests doubt that we need to set it on node since we're adding public addresses * address @dmitry-markin comments * remove autonat * removed unused var * fix EOL * update smallvec and sha2 in attempt to compile polkadot * bump k256 in attempt to build cumulus --------- Co-authored-by: parity-processbot <> * Bump libp2p to 0.52.3 * Bump libp2p to 0.52.4 --------- Co-authored-by: Anton Co-authored-by: Dmitry Markin Co-authored-by: Aaro Altonen <48052676+altonen@users.noreply.github.com> --- Cargo.lock | 2961 ++++++++--------- bin/node/cli/Cargo.toml | 2 +- client/authority-discovery/Cargo.toml | 3 +- client/authority-discovery/src/error.rs | 2 +- client/authority-discovery/src/tests.rs | 19 +- client/authority-discovery/src/worker.rs | 22 +- .../src/worker/addr_cache.rs | 29 +- .../src/worker/schema/tests.rs | 6 +- .../authority-discovery/src/worker/tests.rs | 8 +- client/cli/Cargo.toml | 4 +- client/cli/src/commands/generate_node_key.rs | 6 +- client/cli/src/commands/inspect_node_key.rs | 10 +- client/cli/src/params/node_key_params.rs | 13 +- client/consensus/aura/Cargo.toml | 2 +- client/consensus/babe/Cargo.toml | 6 +- client/consensus/babe/rpc/Cargo.toml | 2 +- client/consensus/babe/src/authorship.rs | 6 +- client/consensus/babe/src/lib.rs | 4 +- client/consensus/babe/src/migration.rs | 4 +- client/consensus/babe/src/tests.rs | 10 +- client/consensus/beefy/Cargo.toml | 2 +- client/consensus/beefy/rpc/Cargo.toml | 2 +- client/consensus/common/Cargo.toml | 2 +- client/consensus/common/src/import_queue.rs | 2 +- .../common/src/import_queue/basic_queue.rs | 2 +- client/consensus/grandpa/Cargo.toml | 2 +- client/consensus/grandpa/rpc/Cargo.toml | 2 +- client/consensus/manual-seal/Cargo.toml | 2 +- client/keystore/src/local.rs | 2 +- client/network-gossip/Cargo.toml | 5 +- client/network-gossip/src/bridge.rs | 5 +- client/network-gossip/src/lib.rs | 6 +- client/network-gossip/src/state_machine.rs | 4 +- client/network-gossip/src/validator.rs | 2 +- client/network/Cargo.toml | 10 +- client/network/README.md | 2 - client/network/bitswap/Cargo.toml | 4 +- client/network/bitswap/src/lib.rs | 2 +- client/network/common/Cargo.toml | 2 +- client/network/common/src/sync.rs | 2 +- client/network/light/Cargo.toml | 2 +- .../src/light_client_requests/handler.rs | 2 +- client/network/src/behaviour.rs | 24 +- client/network/src/config.rs | 37 +- client/network/src/discovery.rs | 307 +- client/network/src/event.rs | 2 +- client/network/src/lib.rs | 4 +- client/network/src/peer_info.rs | 220 +- client/network/src/protocol.rs | 92 +- .../src/protocol/notifications/behaviour.rs | 390 +-- .../src/protocol/notifications/handler.rs | 1359 ++++---- .../src/protocol/notifications/tests.rs | 87 +- .../protocol/notifications/upgrade/collec.rs | 12 +- .../notifications/upgrade/notifications.rs | 205 +- client/network/src/request_responses.rs | 320 +- client/network/src/service.rs | 225 +- client/network/src/service/signature.rs | 2 +- client/network/src/service/traits.rs | 2 +- client/network/src/transport.rs | 54 +- client/network/src/types.rs | 8 +- client/network/sync/Cargo.toml | 6 +- client/network/test/Cargo.toml | 4 +- client/network/transactions/Cargo.toml | 2 +- client/network/transactions/src/lib.rs | 4 +- client/offchain/Cargo.toml | 4 +- client/peerset/Cargo.toml | 2 +- client/peerset/src/lib.rs | 4 +- client/peerset/src/peersstate.rs | 4 +- client/peerset/tests/fuzz.rs | 2 +- client/rpc-servers/Cargo.toml | 2 +- client/rpc-spec-v2/Cargo.toml | 2 +- client/rpc/Cargo.toml | 4 +- client/service/Cargo.toml | 2 +- client/service/src/lib.rs | 2 +- client/service/test/Cargo.toml | 2 +- client/storage-monitor/Cargo.toml | 2 +- client/telemetry/Cargo.toml | 2 +- client/telemetry/src/transport.rs | 2 +- frame/babe/src/lib.rs | 4 +- frame/babe/src/mock.rs | 10 +- frame/babe/src/randomness.rs | 8 +- frame/babe/src/tests.rs | 4 +- frame/state-trie-migration/Cargo.toml | 2 +- frame/support/Cargo.toml | 4 +- primitives/consensus/babe/Cargo.toml | 2 +- primitives/consensus/babe/src/digests.rs | 8 +- primitives/consensus/babe/src/lib.rs | 4 +- primitives/consensus/vrf/Cargo.toml | 2 +- primitives/consensus/vrf/src/schnorrkel.rs | 39 +- primitives/core/Cargo.toml | 9 +- primitives/core/hashing/Cargo.toml | 2 +- primitives/io/Cargo.toml | 5 +- primitives/io/src/lib.rs | 6 +- primitives/keystore/Cargo.toml | 4 +- primitives/keystore/src/lib.rs | 4 +- primitives/keystore/src/testing.rs | 2 +- primitives/keystore/src/vrf.rs | 6 +- primitives/state-machine/Cargo.toml | 2 +- primitives/weights/Cargo.toml | 2 +- test-utils/Cargo.toml | 2 +- test-utils/test-crate/Cargo.toml | 2 +- utils/frame/remote-externalities/Cargo.toml | 2 +- utils/frame/rpc/client/Cargo.toml | 2 +- utils/frame/rpc/support/Cargo.toml | 2 +- utils/frame/rpc/system/Cargo.toml | 2 +- utils/frame/try-runtime/cli/Cargo.toml | 2 +- utils/prometheus/Cargo.toml | 4 +- 107 files changed, 3282 insertions(+), 3452 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d0aea7729bd2d..7dca101dc51e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,115 +38,39 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aead" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" -dependencies = [ - "generic-array 0.14.6", -] - -[[package]] -name = "aead" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" -dependencies = [ - "generic-array 0.14.6", - "rand_core 0.6.4", -] - -[[package]] -name = "aead" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c192eb8f11fc081b0fe4259ba5af04217d4e0faddd02417310a927911abd7c8" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ "crypto-common", - "generic-array 0.14.6", -] - -[[package]] -name = "aes" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" -dependencies = [ - "aes-soft", - "aesni", - "cipher 0.2.5", -] - -[[package]] -name = "aes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" -dependencies = [ - "cfg-if", - "cipher 0.3.0", - "cpufeatures", - "opaque-debug 0.3.0", + "generic-array", ] [[package]] name = "aes" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433cfd6710c9986c576a25ca913c39d66a6474107b406f34f91d4a8923395241" +checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" dependencies = [ "cfg-if", - "cipher 0.4.3", + "cipher", "cpufeatures", ] -[[package]] -name = "aes-gcm" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" -dependencies = [ - "aead 0.4.3", - "aes 0.7.5", - "cipher 0.3.0", - "ctr 0.8.0", - "ghash 0.4.4", - "subtle", -] - [[package]] name = "aes-gcm" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "82e1366e0c69c9f927b1fa5ce2c7bf9eafc8f9268c0b9800729e8b267612447c" dependencies = [ - "aead 0.5.1", - "aes 0.8.2", - "cipher 0.4.3", - "ctr 0.9.2", - "ghash 0.5.0", + "aead", + "aes", + "cipher", + "ctr", + "ghash", "subtle", ] -[[package]] -name = "aes-soft" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" -dependencies = [ - "cipher 0.2.5", - "opaque-debug 0.3.0", -] - -[[package]] -name = "aesni" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" -dependencies = [ - "cipher 0.2.5", - "opaque-debug 0.3.0", -] - [[package]] name = "ahash" version = "0.7.6" @@ -160,14 +84,15 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "getrandom 0.2.8", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -179,6 +104,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + [[package]] name = "android_system_properties" version = "0.1.5" @@ -224,12 +155,6 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e90af4de65aa7b293ef2d09daff88501eb254f58edde2e1ac02c82d873eadad" -[[package]] -name = "arc-swap" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" - [[package]] name = "array-bytes" version = "4.2.0" @@ -238,64 +163,30 @@ checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" [[package]] name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "arrayvec" -version = "0.5.2" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" [[package]] name = "arrayvec" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" - -[[package]] -name = "asn1-rs" -version = "0.3.1" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ff05a702273012438132f449575dbc804e27b2f3cbe3069aa237d26c98fa33" -dependencies = [ - "asn1-rs-derive 0.1.0", - "asn1-rs-impl", - "displaydoc", - "nom", - "num-traits", - "rusticata-macros", - "thiserror", - "time 0.3.20", -] +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "asn1-rs" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf6690c370453db30743b373a60ba498fc0d6d83b11f4abfd87a84a075db5dd4" +checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" dependencies = [ - "asn1-rs-derive 0.4.0", + "asn1-rs-derive", "asn1-rs-impl", "displaydoc", "nom", "num-traits", "rusticata-macros", "thiserror", - "time 0.3.20", -] - -[[package]] -name = "asn1-rs-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8b7511298d5b7784b40b092d9e9dcd3a627a5707e4b5e507931ab0d44eeebf" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "synstructure", + "time 0.3.36", ] [[package]] @@ -306,7 +197,7 @@ checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "synstructure", ] @@ -318,15 +209,9 @@ checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] -[[package]] -name = "asn1_der" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e22d1f4b888c298a027c99dc9048015fac177587de20fc30232a057dfbe24a21" - [[package]] name = "assert_cmd" version = "2.0.8" @@ -354,28 +239,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" dependencies = [ "concurrent-queue", - "event-listener", + "event-listener 2.5.3", "futures-core", ] [[package]] name = "async-io" -version = "1.12.0" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c374dda1ed3e7d8f0d9ba58715f924862c63eae6849c92d3a18e7fbde9e2794" +checksum = "0d6baa8f0178795da0e71bc42c9e5d13261aac7ee549853162e66a241ba17964" dependencies = [ - "async-lock", - "autocfg", + "async-lock 3.4.0", + "cfg-if", "concurrent-queue", - "futures-lite", - "libc", - "log", + "futures-io", + "futures-lite 2.3.0", "parking", "polling", + "rustix 0.38.34", "slab", - "socket2", - "waker-fn", - "windows-sys 0.42.0", + "tracing", + "windows-sys 0.52.0", ] [[package]] @@ -384,8 +268,19 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" dependencies = [ - "event-listener", - "futures-lite", + "event-listener 2.5.3", + "futures-lite 1.12.0", +] + +[[package]] +name = "async-lock" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" +dependencies = [ + "event-listener 5.3.1", + "event-listener-strategy", + "pin-project-lite 0.2.14", ] [[package]] @@ -396,7 +291,7 @@ checksum = "ad445822218ce64be7a341abfb0b1ea43b5c23aa83902542a4542e78309d8e5e" dependencies = [ "async-stream-impl", "futures-core", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.14", ] [[package]] @@ -407,18 +302,18 @@ checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] name = "async-trait" -version = "0.1.64" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd7fce9ba8c3c042128ce72d8b2ddbf3a05747efb67ea0313c635e10bda47a2" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.68", ] [[package]] @@ -431,14 +326,19 @@ dependencies = [ "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.14", ] [[package]] -name = "atomic-waker" -version = "1.1.0" +name = "attohttpc" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599" +checksum = "8d9a9bf8b79a749ee0b911b91b671cc2b6c670bdbc7e3dfd537576ddc94bb2a2" +dependencies = [ + "http", + "log", + "url", +] [[package]] name = "atty" @@ -480,9 +380,9 @@ checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" [[package]] name = "base16ct" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" [[package]] name = "base58" @@ -553,7 +453,7 @@ version = "0.64.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cexpr", "clang-sys", "lazy_static", @@ -564,7 +464,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn", + "syn 1.0.109", ] [[package]] @@ -573,6 +473,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + [[package]] name = "bitvec" version = "1.0.1" @@ -591,7 +497,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -601,7 +507,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec", "constant_time_eq", ] @@ -612,7 +518,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec", "constant_time_eq", ] @@ -623,22 +529,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ae2468a89544a466886840aa467a25b766499f4f04bf7d9fcd10ecee9fccef" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec", "cc", "cfg-if", "constant_time_eq", -] - -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding 0.1.5", - "byte-tools", - "byteorder", - "generic-array 0.12.4", + "digest 0.10.7", ] [[package]] @@ -647,7 +542,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.6", + "generic-array", ] [[package]] @@ -656,34 +551,9 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" dependencies = [ - "generic-array 0.14.6", -] - -[[package]] -name = "block-modes" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a0e8073e8baa88212fb5823574c02ebccb395136ba9a164ab89379ec6072f0" -dependencies = [ - "block-padding 0.2.1", - "cipher 0.2.5", + "generic-array", ] -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - [[package]] name = "bounded-collections" version = "0.1.5" @@ -698,9 +568,12 @@ dependencies = [ [[package]] name = "bs58" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +dependencies = [ + "tinyvec", +] [[package]] name = "bstr" @@ -735,12 +608,6 @@ version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - [[package]] name = "bytemuck" version = "1.13.0" @@ -755,9 +622,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.4.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "bzip2-sys" @@ -817,17 +684,6 @@ dependencies = [ "jobserver", ] -[[package]] -name = "ccm" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca1a8fbc20b50ac9673ff014abfb2b5f4085ee1a850d408f14a159c5853ac7" -dependencies = [ - "aead 0.3.2", - "cipher 0.2.5", - "subtle", -] - [[package]] name = "cexpr" version = "0.6.0" @@ -860,25 +716,24 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "chacha20" -version = "0.8.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" +checksum = "c7fc89c7c5b9e7a02dfe45cd2367bae382f9ed31c61ca8debe5f827c420a2f08" dependencies = [ "cfg-if", - "cipher 0.3.0", + "cipher", "cpufeatures", - "zeroize", ] [[package]] name = "chacha20poly1305" -version = "0.9.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" dependencies = [ - "aead 0.4.3", + "aead", "chacha20", - "cipher 0.3.0", + "cipher", "poly1305", "zeroize", ] @@ -952,24 +807,6 @@ dependencies = [ "unsigned-varint", ] -[[package]] -name = "cipher" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -dependencies = [ - "generic-array 0.14.6", -] - -[[package]] -name = "cipher" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" -dependencies = [ - "generic-array 0.14.6", -] - [[package]] name = "cipher" version = "0.4.3" @@ -978,6 +815,7 @@ checksum = "d1873270f8f7942c191139cb8a40fd228da6c3fd2fc376d7e92d47aa14aeb59e" dependencies = [ "crypto-common", "inout", + "zeroize", ] [[package]] @@ -1006,9 +844,9 @@ version = "3.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" dependencies = [ - "bitflags", + "bitflags 1.3.2", "clap_lex 0.2.4", - "indexmap", + "indexmap 1.9.2", "textwrap", ] @@ -1018,7 +856,7 @@ version = "4.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" dependencies = [ - "bitflags", + "bitflags 1.3.2", "clap_derive", "clap_lex 0.3.2", "is-terminal", @@ -1046,7 +884,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1090,9 +928,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.1.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c278839b831783b70278b14df4d45e1beb1aad306c07bb796637de9a0e323e8e" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" dependencies = [ "crossbeam-utils", ] @@ -1145,9 +983,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -1167,7 +1005,7 @@ version = "0.93.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9489fa336927df749631f1008007ced2871068544f40a202ce6d93fbf2366a7b" dependencies = [ - "arrayvec 0.7.2", + "arrayvec", "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", @@ -1251,21 +1089,6 @@ dependencies = [ "wasmtime-types", ] -[[package]] -name = "crc" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" -dependencies = [ - "crc-catalog", -] - -[[package]] -name = "crc-catalog" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" - [[package]] name = "crc32fast" version = "1.3.2" @@ -1364,11 +1187,11 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" -version = "0.4.9" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" dependencies = [ - "generic-array 0.14.6", + "generic-array", "rand_core 0.6.4", "subtle", "zeroize", @@ -1380,7 +1203,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.6", + "generic-array", "rand_core 0.6.4", "typenum", ] @@ -1391,7 +1214,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "generic-array 0.14.6", + "generic-array", "subtle", ] @@ -1401,7 +1224,7 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" dependencies = [ - "generic-array 0.14.6", + "generic-array", "subtle", ] @@ -1412,16 +1235,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" dependencies = [ "quote", - "syn", -] - -[[package]] -name = "ctr" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" -dependencies = [ - "cipher 0.3.0", + "syn 1.0.109", ] [[package]] @@ -1430,47 +1244,34 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" dependencies = [ - "cipher 0.4.3", -] - -[[package]] -name = "curve25519-dalek" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a9b85542f99a2dfa2a1b8e192662741c9859a846b296bef1c92ef9b58b5a216" -dependencies = [ - "byteorder", - "digest 0.8.1", - "rand_core 0.5.1", - "subtle", - "zeroize", + "cipher", ] [[package]] name = "curve25519-dalek" -version = "3.2.0" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "rustc_version 0.4.0", "subtle", "zeroize", ] [[package]] -name = "curve25519-dalek" -version = "4.0.0-rc.0" +name = "curve25519-dalek-derive" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da00a7a9a4eb92a0a0f8e75660926d48f0d0f3c537e455c457bcdaa1e16b1ac" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ - "cfg-if", - "fiat-crypto", - "packed_simd_2", - "platforms 3.0.2", - "subtle", - "zeroize", + "proc-macro2", + "quote", + "syn 2.0.68", ] [[package]] @@ -1497,7 +1298,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn", + "syn 1.0.109", ] [[package]] @@ -1514,88 +1315,52 @@ checksum = "086c685979a698443656e5cf7856c95c642295a38599f12fb1ff76fb28d19892" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] -name = "darling" -version = "0.14.3" +name = "data-encoding" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0808e1bd8671fb44a113a14e13497557533369847788fa2ae912b6ebfce9fa8" -dependencies = [ - "darling_core", - "darling_macro", -] +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] -name = "darling_core" -version = "0.14.3" +name = "data-encoding-macro" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "001d80444f28e193f30c2f293455da62dcf9a6b29918a4253152ae2b1de592cb" +checksum = "86927b7cd2fe88fa698b87404b287ab98d1a0063a34071d92e575b72d3029aca" dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn", + "data-encoding", + "data-encoding-macro-internal", ] [[package]] -name = "darling_macro" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b36230598a2d5de7ec1c6f51f72d8a99a9208daff41de2084d06e3fd3ea56685" -dependencies = [ - "darling_core", - "quote", - "syn", -] - -[[package]] -name = "data-encoding" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d8666cb01533c39dde32bcbab8e227b4ed6679b2c925eba05feabea39508fb" - -[[package]] -name = "data-encoding-macro" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86927b7cd2fe88fa698b87404b287ab98d1a0063a34071d92e575b72d3029aca" -dependencies = [ - "data-encoding", - "data-encoding-macro-internal", -] - -[[package]] -name = "data-encoding-macro-internal" -version = "0.1.10" +name = "data-encoding-macro-internal" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5bbed42daaa95e780b60a50546aa345b8413a1e46f9a40a12907d3598f038db" dependencies = [ "data-encoding", - "syn", + "syn 1.0.109", ] [[package]] name = "der" -version = "0.6.1" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", - "pem-rfc7468", "zeroize", ] [[package]] name = "der-parser" -version = "7.0.0" +version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe398ac75057914d7d07307bf67dc7f3f574a26783b4fc7805a20ffa9f506e82" +checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" dependencies = [ - "asn1-rs 0.3.1", + "asn1-rs", "displaydoc", "nom", "num-bigint", @@ -1604,17 +1369,12 @@ dependencies = [ ] [[package]] -name = "der-parser" -version = "8.1.0" +name = "deranged" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42d4bc9b0db0a0df9ae64634ac5bdefb7afcb534e182275ca0beadbe486701c1" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ - "asn1-rs 0.5.1", - "displaydoc", - "nom", - "num-bigint", - "num-traits", - "rusticata-macros", + "powerfmt", ] [[package]] @@ -1625,38 +1385,7 @@ checksum = "e79116f119dd1dba1abf1f3405f03b9b0e79a27a3883864bfebded8a3dc768cd" dependencies = [ "proc-macro2", "quote", - "syn", -] - -[[package]] -name = "derive_builder" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07adf7be193b71cc36b193d0f5fe60b918a3a9db4dad0449f57bcfd519704a3" -dependencies = [ - "derive_builder_macro", -] - -[[package]] -name = "derive_builder_core" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "derive_builder_macro" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68" -dependencies = [ - "derive_builder_core", - "syn", + "syn 1.0.109", ] [[package]] @@ -1667,7 +1396,7 @@ checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1682,31 +1411,23 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.4", -] - [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.6", + "generic-array", ] [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.3", + "const-oid", "crypto-common", "subtle", ] @@ -1754,13 +1475,13 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.3" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.68", ] [[package]] @@ -1811,7 +1532,7 @@ checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1822,74 +1543,76 @@ checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "ecdsa" -version = "0.14.8" +version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der", + "digest 0.10.7", "elliptic-curve", "rfc6979", "signature", + "spki", ] [[package]] name = "ed25519" -version = "1.5.3" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ + "pkcs8", "signature", ] [[package]] name = "ed25519-dalek" -version = "1.0.1" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ - "curve25519-dalek 3.2.0", + "curve25519-dalek", "ed25519", - "rand 0.7.3", + "rand_core 0.6.4", "serde", - "sha2 0.9.9", + "sha2 0.10.8", + "subtle", "zeroize", ] [[package]] name = "ed25519-zebra" -version = "3.1.0" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ - "curve25519-dalek 3.2.0", - "hashbrown 0.12.3", + "curve25519-dalek", + "ed25519", + "hashbrown 0.14.3", "hex", "rand_core 0.6.4", - "sha2 0.9.9", + "sha2 0.10.8", "zeroize", ] [[package]] name = "either" -version = "1.8.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "elliptic-curve" -version = "0.12.3" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct", "crypto-bigint", - "der", - "digest 0.10.6", + "digest 0.10.7", "ff", - "generic-array 0.14.6", + "generic-array", "group", - "hkdf", - "pem-rfc7468", "pkcs8", "rand_core 0.6.4", "sec1", @@ -1906,7 +1629,19 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 1.0.109", +] + +[[package]] +name = "enum-as-inner" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ffccbb6966c05b32ef8fbac435df276c4ae4d3dc55a8cd0eb9745e6c12f546a" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.68", ] [[package]] @@ -1926,7 +1661,7 @@ checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -1961,6 +1696,12 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.2.8" @@ -1972,6 +1713,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "errno-dragonfly" version = "0.1.2" @@ -1988,6 +1739,27 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "event-listener" +version = "5.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite 0.2.14", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" +dependencies = [ + "event-listener 5.3.1", + "pin-project-lite 0.2.14", +] + [[package]] name = "exit-future" version = "0.2.0" @@ -2007,15 +1779,9 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - [[package]] name = "fallible-iterator" version = "0.2.0" @@ -2042,9 +1808,9 @@ dependencies = [ [[package]] name = "ff" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" dependencies = [ "rand_core 0.6.4", "subtle", @@ -2052,9 +1818,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.1.17" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a214f5bb88731d436478f3ae1f8a277b62124089ba9fb67f4f93fb100ef73c90" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "file-per-thread-logger" @@ -2113,17 +1879,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" -[[package]] -name = "flate2" -version = "1.0.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" -dependencies = [ - "crc32fast", - "libz-sys", - "miniz_oxide", -] - [[package]] name = "float-cmp" version = "0.9.0" @@ -2148,9 +1903,9 @@ dependencies = [ [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -2260,7 +2015,7 @@ dependencies = [ "quote", "scale-info", "sp-arithmetic", - "syn", + "syn 1.0.109", "trybuild", ] @@ -2355,7 +2110,7 @@ name = "frame-support" version = "4.0.0-dev" dependencies = [ "assert_matches", - "bitflags", + "bitflags 1.3.2", "environmental", "frame-metadata", "frame-support-procedural", @@ -2397,7 +2152,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2408,7 +2163,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2417,7 +2172,7 @@ version = "3.0.0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -2561,9 +2316,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e2792b0ff0340399d58445b88fd9770e3489eff258a4cbc1523418f12abf84" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -2574,11 +2329,21 @@ dependencies = [ "futures-util", ] +[[package]] +name = "futures-bounded" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b07bbbe7d7e78809544c6f718d875627addc73a7c3582447abc052cd3dc67e0" +dependencies = [ + "futures-timer", + "futures-util", +] + [[package]] name = "futures-channel" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -2586,15 +2351,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -2604,9 +2369,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb8371b6fb2aeb2d280374607aeabfc99d95c72edfe51692e42d3d7f0d08531" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" @@ -2619,43 +2384,52 @@ dependencies = [ "futures-io", "memchr", "parking", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.14", "waker-fn", ] +[[package]] +name = "futures-lite" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" +dependencies = [ + "futures-core", + "pin-project-lite 0.2.14", +] + [[package]] name = "futures-macro" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.68", ] [[package]] name = "futures-rustls" -version = "0.22.2" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" +checksum = "35bd3cf68c183738046838e300353e4716c674dc5e56890de4826801a6622a28" dependencies = [ "futures-io", - "rustls 0.20.8", - "webpki 0.22.0", + "rustls 0.21.12", ] [[package]] name = "futures-sink" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-timer" @@ -2665,9 +2439,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.26" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -2676,7 +2450,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.14", "pin-utils", "slab", ] @@ -2703,15 +2477,6 @@ dependencies = [ "pallet-staking", ] -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - [[package]] name = "generic-array" version = "0.14.6" @@ -2720,6 +2485,7 @@ checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", "version_check", + "zeroize", ] [[package]] @@ -2755,13 +2521,13 @@ dependencies = [ ] [[package]] -name = "ghash" -version = "0.4.4" +name = "getrandom_or_panic" +version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" +checksum = "6ea1015b5a70616b688dc230cfe50c8af89d972cb132d5a622814d29773b10b9" dependencies = [ - "opaque-debug 0.3.0", - "polyval 0.5.3", + "rand 0.8.5", + "rand_core 0.6.4", ] [[package]] @@ -2770,8 +2536,8 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" dependencies = [ - "opaque-debug 0.3.0", - "polyval 0.6.0", + "opaque-debug", + "polyval", ] [[package]] @@ -2781,7 +2547,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" dependencies = [ "fallible-iterator", - "indexmap", + "indexmap 1.9.2", "stable_deref_trait", ] @@ -2797,7 +2563,7 @@ version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf7f68c2995f392c49fffb4f95ae2c873297830eb25c6bc4c114ce8f4562acc" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", "libgit2-sys", "log", @@ -2825,9 +2591,9 @@ dependencies = [ [[package]] name = "group" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff", "rand_core 0.6.4", @@ -2846,7 +2612,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.2", "slab", "tokio", "tokio-util", @@ -2903,7 +2669,17 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", +] + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash 0.8.6", + "allocator-api2", ] [[package]] @@ -2936,6 +2712,12 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -2944,9 +2726,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hkdf" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" dependencies = [ "hmac 0.12.1", ] @@ -2977,7 +2759,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -2987,7 +2769,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" dependencies = [ "digest 0.9.0", - "generic-array 0.14.6", + "generic-array", "hmac 0.8.1", ] @@ -3033,7 +2815,7 @@ checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.14", ] [[package]] @@ -3076,8 +2858,8 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project-lite 0.2.9", - "socket2", + "pin-project-lite 0.2.14", + "socket2 0.4.7", "tokio", "tower-service", "tracing", @@ -3123,12 +2905,6 @@ dependencies = [ "cxx-build", ] -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - [[package]] name = "idna" version = "0.2.3" @@ -3142,9 +2918,19 @@ dependencies = [ [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "idna" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -3152,19 +2938,19 @@ dependencies = [ [[package]] name = "if-addrs" -version = "0.7.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbc0fa01ffc752e9dbc72818cdb072cd028b86be5e09dd04c5a643704fe101a9" +checksum = "cabb0019d51a643781ff15c9c8a3e5dedc365c47211270f4e8f82812fedd8f0a" dependencies = [ "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] name = "if-watch" -version = "3.0.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba7abdbb86e485125dad06c2691e1e393bf3b08c7b743b43aa162a00fd39062e" +checksum = "d6b0422c86d7ce0e97169cc42e04ae643caf278874a7a3c87b8150a220dc7e1e" dependencies = [ "async-io", "core-foundation", @@ -3179,6 +2965,25 @@ dependencies = [ "windows", ] +[[package]] +name = "igd-next" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "064d90fec10d541084e7b39ead8875a5a80d9114a2b18791565253bae25f49e4" +dependencies = [ + "async-trait", + "attohttpc", + "bytes", + "futures", + "http", + "hyper", + "log", + "rand 0.8.5", + "tokio", + "url", + "xmltree", +] + [[package]] name = "impl-codec" version = "0.6.0" @@ -3205,7 +3010,7 @@ checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3219,6 +3024,16 @@ dependencies = [ "serde", ] +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown 0.14.3", +] + [[package]] name = "indexmap-nostd" version = "0.4.0" @@ -3231,7 +3046,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ - "generic-array 0.14.6", + "generic-array", ] [[package]] @@ -3252,25 +3067,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "interceptor" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e8a11ae2da61704edada656798b61c94b35ecac2c58eb955156987d5e6be90b" -dependencies = [ - "async-trait", - "bytes", - "log", - "rand 0.8.5", - "rtcp", - "rtp", - "thiserror", - "tokio", - "waitgroup", - "webrtc-srtp", - "webrtc-util", -] - [[package]] name = "io-lifetimes" version = "0.7.5" @@ -3299,7 +3095,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd302af1b90f2463a98fa5ad469fc212c8e3175a41c3068601bfa2727591c5be" dependencies = [ - "socket2", + "socket2 0.4.7", "widestring", "winapi", "winreg", @@ -3349,9 +3145,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] @@ -3388,7 +3184,7 @@ dependencies = [ "tokio-rustls", "tokio-util", "tracing", - "webpki-roots", + "webpki-roots 0.22.6", ] [[package]] @@ -3398,8 +3194,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4e70b4439a751a5de7dd5ed55eacff78ebf4ffe0fc009cb1ebb11417f5b536b" dependencies = [ "anyhow", - "arrayvec 0.7.2", - "async-lock", + "arrayvec", + "async-lock 2.6.0", "async-trait", "beef", "futures-channel", @@ -3429,7 +3225,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -3482,14 +3278,15 @@ dependencies = [ [[package]] name = "k256" -version = "0.11.6" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72c1e0b51e7ec0a97369623508396067a486bd0cbed95a2659a4b863d28cfc8b" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" dependencies = [ "cfg-if", "ecdsa", "elliptic-curve", - "sha2 0.10.6", + "once_cell", + "sha2 0.10.8", ] [[package]] @@ -3667,9 +3464,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libgit2-sys" @@ -3693,12 +3490,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "libm" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" - [[package]] name = "libm" version = "0.2.6" @@ -3707,114 +3498,103 @@ checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" [[package]] name = "libp2p" -version = "0.50.0" +version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e0a0d2f693675f49ded13c5d510c48b78069e23cbd9108d7ccd59f6dc568819" +checksum = "e94495eb319a85b70a68b85e2389a95bb3555c71c49025b78c691a854a7e6464" dependencies = [ "bytes", + "either", "futures", "futures-timer", "getrandom 0.2.8", "instant", - "libp2p-core 0.38.0", + "libp2p-allow-block-list", + "libp2p-connection-limits", + "libp2p-core", "libp2p-dns", "libp2p-identify", + "libp2p-identity", "libp2p-kad", "libp2p-mdns", "libp2p-metrics", - "libp2p-mplex", - "libp2p-noise 0.41.0", + "libp2p-noise", "libp2p-ping", "libp2p-quic", "libp2p-request-response", "libp2p-swarm", "libp2p-tcp", + "libp2p-upnp", "libp2p-wasm-ext", - "libp2p-webrtc", "libp2p-websocket", "libp2p-yamux", - "multiaddr 0.16.0", - "parking_lot 0.12.1", + "multiaddr", "pin-project", - "smallvec", + "rw-stream-sink", + "thiserror", ] [[package]] -name = "libp2p-core" -version = "0.38.0" +name = "libp2p-allow-block-list" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a8fcd392ff67af6cc3f03b1426c41f7f26b6b9aff2dc632c1c56dd649e571f" +checksum = "55b46558c5c0bf99d3e2a1a38fd54ff5476ca66dd1737b12466a1824dd219311" dependencies = [ - "asn1_der", - "bs58", - "ed25519-dalek", - "either", - "fnv", - "futures", - "futures-timer", - "instant", - "log", - "multiaddr 0.16.0", - "multihash 0.16.3", - "multistream-select", - "once_cell", - "parking_lot 0.12.1", - "pin-project", - "prost", - "prost-build", - "rand 0.8.5", - "rw-stream-sink", - "sec1", - "sha2 0.10.6", - "smallvec", - "thiserror", - "unsigned-varint", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "void", +] + +[[package]] +name = "libp2p-connection-limits" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f5107ad45cb20b2f6c3628c7b6014b996fcb13a88053f4569c872c6e30abf58" +dependencies = [ + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", "void", - "zeroize", ] [[package]] name = "libp2p-core" -version = "0.39.0" +version = "0.40.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881d9a54e97d97cdaa4125d48269d97ca8c40e5fefec6b85b30440dc60cc551f" +checksum = "dd44289ab25e4c9230d9246c475a22241e301b23e8f4061d3bdef304a1a99713" dependencies = [ - "asn1_der", - "bs58", - "ed25519-dalek", "either", "fnv", "futures", "futures-timer", "instant", + "libp2p-identity", "log", - "multiaddr 0.17.0", - "multihash 0.17.0", + "multiaddr", + "multihash 0.19.1", "multistream-select", "once_cell", "parking_lot 0.12.1", "pin-project", - "prost", - "prost-build", + "quick-protobuf", "rand 0.8.5", "rw-stream-sink", - "sec1", - "sha2 0.10.6", "smallvec", "thiserror", "unsigned-varint", "void", - "zeroize", ] [[package]] name = "libp2p-dns" -version = "0.38.0" +version = "0.40.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e42a271c1b49f789b92f7fc87749fa79ce5c7bdc88cbdfacb818a4bca47fec5" +checksum = "e6a18db73084b4da2871438f6239fef35190b05023de7656e877c18a00541a3b" dependencies = [ + "async-trait", "futures", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "log", "parking_lot 0.12.1", "smallvec", @@ -3823,32 +3603,52 @@ dependencies = [ [[package]] name = "libp2p-identify" -version = "0.41.1" +version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c052d0026f4817b44869bfb6810f4e1112f43aec8553f2cb38881c524b563abf" +checksum = "45a96638a0a176bec0a4bcaebc1afa8cf909b114477209d7456ade52c61cd9cd" dependencies = [ "asynchronous-codec", + "either", "futures", + "futures-bounded", "futures-timer", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", - "lru", - "prost", - "prost-build", - "prost-codec", + "lru 0.12.3", + "quick-protobuf", + "quick-protobuf-codec", "smallvec", "thiserror", "void", ] +[[package]] +name = "libp2p-identity" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cca1eb2bc1fd29f099f3daaab7effd01e1a54b7c577d0ed082521034d912e8" +dependencies = [ + "bs58", + "ed25519-dalek", + "hkdf", + "multihash 0.19.1", + "quick-protobuf", + "rand 0.8.5", + "sha2 0.10.8", + "thiserror", + "tracing", + "zeroize", +] + [[package]] name = "libp2p-kad" -version = "0.42.1" +version = "0.44.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2766dcd2be8c87d5e1f35487deb22d765f49c6ae1251b3633efe3b25698bd3d2" +checksum = "16ea178dabba6dde6ffc260a8e0452ccdc8f79becf544946692fff9d412fc29d" dependencies = [ - "arrayvec 0.7.2", + "arrayvec", "asynchronous-codec", "bytes", "either", @@ -3856,13 +3656,14 @@ dependencies = [ "futures", "futures-timer", "instant", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", - "prost", - "prost-build", + "quick-protobuf", + "quick-protobuf-codec", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.8", "smallvec", "thiserror", "uint", @@ -3872,112 +3673,79 @@ dependencies = [ [[package]] name = "libp2p-mdns" -version = "0.42.0" +version = "0.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f378264aade9872d6ccd315c0accc18be3a35d15fc1b9c36e5b6f983b62b5b" +checksum = "42a2567c305232f5ef54185e9604579a894fd0674819402bb0ac0246da82f52a" dependencies = [ "data-encoding", "futures", "if-watch", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.5.7", "tokio", - "trust-dns-proto", + "trust-dns-proto 0.22.0", "void", ] [[package]] name = "libp2p-metrics" -version = "0.11.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad8a64f29da86005c86a4d2728b8a0719e9b192f4092b609fd8790acb9dec55" +checksum = "239ba7d28f8d0b5d77760dc6619c05c7e88e74ec8fbbe97f856f20a56745e620" dependencies = [ - "libp2p-core 0.38.0", + "instant", + "libp2p-core", "libp2p-identify", + "libp2p-identity", "libp2p-kad", "libp2p-ping", "libp2p-swarm", - "prometheus-client", -] - -[[package]] -name = "libp2p-mplex" -version = "0.38.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03805b44107aa013e7cbbfa5627b31c36cbedfdfb00603c0311998882bc4bace" -dependencies = [ - "asynchronous-codec", - "bytes", - "futures", - "libp2p-core 0.38.0", - "log", - "nohash-hasher", - "parking_lot 0.12.1", - "rand 0.8.5", - "smallvec", - "unsigned-varint", -] - -[[package]] -name = "libp2p-noise" -version = "0.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a978cb57efe82e892ec6f348a536bfbd9fee677adbe5689d7a93ad3a9bffbf2e" -dependencies = [ - "bytes", - "curve25519-dalek 3.2.0", - "futures", - "libp2p-core 0.38.0", - "log", "once_cell", - "prost", - "prost-build", - "rand 0.8.5", - "sha2 0.10.6", - "snow", - "static_assertions", - "thiserror", - "x25519-dalek 1.1.1", - "zeroize", + "prometheus-client", ] [[package]] name = "libp2p-noise" -version = "0.42.0" +version = "0.43.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1216f9ec823ac7a2289b954674c54cbce81c9e45920b4fcf173018ede4295246" +checksum = "d2eeec39ad3ad0677551907dd304b2f13f17208ccebe333bef194076cd2e8921" dependencies = [ "bytes", - "curve25519-dalek 3.2.0", + "curve25519-dalek", "futures", - "libp2p-core 0.39.0", + "libp2p-core", + "libp2p-identity", "log", + "multiaddr", + "multihash 0.19.1", "once_cell", - "prost", - "prost-build", + "quick-protobuf", "rand 0.8.5", - "sha2 0.10.6", + "sha2 0.10.8", "snow", "static_assertions", "thiserror", - "x25519-dalek 1.1.1", + "x25519-dalek", "zeroize", ] [[package]] name = "libp2p-ping" -version = "0.41.0" +version = "0.43.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "929fcace45a112536e22b3dcfd4db538723ef9c3cb79f672b98be2cc8e25f37f" +checksum = "e702d75cd0827dfa15f8fd92d15b9932abe38d10d21f47c50438c71dd1b5dae3" dependencies = [ + "either", "futures", "futures-timer", "instant", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", "rand 0.8.5", @@ -3986,184 +3754,177 @@ dependencies = [ [[package]] name = "libp2p-quic" -version = "0.7.0-alpha.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5971f629ff7519f4d4889a7c981f0dc09c6ad493423cd8a13ee442de241bc8c8" +checksum = "130d451d83f21b81eb7b35b360bc7972aeafb15177784adc56528db082e6b927" dependencies = [ "bytes", "futures", "futures-timer", "if-watch", - "libp2p-core 0.39.0", + "libp2p-core", + "libp2p-identity", "libp2p-tls", "log", "parking_lot 0.12.1", - "quinn-proto", + "quinn", "rand 0.8.5", - "rustls 0.20.8", + "ring 0.16.20", + "rustls 0.21.12", + "socket2 0.5.7", "thiserror", "tokio", ] [[package]] name = "libp2p-request-response" -version = "0.23.0" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3236168796727bfcf4927f766393415361e2c644b08bedb6a6b13d957c9a4884" +checksum = "d8e3b4d67870478db72bac87bfc260ee6641d0734e0e3e275798f089c3fecfd4" dependencies = [ "async-trait", - "bytes", "futures", "instant", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-swarm", "log", "rand 0.8.5", "smallvec", - "unsigned-varint", + "void", ] [[package]] name = "libp2p-swarm" -version = "0.41.1" +version = "0.43.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a35472fe3276b3855c00f1c032ea8413615e030256429ad5349cdf67c6e1a0" +checksum = "580189e0074af847df90e75ef54f3f30059aedda37ea5a1659e8b9fca05c0141" dependencies = [ "either", "fnv", "futures", "futures-timer", "instant", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "libp2p-swarm-derive", "log", - "pin-project", + "multistream-select", + "once_cell", "rand 0.8.5", "smallvec", - "thiserror", "tokio", "void", ] [[package]] name = "libp2p-swarm-derive" -version = "0.31.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d527d5827582abd44a6d80c07ff8b50b4ee238a8979e05998474179e79dc400" +checksum = "c4d5ec2a3df00c7836d7696c136274c9c59705bac69133253696a6c932cd1d74" dependencies = [ "heck", + "proc-macro-warning", + "proc-macro2", "quote", - "syn", + "syn 2.0.68", ] [[package]] name = "libp2p-tcp" -version = "0.38.0" +version = "0.40.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b257baf6df8f2df39678b86c578961d48cc8b68642a12f0f763f56c8e5858d" +checksum = "b558dd40d1bcd1aaaed9de898e9ec6a436019ecc2420dd0016e712fbb61c5508" dependencies = [ "futures", "futures-timer", "if-watch", "libc", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "log", - "socket2", + "socket2 0.5.7", "tokio", ] [[package]] name = "libp2p-tls" -version = "0.1.0-alpha.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9baf6f6292149e124ee737d9a79dbee783f29473fc368c7faad9d157841078a" +checksum = "8218d1d5482b122ccae396bbf38abdcb283ecc96fa54760e1dfd251f0546ac61" dependencies = [ "futures", "futures-rustls", - "libp2p-core 0.39.0", - "rcgen 0.10.0", - "ring", - "rustls 0.20.8", + "libp2p-core", + "libp2p-identity", + "rcgen", + "ring 0.16.20", + "rustls 0.21.12", + "rustls-webpki", "thiserror", - "webpki 0.22.0", - "x509-parser 0.14.0", + "x509-parser", "yasna", ] [[package]] -name = "libp2p-wasm-ext" -version = "0.38.0" +name = "libp2p-upnp" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bb1a35299860e0d4b3c02a3e74e3b293ad35ae0cee8a056363b0c862d082069" +checksum = "82775a47b34f10f787ad3e2a22e2c1541e6ebef4fe9f28f3ac553921554c94c1" dependencies = [ "futures", - "js-sys", - "libp2p-core 0.38.0", - "parity-send-wrapper", - "wasm-bindgen", - "wasm-bindgen-futures", + "futures-timer", + "igd-next", + "libp2p-core", + "libp2p-swarm", + "log", + "tokio", + "void", ] [[package]] -name = "libp2p-webrtc" -version = "0.4.0-alpha.2" +name = "libp2p-wasm-ext" +version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4401ec550d36f413310ba5d4bf564bb21f89fb1601cadb32b2300f8bc1eb5b" +checksum = "1e5d8e3a9e07da0ef5b55a9f26c009c8fb3c725d492d8bb4b431715786eea79c" dependencies = [ - "async-trait", - "asynchronous-codec", - "bytes", "futures", - "futures-timer", - "hex", - "if-watch", - "libp2p-core 0.39.0", - "libp2p-noise 0.42.0", - "log", - "multihash 0.17.0", - "prost", - "prost-build", - "prost-codec", - "rand 0.8.5", - "rcgen 0.9.3", - "serde", - "stun", - "thiserror", - "tinytemplate", - "tokio", - "tokio-util", - "webrtc", + "js-sys", + "libp2p-core", + "send_wrapper", + "wasm-bindgen", + "wasm-bindgen-futures", ] [[package]] name = "libp2p-websocket" -version = "0.40.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d705506030d5c0aaf2882437c70dab437605f21c5f9811978f694e6917a3b54" +checksum = "3facf0691bab65f571bc97c6c65ffa836248ca631d631b7691ac91deb7fceb5f" dependencies = [ "either", "futures", "futures-rustls", - "libp2p-core 0.38.0", + "libp2p-core", + "libp2p-identity", "log", "parking_lot 0.12.1", "quicksink", "rw-stream-sink", "soketto", "url", - "webpki-roots", + "webpki-roots 0.25.4", ] [[package]] name = "libp2p-yamux" -version = "0.42.0" +version = "0.44.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f63594a0aa818642d9d4915c791945053877253f08a3626f13416b5cd928a29" +checksum = "8eedcb62824c4300efb9cfd4e2a6edaf3ca097b9e68b36dabe45a44469fd6a85" dependencies = [ "futures", - "libp2p-core 0.38.0", + "libp2p-core", "log", - "parking_lot 0.12.1", "thiserror", "yamux", ] @@ -4288,6 +4049,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + [[package]] name = "lite-json" version = "0.2.0" @@ -4318,12 +4085,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "lru" @@ -4334,6 +4098,15 @@ dependencies = [ "hashbrown 0.12.3", ] +[[package]] +name = "lru" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +dependencies = [ + "hashbrown 0.14.3", +] + [[package]] name = "lru-cache" version = "0.1.2" @@ -4411,15 +4184,6 @@ dependencies = [ "rawpointer", ] -[[package]] -name = "md-5" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" -dependencies = [ - "digest 0.10.6", -] - [[package]] name = "memchr" version = "2.5.0" @@ -4488,13 +4252,13 @@ checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" [[package]] name = "merlin" -version = "2.0.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" +checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" dependencies = [ "byteorder", "keccak", - "rand_core 0.5.1", + "rand_core 0.6.4", "zeroize", ] @@ -4515,14 +4279,13 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.6" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", - "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -4588,38 +4351,21 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn", -] - -[[package]] -name = "multiaddr" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aebdb21e90f81d13ed01dc84123320838e53963c2ca94b60b305d3fa64f31e" -dependencies = [ - "arrayref", - "byteorder", - "data-encoding", - "multibase", - "multihash 0.16.3", - "percent-encoding", - "serde", - "static_assertions", - "unsigned-varint", - "url", + "syn 1.0.109", ] [[package]] name = "multiaddr" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b53e0cc5907a5c216ba6584bf74be8ab47d6d6289f72793b2dddbf15dc3bf8c" +checksum = "92a651988b3ed3ad1bc8c87d016bb92f6f395b84ed1db9b926b32b1fc5a2c8b5" dependencies = [ "arrayref", "byteorder", "data-encoding", + "libp2p-identity", "multibase", - "multihash 0.17.0", + "multihash 0.19.1", "percent-encoding", "serde", "static_assertions", @@ -4648,37 +4394,78 @@ dependencies = [ "blake2s_simd", "blake3", "core2", - "digest 0.10.6", - "multihash-derive", - "sha2 0.10.6", + "digest 0.10.7", + "multihash-derive 0.8.0", + "sha2 0.10.8", "sha3", "unsigned-varint", ] [[package]] name = "multihash" -version = "0.17.0" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" +checksum = "076d548d76a0e2a0d4ab471d0b1c36c577786dfc4471242035d97a12a735c492" dependencies = [ "core2", - "digest 0.10.6", - "multihash-derive", - "sha2 0.10.6", "unsigned-varint", ] +[[package]] +name = "multihash-codetable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e46d7ff0b9b8d818e709e12135bfb6582fcde982ba2be48ea52e6e1df098c7a4" +dependencies = [ + "blake2b_simd", + "blake2s_simd", + "blake3", + "core2", + "digest 0.10.7", + "multihash-derive 0.9.0", + "ripemd", + "sha-1 0.10.1", + "sha2 0.10.8", + "sha3", + "strobe-rs", +] + [[package]] name = "multihash-derive" -version = "0.8.1" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc076939022111618a5026d3be019fd8b366e76314538ff9a1b59ffbcbf98bcd" +dependencies = [ + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] + +[[package]] +name = "multihash-derive" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "890e72cb7396cb99ed98c1246a97b243cc16394470d94e0bc8b0c2c11d84290e" +dependencies = [ + "core2", + "multihash 0.19.1", + "multihash-derive-impl", +] + +[[package]] +name = "multihash-derive-impl" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" +checksum = "d38685e08adb338659871ecfc6ee47ba9b22dcc8abcf6975d379cc49145c3040" dependencies = [ "proc-macro-crate", "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "synstructure", ] @@ -4690,9 +4477,9 @@ checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" [[package]] name = "multistream-select" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" +checksum = "ea0df8e5eec2298a62b326ee4f0d7fe1a6b90a09dfcf9df37b38f947a8c42f19" dependencies = [ "bytes", "futures", @@ -4726,7 +4513,7 @@ checksum = "d232c68884c0c99810a5a4d333ef7e47689cfd0edc85efc9e54e1e6bf5212766" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -4757,7 +4544,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" dependencies = [ "anyhow", - "bitflags", + "bitflags 1.3.2", "byteorder", "libc", "netlink-packet-core", @@ -4810,10 +4597,9 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", - "memoffset 0.6.5", ] [[package]] @@ -4822,7 +4608,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset 0.7.1", @@ -4894,7 +4680,7 @@ dependencies = [ "pallet-timestamp", "pallet-transaction-payment", "parity-scale-codec", - "platforms 2.0.0", + "platforms", "rand 0.8.5", "regex", "sc-authority-discovery", @@ -5224,13 +5010,19 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-format" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" dependencies = [ - "arrayvec 0.7.2", + "arrayvec", "itoa", ] @@ -5263,7 +5055,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", - "libm 0.2.6", + "libm", ] [[package]] @@ -5284,7 +5076,7 @@ checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ "crc32fast", "hashbrown 0.12.3", - "indexmap", + "indexmap 1.9.2", "memchr", ] @@ -5297,29 +5089,20 @@ dependencies = [ "memchr", ] -[[package]] -name = "oid-registry" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38e20717fa0541f39bd146692035c37bedfa532b3e5071b35761082407546b2a" -dependencies = [ - "asn1-rs 0.3.1", -] - [[package]] name = "oid-registry" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" dependencies = [ - "asn1-rs 0.5.1", + "asn1-rs", ] [[package]] name = "once_cell" -version = "1.17.1" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oorandom" @@ -5327,12 +5110,6 @@ version = "11.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - [[package]] name = "opaque-debug" version = "0.3.0" @@ -5367,40 +5144,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] -name = "p256" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" -dependencies = [ - "ecdsa", - "elliptic-curve", - "sha2 0.10.6", -] - -[[package]] -name = "p384" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" -dependencies = [ - "ecdsa", - "elliptic-curve", - "sha2 0.10.6", -] - -[[package]] -name = "packed_simd_2" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1914cd452d8fccd6f9db48147b29fd4ae05bea9dc5d9ad578509f72415de282" -dependencies = [ - "cfg-if", - "libm 0.1.4", -] - -[[package]] -name = "pallet-alliance" -version = "4.0.0-dev" +name = "pallet-alliance" +version = "4.0.0-dev" dependencies = [ "array-bytes", "frame-benchmarking", @@ -5723,7 +5468,7 @@ version = "4.0.0-dev" dependencies = [ "array-bytes", "assert_matches", - "bitflags", + "bitflags 1.3.2", "env_logger 0.9.3", "environmental", "frame-benchmarking", @@ -5760,7 +5505,7 @@ dependencies = [ name = "pallet-contracts-primitives" version = "7.0.0" dependencies = [ - "bitflags", + "bitflags 1.3.2", "parity-scale-codec", "scale-info", "sp-runtime", @@ -5774,7 +5519,7 @@ version = "4.0.0-dev" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -6659,7 +6404,7 @@ dependencies = [ "proc-macro2", "quote", "sp-runtime", - "syn", + "syn 1.0.109", ] [[package]] @@ -6949,7 +6694,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "637935964ff85a605d114591d4d2c13c5d1ba2806dae97cea6bf180238a749ac" dependencies = [ - "arrayvec 0.7.2", + "arrayvec", "bitvec", "byte-slice-cast", "bytes", @@ -6967,15 +6712,9 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] -[[package]] -name = "parity-send-wrapper" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" - [[package]] name = "parity-wasm" version = "0.45.0" @@ -7057,7 +6796,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -7075,20 +6814,11 @@ dependencies = [ "base64 0.13.1", ] -[[package]] -name = "pem-rfc7468" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d159833a9105500e0398934e205e0773f0b27529557134ecfc51c27646adac" -dependencies = [ - "base64ct", -] - [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" @@ -7120,7 +6850,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -7131,7 +6861,7 @@ checksum = "e6f60b2ba541577e2a0c307c8f39d1439108120eb7903adeb6497fa880c59616" dependencies = [ "once_cell", "pest", - "sha2 0.10.6", + "sha2 0.10.8", ] [[package]] @@ -7141,27 +6871,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 1.9.2", ] [[package]] name = "pin-project" -version = "1.0.12" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.0.12" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" +checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.68", ] [[package]] @@ -7172,9 +6902,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -7184,9 +6914,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkcs8" -version = "0.9.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ "der", "spki", @@ -7204,12 +6934,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8d0eef3571242013a0d5dc84861c3ae4a652e56e12adf8bdc26ff5f8cb34c94" -[[package]] -name = "platforms" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" - [[package]] name = "plotters" version = "0.3.4" @@ -7240,52 +6964,47 @@ dependencies = [ [[package]] name = "polling" -version = "2.5.2" +version = "3.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22122d5ec4f9fe1b3916419b76be1e80bcb93f618d071d2edf841b137b2a2bd6" +checksum = "a3ed00ed3fbf728b5816498ecd316d1716eecaced9c0c8d2c5a6740ca214985b" dependencies = [ - "autocfg", "cfg-if", - "libc", - "log", - "wepoll-ffi", - "windows-sys 0.42.0", + "concurrent-queue", + "hermit-abi 0.4.0", + "pin-project-lite 0.2.14", + "rustix 0.38.34", + "tracing", + "windows-sys 0.52.0", ] [[package]] name = "poly1305" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" dependencies = [ "cpufeatures", - "opaque-debug 0.3.0", - "universal-hash 0.4.1", + "opaque-debug", + "universal-hash", ] [[package]] name = "polyval" -version = "0.5.3" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" dependencies = [ "cfg-if", "cpufeatures", - "opaque-debug 0.3.0", - "universal-hash 0.4.1", + "opaque-debug", + "universal-hash", ] [[package]] -name = "polyval" -version = "0.6.0" +name = "powerfmt" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef234e08c11dfcb2e56f79fd70f6f2eb7f025c0ce2333e82f4f0518ecad30c6" -dependencies = [ - "cfg-if", - "cpufeatures", - "opaque-debug 0.3.0", - "universal-hash 0.5.0", -] +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" @@ -7342,7 +7061,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e97e3215779627f01ee256d2fad52f3d95e8e1c11e9fc6fd08f7cd455d5d5c78" dependencies = [ "proc-macro2", - "syn", + "syn 1.0.109", ] [[package]] @@ -7360,12 +7079,12 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.1.3" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ - "thiserror", - "toml", + "once_cell", + "toml_edit", ] [[package]] @@ -7377,7 +7096,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -7392,11 +7111,22 @@ dependencies = [ "version_check", ] +[[package]] +name = "proc-macro-warning" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.68", +] + [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -7417,25 +7147,25 @@ dependencies = [ [[package]] name = "prometheus-client" -version = "0.18.1" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83cd1b99916654a69008fd66b4f9397fbe08e6e51dfe23d4417acf5d3b8cb87c" +checksum = "3c99afa9a01501019ac3a14d71d9f94050346f55ca471ce90c799a15c58f61e2" dependencies = [ "dtoa", "itoa", "parking_lot 0.12.1", - "prometheus-client-derive-text-encode", + "prometheus-client-derive-encode", ] [[package]] -name = "prometheus-client-derive-text-encode" -version = "0.3.0" +name = "prometheus-client-derive-encode" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66a455fbcb954c1a7decf3c586e860fd7889cddf4b8e164be736dbac95a953cd" +checksum = "72b6a5217beb0ad503ee7fa752d451c905113d70721b937126158f3106a48cc1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -7465,24 +7195,11 @@ dependencies = [ "prost", "prost-types", "regex", - "syn", + "syn 1.0.109", "tempfile", "which", ] -[[package]] -name = "prost-codec" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc34979ff898b6e141106178981ce2596c387ea6e62533facfc61a37fc879c0" -dependencies = [ - "asynchronous-codec", - "bytes", - "prost", - "thiserror", - "unsigned-varint", -] - [[package]] name = "prost-derive" version = "0.11.8" @@ -7493,7 +7210,7 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -7520,6 +7237,28 @@ version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" +[[package]] +name = "quick-protobuf" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d6da84cc204722a989e01ba2f6e1e276e190f22263d0cb6ce8526fcdb0d2e1f" +dependencies = [ + "byteorder", +] + +[[package]] +name = "quick-protobuf-codec" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ededb1cd78531627244d51dd0c7139fbe736c7d57af0092a76f0ffb2f56e98" +dependencies = [ + "asynchronous-codec", + "bytes", + "quick-protobuf", + "thiserror", + "unsigned-varint", +] + [[package]] name = "quickcheck" version = "1.0.3" @@ -7540,29 +7279,59 @@ dependencies = [ "pin-project-lite 0.1.12", ] +[[package]] +name = "quinn" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cc2c5017e4b43d5995dcea317bc46c1e09404c0a9664d2908f7f02dfe943d75" +dependencies = [ + "bytes", + "futures-io", + "pin-project-lite 0.2.14", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls 0.21.12", + "thiserror", + "tokio", + "tracing", +] + [[package]] name = "quinn-proto" -version = "0.9.2" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4ced82a24bb281af338b9e8f94429b6eca01b4e66d899f40031f074e74c9" +checksum = "141bf7dfde2fbc246bfd3fe12f2455aa24b0fbd9af535d8c86c7bd1381ff2b1a" dependencies = [ "bytes", "rand 0.8.5", - "ring", + "ring 0.16.20", "rustc-hash", - "rustls 0.20.8", + "rustls 0.21.12", "slab", "thiserror", "tinyvec", "tracing", - "webpki 0.22.0", +] + +[[package]] +name = "quinn-udp" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "055b4e778e8feb9f93c4e439f71dc2156ef13360b432b799e179a8c4cdf0b1d7" +dependencies = [ + "bytes", + "libc", + "socket2 0.5.7", + "tracing", + "windows-sys 0.48.0", ] [[package]] name = "quote" -version = "1.0.23" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -7691,19 +7460,6 @@ dependencies = [ "num_cpus", ] -[[package]] -name = "rcgen" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" -dependencies = [ - "pem", - "ring", - "time 0.3.20", - "x509-parser 0.13.2", - "yasna", -] - [[package]] name = "rcgen" version = "0.10.0" @@ -7711,8 +7467,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", - "ring", - "time 0.3.20", + "ring 0.16.20", + "time 0.3.36", "yasna", ] @@ -7722,7 +7478,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -7753,7 +7509,7 @@ checksum = "9f9c0c92af03644e4806106281fe2e068ac5bc0ae74a707266d06ea27bccee5f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -7800,7 +7556,7 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", "mach", "winapi", @@ -7818,13 +7574,12 @@ dependencies = [ [[package]] name = "rfc6979" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ - "crypto-bigint", "hmac 0.12.1", - "zeroize", + "subtle", ] [[package]] @@ -7837,11 +7592,34 @@ dependencies = [ "libc", "once_cell", "spin 0.5.2", - "untrusted", + "untrusted 0.7.1", "web-sys", "winapi", ] +[[package]] +name = "ring" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9babe80d5c16becf6594aa32ad2be8fe08498e7ae60b77de8df700e67f191d7e" +dependencies = [ + "cc", + "getrandom 0.2.8", + "libc", + "spin 0.9.5", + "untrusted 0.9.0", + "windows-sys 0.48.0", +] + +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest 0.10.7", +] + [[package]] name = "rocksdb" version = "0.19.0" @@ -7863,17 +7641,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rtcp" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1919efd6d4a6a85d13388f9487549bb8e359f17198cc03ffd72f79b553873691" -dependencies = [ - "bytes", - "thiserror", - "webrtc-util", -] - [[package]] name = "rtnetlink" version = "0.10.1" @@ -7899,20 +7666,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rtp" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2a095411ff00eed7b12e4c6a118ba984d113e1079582570d56a5ee723f11f80" -dependencies = [ - "async-trait", - "bytes", - "rand 0.8.5", - "serde", - "thiserror", - "webrtc-util", -] - [[package]] name = "rustc-demangle" version = "0.1.21" @@ -7964,8 +7717,8 @@ version = "0.35.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "727a1a6d65f786ec22df8a81ca3121107f235970dc1705ed681d3e6e8b9cd5f9" dependencies = [ - "bitflags", - "errno", + "bitflags 1.3.2", + "errno 0.2.8", "io-lifetimes 0.7.5", "libc", "linux-raw-sys 0.0.46", @@ -7978,8 +7731,8 @@ version = "0.36.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" dependencies = [ - "bitflags", - "errno", + "bitflags 1.3.2", + "errno 0.2.8", "io-lifetimes 1.0.5", "libc", "linux-raw-sys 0.1.4", @@ -7987,16 +7740,16 @@ dependencies = [ ] [[package]] -name = "rustls" -version = "0.19.1" +name = "rustix" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "base64 0.13.1", - "log", - "ring", - "sct 0.6.1", - "webpki 0.21.4", + "bitflags 2.5.0", + "errno 0.3.9", + "libc", + "linux-raw-sys 0.4.14", + "windows-sys 0.52.0", ] [[package]] @@ -8006,9 +7759,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ "log", - "ring", - "sct 0.7.0", - "webpki 0.22.0", + "ring 0.16.20", + "sct", + "webpki", +] + +[[package]] +name = "rustls" +version = "0.21.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +dependencies = [ + "log", + "ring 0.17.3", + "rustls-webpki", + "sct", ] [[package]] @@ -8032,6 +7797,16 @@ dependencies = [ "base64 0.21.0", ] +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring 0.17.3", + "untrusted 0.9.0", +] + [[package]] name = "rustversion" version = "1.0.11" @@ -8051,9 +7826,9 @@ dependencies = [ [[package]] name = "rw-stream-sink" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" +checksum = "d8c9026ff5d2f23da5e45bbc283f156383001bfb09c4e44256d02c1a685fe9a1" dependencies = [ "futures", "pin-project", @@ -8113,6 +7888,7 @@ dependencies = [ "ip_network", "libp2p", "log", + "multihash-codetable", "parity-scale-codec", "prost", "prost-build", @@ -8199,7 +7975,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -8212,7 +7988,7 @@ dependencies = [ "fdlimit", "futures", "futures-timer", - "libp2p", + "libp2p-identity", "log", "names", "parity-scale-codec", @@ -8312,7 +8088,7 @@ dependencies = [ "async-trait", "futures", "futures-timer", - "libp2p", + "libp2p-identity", "log", "mockall", "parking_lot 0.12.1", @@ -8523,7 +8299,7 @@ dependencies = [ name = "sc-consensus-grandpa" version = "0.10.0-dev" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "array-bytes", "assert_matches", "async-trait", @@ -8681,7 +8457,7 @@ dependencies = [ "assert_matches", "criterion", "env_logger 0.9.3", - "lru", + "lru 0.8.1", "num_cpus", "parity-scale-codec", "parking_lot 0.12.1", @@ -8807,9 +8583,10 @@ dependencies = [ "futures-timer", "ip_network", "libp2p", + "libp2p-kad", "linked_hash_set", "log", - "lru", + "lru 0.8.1", "mockall", "multistream-select", "parity-scale-codec", @@ -8843,6 +8620,7 @@ dependencies = [ "tokio-test", "tokio-util", "unsigned-varint", + "void", "zeroize", ] @@ -8852,7 +8630,7 @@ version = "0.10.0-dev" dependencies = [ "cid", "futures", - "libp2p", + "libp2p-identity", "log", "prost", "prost-build", @@ -8878,11 +8656,11 @@ version = "0.10.0-dev" dependencies = [ "array-bytes", "async-trait", - "bitflags", + "bitflags 1.3.2", "bytes", "futures", "futures-timer", - "libp2p", + "libp2p-identity", "parity-scale-codec", "prost-build", "sc-consensus", @@ -8904,12 +8682,13 @@ dependencies = [ name = "sc-network-gossip" version = "0.10.0-dev" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "futures", "futures-timer", - "libp2p", + "libp2p-identity", "log", - "lru", + "lru 0.8.1", + "multiaddr", "quickcheck", "sc-network", "sc-network-common", @@ -8927,7 +8706,7 @@ version = "0.10.0-dev" dependencies = [ "array-bytes", "futures", - "libp2p", + "libp2p-identity", "log", "parity-scale-codec", "prost", @@ -8953,7 +8732,7 @@ dependencies = [ "futures-timer", "libp2p", "log", - "lru", + "lru 0.8.1", "mockall", "parity-scale-codec", "prost", @@ -9074,7 +8853,7 @@ name = "sc-peerset" version = "4.0.0-dev" dependencies = [ "futures", - "libp2p", + "libp2p-identity", "log", "rand 0.8.5", "sc-utils", @@ -9426,7 +9205,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -9515,7 +9294,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -9533,25 +9312,26 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "cfg-if", "hashbrown 0.13.2", ] [[package]] name = "schnorrkel" -version = "0.9.1" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" +checksum = "8de18f6d8ba0aad7045f5feae07ec29899c1112584a38509a84ad7b04451eaa0" dependencies = [ + "aead", "arrayref", - "arrayvec 0.5.2", - "curve25519-dalek 2.1.3", - "getrandom 0.1.16", + "arrayvec", + "curve25519-dalek", + "getrandom_or_panic", "merlin", - "rand 0.7.3", - "rand_core 0.5.1", - "sha2 0.8.2", + "rand_core 0.6.4", + "serde_bytes", + "sha2 0.10.8", "subtle", "zeroize", ] @@ -9568,47 +9348,25 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" -[[package]] -name = "sct" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "sct" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "sdp" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d22a5ef407871893fd72b4562ee15e4742269b173959db4b8df6f538c414e13" -dependencies = [ - "rand 0.8.5", - "substring", - "thiserror", - "url", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] name = "sec1" -version = "0.3.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +checksum = "48518a2b5775ba8ca5b46596aae011caa431e6ce7e4a67ead66d92f08884220e" dependencies = [ "base16ct", "der", - "generic-array 0.14.6", + "generic-array", "pkcs8", "subtle", "zeroize", @@ -9647,7 +9405,7 @@ version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -9697,24 +9455,39 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" + [[package]] name = "serde" -version = "1.0.152" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] +[[package]] +name = "serde_bytes" +version = "0.11.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" +dependencies = [ + "serde", +] + [[package]] name = "serde_derive" -version = "1.0.152" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.68", ] [[package]] @@ -9738,30 +9511,18 @@ dependencies = [ "cfg-if", "cpufeatures", "digest 0.9.0", - "opaque-debug 0.3.0", + "opaque-debug", ] [[package]] -name = "sha1" -version = "0.10.5" +name = "sha-1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.6", -] - -[[package]] -name = "sha2" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", + "digest 0.10.7", ] [[package]] @@ -9774,18 +9535,18 @@ dependencies = [ "cfg-if", "cpufeatures", "digest 0.9.0", - "opaque-debug 0.3.0", + "opaque-debug", ] [[package]] name = "sha2" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.6", + "digest 0.10.7", ] [[package]] @@ -9794,7 +9555,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", "keccak", ] @@ -9824,11 +9585,11 @@ dependencies = [ [[package]] name = "signature" -version = "1.6.4" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ - "digest 0.10.6", + "digest 0.10.7", "rand_core 0.6.4", ] @@ -9868,9 +9629,9 @@ checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" [[package]] name = "smallvec" -version = "1.10.0" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "snap" @@ -9880,18 +9641,18 @@ checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831" [[package]] name = "snow" -version = "0.9.1" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ba5f4d4ff12bdb6a169ed51b7c48c0e0ac4b0b4b31012b2571e97d78d3201d" +checksum = "850948bee068e713b8ab860fe1adc4d109676ab4c3b621fd8147f06b261f2f85" dependencies = [ - "aes-gcm 0.9.4", + "aes-gcm", "blake2", "chacha20poly1305", - "curve25519-dalek 4.0.0-rc.0", + "curve25519-dalek", "rand_core 0.6.4", - "ring", + "ring 0.17.3", "rustc_version 0.4.0", - "sha2 0.10.6", + "sha2 0.10.8", "subtle", ] @@ -9905,6 +9666,16 @@ dependencies = [ "winapi", ] +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + [[package]] name = "soketto" version = "0.7.1" @@ -9913,13 +9684,12 @@ checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" dependencies = [ "base64 0.13.1", "bytes", - "flate2", "futures", "http", "httparse", "log", "rand 0.8.5", - "sha-1", + "sha-1 0.9.8", ] [[package]] @@ -9950,7 +9720,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -10054,7 +9824,7 @@ version = "4.0.0-dev" dependencies = [ "futures", "log", - "lru", + "lru 0.8.1", "parity-scale-codec", "parking_lot 0.12.1", "sp-api", @@ -10196,7 +9966,7 @@ version = "7.0.0" dependencies = [ "array-bytes", "base58", - "bitflags", + "bitflags 1.3.2", "blake2", "bounded-collections", "criterion", @@ -10242,8 +10012,8 @@ version = "5.0.0" dependencies = [ "blake2b_simd", "byteorder", - "digest 0.10.6", - "sha2 0.10.6", + "digest 0.10.7", + "sha2 0.10.8", "sha3", "sp-std", "twox-hash", @@ -10256,7 +10026,7 @@ dependencies = [ "proc-macro2", "quote", "sp-core-hashing", - "syn", + "syn 1.0.109", ] [[package]] @@ -10273,7 +10043,7 @@ version = "5.0.0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -10306,7 +10076,6 @@ name = "sp-io" version = "7.0.0" dependencies = [ "bytes", - "ed25519", "ed25519-dalek", "futures", "libsecp256k1", @@ -10493,7 +10262,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -10670,7 +10439,7 @@ dependencies = [ name = "sp-trie" version = "7.0.0" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "array-bytes", "criterion", "hash-db", @@ -10717,7 +10486,7 @@ dependencies = [ "proc-macro2", "quote", "sp-version", - "syn", + "syn 1.0.109", ] [[package]] @@ -10761,9 +10530,9 @@ checksum = "7dccf47db1b41fa1573ed27ccf5e08e3ca771cb994f776668c5ebda893b248fc" [[package]] name = "spki" -version = "0.6.0" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", "der", @@ -10802,7 +10571,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a2a1c578e98c1c16fc3b8ec1328f7659a500737d7a0c6d625e73e830ff9c1f6" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg_aliases", "libc", "parking_lot 0.11.2", @@ -10821,18 +10590,31 @@ dependencies = [ "memchr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "strum" -version = "0.24.1" +name = "strobe-rs" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fabb238a1cccccfa4c4fb703670c0d157e1256c1ba695abf1b93bd2bb14bab2d" +dependencies = [ + "bitflags 1.3.2", + "byteorder", + "keccak", + "subtle", + "zeroize", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "strum" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" dependencies = [ @@ -10849,26 +10631,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", -] - -[[package]] -name = "stun" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7e94b1ec00bad60e6410e058b52f1c66de3dc5fe4d62d09b3e52bb7d3b73e25" -dependencies = [ - "base64 0.13.1", - "crc", - "lazy_static", - "md-5", - "rand 0.8.5", - "ring", - "subtle", - "thiserror", - "tokio", - "url", - "webrtc-util", + "syn 1.0.109", ] [[package]] @@ -10881,9 +10644,9 @@ dependencies = [ [[package]] name = "substrate-bip39" -version = "0.4.4" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49eee6965196b32f882dd2ee85a92b1dbead41b04e53907f269de3b0dc04733c" +checksum = "6a7590dc041b9bc2825e52ce5af8416c73dbe9d0654402bfd4b4941938b94d8f" dependencies = [ "hmac 0.11.0", "pbkdf2 0.8.0", @@ -10896,7 +10659,7 @@ dependencies = [ name = "substrate-build-script-utils" version = "3.0.0" dependencies = [ - "platforms 2.0.0", + "platforms", ] [[package]] @@ -11119,7 +10882,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -11147,15 +10910,6 @@ dependencies = [ "wasm-opt", ] -[[package]] -name = "substring" -version = "1.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ee6433ecef213b2e72f587ef64a2f5943e7cd16fbd82dbe8bc07486c534c86" -dependencies = [ - "autocfg", -] - [[package]] name = "subtle" version = "2.4.1" @@ -11173,6 +10927,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "synstructure" version = "0.12.6" @@ -11181,7 +10946,7 @@ checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "unicode-xid", ] @@ -11191,7 +10956,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d75182f12f490e953596550b65ee31bda7c8e043d9386174b353bda50838c3fd" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] @@ -11254,22 +11019,22 @@ checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] name = "thiserror" -version = "1.0.38" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.38" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.68", ] [[package]] @@ -11320,11 +11085,14 @@ dependencies = [ [[package]] name = "time" -version = "0.3.20" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ + "deranged", "itoa", + "num-conv", + "powerfmt", "serde", "time-core", "time-macros", @@ -11332,16 +11100,17 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.8" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] @@ -11357,7 +11126,7 @@ dependencies = [ "pbkdf2 0.11.0", "rand 0.8.5", "rustc-hash", - "sha2 0.10.6", + "sha2 0.10.8", "thiserror", "unicode-normalization", "wasm-bindgen", @@ -11400,33 +11169,32 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.25.0" +version = "1.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" +checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" dependencies = [ - "autocfg", + "backtrace", "bytes", "libc", - "memchr", "mio", "num_cpus", "parking_lot 0.12.1", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.14", "signal-hook-registry", - "socket2", + "socket2 0.5.7", "tokio-macros", - "windows-sys 0.42.0", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "1.8.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.68", ] [[package]] @@ -11437,7 +11205,7 @@ checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" dependencies = [ "rustls 0.20.8", "tokio", - "webpki 0.22.0", + "webpki", ] [[package]] @@ -11447,7 +11215,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" dependencies = [ "futures-core", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.14", "tokio", "tokio-util", ] @@ -11475,7 +11243,7 @@ dependencies = [ "futures-core", "futures-io", "futures-sink", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.14", "tokio", "tracing", ] @@ -11489,6 +11257,23 @@ dependencies = [ "serde", ] +[[package]] +name = "toml_datetime" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" + +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap 2.2.6", + "toml_datetime", + "winnow", +] + [[package]] name = "tower" version = "0.4.13" @@ -11506,14 +11291,14 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" dependencies = [ - "bitflags", + "bitflags 1.3.2", "bytes", "futures-core", "futures-util", "http", "http-body", "http-range-header", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.14", "tower-layer", "tower-service", ] @@ -11538,7 +11323,7 @@ checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.14", "tracing-attributes", "tracing-core", ] @@ -11551,7 +11336,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -11693,7 +11478,7 @@ dependencies = [ "async-trait", "cfg-if", "data-encoding", - "enum-as-inner", + "enum-as-inner 0.5.1", "futures-channel", "futures-io", "futures-util", @@ -11702,7 +11487,32 @@ dependencies = [ "lazy_static", "rand 0.8.5", "smallvec", - "socket2", + "socket2 0.4.7", + "thiserror", + "tinyvec", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "trust-dns-proto" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3119112651c157f4488931a01e586aa459736e9d6046d3bd9105ffb69352d374" +dependencies = [ + "async-trait", + "cfg-if", + "data-encoding", + "enum-as-inner 0.6.0", + "futures-channel", + "futures-io", + "futures-util", + "idna 0.4.0", + "ipnet", + "once_cell", + "rand 0.8.5", + "smallvec", "thiserror", "tinyvec", "tokio", @@ -11712,22 +11522,23 @@ dependencies = [ [[package]] name = "trust-dns-resolver" -version = "0.22.0" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aff21aa4dcefb0a1afbfac26deb0adc93888c7d295fb63ab273ef276ba2b7cfe" +checksum = "10a3e6c3aff1718b3c73e395d1f35202ba2ffa847c6a62eea0db8fb4cfe30be6" dependencies = [ "cfg-if", "futures-util", "ipconfig", - "lazy_static", "lru-cache", + "once_cell", "parking_lot 0.12.1", + "rand 0.8.5", "resolv-conf", "smallvec", "thiserror", "tokio", "tracing", - "trust-dns-proto", + "trust-dns-proto 0.23.2", ] [[package]] @@ -11795,25 +11606,6 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" -[[package]] -name = "turn" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4712ee30d123ec7ae26d1e1b218395a16c87cdbaf4b3925d170d684af62ea5e8" -dependencies = [ - "async-trait", - "base64 0.13.1", - "futures", - "log", - "md-5", - "rand 0.8.5", - "ring", - "stun", - "thiserror", - "tokio", - "webrtc-util", -] - [[package]] name = "twox-hash" version = "1.6.3" @@ -11821,7 +11613,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", - "digest 0.10.6", + "digest 0.10.7", "rand 0.8.5", "static_assertions", ] @@ -11883,16 +11675,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" -[[package]] -name = "universal-hash" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" -dependencies = [ - "generic-array 0.14.6", - "subtle", -] - [[package]] name = "universal-hash" version = "0.5.0" @@ -11922,23 +11704,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] -name = "url" -version = "2.3.1" +name = "untrusted" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" -dependencies = [ - "form_urlencoded", - "idna 0.3.0", - "percent-encoding", -] +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] -name = "uuid" -version = "1.3.0" +name = "url" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ - "getrandom 0.2.8", + "form_urlencoded", + "idna 0.5.0", + "percent-encoding", ] [[package]] @@ -11974,15 +11753,6 @@ dependencies = [ "libc", ] -[[package]] -name = "waitgroup" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1f50000a783467e6c0200f9d10642f4bc424e39efc1b770203e88b488f79292" -dependencies = [ - "atomic-waker", -] - [[package]] name = "waker-fn" version = "1.1.0" @@ -12030,9 +11800,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -12040,24 +11810,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.68", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.34" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "js-sys", @@ -12067,9 +11837,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -12077,22 +11847,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.68", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-encoder" @@ -12222,7 +11992,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" dependencies = [ "downcast-rs", - "libm 0.2.6", + "libm", "memory_units", "num-rational", "num-traits", @@ -12236,7 +12006,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5bf998ab792be85e20e771fe14182b4295571ad1d4f89d3da521c1bef5f597a" dependencies = [ "downcast-rs", - "libm 0.2.6", + "libm", "num-traits", ] @@ -12246,7 +12016,7 @@ version = "0.100.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64b20236ab624147dfbb62cf12a19aaf66af0e41b8398838b66e997d07d269d4" dependencies = [ - "indexmap", + "indexmap 1.9.2", "url", ] @@ -12268,7 +12038,7 @@ dependencies = [ "anyhow", "bincode", "cfg-if", - "indexmap", + "indexmap 1.9.2", "libc", "log", "object 0.29.0", @@ -12310,7 +12080,7 @@ dependencies = [ "log", "rustix 0.36.8", "serde", - "sha2 0.10.6", + "sha2 0.10.8", "toml", "windows-sys 0.42.0", "zstd", @@ -12346,7 +12116,7 @@ dependencies = [ "anyhow", "cranelift-entity", "gimli 0.26.2", - "indexmap", + "indexmap 1.9.2", "log", "object 0.29.0", "serde", @@ -12411,7 +12181,7 @@ dependencies = [ "anyhow", "cc", "cfg-if", - "indexmap", + "indexmap 1.9.2", "libc", "log", "mach", @@ -12469,24 +12239,14 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "webpki" version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -12495,229 +12255,14 @@ version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ - "webpki 0.22.0", + "webpki", ] [[package]] -name = "webrtc" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3bc9049bdb2cea52f5fd4f6f728184225bdb867ed0dc2410eab6df5bdd67bb" -dependencies = [ - "arc-swap", - "async-trait", - "bytes", - "hex", - "interceptor", - "lazy_static", - "log", - "rand 0.8.5", - "rcgen 0.9.3", - "regex", - "ring", - "rtcp", - "rtp", - "rustls 0.19.1", - "sdp", - "serde", - "serde_json", - "sha2 0.10.6", - "stun", - "thiserror", - "time 0.3.20", - "tokio", - "turn", - "url", - "waitgroup", - "webrtc-data", - "webrtc-dtls", - "webrtc-ice", - "webrtc-mdns", - "webrtc-media", - "webrtc-sctp", - "webrtc-srtp", - "webrtc-util", -] - -[[package]] -name = "webrtc-data" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef36a4d12baa6e842582fe9ec16a57184ba35e1a09308307b67d43ec8883100" -dependencies = [ - "bytes", - "derive_builder", - "log", - "thiserror", - "tokio", - "webrtc-sctp", - "webrtc-util", -] - -[[package]] -name = "webrtc-dtls" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942be5bd85f072c3128396f6e5a9bfb93ca8c1939ded735d177b7bcba9a13d05" -dependencies = [ - "aes 0.6.0", - "aes-gcm 0.10.1", - "async-trait", - "bincode", - "block-modes", - "byteorder", - "ccm", - "curve25519-dalek 3.2.0", - "der-parser 8.1.0", - "elliptic-curve", - "hkdf", - "hmac 0.12.1", - "log", - "oid-registry 0.6.1", - "p256", - "p384", - "rand 0.8.5", - "rand_core 0.6.4", - "rcgen 0.9.3", - "ring", - "rustls 0.19.1", - "sec1", - "serde", - "sha1", - "sha2 0.10.6", - "signature", - "subtle", - "thiserror", - "tokio", - "webpki 0.21.4", - "webrtc-util", - "x25519-dalek 2.0.0-pre.1", - "x509-parser 0.13.2", -] - -[[package]] -name = "webrtc-ice" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465a03cc11e9a7d7b4f9f99870558fe37a102b65b93f8045392fef7c67b39e80" -dependencies = [ - "arc-swap", - "async-trait", - "crc", - "log", - "rand 0.8.5", - "serde", - "serde_json", - "stun", - "thiserror", - "tokio", - "turn", - "url", - "uuid", - "waitgroup", - "webrtc-mdns", - "webrtc-util", -] - -[[package]] -name = "webrtc-mdns" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" -dependencies = [ - "log", - "socket2", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "webrtc-media" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a3c157a040324e5049bcbd644ffc9079e6738fa2cfab2bcff64e5cc4c00d7" -dependencies = [ - "byteorder", - "bytes", - "derive_builder", - "displaydoc", - "rand 0.8.5", - "rtp", - "thiserror", - "webrtc-util", -] - -[[package]] -name = "webrtc-sctp" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d47adcd9427eb3ede33d5a7f3424038f63c965491beafcc20bc650a2f6679c0" -dependencies = [ - "arc-swap", - "async-trait", - "bytes", - "crc", - "log", - "rand 0.8.5", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "webrtc-srtp" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6183edc4c1c6c0175f8812eefdce84dfa0aea9c3ece71c2bf6ddd3c964de3da5" -dependencies = [ - "aead 0.4.3", - "aes 0.7.5", - "aes-gcm 0.9.4", - "async-trait", - "byteorder", - "bytes", - "ctr 0.8.0", - "hmac 0.11.0", - "log", - "rtcp", - "rtp", - "sha-1", - "subtle", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "webrtc-util" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" -dependencies = [ - "async-trait", - "bitflags", - "bytes", - "cc", - "ipnet", - "lazy_static", - "libc", - "log", - "nix 0.24.3", - "rand 0.8.5", - "thiserror", - "tokio", - "winapi", -] - -[[package]] -name = "wepoll-ffi" -version = "0.1.2" +name = "webpki-roots" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" -dependencies = [ - "cc", -] +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "which" @@ -12779,15 +12324,21 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.34.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45296b64204227616fdbf2614cefa4c236b98ee64dfaaaa435207ed99fe7829f" +checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" dependencies = [ - "windows_aarch64_msvc 0.34.0", - "windows_i686_gnu 0.34.0", - "windows_i686_msvc 0.34.0", - "windows_x86_64_gnu 0.34.0", - "windows_x86_64_msvc 0.34.0", + "windows-core", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets 0.48.5", ] [[package]] @@ -12796,12 +12347,12 @@ version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", + "windows_aarch64_gnullvm 0.42.1", "windows_aarch64_msvc 0.42.1", "windows_i686_gnu 0.42.1", "windows_i686_msvc 0.42.1", "windows_x86_64_gnu 0.42.1", - "windows_x86_64_gnullvm", + "windows_x86_64_gnullvm 0.42.1", "windows_x86_64_msvc 0.42.1", ] @@ -12811,7 +12362,25 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.1", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", ] [[package]] @@ -12820,15 +12389,46 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" dependencies = [ - "windows_aarch64_gnullvm", + "windows_aarch64_gnullvm 0.42.1", "windows_aarch64_msvc 0.42.1", "windows_i686_gnu 0.42.1", "windows_i686_msvc 0.42.1", "windows_x86_64_gnu 0.42.1", - "windows_x86_64_gnullvm", + "windows_x86_64_gnullvm 0.42.1", "windows_x86_64_msvc 0.42.1", ] +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.1" @@ -12836,10 +12436,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" [[package]] -name = "windows_aarch64_msvc" -version = "0.34.0" +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -12848,10 +12454,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" [[package]] -name = "windows_i686_gnu" -version = "0.34.0" +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -12860,10 +12472,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" [[package]] -name = "windows_i686_msvc" -version = "0.34.0" +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -12872,10 +12496,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" [[package]] -name = "windows_x86_64_gnu" -version = "0.34.0" +name = "windows_i686_msvc" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -12883,6 +12513,18 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.1" @@ -12890,10 +12532,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" [[package]] -name = "windows_x86_64_msvc" -version = "0.34.0" +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -12901,6 +12549,27 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.10.1" @@ -12921,73 +12590,59 @@ dependencies = [ [[package]] name = "x25519-dalek" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" -dependencies = [ - "curve25519-dalek 3.2.0", - "rand_core 0.5.1", - "zeroize", -] - -[[package]] -name = "x25519-dalek" -version = "2.0.0-pre.1" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5da623d8af10a62342bcbbb230e33e58a63255a58012f8653c578e54bab48df" +checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" dependencies = [ - "curve25519-dalek 3.2.0", + "curve25519-dalek", "rand_core 0.6.4", + "serde", "zeroize", ] [[package]] name = "x509-parser" -version = "0.13.2" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb9bace5b5589ffead1afb76e43e34cff39cd0f3ce7e170ae0c29e53b88eb1c" +checksum = "7069fba5b66b9193bd2c5d3d4ff12b839118f6bcbef5328efafafb5395cf63da" dependencies = [ - "asn1-rs 0.3.1", - "base64 0.13.1", + "asn1-rs", "data-encoding", - "der-parser 7.0.0", + "der-parser", "lazy_static", "nom", - "oid-registry 0.4.0", - "ring", + "oid-registry", "rusticata-macros", "thiserror", - "time 0.3.20", + "time 0.3.36", ] [[package]] -name = "x509-parser" -version = "0.14.0" +name = "xml-rs" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" + +[[package]] +name = "xmltree" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8" +checksum = "d7d8a75eaf6557bb84a65ace8609883db44a29951042ada9b393151532e41fcb" dependencies = [ - "asn1-rs 0.5.1", - "base64 0.13.1", - "data-encoding", - "der-parser 8.1.0", - "lazy_static", - "nom", - "oid-registry 0.6.1", - "rusticata-macros", - "thiserror", - "time 0.3.20", + "xml-rs", ] [[package]] name = "yamux" -version = "0.10.2" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d9ba232399af1783a58d8eb26f6b5006fbefe2dc9ef36bd283324792d03ea5" +checksum = "9ed0164ae619f2dc144909a9f082187ebb5893693d8c0196e8085283ccd4b776" dependencies = [ "futures", "log", "nohash-hasher", "parking_lot 0.12.1", + "pin-project", "rand 0.8.5", "static_assertions", ] @@ -13000,18 +12655,38 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "yasna" -version = "0.5.1" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" +dependencies = [ + "time 0.3.36", +] + +[[package]] +name = "zerocopy" +version = "0.7.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aed2e7a52e3744ab4d0c05c20aa065258e84c49fd4226f5191b2ed29712710b4" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ - "time 0.3.20", + "proc-macro2", + "quote", + "syn 2.0.68", ] [[package]] name = "zeroize" -version = "1.5.7" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ "zeroize_derive", ] @@ -13024,7 +12699,7 @@ checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", "synstructure", ] diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index 4451935c36035..ca343ac7d94f3 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -122,7 +122,7 @@ regex = "1.6.0" platforms = "2.0" soketto = "0.7.1" criterion = { version = "0.4.0", features = ["async_tokio"] } -tokio = { version = "1.22.0", features = ["macros", "time", "parking_lot"] } +tokio = { version = "1.28.0", features = ["macros", "time", "parking_lot"] } tokio-util = { version = "0.7.4", features = ["compat"] } wait-timeout = "0.2" substrate-rpc-client = { path = "../../../utils/frame/rpc/client" } diff --git a/client/authority-discovery/Cargo.toml b/client/authority-discovery/Cargo.toml index 900d9c59dfdae..2d9f5e8fc6e3d 100644 --- a/client/authority-discovery/Cargo.toml +++ b/client/authority-discovery/Cargo.toml @@ -21,7 +21,8 @@ codec = { package = "parity-scale-codec", version = "3.2.2", default-features = futures = "0.3.21" futures-timer = "3.0.1" ip_network = "0.4.1" -libp2p = { version = "0.50.0", features = ["kad"] } +libp2p = { version = "0.52.4", features = ["kad", "ed25519"] } +multihash-codetable = { version = "0.1.0", features = ["sha2", "digest"] } log = "0.4.17" prost = "0.11" rand = "0.8.5" diff --git a/client/authority-discovery/src/error.rs b/client/authority-discovery/src/error.rs index 89c05b71b9ea6..f48ed9fef1c2b 100644 --- a/client/authority-discovery/src/error.rs +++ b/client/authority-discovery/src/error.rs @@ -57,7 +57,7 @@ pub enum Error { ParsingMultiaddress(#[from] libp2p::core::multiaddr::Error), #[error("Failed to parse a libp2p key.")] - ParsingLibp2pIdentity(#[from] libp2p::identity::error::DecodingError), + ParsingLibp2pIdentity(#[from] libp2p::identity::DecodingError), #[error("Failed to sign using a specific public key.")] MissingSignature(CryptoTypePublicPair), diff --git a/client/authority-discovery/src/tests.rs b/client/authority-discovery/src/tests.rs index 982c3fc04c590..188f90c7d212c 100644 --- a/client/authority-discovery/src/tests.rs +++ b/client/authority-discovery/src/tests.rs @@ -25,8 +25,9 @@ use crate::{ }; use futures::{channel::mpsc::channel, executor::LocalPool, task::LocalSpawn}; -use libp2p::core::{ - multiaddr::{Multiaddr, Protocol}, +use libp2p::{ + core::multiaddr::{Multiaddr, Protocol}, + identity::ed25519, PeerId, }; use std::{collections::HashSet, sync::Arc}; @@ -56,7 +57,7 @@ fn get_addresses_and_authority_id() { let remote_addr = "/ip6/2001:db8:0:0:0:0:0:2/tcp/30333" .parse::() .unwrap() - .with(Protocol::P2p(remote_peer_id.into())); + .with(Protocol::P2p(remote_peer_id)); let test_api = Arc::new(TestApi { authorities: vec![] }); @@ -87,18 +88,16 @@ fn get_addresses_and_authority_id() { fn cryptos_are_compatible() { use sp_core::crypto::Pair; - let libp2p_secret = libp2p::identity::Keypair::generate_ed25519(); - let libp2p_public = libp2p_secret.public(); + let libp2p_keypair = ed25519::Keypair::generate(); + let libp2p_public = libp2p_keypair.public(); - let sp_core_secret = { - let libp2p::identity::Keypair::Ed25519(libp2p_ed_secret) = libp2p_secret.clone(); - sp_core::ed25519::Pair::from_seed_slice(&libp2p_ed_secret.secret().as_ref()).unwrap() - }; + let sp_core_secret = + { sp_core::ed25519::Pair::from_seed_slice(&libp2p_keypair.secret().as_ref()).unwrap() }; let sp_core_public = sp_core_secret.public(); let message = b"we are more powerful than not to be better"; - let libp2p_signature = libp2p_secret.sign(message).unwrap(); + let libp2p_signature = libp2p_keypair.sign(message); let sp_core_signature = sp_core_secret.sign(message); // no error expected... assert!(sp_core::ed25519::Pair::verify( diff --git a/client/authority-discovery/src/worker.rs b/client/authority-discovery/src/worker.rs index 034d72902e65d..1ebe6d3bec00d 100644 --- a/client/authority-discovery/src/worker.rs +++ b/client/authority-discovery/src/worker.rs @@ -34,11 +34,9 @@ use futures::{channel::mpsc, future, stream::Fuse, FutureExt, Stream, StreamExt} use addr_cache::AddrCache; use codec::Decode; use ip_network::IpNetwork; -use libp2p::{ - core::multiaddr, - multihash::{Multihash, MultihashDigest}, - Multiaddr, PeerId, -}; +use libp2p::{core::multiaddr, identity::PublicKey, Multiaddr}; +use multihash_codetable::{Code, MultihashDigest}; + use log::{debug, error, log_enabled}; use prometheus_endpoint::{register, Counter, CounterVec, Gauge, Opts, U64}; use prost::Message; @@ -299,7 +297,7 @@ where } fn addresses_to_publish(&self) -> impl Iterator { - let peer_id: Multihash = self.network.local_peer_id().into(); + let peer_id = self.network.local_peer_id(); let publish_non_global_ips = self.publish_non_global_ips; self.network .external_addresses() @@ -526,7 +524,7 @@ where .map_err(Error::ParsingMultiaddress)?; let get_peer_id = |a: &Multiaddr| match a.iter().last() { - Some(multiaddr::Protocol::P2p(key)) => PeerId::from_multihash(key).ok(), + Some(multiaddr::Protocol::P2p(peer_id)) => Some(peer_id), _ => None, }; @@ -546,10 +544,8 @@ where // properly signed by the owner of the PeerId if let Some(peer_signature) = peer_signature { - let public_key = libp2p::identity::PublicKey::from_protobuf_encoding( - &peer_signature.public_key, - ) - .map_err(Error::ParsingLibp2pIdentity)?; + let public_key = PublicKey::try_decode_protobuf(&peer_signature.public_key) + .map_err(Error::ParsingLibp2pIdentity)?; let signature = Signature { public_key, bytes: peer_signature.signature }; if !signature.verify(record, &remote_peer_id) { @@ -621,7 +617,7 @@ pub trait NetworkProvider: NetworkDHTProvider + NetworkStateInfo + NetworkSigner impl NetworkProvider for T where T: NetworkDHTProvider + NetworkStateInfo + NetworkSigner {} fn hash_authority_id(id: &[u8]) -> KademliaKey { - KademliaKey::new(&libp2p::multihash::Code::Sha2_256.digest(id).digest()) + KademliaKey::new(&Code::Sha2_256.digest(id).digest()) } // Makes sure all values are the same and returns it @@ -658,7 +654,7 @@ fn sign_record_with_peer_id( let signature = network .sign_with_local_identity(serialized_record) .map_err(|_| Error::Signing)?; - let public_key = signature.public_key.to_protobuf_encoding(); + let public_key = signature.public_key.encode_protobuf(); let signature = signature.bytes; Ok(schema::PeerSignature { signature, public_key }) } diff --git a/client/authority-discovery/src/worker/addr_cache.rs b/client/authority-discovery/src/worker/addr_cache.rs index 8084b7f0a6dff..ad7bf61d650f0 100644 --- a/client/authority-discovery/src/worker/addr_cache.rs +++ b/client/authority-discovery/src/worker/addr_cache.rs @@ -162,8 +162,8 @@ impl AddrCache { fn peer_id_from_multiaddr(addr: &Multiaddr) -> Option { addr.iter().last().and_then(|protocol| { - if let Protocol::P2p(multihash) = protocol { - PeerId::from_multihash(multihash).ok() + if let Protocol::P2p(peer_id) = protocol { + Some(peer_id) } else { None } @@ -178,7 +178,8 @@ fn addresses_to_peer_ids(addresses: &HashSet) -> HashSet { mod tests { use super::*; - use libp2p::multihash::{self, Multihash}; + use libp2p::multihash::Multihash; + use multihash_codetable::Code; use quickcheck::{Arbitrary, Gen, QuickCheck, TestResult}; use sp_authority_discovery::{AuthorityId, AuthorityPair}; @@ -200,14 +201,13 @@ mod tests { impl Arbitrary for TestMultiaddr { fn arbitrary(g: &mut Gen) -> Self { let seed = (0..32).map(|_| u8::arbitrary(g)).collect::>(); - let peer_id = PeerId::from_multihash( - Multihash::wrap(multihash::Code::Sha2_256.into(), &seed).unwrap(), - ) - .unwrap(); + let peer_id = + PeerId::from_multihash(Multihash::wrap(Code::Sha2_256.into(), &seed).unwrap()) + .unwrap(); let multiaddr = "/ip6/2001:db8:0:0:0:0:0:2/tcp/30333" .parse::() .unwrap() - .with(Protocol::P2p(peer_id.into())); + .with(Protocol::P2p(peer_id)); TestMultiaddr(multiaddr) } @@ -219,18 +219,17 @@ mod tests { impl Arbitrary for TestMultiaddrsSamePeerCombo { fn arbitrary(g: &mut Gen) -> Self { let seed = (0..32).map(|_| u8::arbitrary(g)).collect::>(); - let peer_id = PeerId::from_multihash( - Multihash::wrap(multihash::Code::Sha2_256.into(), &seed).unwrap(), - ) - .unwrap(); + let peer_id = + PeerId::from_multihash(Multihash::wrap(Code::Sha2_256.into(), &seed).unwrap()) + .unwrap(); let multiaddr1 = "/ip6/2001:db8:0:0:0:0:0:2/tcp/30333" .parse::() .unwrap() - .with(Protocol::P2p(peer_id.into())); + .with(Protocol::P2p(peer_id)); let multiaddr2 = "/ip6/2002:db8:0:0:0:0:0:2/tcp/30133" .parse::() .unwrap() - .with(Protocol::P2p(peer_id.into())); + .with(Protocol::P2p(peer_id)); TestMultiaddrsSamePeerCombo(multiaddr1, multiaddr2) } } @@ -367,7 +366,7 @@ mod tests { let mut addr_cache = AddrCache::new(); let peer_id = PeerId::random(); - let addr = Multiaddr::empty().with(Protocol::P2p(peer_id.into())); + let addr = Multiaddr::empty().with(Protocol::P2p(peer_id)); let authority_id0 = AuthorityPair::generate().0.public(); let authority_id1 = AuthorityPair::generate().0.public(); diff --git a/client/authority-discovery/src/worker/schema/tests.rs b/client/authority-discovery/src/worker/schema/tests.rs index 89c921e0c9fda..c765e4e5384db 100644 --- a/client/authority-discovery/src/worker/schema/tests.rs +++ b/client/authority-discovery/src/worker/schema/tests.rs @@ -21,7 +21,7 @@ mod schema_v1 { } use super::*; -use libp2p::{multiaddr::Multiaddr, PeerId}; +use libp2p::{identity::Keypair, multiaddr::Multiaddr, PeerId}; use prost::Message; #[test] @@ -55,7 +55,7 @@ fn v2_decodes_v1() { #[test] fn v1_decodes_v2() { - let peer_secret = libp2p::identity::Keypair::generate_ed25519(); + let peer_secret = Keypair::generate_ed25519(); let peer_public = peer_secret.public(); let peer_id = peer_public.to_peer_id(); let multiaddress: Multiaddr = @@ -67,7 +67,7 @@ fn v1_decodes_v2() { let record_v2 = AuthorityRecord { addresses: vec_addresses.clone() }; let mut vec_record_v2 = vec![]; record_v2.encode(&mut vec_record_v2).unwrap(); - let vec_peer_public = peer_public.to_protobuf_encoding(); + let vec_peer_public = peer_public.encode_protobuf(); let peer_signature_v2 = PeerSignature { public_key: vec_peer_public, signature: vec_peer_signature }; let signed_record_v2 = SignedAuthorityRecord { diff --git a/client/authority-discovery/src/worker/tests.rs b/client/authority-discovery/src/worker/tests.rs index febe40657e06a..eb692678c93f9 100644 --- a/client/authority-discovery/src/worker/tests.rs +++ b/client/authority-discovery/src/worker/tests.rs @@ -31,7 +31,7 @@ use futures::{ }; use libp2p::{ core::multiaddr, - identity::{error::SigningError, Keypair}, + identity::{Keypair, SigningError}, kad::record::Key as KademliaKey, PeerId, }; @@ -418,7 +418,7 @@ fn dont_stop_polling_dht_event_stream_after_bogus_event() { let peer_id = PeerId::random(); let address: Multiaddr = "/ip6/2001:db8:0:0:0:0:0:1/tcp/30333".parse().unwrap(); - address.with(multiaddr::Protocol::P2p(peer_id.into())) + address.with(multiaddr::Protocol::P2p(peer_id)) }; let remote_key_store = KeyStore::new(); let remote_public_key: AuthorityId = @@ -530,7 +530,7 @@ impl DhtValueFoundTester { let address: Multiaddr = format!("/ip6/2001:db8:0:0:0:0:0:{:x}/tcp/30333", idx).parse().unwrap(); - address.with(multiaddr::Protocol::P2p(peer_id.into())) + address.with(multiaddr::Protocol::P2p(peer_id)) } fn process_value_found( @@ -753,7 +753,7 @@ fn lookup_throttling() { let peer_id = PeerId::random(); let address: Multiaddr = "/ip6/2001:db8:0:0:0:0:0:1/tcp/30333".parse().unwrap(); - address.with(multiaddr::Protocol::P2p(peer_id.into())) + address.with(multiaddr::Protocol::P2p(peer_id)) }; let remote_key_store = KeyStore::new(); let remote_public_keys: Vec = (0..20) diff --git a/client/cli/Cargo.toml b/client/cli/Cargo.toml index c0da53ad129d5..840cff6b5cac5 100644 --- a/client/cli/Cargo.toml +++ b/client/cli/Cargo.toml @@ -18,7 +18,7 @@ chrono = "0.4.10" clap = { version = "4.0.9", features = ["derive", "string"] } fdlimit = "0.2.1" futures = "0.3.21" -libp2p = "0.50.0" +libp2p-identity = { version = "0.2.0", features = ["peerid", "ed25519"]} log = "0.4.17" names = { version = "0.13.0", default-features = false } parity-scale-codec = "3.2.2" @@ -29,7 +29,7 @@ serde = "1.0.136" serde_json = "1.0.85" thiserror = "1.0.30" tiny-bip39 = "1.0.0" -tokio = { version = "1.22.0", features = ["signal", "rt-multi-thread", "parking_lot"] } +tokio = { version = "1.28.0", features = ["signal", "rt-multi-thread", "parking_lot"] } sc-client-api = { version = "4.0.0-dev", path = "../api" } sc-client-db = { version = "0.10.0-dev", default-features = false, path = "../db" } sc-keystore = { version = "4.0.0-dev", path = "../keystore" } diff --git a/client/cli/src/commands/generate_node_key.rs b/client/cli/src/commands/generate_node_key.rs index 2288cd4037773..6ba84ad9d634a 100644 --- a/client/cli/src/commands/generate_node_key.rs +++ b/client/cli/src/commands/generate_node_key.rs @@ -19,7 +19,7 @@ use crate::Error; use clap::Parser; -use libp2p::identity::{ed25519 as libp2p_ed25519, PublicKey}; +use libp2p_identity::{ed25519, Keypair}; use std::{ fs, io::{self, Write}, @@ -50,7 +50,7 @@ pub struct GenerateNodeKeyCmd { impl GenerateNodeKeyCmd { /// Run the command pub fn run(&self) -> Result<(), Error> { - let keypair = libp2p_ed25519::Keypair::generate(); + let keypair = ed25519::Keypair::generate(); let secret = keypair.secret(); @@ -65,7 +65,7 @@ impl GenerateNodeKeyCmd { None => io::stdout().lock().write_all(&file_data)?, } - eprintln!("{}", PublicKey::Ed25519(keypair.public()).to_peer_id()); + eprintln!("{}", Keypair::from(keypair).public().to_peer_id()); Ok(()) } diff --git a/client/cli/src/commands/inspect_node_key.rs b/client/cli/src/commands/inspect_node_key.rs index 2370f4a0989ba..4ff12f4e2255b 100644 --- a/client/cli/src/commands/inspect_node_key.rs +++ b/client/cli/src/commands/inspect_node_key.rs @@ -19,7 +19,7 @@ use crate::Error; use clap::Parser; -use libp2p::identity::{ed25519, PublicKey}; +use libp2p_identity::Keypair; use std::{ fs, io::{self, Read}, @@ -70,12 +70,10 @@ impl InspectNodeKeyCmd { .map_err(|_| "failed to decode secret as hex")?; } - let secret = - ed25519::SecretKey::from_bytes(&mut file_data).map_err(|_| "Bad node key file")?; + let keypair = + Keypair::ed25519_from_bytes(&mut file_data).map_err(|_| "Bad node key file")?; - let keypair = ed25519::Keypair::from(secret); - - println!("{}", PublicKey::Ed25519(keypair.public()).to_peer_id()); + println!("{}", keypair.public().to_peer_id()); Ok(()) } diff --git a/client/cli/src/params/node_key_params.rs b/client/cli/src/params/node_key_params.rs index 074b95bea0f3a..5366423aa37f3 100644 --- a/client/cli/src/params/node_key_params.rs +++ b/client/cli/src/params/node_key_params.rs @@ -113,7 +113,7 @@ fn invalid_node_key(e: impl std::fmt::Display) -> error::Error { /// Parse a Ed25519 secret key from a hex string into a `sc_network::Secret`. fn parse_ed25519_secret(hex: &str) -> error::Result { H256::from_str(hex).map_err(invalid_node_key).and_then(|bytes| { - ed25519::SecretKey::from_bytes(bytes) + ed25519::SecretKey::try_from_bytes(bytes) .map(sc_network::config::Secret::Input) .map_err(invalid_node_key) }) @@ -123,7 +123,7 @@ fn parse_ed25519_secret(hex: &str) -> error::Result {}, - _ => panic!("Invalid key"), + if let Ok(pair) = node_key.try_into_ed25519() { + if pair.secret().as_ref() != key.as_ref() { + panic!("Invalid key") + } + } else { + panic!("Invalid key") } } diff --git a/client/consensus/aura/Cargo.toml b/client/consensus/aura/Cargo.toml index 4c0305e9f66e7..e746a6d0bd419 100644 --- a/client/consensus/aura/Cargo.toml +++ b/client/consensus/aura/Cargo.toml @@ -46,4 +46,4 @@ sp-keyring = { version = "7.0.0", path = "../../../primitives/keyring" } sp-timestamp = { version = "4.0.0-dev", path = "../../../primitives/timestamp" } sp-tracing = { version = "6.0.0", path = "../../../primitives/tracing" } substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" } -tokio = { version = "1.22.0" } +tokio = { version = "1.28.0" } diff --git a/client/consensus/babe/Cargo.toml b/client/consensus/babe/Cargo.toml index 8088bef9d7e1b..abc398cefe8d0 100644 --- a/client/consensus/babe/Cargo.toml +++ b/client/consensus/babe/Cargo.toml @@ -19,12 +19,12 @@ scale-info = { version = "2.1.1", features = ["derive"] } codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } futures = "0.3.21" log = "0.4.17" -merlin = "2.0" +merlin = "3.0" num-bigint = "0.4.3" num-rational = "0.4.1" num-traits = "0.2.8" parking_lot = "0.12.1" -schnorrkel = { version = "0.9.1", features = ["preaudit_deprecated"] } +schnorrkel = { version = "0.11.4", features = ["preaudit_deprecated"] } thiserror = "1.0" fork-tree = { version = "3.0.0", path = "../../../utils/fork-tree" } prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../../utils/prometheus" } @@ -56,4 +56,4 @@ sc-network-test = { version = "0.8.0", path = "../../network/test" } sp-timestamp = { version = "4.0.0-dev", path = "../../../primitives/timestamp" } sp-tracing = { version = "6.0.0", path = "../../../primitives/tracing" } substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" } -tokio = "1.22.0" +tokio = "1.28.0" diff --git a/client/consensus/babe/rpc/Cargo.toml b/client/consensus/babe/rpc/Cargo.toml index 4f5aaf85494b9..0fadf3cde37e6 100644 --- a/client/consensus/babe/rpc/Cargo.toml +++ b/client/consensus/babe/rpc/Cargo.toml @@ -32,7 +32,7 @@ sp-runtime = { version = "7.0.0", path = "../../../../primitives/runtime" } [dev-dependencies] serde_json = "1.0.85" tempfile = "3.1.0" -tokio = "1.22.0" +tokio = "1.28.0" sc-consensus = { version = "0.10.0-dev", path = "../../../consensus/common" } sc-keystore = { version = "4.0.0-dev", path = "../../../keystore" } sp-keyring = { version = "7.0.0", path = "../../../../primitives/keyring" } diff --git a/client/consensus/babe/src/authorship.rs b/client/consensus/babe/src/authorship.rs index 195a19b3d0f61..d282ac8fb24bf 100644 --- a/client/consensus/babe/src/authorship.rs +++ b/client/consensus/babe/src/authorship.rs @@ -27,7 +27,7 @@ use sp_consensus_babe::{ digests::{PreDigest, PrimaryPreDigest, SecondaryPlainPreDigest, SecondaryVRFPreDigest}, make_transcript, make_transcript_data, AuthorityId, BabeAuthorityWeight, Slot, BABE_VRF_PREFIX, }; -use sp_consensus_vrf::schnorrkel::{VRFOutput, VRFProof}; +use sp_consensus_vrf::schnorrkel::{VRFPreOut, VRFProof}; use sp_core::{blake2_256, crypto::ByteArray, U256}; use sp_keystore::{SyncCryptoStore, SyncCryptoStorePtr}; @@ -162,7 +162,7 @@ fn claim_secondary_slot( if let Ok(Some(signature)) = result { Some(PreDigest::SecondaryVRF(SecondaryVRFPreDigest { slot, - vrf_output: VRFOutput(signature.output), + vrf_output: VRFPreOut(signature.output), vrf_proof: VRFProof(signature.proof), authority_index: *authority_index as u32, })) @@ -271,7 +271,7 @@ fn claim_primary_slot( if check_primary_threshold(&inout, threshold) { let pre_digest = PreDigest::Primary(PrimaryPreDigest { slot, - vrf_output: VRFOutput(signature.output), + vrf_output: VRFPreOut(signature.output), vrf_proof: VRFProof(signature.proof), authority_index: *authority_index as u32, }); diff --git a/client/consensus/babe/src/lib.rs b/client/consensus/babe/src/lib.rs index 1d42057a36b23..a348f9e97a2ef 100644 --- a/client/consensus/babe/src/lib.rs +++ b/client/consensus/babe/src/lib.rs @@ -134,7 +134,7 @@ pub use sp_consensus_babe::{ PrimaryPreDigest, SecondaryPlainPreDigest, }, AuthorityId, AuthorityPair, AuthoritySignature, BabeApi, BabeAuthorityWeight, BabeBlockWeight, - BabeConfiguration, BabeEpochConfiguration, ConsensusLog, BABE_ENGINE_ID, VRF_OUTPUT_LENGTH, + BabeConfiguration, BabeEpochConfiguration, ConsensusLog, BABE_ENGINE_ID, VRF_PREOUT_LENGTH, }; pub use aux_schema::load_block_weight as block_weight; @@ -161,7 +161,7 @@ pub struct Epoch { /// The authorities and their weights. pub authorities: Vec<(AuthorityId, BabeAuthorityWeight)>, /// Randomness for this epoch. - pub randomness: [u8; VRF_OUTPUT_LENGTH], + pub randomness: [u8; VRF_PREOUT_LENGTH], /// Configuration of the epoch. pub config: BabeEpochConfiguration, } diff --git a/client/consensus/babe/src/migration.rs b/client/consensus/babe/src/migration.rs index ec864b8e5510f..1b9948c427174 100644 --- a/client/consensus/babe/src/migration.rs +++ b/client/consensus/babe/src/migration.rs @@ -18,7 +18,7 @@ use crate::{ AuthorityId, BabeAuthorityWeight, BabeConfiguration, BabeEpochConfiguration, Epoch, - NextEpochDescriptor, VRF_OUTPUT_LENGTH, + NextEpochDescriptor, VRF_PREOUT_LENGTH, }; use codec::{Decode, Encode}; use sc_consensus_epochs::Epoch as EpochT; @@ -36,7 +36,7 @@ pub struct EpochV0 { /// The authorities and their weights. pub authorities: Vec<(AuthorityId, BabeAuthorityWeight)>, /// Randomness for this epoch. - pub randomness: [u8; VRF_OUTPUT_LENGTH], + pub randomness: [u8; VRF_PREOUT_LENGTH], } impl EpochT for EpochV0 { diff --git a/client/consensus/babe/src/tests.rs b/client/consensus/babe/src/tests.rs index 25f1f87235702..ac4bfc599fab2 100644 --- a/client/consensus/babe/src/tests.rs +++ b/client/consensus/babe/src/tests.rs @@ -37,7 +37,7 @@ use sp_consensus_babe::{ AuthorityId, AuthorityPair, Slot, }; use sp_consensus_slots::SlotDuration; -use sp_consensus_vrf::schnorrkel::VRFOutput; +use sp_consensus_vrf::schnorrkel::VRFPreOut; use sp_core::crypto::Pair; use sp_keyring::Sr25519Keyring; use sp_keystore::{ @@ -641,7 +641,7 @@ fn claim_vrf_check() { let sign = SyncCryptoStore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) .unwrap() .unwrap(); - assert_eq!(pre_digest.vrf_output, VRFOutput(sign.output)); + assert_eq!(pre_digest.vrf_output, VRFPreOut(sign.output)); // We expect a SecondaryVRF claim for slot 1 let pre_digest = match claim_slot(1.into(), &epoch, &keystore).unwrap().0 { @@ -652,7 +652,7 @@ fn claim_vrf_check() { let sign = SyncCryptoStore::sr25519_vrf_sign(&*keystore, AuthorityId::ID, &public, transcript) .unwrap() .unwrap(); - assert_eq!(pre_digest.vrf_output, VRFOutput(sign.output)); + assert_eq!(pre_digest.vrf_output, VRFPreOut(sign.output)); // Check that correct epoch index has been used if epochs are skipped (primary VRF) let slot = Slot::from(103); @@ -666,7 +666,7 @@ fn claim_vrf_check() { .unwrap() .unwrap(); assert_eq!(fixed_epoch.epoch_index, 11); - assert_eq!(claim.vrf_output, VRFOutput(sign.output)); + assert_eq!(claim.vrf_output, VRFPreOut(sign.output)); // Check that correct epoch index has been used if epochs are skipped (secondary VRF) let slot = Slot::from(100); @@ -680,7 +680,7 @@ fn claim_vrf_check() { .unwrap() .unwrap(); assert_eq!(fixed_epoch.epoch_index, 11); - assert_eq!(pre_digest.vrf_output, VRFOutput(sign.output)); + assert_eq!(pre_digest.vrf_output, VRFPreOut(sign.output)); } // Propose and import a new BABE block on top of the given parent. diff --git a/client/consensus/beefy/Cargo.toml b/client/consensus/beefy/Cargo.toml index 161d53777ebc1..38d1517dc07d3 100644 --- a/client/consensus/beefy/Cargo.toml +++ b/client/consensus/beefy/Cargo.toml @@ -41,7 +41,7 @@ sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } [dev-dependencies] serde = "1.0.136" tempfile = "3.1.0" -tokio = "1.22.0" +tokio = "1.28.0" sc-block-builder = { version = "0.10.0-dev", path = "../../block-builder" } sc-network-test = { version = "0.8.0", path = "../../network/test" } sp-consensus-grandpa = { version = "4.0.0-dev", path = "../../../primitives/consensus/grandpa" } diff --git a/client/consensus/beefy/rpc/Cargo.toml b/client/consensus/beefy/rpc/Cargo.toml index d6dfa8731a3be..873a60a6a14b1 100644 --- a/client/consensus/beefy/rpc/Cargo.toml +++ b/client/consensus/beefy/rpc/Cargo.toml @@ -26,4 +26,4 @@ sp-runtime = { version = "7.0.0", path = "../../../../primitives/runtime" } serde_json = "1.0.85" sc-rpc = { version = "4.0.0-dev", features = ["test-helpers"], path = "../../../rpc" } substrate-test-runtime-client = { version = "2.0.0", path = "../../../../test-utils/runtime/client" } -tokio = { version = "1.22.0", features = ["macros"] } +tokio = { version = "1.28.0", features = ["macros"] } diff --git a/client/consensus/common/Cargo.toml b/client/consensus/common/Cargo.toml index d9e80e1e5ce99..f5e9858247e33 100644 --- a/client/consensus/common/Cargo.toml +++ b/client/consensus/common/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] async-trait = "0.1.57" futures = { version = "0.3.21", features = ["thread-pool"] } futures-timer = "3.0.1" -libp2p = "0.50.0" +libp2p-identity = { version = "0.2.0", features = ["peerid", "ed25519"] } log = "0.4.17" mockall = "0.11.3" parking_lot = "0.12.1" diff --git a/client/consensus/common/src/import_queue.rs b/client/consensus/common/src/import_queue.rs index cec9aca47e29f..11ebbd4036a20 100644 --- a/client/consensus/common/src/import_queue.rs +++ b/client/consensus/common/src/import_queue.rs @@ -66,7 +66,7 @@ pub type BoxJustificationImport = Box + Send + Sync>; /// Maps to the RuntimeOrigin used by the network. -pub type RuntimeOrigin = libp2p::PeerId; +pub type RuntimeOrigin = libp2p_identity::PeerId; /// Block data used by the queue. #[derive(Debug, PartialEq, Eq, Clone)] diff --git a/client/consensus/common/src/import_queue/basic_queue.rs b/client/consensus/common/src/import_queue/basic_queue.rs index 653c88321554e..b93913703d39f 100644 --- a/client/consensus/common/src/import_queue/basic_queue.rs +++ b/client/consensus/common/src/import_queue/basic_queue.rs @@ -635,7 +635,7 @@ mod tests { let hash = Hash::random(); finality_sender .unbounded_send(worker_messages::ImportJustification( - libp2p::PeerId::random(), + libp2p_identity::PeerId::random(), hash, 1, (*b"TEST", Vec::new()), diff --git a/client/consensus/grandpa/Cargo.toml b/client/consensus/grandpa/Cargo.toml index 511e546aa7256..d2eee7cfdc480 100644 --- a/client/consensus/grandpa/Cargo.toml +++ b/client/consensus/grandpa/Cargo.toml @@ -52,7 +52,7 @@ sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } assert_matches = "1.3.0" finality-grandpa = { version = "0.16.1", features = ["derive-codec", "test-helpers"] } serde = "1.0.136" -tokio = "1.22.0" +tokio = "1.28.0" sc-network = { version = "0.10.0-dev", path = "../../network" } sc-network-test = { version = "0.8.0", path = "../../network/test" } sp-keyring = { version = "7.0.0", path = "../../../primitives/keyring" } diff --git a/client/consensus/grandpa/rpc/Cargo.toml b/client/consensus/grandpa/rpc/Cargo.toml index 4880b50d30630..f61a537d1ea89 100644 --- a/client/consensus/grandpa/rpc/Cargo.toml +++ b/client/consensus/grandpa/rpc/Cargo.toml @@ -31,4 +31,4 @@ sp-core = { version = "7.0.0", path = "../../../../primitives/core" } sp-consensus-grandpa = { version = "4.0.0-dev", path = "../../../../primitives/consensus/grandpa" } sp-keyring = { version = "7.0.0", path = "../../../../primitives/keyring" } substrate-test-runtime-client = { version = "2.0.0", path = "../../../../test-utils/runtime/client" } -tokio = { version = "1.22.0", features = ["macros"] } +tokio = { version = "1.28.0", features = ["macros"] } diff --git a/client/consensus/manual-seal/Cargo.toml b/client/consensus/manual-seal/Cargo.toml index 19c4b22247e0f..fcbe219473ceb 100644 --- a/client/consensus/manual-seal/Cargo.toml +++ b/client/consensus/manual-seal/Cargo.toml @@ -42,7 +42,7 @@ sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } sp-timestamp = { version = "4.0.0-dev", path = "../../../primitives/timestamp" } [dev-dependencies] -tokio = { version = "1.22.0", features = ["rt-multi-thread", "macros"] } +tokio = { version = "1.28.0", features = ["rt-multi-thread", "macros"] } sc-basic-authorship = { version = "0.10.0-dev", path = "../../basic-authorship" } substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" } substrate-test-runtime-transaction-pool = { version = "2.0.0", path = "../../../test-utils/runtime/transaction-pool" } diff --git a/client/keystore/src/local.rs b/client/keystore/src/local.rs index cd55739a9fac3..04ec38b5f38b7 100644 --- a/client/keystore/src/local.rs +++ b/client/keystore/src/local.rs @@ -334,7 +334,7 @@ impl SyncCryptoStore for LocalKeystore { if let Some(pair) = pair { let (inout, proof, _) = pair.as_ref().vrf_sign(transcript); - Ok(Some(VRFSignature { output: inout.to_output(), proof })) + Ok(Some(VRFSignature { output: inout.to_preout(), proof })) } else { Ok(None) } diff --git a/client/network-gossip/Cargo.toml b/client/network-gossip/Cargo.toml index 5c1bc91f105c8..7398c5316bfbf 100644 --- a/client/network-gossip/Cargo.toml +++ b/client/network-gossip/Cargo.toml @@ -17,7 +17,8 @@ targets = ["x86_64-unknown-linux-gnu"] ahash = "0.8.2" futures = "0.3.21" futures-timer = "3.0.1" -libp2p = "0.50.0" +libp2p-identity = { version = "0.2.0", features = ["peerid", "ed25519"]} +multiaddr = "0.18.0" log = "0.4.17" lru = "0.8.1" tracing = "0.1.29" @@ -28,6 +29,6 @@ sc-peerset = { version = "4.0.0-dev", path = "../peerset" } sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" } [dev-dependencies] -tokio = "1.22.0" +tokio = "1.28.0" quickcheck = { version = "1.0.3", default-features = false } substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" } diff --git a/client/network-gossip/src/bridge.rs b/client/network-gossip/src/bridge.rs index 4793d7822ddbe..d97c1811b5ee7 100644 --- a/client/network-gossip/src/bridge.rs +++ b/client/network-gossip/src/bridge.rs @@ -29,7 +29,7 @@ use futures::{ channel::mpsc::{channel, Receiver, Sender}, prelude::*, }; -use libp2p::PeerId; +use libp2p_identity::PeerId; use log::trace; use prometheus_endpoint::Registry; use sp_runtime::traits::Block as BlockT; @@ -331,12 +331,13 @@ impl futures::future::FusedFuture for GossipEngine { #[cfg(test)] mod tests { use super::*; - use crate::{multiaddr::Multiaddr, ValidationResult, ValidatorContext}; + use crate::{ValidationResult, ValidatorContext}; use futures::{ channel::mpsc::{unbounded, UnboundedSender}, executor::{block_on, block_on_stream}, future::poll_fn, }; + use multiaddr::Multiaddr; use quickcheck::{Arbitrary, Gen, QuickCheck}; use sc_network::{ config::MultiaddrWithPeerId, NetworkBlock, NetworkEventStream, NetworkNotification, diff --git a/client/network-gossip/src/lib.rs b/client/network-gossip/src/lib.rs index ef87dd599e010..d126f85646e6c 100644 --- a/client/network-gossip/src/lib.rs +++ b/client/network-gossip/src/lib.rs @@ -67,7 +67,8 @@ pub use self::{ validator::{DiscardAll, MessageIntent, ValidationResult, Validator, ValidatorContext}, }; -use libp2p::{multiaddr, PeerId}; +use libp2p_identity::PeerId; +use multiaddr::{Multiaddr, Protocol}; use sc_network::{ types::ProtocolName, NetworkBlock, NetworkEventStream, NetworkNotification, NetworkPeers, }; @@ -82,8 +83,7 @@ mod validator; /// Abstraction over a network. pub trait Network: NetworkPeers + NetworkEventStream + NetworkNotification { fn add_set_reserved(&self, who: PeerId, protocol: ProtocolName) { - let addr = - iter::once(multiaddr::Protocol::P2p(who.into())).collect::(); + let addr = Multiaddr::empty().with(Protocol::P2p(who)); let result = self.add_peers_to_reserved_set(protocol, iter::once(addr).collect()); if let Err(err) = result { log::error!(target: "gossip", "add_set_reserved failed: {}", err); diff --git a/client/network-gossip/src/state_machine.rs b/client/network-gossip/src/state_machine.rs index e6d2b0e2ae4c8..d2a4d73c0b554 100644 --- a/client/network-gossip/src/state_machine.rs +++ b/client/network-gossip/src/state_machine.rs @@ -19,7 +19,7 @@ use crate::{MessageIntent, Network, ValidationResult, Validator, ValidatorContext}; use ahash::AHashSet; -use libp2p::PeerId; +use libp2p_identity::PeerId; use lru::LruCache; use prometheus_endpoint::{register, Counter, PrometheusError, Registry, U64}; use sc_network::types::ProtocolName; @@ -524,8 +524,8 @@ impl Metrics { #[cfg(test)] mod tests { use super::*; - use crate::multiaddr::Multiaddr; use futures::prelude::*; + use multiaddr::Multiaddr; use sc_network::{ config::MultiaddrWithPeerId, event::Event, NetworkBlock, NetworkEventStream, NetworkNotification, NetworkPeers, NotificationSenderError, diff --git a/client/network-gossip/src/validator.rs b/client/network-gossip/src/validator.rs index 2272efba50652..04585bb721849 100644 --- a/client/network-gossip/src/validator.rs +++ b/client/network-gossip/src/validator.rs @@ -16,7 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use libp2p::PeerId; +use libp2p_identity::PeerId; use sc_network_common::role::ObservedRole; use sp_runtime::traits::Block as BlockT; diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 90b5ce871ef1a..4685d85712275 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -25,7 +25,8 @@ fnv = "1.0.6" futures = "0.3.21" futures-timer = "3.0.2" ip_network = "0.4.1" -libp2p = { version = "0.50.0", features = ["dns", "identify", "kad", "macros", "mdns", "mplex", "noise", "ping", "tcp", "tokio", "yamux", "websocket"] } +libp2p = { version = "0.52.4", features = ["dns", "identify", "kad", "macros", "mdns", "noise", "ping", "tcp", "tokio", "yamux", "websocket", "request-response"] } +libp2p-kad = { version = "0.44.2" } linked_hash_set = "0.1.3" log = "0.4.17" lru = "0.8.1" @@ -35,9 +36,10 @@ pin-project = "1.0.12" rand = "0.8.5" serde = { version = "1.0.136", features = ["derive"] } serde_json = "1.0.85" -smallvec = "1.8.0" +smallvec = "1.11.0" thiserror = "1.0" unsigned-varint = { version = "0.7.1", features = ["futures", "asynchronous_codec"] } +void = "1" zeroize = "1.4.3" prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" } sc-block-builder = { version = "0.10.0-dev", path = "../block-builder" } @@ -54,10 +56,10 @@ sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" } [dev-dependencies] assert_matches = "1.3" -multistream-select = "0.12.1" +multistream-select = "0.13.0" rand = "0.8.5" tempfile = "3.1.0" -tokio = { version = "1.22.0", features = ["macros"] } +tokio = { version = "1.28.0", features = ["macros"] } tokio-util = { version = "0.7.4", features = ["compat"] } tokio-test = "0.4.2" sc-network-light = { version = "0.10.0-dev", path = "./light" } diff --git a/client/network/README.md b/client/network/README.md index d396747241ab1..be084816b441d 100644 --- a/client/network/README.md +++ b/client/network/README.md @@ -66,8 +66,6 @@ negotiated and applied. The exact handshake protocol is experimental and is subj The following multiplexing protocols are supported: -- [Mplex](https://github.com/libp2p/specs/tree/master/mplex). Support for mplex will likely -be deprecated in the future. - [Yamux](https://github.com/hashicorp/yamux/blob/master/spec.md). ## Substreams diff --git a/client/network/bitswap/Cargo.toml b/client/network/bitswap/Cargo.toml index ee2e0cfc79ff7..829b00725914a 100644 --- a/client/network/bitswap/Cargo.toml +++ b/client/network/bitswap/Cargo.toml @@ -18,7 +18,7 @@ prost-build = "0.11" [dependencies] cid = "0.8.6" futures = "0.3.21" -libp2p = "0.50.0" +libp2p-identity = { version = "0.2.0", features = ["peerid"] } log = "0.4.17" prost = "0.11" thiserror = "1.0" @@ -30,7 +30,7 @@ sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } [dev-dependencies] -tokio = { version = "1.22.0", features = ["full"] } +tokio = { version = "1.28.0", features = ["full"] } sc-block-builder = { version = "0.10.0-dev", path = "../../block-builder" } sc-consensus = { version = "0.10.0-dev", path = "../../consensus/common" } sp-core = { version = "7.0.0", path = "../../../primitives/core" } diff --git a/client/network/bitswap/src/lib.rs b/client/network/bitswap/src/lib.rs index 5a7a7b51355c6..6ea7bc7e7a38a 100644 --- a/client/network/bitswap/src/lib.rs +++ b/client/network/bitswap/src/lib.rs @@ -22,7 +22,7 @@ use cid::{self, Version}; use futures::{channel::mpsc, StreamExt}; -use libp2p::core::PeerId; +use libp2p_identity::PeerId; use log::{debug, error, trace}; use prost::Message; use sc_client_api::BlockBackend; diff --git a/client/network/common/Cargo.toml b/client/network/common/Cargo.toml index 983342b014b82..27e7e075c4c07 100644 --- a/client/network/common/Cargo.toml +++ b/client/network/common/Cargo.toml @@ -25,7 +25,7 @@ codec = { package = "parity-scale-codec", version = "3.2.2", features = [ ] } futures = "0.3.21" futures-timer = "3.0.2" -libp2p = { version = "0.50.0", features = ["request-response", "kad"] } +libp2p-identity = { version = "0.2.0", features = ["peerid"] } prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../../utils/prometheus" } smallvec = "1.8.0" sc-consensus = { version = "0.10.0-dev", path = "../../consensus/common" } diff --git a/client/network/common/src/sync.rs b/client/network/common/src/sync.rs index 130f354b70050..8a357a6f16f18 100644 --- a/client/network/common/src/sync.rs +++ b/client/network/common/src/sync.rs @@ -25,7 +25,7 @@ pub mod warp; use crate::role::Roles; use futures::Stream; -use libp2p::PeerId; +use libp2p_identity::PeerId; use message::{BlockAnnounce, BlockData, BlockRequest, BlockResponse}; use sc_consensus::{import_queue::RuntimeOrigin, IncomingBlock}; diff --git a/client/network/light/Cargo.toml b/client/network/light/Cargo.toml index ed2a5d6cb4ec6..c4b898b8c247f 100644 --- a/client/network/light/Cargo.toml +++ b/client/network/light/Cargo.toml @@ -21,7 +21,7 @@ codec = { package = "parity-scale-codec", version = "3.2.2", features = [ "derive", ] } futures = "0.3.21" -libp2p = "0.50.0" +libp2p-identity = { version = "0.2.0", features = ["peerid"] } log = "0.4.16" prost = "0.11" sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" } diff --git a/client/network/light/src/light_client_requests/handler.rs b/client/network/light/src/light_client_requests/handler.rs index db2630b79f498..2a68ebe9c2b23 100644 --- a/client/network/light/src/light_client_requests/handler.rs +++ b/client/network/light/src/light_client_requests/handler.rs @@ -25,7 +25,7 @@ use crate::schema; use codec::{self, Decode, Encode}; use futures::{channel::mpsc, prelude::*}; -use libp2p::PeerId; +use libp2p_identity::PeerId; use log::{debug, trace}; use prost::Message; use sc_client_api::{BlockBackend, ProofProvider}; diff --git a/client/network/src/behaviour.rs b/client/network/src/behaviour.rs index f068099928efc..6b75990f602ac 100644 --- a/client/network/src/behaviour.rs +++ b/client/network/src/behaviour.rs @@ -28,10 +28,8 @@ use crate::{ use bytes::Bytes; use futures::channel::oneshot; use libp2p::{ - core::{Multiaddr, PeerId, PublicKey}, - identify::Info as IdentifyInfo, - kad::record, - swarm::NetworkBehaviour, + connection_limits::ConnectionLimits, core::Multiaddr, identify::Info as IdentifyInfo, + identity::PublicKey, kad::RecordKey, swarm::NetworkBehaviour, PeerId, }; use sc_network_common::role::{ObservedRole, Roles}; @@ -43,7 +41,7 @@ pub use crate::request_responses::{InboundFailure, OutboundFailure, RequestId, R /// General behaviour of the network. Combines all protocols together. #[derive(NetworkBehaviour)] -#[behaviour(out_event = "BehaviourOut")] +#[behaviour(to_swarm = "BehaviourOut")] pub struct Behaviour { /// All the substrate-specific protocols. substrate: Protocol, @@ -52,6 +50,8 @@ pub struct Behaviour { peer_info: peer_info::PeerInfoBehaviour, /// Discovers nodes of the network. discovery: DiscoveryBehaviour, + /// Connection limits. + connection_limits: libp2p::connection_limits::Behaviour, /// Generic request-response protocols. request_responses: request_responses::RequestResponsesBehaviour, } @@ -172,11 +172,13 @@ impl Behaviour { disco_config: DiscoveryConfig, request_response_protocols: Vec, peerset: PeersetHandle, + connection_limits: ConnectionLimits, ) -> Result { Ok(Self { substrate, peer_info: peer_info::PeerInfoBehaviour::new(user_agent, local_public_key), discovery: disco_config.finish(), + connection_limits: libp2p::connection_limits::Behaviour::new(connection_limits), request_responses: request_responses::RequestResponsesBehaviour::new( request_response_protocols.into_iter(), peerset, @@ -248,7 +250,7 @@ impl Behaviour { pub fn add_self_reported_address_to_dht( &mut self, peer_id: &PeerId, - supported_protocols: &[impl AsRef<[u8]>], + supported_protocols: &[impl AsRef], addr: Multiaddr, ) { self.discovery.add_self_reported_address(peer_id, supported_protocols, addr); @@ -256,13 +258,13 @@ impl Behaviour { /// Start querying a record from the DHT. Will later produce either a `ValueFound` or a /// `ValueNotFound` event. - pub fn get_value(&mut self, key: record::Key) { + pub fn get_value(&mut self, key: RecordKey) { self.discovery.get_value(key); } /// Starts putting a record into DHT. Will later produce either a `ValuePut` or a /// `ValuePutFailed` event. - pub fn put_value(&mut self, key: record::Key, value: Vec) { + pub fn put_value(&mut self, key: RecordKey, value: Vec) { self.discovery.put_value(key, value); } } @@ -352,3 +354,9 @@ impl From for BehaviourOut { } } } + +impl From for BehaviourOut { + fn from(e: void::Void) -> Self { + void::unreachable(e) + } +} diff --git a/client/network/src/config.rs b/client/network/src/config.rs index 925a7795d290f..abf592cc023a4 100644 --- a/client/network/src/config.rs +++ b/client/network/src/config.rs @@ -28,8 +28,9 @@ pub use crate::{ types::ProtocolName, }; +pub use libp2p::{identity::Keypair, multiaddr, Multiaddr, PeerId}; + use codec::Encode; -use libp2p::{identity::Keypair, multiaddr, Multiaddr, PeerId}; use prometheus_endpoint::Registry; pub use sc_network_common::{role::Role, sync::warp::WarpSyncProvider, ExHashT}; use zeroize::Zeroize; @@ -99,8 +100,7 @@ pub fn parse_str_addr(addr_str: &str) -> Result<(PeerId, Multiaddr), ParseErr> { /// Splits a Multiaddress into a Multiaddress and PeerId. pub fn parse_addr(mut addr: Multiaddr) -> Result<(PeerId, Multiaddr), ParseErr> { let who = match addr.pop() { - Some(multiaddr::Protocol::P2p(key)) => - PeerId::from_multihash(key).map_err(|_| ParseErr::InvalidPeerId)?, + Some(multiaddr::Protocol::P2p(peer_id)) => peer_id, _ => return Err(ParseErr::PeerIdMissing), }; @@ -133,7 +133,7 @@ pub struct MultiaddrWithPeerId { impl MultiaddrWithPeerId { /// Concatenates the multiaddress and peer ID into one multiaddress containing both. pub fn concat(&self) -> Multiaddr { - let proto = multiaddr::Protocol::P2p(From::from(self.peer_id)); + let proto = multiaddr::Protocol::P2p(self.peer_id); self.multiaddr.clone().with(proto) } } @@ -171,8 +171,6 @@ impl TryFrom for MultiaddrWithPeerId { pub enum ParseErr { /// Error while parsing the multiaddress. MultiaddrParse(multiaddr::Error), - /// Multihash of the peer ID is invalid. - InvalidPeerId, /// The peer ID is missing from the address. PeerIdMissing, } @@ -181,7 +179,6 @@ impl fmt::Display for ParseErr { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::MultiaddrParse(err) => write!(f, "{}", err), - Self::InvalidPeerId => write!(f, "Peer id at the end of the address is invalid"), Self::PeerIdMissing => write!(f, "Peer id is missing from the address"), } } @@ -191,7 +188,6 @@ impl std::error::Error for ParseErr { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { match self { Self::MultiaddrParse(err) => Some(err), - Self::InvalidPeerId => None, Self::PeerIdMissing => None, } } @@ -360,7 +356,7 @@ impl NodeKeyConfig { match self { Ed25519(Secret::New) => Ok(Keypair::generate_ed25519()), - Ed25519(Secret::Input(k)) => Ok(Keypair::Ed25519(k.into())), + Ed25519(Secret::Input(k)) => Ok(ed25519::Keypair::from(k).into()), Ed25519(Secret::File(f)) => get_secret( f, @@ -371,14 +367,14 @@ impl NodeKeyConfig { None } }) { - Some(s) => ed25519::SecretKey::from_bytes(s), - _ => ed25519::SecretKey::from_bytes(&mut b), + Some(s) => ed25519::SecretKey::try_from_bytes(s), + _ => ed25519::SecretKey::try_from_bytes(&mut b), }, ed25519::SecretKey::generate, |b| b.as_ref().to_vec(), ) .map(ed25519::Keypair::from) - .map(Keypair::Ed25519), + .map(Keypair::from), } } } @@ -727,9 +723,14 @@ mod tests { tempfile::Builder::new().prefix(prefix).tempdir().unwrap() } - fn secret_bytes(kp: &Keypair) -> Vec { - let Keypair::Ed25519(p) = kp; - p.secret().as_ref().iter().cloned().collect() + fn secret_bytes(kp: Keypair) -> Vec { + kp.try_into_ed25519() + .expect("ed25519 keypair") + .secret() + .as_ref() + .iter() + .cloned() + .collect() } #[test] @@ -739,7 +740,7 @@ mod tests { let file = tmp.path().join("x").to_path_buf(); let kp1 = NodeKeyConfig::Ed25519(Secret::File(file.clone())).into_keypair().unwrap(); let kp2 = NodeKeyConfig::Ed25519(Secret::File(file.clone())).into_keypair().unwrap(); - assert!(file.is_file() && secret_bytes(&kp1) == secret_bytes(&kp2)) + assert!(file.is_file() && secret_bytes(kp1) == secret_bytes(kp2)) } #[test] @@ -747,13 +748,13 @@ mod tests { let sk = ed25519::SecretKey::generate(); let kp1 = NodeKeyConfig::Ed25519(Secret::Input(sk.clone())).into_keypair().unwrap(); let kp2 = NodeKeyConfig::Ed25519(Secret::Input(sk)).into_keypair().unwrap(); - assert!(secret_bytes(&kp1) == secret_bytes(&kp2)); + assert!(secret_bytes(kp1) == secret_bytes(kp2)); } #[test] fn test_secret_new() { let kp1 = NodeKeyConfig::Ed25519(Secret::New).into_keypair().unwrap(); let kp2 = NodeKeyConfig::Ed25519(Secret::New).into_keypair().unwrap(); - assert!(secret_bytes(&kp1) != secret_bytes(&kp2)); + assert!(secret_bytes(kp1) != secret_bytes(kp2)); } } diff --git a/client/network/src/discovery.rs b/client/network/src/discovery.rs index 7100c0c70d525..7f1638732acf4 100644 --- a/client/network/src/discovery.rs +++ b/client/network/src/discovery.rs @@ -53,26 +53,23 @@ use futures::prelude::*; use futures_timer::Delay; use ip_network::IpNetwork; use libp2p::{ - core::{connection::ConnectionId, Multiaddr, PeerId, PublicKey}, + core::{Endpoint, Multiaddr}, kad::{ - handler::KademliaHandlerProto, - record::{ - self, - store::{MemoryStore, RecordStore}, - }, - GetClosestPeersError, GetRecordOk, Kademlia, KademliaBucketInserts, KademliaConfig, - KademliaEvent, QueryId, QueryResult, Quorum, Record, + record::store::{MemoryStore, RecordStore}, + Behaviour as Kademlia, BucketInserts, Config as KademliaConfig, Event as KademliaEvent, + GetClosestPeersError, GetRecordOk, QueryId, QueryResult, Quorum, Record, RecordKey, }, mdns::{self, tokio::Behaviour as TokioMdns}, multiaddr::Protocol, swarm::{ behaviour::{ - toggle::{Toggle, ToggleIntoConnectionHandler}, - DialFailure, FromSwarm, NewExternalAddr, + toggle::{Toggle, ToggleConnectionHandler}, + DialFailure, ExternalAddrConfirmed, FromSwarm, }, - ConnectionHandler, DialError, IntoConnectionHandler, NetworkBehaviour, - NetworkBehaviourAction, PollParameters, + ConnectionDenied, ConnectionId, DialError, NetworkBehaviour, PollParameters, + StreamProtocol, THandler, THandlerInEvent, THandlerOutEvent, ToSwarm, }, + PeerId, }; use log::{debug, info, trace, warn}; use sp_core::hexdisplay::HexDisplay; @@ -102,14 +99,14 @@ pub struct DiscoveryConfig { discovery_only_if_under_num: u64, enable_mdns: bool, kademlia_disjoint_query_paths: bool, - kademlia_protocols: Vec>, + kademlia_protocols: Vec, } impl DiscoveryConfig { /// Create a default configuration with the given public key. - pub fn new(local_public_key: PublicKey) -> Self { + pub fn new(local_peer_id: PeerId) -> Self { Self { - local_peer_id: local_public_key.to_peer_id(), + local_peer_id, permanent_addresses: Vec::new(), dht_random_walk: true, allow_private_ip: true, @@ -204,7 +201,7 @@ impl DiscoveryConfig { // By default Kademlia attempts to insert all peers into its routing table once a // dialing attempt succeeds. In order to control which peer is added, disable the // auto-insertion and instead add peers manually. - config.set_kbucket_inserts(KademliaBucketInserts::Manual); + config.set_kbucket_inserts(BucketInserts::Manual); config.disjoint_query_paths(kademlia_disjoint_query_paths); let store = MemoryStore::new(local_peer_id); @@ -235,7 +232,7 @@ impl DiscoveryConfig { allow_private_ip, discovery_only_if_under_num, mdns: if enable_mdns { - match TokioMdns::new(mdns::Config::default()) { + match TokioMdns::new(mdns::Config::default(), local_peer_id) { Ok(mdns) => Some(mdns), Err(err) => { warn!(target: "sub-libp2p", "Failed to initialize mDNS: {:?}", err); @@ -339,7 +336,7 @@ impl DiscoveryBehaviour { pub fn add_self_reported_address( &mut self, peer_id: &PeerId, - supported_protocols: &[impl AsRef<[u8]>], + supported_protocols: &[impl AsRef], addr: Multiaddr, ) { if let Some(kademlia) = self.kademlia.as_mut() { @@ -358,7 +355,7 @@ impl DiscoveryBehaviour { trace!( target: "sub-libp2p", "Adding self-reported address {} from {} to Kademlia DHT {}.", - addr, peer_id, String::from_utf8_lossy(matching_protocol.as_ref()), + addr, peer_id, matching_protocol.as_ref(), ); kademlia.add_address(peer_id, addr.clone()); } else { @@ -374,7 +371,7 @@ impl DiscoveryBehaviour { /// Start fetching a record from the DHT. /// /// A corresponding `ValueFound` or `ValueNotFound` event will later be generated. - pub fn get_value(&mut self, key: record::Key) { + pub fn get_value(&mut self, key: RecordKey) { if let Some(k) = self.kademlia.as_mut() { k.get_record(key.clone()); } @@ -384,7 +381,7 @@ impl DiscoveryBehaviour { /// `get_value`. /// /// A corresponding `ValuePut` or `ValuePutFailed` event will later be generated. - pub fn put_value(&mut self, key: record::Key, value: Vec) { + pub fn put_value(&mut self, key: RecordKey, value: Vec) { if let Some(k) = self.kademlia.as_mut() { if let Err(e) = k.put_record(Record::new(key.clone(), value.clone()), Quorum::All) { warn!(target: "sub-libp2p", "Libp2p => Failed to put record: {:?}", e); @@ -443,7 +440,7 @@ impl DiscoveryBehaviour { #[derive(Debug)] pub enum DiscoveryOut { /// A connection to a peer has been established but the peer has not been - /// added to the routing table because [`KademliaBucketInserts::Manual`] is + /// added to the routing table because [`BucketInserts::Manual`] is /// configured. If the peer is to be included in the routing table, it must /// be explicitly added via /// [`DiscoveryBehaviour::add_self_reported_address`]. @@ -460,22 +457,22 @@ pub enum DiscoveryOut { /// The DHT yielded results for the record request. /// /// Returning the result grouped in (key, value) pairs as well as the request duration. - ValueFound(Vec<(record::Key, Vec)>, Duration), + ValueFound(Vec<(RecordKey, Vec)>, Duration), /// The record requested was not found in the DHT. /// /// Returning the corresponding key as well as the request duration. - ValueNotFound(record::Key, Duration), + ValueNotFound(RecordKey, Duration), /// The record with a given key was successfully inserted into the DHT. /// /// Returning the corresponding key as well as the request duration. - ValuePut(record::Key, Duration), + ValuePut(RecordKey, Duration), /// Inserting a value into the DHT failed. /// /// Returning the corresponding key as well as the request duration. - ValuePutFailed(record::Key, Duration), + ValuePutFailed(RecordKey, Duration), /// Started a random Kademlia query. /// @@ -484,29 +481,84 @@ pub enum DiscoveryOut { } impl NetworkBehaviour for DiscoveryBehaviour { - type ConnectionHandler = ToggleIntoConnectionHandler>; - type OutEvent = DiscoveryOut; + type ConnectionHandler = + ToggleConnectionHandler< as NetworkBehaviour>::ConnectionHandler>; + type ToSwarm = DiscoveryOut; + + fn handle_established_inbound_connection( + &mut self, + connection_id: ConnectionId, + peer: PeerId, + local_addr: &Multiaddr, + remote_addr: &Multiaddr, + ) -> Result, ConnectionDenied> { + self.kademlia.handle_established_inbound_connection( + connection_id, + peer, + local_addr, + remote_addr, + ) + } - fn new_handler(&mut self) -> Self::ConnectionHandler { - self.kademlia.new_handler() + fn handle_established_outbound_connection( + &mut self, + connection_id: ConnectionId, + peer: PeerId, + addr: &Multiaddr, + role_override: Endpoint, + ) -> Result, ConnectionDenied> { + self.kademlia.handle_established_outbound_connection( + connection_id, + peer, + addr, + role_override, + ) } - fn addresses_of_peer(&mut self, peer_id: &PeerId) -> Vec { + fn handle_pending_inbound_connection( + &mut self, + connection_id: ConnectionId, + local_addr: &Multiaddr, + remote_addr: &Multiaddr, + ) -> Result<(), ConnectionDenied> { + self.kademlia + .handle_pending_inbound_connection(connection_id, local_addr, remote_addr) + } + + fn handle_pending_outbound_connection( + &mut self, + connection_id: ConnectionId, + maybe_peer: Option, + addresses: &[Multiaddr], + effective_role: Endpoint, + ) -> Result, ConnectionDenied> { + let Some(peer_id) = maybe_peer else { return Ok(Vec::new()); }; + let mut list = self .permanent_addresses .iter() - .filter_map(|(p, a)| if p == peer_id { Some(a.clone()) } else { None }) + .filter_map(|(p, a)| (*p == peer_id).then_some(a.clone())) .collect::>(); - if let Some(ephemeral_addresses) = self.ephemeral_addresses.get(peer_id) { + if let Some(ephemeral_addresses) = self.ephemeral_addresses.get(&peer_id) { list.extend(ephemeral_addresses.clone()); } { - let mut list_to_filter = self.kademlia.addresses_of_peer(peer_id); + let mut list_to_filter = self.kademlia.handle_pending_outbound_connection( + connection_id, + maybe_peer, + addresses, + effective_role, + )?; if let Some(ref mut mdns) = self.mdns { - list_to_filter.extend(mdns.addresses_of_peer(peer_id)); + list_to_filter.extend(mdns.handle_pending_outbound_connection( + connection_id, + maybe_peer, + addresses, + effective_role, + )?); } if !self.allow_private_ip { @@ -522,7 +574,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { trace!(target: "sub-libp2p", "Addresses of {:?}: {:?}", peer_id, list); - list + Ok(list) } fn on_swarm_event(&mut self, event: FromSwarm) { @@ -561,11 +613,11 @@ impl NetworkBehaviour for DiscoveryBehaviour { FromSwarm::ListenerError(e) => { self.kademlia.on_swarm_event(FromSwarm::ListenerError(e)); }, - FromSwarm::ExpiredExternalAddr(e) => { + FromSwarm::ExternalAddrExpired(e) => { // We intentionally don't remove the element from `known_external_addresses` in // order to not print the log line again. - self.kademlia.on_swarm_event(FromSwarm::ExpiredExternalAddr(e)); + self.kademlia.on_swarm_event(FromSwarm::ExternalAddrExpired(e)); }, FromSwarm::NewListener(e) => { self.kademlia.on_swarm_event(FromSwarm::NewListener(e)); @@ -573,8 +625,21 @@ impl NetworkBehaviour for DiscoveryBehaviour { FromSwarm::ExpiredListenAddr(e) => { self.kademlia.on_swarm_event(FromSwarm::ExpiredListenAddr(e)); }, - FromSwarm::NewExternalAddr(e @ NewExternalAddr { addr }) => { - let new_addr = addr.clone().with(Protocol::P2p(self.local_peer_id.into())); + FromSwarm::NewExternalAddrCandidate(e) => { + self.kademlia.on_swarm_event(FromSwarm::NewExternalAddrCandidate(e)); + }, + FromSwarm::AddressChange(e) => { + self.kademlia.on_swarm_event(FromSwarm::AddressChange(e)); + }, + FromSwarm::NewListenAddr(e) => { + self.kademlia.on_swarm_event(FromSwarm::NewListenAddr(e)); + + if let Some(ref mut mdns) = self.mdns { + mdns.on_swarm_event(FromSwarm::NewListenAddr(e)); + } + }, + FromSwarm::ExternalAddrConfirmed(e @ ExternalAddrConfirmed { addr }) => { + let new_addr = addr.clone().with(Protocol::P2p(self.local_peer_id)); if Self::can_add_to_dht(addr) { // NOTE: we might re-discover the same address multiple times @@ -588,13 +653,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { } } - self.kademlia.on_swarm_event(FromSwarm::NewExternalAddr(e)); - }, - FromSwarm::AddressChange(e) => { - self.kademlia.on_swarm_event(FromSwarm::AddressChange(e)); - }, - FromSwarm::NewListenAddr(e) => { - self.kademlia.on_swarm_event(FromSwarm::NewListenAddr(e)); + self.kademlia.on_swarm_event(FromSwarm::ExternalAddrConfirmed(e)); }, } } @@ -603,8 +662,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { &mut self, peer_id: PeerId, connection_id: ConnectionId, - event: <::Handler as - ConnectionHandler>::OutEvent, + event: THandlerOutEvent, ) { self.kademlia.on_connection_handler_event(peer_id, connection_id, event); } @@ -613,10 +671,10 @@ impl NetworkBehaviour for DiscoveryBehaviour { &mut self, cx: &mut Context, params: &mut impl PollParameters, - ) -> Poll> { + ) -> Poll>> { // Immediately process the content of `discovered`. if let Some(ev) = self.pending_events.pop_front() { - return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev)) + return Poll::Ready(ToSwarm::GenerateEvent(ev)) } // Poll the stream that fires when we need to start a random Kademlia query. @@ -650,7 +708,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { if actually_started { let ev = DiscoveryOut::RandomKademliaStarted; - return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev)) + return Poll::Ready(ToSwarm::GenerateEvent(ev)) } } } @@ -658,18 +716,18 @@ impl NetworkBehaviour for DiscoveryBehaviour { while let Poll::Ready(ev) = self.kademlia.poll(cx, params) { match ev { - NetworkBehaviourAction::GenerateEvent(ev) => match ev { + ToSwarm::GenerateEvent(ev) => match ev { KademliaEvent::RoutingUpdated { peer, .. } => { let ev = DiscoveryOut::Discovered(peer); - return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev)) + return Poll::Ready(ToSwarm::GenerateEvent(ev)) }, KademliaEvent::UnroutablePeer { peer, .. } => { let ev = DiscoveryOut::UnroutablePeer(peer); - return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev)) + return Poll::Ready(ToSwarm::GenerateEvent(ev)) }, KademliaEvent::RoutablePeer { peer, .. } => { let ev = DiscoveryOut::Discovered(peer); - return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev)) + return Poll::Ready(ToSwarm::GenerateEvent(ev)) }, KademliaEvent::PendingRoutablePeer { .. } | KademliaEvent::InboundRequest { .. } => { @@ -777,7 +835,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { ) }, }; - return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev)) + return Poll::Ready(ToSwarm::GenerateEvent(ev)) }, KademliaEvent::OutboundQueryProgressed { result: QueryResult::PutRecord(res), @@ -799,7 +857,7 @@ impl NetworkBehaviour for DiscoveryBehaviour { ) }, }; - return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev)) + return Poll::Ready(ToSwarm::GenerateEvent(ev)) }, KademliaEvent::OutboundQueryProgressed { result: QueryResult::RepublishRecord(res), @@ -821,24 +879,20 @@ impl NetworkBehaviour for DiscoveryBehaviour { warn!(target: "sub-libp2p", "Libp2p => Unhandled Kademlia event: {:?}", e) }, }, - NetworkBehaviourAction::Dial { opts, handler } => - return Poll::Ready(NetworkBehaviourAction::Dial { opts, handler }), - NetworkBehaviourAction::NotifyHandler { peer_id, handler, event } => - return Poll::Ready(NetworkBehaviourAction::NotifyHandler { - peer_id, - handler, - event, - }), - NetworkBehaviourAction::ReportObservedAddr { address, score } => - return Poll::Ready(NetworkBehaviourAction::ReportObservedAddr { - address, - score, - }), - NetworkBehaviourAction::CloseConnection { peer_id, connection } => - return Poll::Ready(NetworkBehaviourAction::CloseConnection { - peer_id, - connection, - }), + ToSwarm::Dial { opts } => return Poll::Ready(ToSwarm::Dial { opts }), + ToSwarm::NotifyHandler { peer_id, handler, event } => + return Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, event }), + ToSwarm::CloseConnection { peer_id, connection } => + return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), + ToSwarm::NewExternalAddrCandidate(observed) => + return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), + ToSwarm::ExternalAddrConfirmed(addr) => + return Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)), + ToSwarm::ExternalAddrExpired(addr) => + return Poll::Ready(ToSwarm::ExternalAddrExpired(addr)), + ToSwarm::ListenOn { opts } => return Poll::Ready(ToSwarm::ListenOn { opts }), + ToSwarm::RemoveListener { id } => + return Poll::Ready(ToSwarm::RemoveListener { id }), } } @@ -846,34 +900,39 @@ impl NetworkBehaviour for DiscoveryBehaviour { if let Some(ref mut mdns) = self.mdns { while let Poll::Ready(ev) = mdns.poll(cx, params) { match ev { - NetworkBehaviourAction::GenerateEvent(event) => match event { + ToSwarm::GenerateEvent(event) => match event { mdns::Event::Discovered(list) => { if self.num_connections >= self.discovery_only_if_under_num { continue } - self.pending_events - .extend(list.map(|(peer_id, _)| DiscoveryOut::Discovered(peer_id))); + self.pending_events.extend( + list.into_iter() + .map(|(peer_id, _)| DiscoveryOut::Discovered(peer_id)), + ); if let Some(ev) = self.pending_events.pop_front() { - return Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev)) + return Poll::Ready(ToSwarm::GenerateEvent(ev)) } }, mdns::Event::Expired(_) => {}, }, - NetworkBehaviourAction::Dial { .. } => { + ToSwarm::Dial { .. } => { unreachable!("mDNS never dials!"); }, - NetworkBehaviourAction::NotifyHandler { event, .. } => match event {}, /* `event` is an enum with no variant */ - NetworkBehaviourAction::ReportObservedAddr { address, score } => - return Poll::Ready(NetworkBehaviourAction::ReportObservedAddr { - address, - score, - }), - NetworkBehaviourAction::CloseConnection { peer_id, connection } => - return Poll::Ready(NetworkBehaviourAction::CloseConnection { - peer_id, - connection, - }), + ToSwarm::NotifyHandler { event, .. } => match event {}, /* `event` is an */ + // enum with no + // variant + ToSwarm::CloseConnection { peer_id, connection } => + return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), + ToSwarm::NewExternalAddrCandidate(observed) => + return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), + ToSwarm::ExternalAddrConfirmed(addr) => + return Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)), + ToSwarm::ExternalAddrExpired(addr) => + return Poll::Ready(ToSwarm::ExternalAddrExpired(addr)), + ToSwarm::ListenOn { opts } => return Poll::Ready(ToSwarm::ListenOn { opts }), + ToSwarm::RemoveListener { id } => + return Poll::Ready(ToSwarm::RemoveListener { id }), } } } @@ -883,21 +942,23 @@ impl NetworkBehaviour for DiscoveryBehaviour { } /// Legacy (fallback) Kademlia protocol name based on `protocol_id`. -fn legacy_kademlia_protocol_name(id: &ProtocolId) -> Vec { - let mut v = vec![b'/']; - v.extend_from_slice(id.as_ref().as_bytes()); - v.extend_from_slice(b"/kad"); - v +fn legacy_kademlia_protocol_name(id: &ProtocolId) -> StreamProtocol { + let name = format!("/{}/kad", id.as_ref()); + StreamProtocol::try_from_owned(name).expect("protocol name is valid. qed") } /// Kademlia protocol name based on `genesis_hash` and `fork_id`. -fn kademlia_protocol_name>(genesis_hash: Hash, fork_id: Option<&str>) -> Vec { +fn kademlia_protocol_name>( + genesis_hash: Hash, + fork_id: Option<&str>, +) -> StreamProtocol { let genesis_hash_hex = bytes2hex("", genesis_hash.as_ref()); - if let Some(fork_id) = fork_id { - format!("/{}/{}/kad", genesis_hash_hex, fork_id).as_bytes().into() + let name = if let Some(fork_id) = fork_id { + format!("/{}/{}/kad", genesis_hash_hex, fork_id) } else { - format!("/{}/kad", genesis_hash_hex).as_bytes().into() - } + format!("/{}/kad", genesis_hash_hex) + }; + StreamProtocol::try_from_owned(name).expect("protocol name is valid. qed") } #[cfg(test)] @@ -912,9 +973,9 @@ mod tests { transport::{MemoryTransport, Transport}, upgrade, }, - identity::{ed25519, Keypair}, - noise, - swarm::{Executor, Swarm, SwarmEvent}, + identity::Keypair, + kad, noise, + swarm::{Executor, Swarm, SwarmBuilder, SwarmEvent}, yamux, Multiaddr, }; use sp_core::hash::H256; @@ -941,17 +1002,14 @@ mod tests { .map(|i| { let keypair = Keypair::generate_ed25519(); - let noise_keys = - noise::Keypair::::new().into_authentic(&keypair).unwrap(); - let transport = MemoryTransport::new() .upgrade(upgrade::Version::V1) - .authenticate(noise::NoiseConfig::xx(noise_keys).into_authenticated()) - .multiplex(yamux::YamuxConfig::default()) + .authenticate(noise::Config::new(&keypair).unwrap()) + .multiplex(yamux::Config::default()) .boxed(); let behaviour = { - let mut config = DiscoveryConfig::new(keypair.public()); + let mut config = DiscoveryConfig::new(keypair.public().to_peer_id()); config .with_permanent_addresses(first_swarm_peer_id_and_addr.clone()) .allow_private_ip(true) @@ -963,12 +1021,25 @@ mod tests { }; let runtime = tokio::runtime::Runtime::new().unwrap(); - let mut swarm = Swarm::with_executor( + let mut swarm = SwarmBuilder::with_executor( transport, behaviour, keypair.public().to_peer_id(), TokioExecutor(runtime), - ); + ) + .build(); + + // Set the Kademlia mode to server so that it can accept incoming requests. + // + // Note: the server mode is set automatically when the node learns its external + // address, but that does not happen in tests => hence we set it manually. + swarm + .behaviour_mut() + .kademlia + .as_mut() + .unwrap() + .set_mode(Some(kad::Mode::Server)); + let listen_addr: Multiaddr = format!("/memory/{}", rand::random::()).parse().unwrap(); @@ -1029,7 +1100,7 @@ mod tests { .add_self_reported_address( &other, &[protocol_name], - addr, + addr.clone(), ); to_discover[swarm_n].remove(&other); @@ -1070,7 +1141,7 @@ mod tests { let mut discovery = { let keypair = Keypair::generate_ed25519(); - let mut config = DiscoveryConfig::new(keypair.public()); + let mut config = DiscoveryConfig::new(keypair.public().to_peer_id()); config .allow_private_ip(true) .allow_non_globals_in_dht(true) @@ -1080,11 +1151,7 @@ mod tests { }; let predictable_peer_id = |bytes: &[u8; 32]| { - Keypair::Ed25519(ed25519::Keypair::from( - ed25519::SecretKey::from_bytes(bytes.to_owned()).unwrap(), - )) - .public() - .to_peer_id() + Keypair::ed25519_from_bytes(bytes.to_owned()).unwrap().public().to_peer_id() }; let remote_peer_id = predictable_peer_id(b"00000000000000000000000000000001"); diff --git a/client/network/src/event.rs b/client/network/src/event.rs index 3ecd8f9311429..3200b5668cb4e 100644 --- a/client/network/src/event.rs +++ b/client/network/src/event.rs @@ -22,7 +22,7 @@ use crate::types::ProtocolName; use bytes::Bytes; -use libp2p::{core::PeerId, kad::record::Key}; +use libp2p::{PeerId, kad::record::Key}; use sc_network_common::role::ObservedRole; diff --git a/client/network/src/lib.rs b/client/network/src/lib.rs index c290f4b94db53..88ce1a8454ea4 100644 --- a/client/network/src/lib.rs +++ b/client/network/src/lib.rs @@ -87,8 +87,6 @@ //! //! The following multiplexing protocols are supported: //! -//! - [Mplex](https://github.com/libp2p/specs/tree/master/mplex). Support for mplex will likely -//! be deprecated in the future. //! - [Yamux](https://github.com/hashicorp/yamux/blob/master/spec.md). //! //! ## Substreams @@ -262,7 +260,7 @@ pub mod utils; pub use event::{DhtEvent, Event}; #[doc(inline)] pub use libp2p::{multiaddr, Multiaddr, PeerId}; -pub use request_responses::{IfDisconnected, RequestFailure, RequestResponseConfig}; +pub use request_responses::{Config, IfDisconnected, RequestFailure}; pub use sc_network_common::{ role::ObservedRole, sync::{ diff --git a/client/network/src/peer_info.rs b/client/network/src/peer_info.rs index 3f769736ff10e..51710f7b36dcb 100644 --- a/client/network/src/peer_info.rs +++ b/client/network/src/peer_info.rs @@ -17,25 +17,27 @@ // along with this program. If not, see . use crate::utils::interval; +use either::Either; use fnv::FnvHashMap; use futures::prelude::*; use libp2p::{ - core::{connection::ConnectionId, either::EitherOutput, ConnectedPoint, PeerId, PublicKey}, + core::{ConnectedPoint, Endpoint}, identify::{ Behaviour as Identify, Config as IdentifyConfig, Event as IdentifyEvent, Info as IdentifyInfo, }, - ping::{Behaviour as Ping, Config as PingConfig, Event as PingEvent, Success as PingSuccess}, + identity::PublicKey, + ping::{Behaviour as Ping, Config as PingConfig, Event as PingEvent}, swarm::{ behaviour::{ AddressChange, ConnectionClosed, ConnectionEstablished, DialFailure, FromSwarm, ListenFailure, }, - ConnectionHandler, IntoConnectionHandler, IntoConnectionHandlerSelect, NetworkBehaviour, - NetworkBehaviourAction, PollParameters, + ConnectionDenied, ConnectionHandler, ConnectionHandlerSelect, ConnectionId, + NetworkBehaviour, PollParameters, THandler, THandlerInEvent, THandlerOutEvent, ToSwarm, }, - Multiaddr, + Multiaddr, PeerId, }; use log::{debug, error, trace}; use smallvec::SmallVec; @@ -116,13 +118,18 @@ impl PeerInfoBehaviour { /// Inserts a ping time in the cache. Has no effect if we don't have any entry for that node, /// which shouldn't happen. - fn handle_ping_report(&mut self, peer_id: &PeerId, ping_time: Duration) { - trace!(target: "sub-libp2p", "Ping time with {:?}: {:?}", peer_id, ping_time); + fn handle_ping_report( + &mut self, + peer_id: &PeerId, + ping_time: Duration, + connection: ConnectionId, + ) { + trace!(target: "sub-libp2p", "Ping time with {:?} via {:?}: {:?}", peer_id, connection, ping_time); if let Some(entry) = self.nodes_info.get_mut(peer_id) { entry.latest_ping = Some(ping_time); } else { error!(target: "sub-libp2p", - "Received ping from node we're not connected to {:?}", peer_id); + "Received ping from node we're not connected to {:?} via {:?}", peer_id, connection); } } @@ -176,20 +183,78 @@ pub enum PeerInfoEvent { } impl NetworkBehaviour for PeerInfoBehaviour { - type ConnectionHandler = IntoConnectionHandlerSelect< + type ConnectionHandler = ConnectionHandlerSelect< ::ConnectionHandler, ::ConnectionHandler, >; - type OutEvent = PeerInfoEvent; + type ToSwarm = PeerInfoEvent; + + fn handle_pending_inbound_connection( + &mut self, + connection_id: ConnectionId, + local_addr: &Multiaddr, + remote_addr: &Multiaddr, + ) -> Result<(), ConnectionDenied> { + self.ping + .handle_pending_inbound_connection(connection_id, local_addr, remote_addr)?; + self.identify + .handle_pending_inbound_connection(connection_id, local_addr, remote_addr) + } + + fn handle_pending_outbound_connection( + &mut self, + _connection_id: ConnectionId, + _maybe_peer: Option, + _addresses: &[Multiaddr], + _effective_role: Endpoint, + ) -> Result, ConnectionDenied> { + // Only `Discovery::handle_pending_outbound_connection` must be returning addresses to + // ensure that we don't return unwanted addresses. + Ok(Vec::new()) + } - fn new_handler(&mut self) -> Self::ConnectionHandler { - IntoConnectionHandler::select(self.ping.new_handler(), self.identify.new_handler()) + fn handle_established_inbound_connection( + &mut self, + connection_id: ConnectionId, + peer: PeerId, + local_addr: &Multiaddr, + remote_addr: &Multiaddr, + ) -> Result, ConnectionDenied> { + let ping_handler = self.ping.handle_established_inbound_connection( + connection_id, + peer, + local_addr, + remote_addr, + )?; + let identify_handler = self.identify.handle_established_inbound_connection( + connection_id, + peer, + local_addr, + remote_addr, + )?; + Ok(ping_handler.select(identify_handler)) } - fn addresses_of_peer(&mut self, _: &PeerId) -> Vec { - // Only `Discovery::addresses_of_peer` must be returning addresses to ensure that we - // don't return unwanted addresses. - Vec::new() + fn handle_established_outbound_connection( + &mut self, + connection_id: ConnectionId, + peer: PeerId, + addr: &Multiaddr, + role_override: Endpoint, + ) -> Result, ConnectionDenied> { + let ping_handler = self.ping.handle_established_outbound_connection( + connection_id, + peer, + addr, + role_override, + )?; + let identify_handler = self.identify.handle_established_outbound_connection( + connection_id, + peer, + addr, + role_override, + )?; + Ok(ping_handler.select(identify_handler)) } fn on_swarm_event(&mut self, event: FromSwarm) { @@ -249,43 +314,48 @@ impl NetworkBehaviour for PeerInfoBehaviour { "Unknown connection to {:?} closed: {:?}", peer_id, endpoint); } }, - FromSwarm::DialFailure(DialFailure { peer_id, handler, error }) => { - let (ping_handler, identity_handler) = handler.into_inner(); + FromSwarm::DialFailure(DialFailure { peer_id, error, connection_id }) => { self.ping.on_swarm_event(FromSwarm::DialFailure(DialFailure { peer_id, - handler: ping_handler, error, + connection_id, })); self.identify.on_swarm_event(FromSwarm::DialFailure(DialFailure { peer_id, - handler: identity_handler, error, + connection_id, })); }, FromSwarm::ListenerClosed(e) => { self.ping.on_swarm_event(FromSwarm::ListenerClosed(e)); self.identify.on_swarm_event(FromSwarm::ListenerClosed(e)); }, - FromSwarm::ListenFailure(ListenFailure { local_addr, send_back_addr, handler }) => { - let (ping_handler, identity_handler) = handler.into_inner(); + FromSwarm::ListenFailure(ListenFailure { + local_addr, + send_back_addr, + error, + connection_id, + }) => { self.ping.on_swarm_event(FromSwarm::ListenFailure(ListenFailure { local_addr, send_back_addr, - handler: ping_handler, + error, + connection_id, })); self.identify.on_swarm_event(FromSwarm::ListenFailure(ListenFailure { local_addr, send_back_addr, - handler: identity_handler, + error, + connection_id, })); }, FromSwarm::ListenerError(e) => { self.ping.on_swarm_event(FromSwarm::ListenerError(e)); self.identify.on_swarm_event(FromSwarm::ListenerError(e)); }, - FromSwarm::ExpiredExternalAddr(e) => { - self.ping.on_swarm_event(FromSwarm::ExpiredExternalAddr(e)); - self.identify.on_swarm_event(FromSwarm::ExpiredExternalAddr(e)); + FromSwarm::ExternalAddrExpired(e) => { + self.ping.on_swarm_event(FromSwarm::ExternalAddrExpired(e)); + self.identify.on_swarm_event(FromSwarm::ExternalAddrExpired(e)); }, FromSwarm::NewListener(e) => { self.ping.on_swarm_event(FromSwarm::NewListener(e)); @@ -295,9 +365,13 @@ impl NetworkBehaviour for PeerInfoBehaviour { self.ping.on_swarm_event(FromSwarm::ExpiredListenAddr(e)); self.identify.on_swarm_event(FromSwarm::ExpiredListenAddr(e)); }, - FromSwarm::NewExternalAddr(e) => { - self.ping.on_swarm_event(FromSwarm::NewExternalAddr(e)); - self.identify.on_swarm_event(FromSwarm::NewExternalAddr(e)); + FromSwarm::NewExternalAddrCandidate(e) => { + self.ping.on_swarm_event(FromSwarm::NewExternalAddrCandidate(e)); + self.identify.on_swarm_event(FromSwarm::NewExternalAddrCandidate(e)); + }, + FromSwarm::ExternalAddrConfirmed(e) => { + self.ping.on_swarm_event(FromSwarm::ExternalAddrConfirmed(e)); + self.identify.on_swarm_event(FromSwarm::ExternalAddrConfirmed(e)); }, FromSwarm::AddressChange(e @ AddressChange { peer_id, old, new, .. }) => { self.ping.on_swarm_event(FromSwarm::AddressChange(e)); @@ -326,13 +400,12 @@ impl NetworkBehaviour for PeerInfoBehaviour { &mut self, peer_id: PeerId, connection_id: ConnectionId, - event: <::Handler as - ConnectionHandler>::OutEvent, + event: THandlerOutEvent, ) { match event { - EitherOutput::First(event) => + Either::Left(event) => self.ping.on_connection_handler_event(peer_id, connection_id, event), - EitherOutput::Second(event) => + Either::Right(event) => self.identify.on_connection_handler_event(peer_id, connection_id, event), } } @@ -341,47 +414,45 @@ impl NetworkBehaviour for PeerInfoBehaviour { &mut self, cx: &mut Context, params: &mut impl PollParameters, - ) -> Poll> { + ) -> Poll>> { loop { match self.ping.poll(cx, params) { Poll::Pending => break, - Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev)) => { - if let PingEvent { peer, result: Ok(PingSuccess::Ping { rtt }) } = ev { - self.handle_ping_report(&peer, rtt) + Poll::Ready(ToSwarm::GenerateEvent(ev)) => { + if let PingEvent { peer, result: Ok(rtt), connection } = ev { + self.handle_ping_report(&peer, rtt, connection) } }, - Poll::Ready(NetworkBehaviourAction::Dial { opts, handler }) => { - let handler = - IntoConnectionHandler::select(handler, self.identify.new_handler()); - return Poll::Ready(NetworkBehaviourAction::Dial { opts, handler }) - }, - Poll::Ready(NetworkBehaviourAction::NotifyHandler { peer_id, handler, event }) => - return Poll::Ready(NetworkBehaviourAction::NotifyHandler { + Poll::Ready(ToSwarm::Dial { opts }) => return Poll::Ready(ToSwarm::Dial { opts }), + Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, event }) => + return Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, - event: EitherOutput::First(event), - }), - 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, + event: Either::Left(event), }), + Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }) => + return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), + Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)) => + return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), + Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)) => + return Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)), + Poll::Ready(ToSwarm::ExternalAddrExpired(addr)) => + return Poll::Ready(ToSwarm::ExternalAddrExpired(addr)), + Poll::Ready(ToSwarm::ListenOn { opts }) => + return Poll::Ready(ToSwarm::ListenOn { opts }), + Poll::Ready(ToSwarm::RemoveListener { id }) => + return Poll::Ready(ToSwarm::RemoveListener { id }), } } loop { match self.identify.poll(cx, params) { Poll::Pending => break, - Poll::Ready(NetworkBehaviourAction::GenerateEvent(event)) => match event { + Poll::Ready(ToSwarm::GenerateEvent(event)) => match event { IdentifyEvent::Received { peer_id, info, .. } => { self.handle_identify_report(&peer_id, &info); let event = PeerInfoEvent::Identified { peer_id, info }; - return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event)) + return Poll::Ready(ToSwarm::GenerateEvent(event)) }, IdentifyEvent::Error { peer_id, error } => { debug!(target: "sub-libp2p", "Identification with peer {:?} failed => {}", peer_id, error) @@ -389,26 +460,25 @@ impl NetworkBehaviour for PeerInfoBehaviour { IdentifyEvent::Pushed { .. } => {}, IdentifyEvent::Sent { .. } => {}, }, - Poll::Ready(NetworkBehaviourAction::Dial { opts, handler }) => { - let handler = IntoConnectionHandler::select(self.ping.new_handler(), handler); - return Poll::Ready(NetworkBehaviourAction::Dial { opts, handler }) - }, - Poll::Ready(NetworkBehaviourAction::NotifyHandler { peer_id, handler, event }) => - return Poll::Ready(NetworkBehaviourAction::NotifyHandler { + Poll::Ready(ToSwarm::Dial { opts }) => return Poll::Ready(ToSwarm::Dial { opts }), + Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, event }) => + return Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, - event: EitherOutput::Second(event), - }), - 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, + event: Either::Right(event), }), + Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }) => + return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), + Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)) => + return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), + Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)) => + return Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)), + Poll::Ready(ToSwarm::ExternalAddrExpired(addr)) => + return Poll::Ready(ToSwarm::ExternalAddrExpired(addr)), + Poll::Ready(ToSwarm::ListenOn { opts }) => + return Poll::Ready(ToSwarm::ListenOn { opts }), + Poll::Ready(ToSwarm::RemoveListener { id }) => + return Poll::Ready(ToSwarm::RemoveListener { id }), } } diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs index 06ca02c0ca8d5..dc9499fd41150 100644 --- a/client/network/src/protocol.rs +++ b/client/network/src/protocol.rs @@ -25,10 +25,10 @@ use crate::{ use bytes::Bytes; use codec::{DecodeAll, Encode}; use libp2p::{ - core::connection::ConnectionId, + core::Endpoint, swarm::{ - behaviour::FromSwarm, ConnectionHandler, IntoConnectionHandler, NetworkBehaviour, - NetworkBehaviourAction, PollParameters, + behaviour::FromSwarm, ConnectionDenied, ConnectionId, NetworkBehaviour, PollParameters, + THandler, THandlerInEvent, THandlerOutEvent, ToSwarm, }, Multiaddr, PeerId, }; @@ -366,16 +366,48 @@ pub enum CustomMessageOutcome { impl NetworkBehaviour for Protocol { type ConnectionHandler = ::ConnectionHandler; - type OutEvent = CustomMessageOutcome; + type ToSwarm = CustomMessageOutcome; - fn new_handler(&mut self) -> Self::ConnectionHandler { - self.behaviour.new_handler() + fn handle_established_inbound_connection( + &mut self, + connection_id: ConnectionId, + peer: PeerId, + local_addr: &Multiaddr, + remote_addr: &Multiaddr, + ) -> Result, ConnectionDenied> { + self.behaviour.handle_established_inbound_connection( + connection_id, + peer, + local_addr, + remote_addr, + ) } - fn addresses_of_peer(&mut self, _: &PeerId) -> Vec { - // Only `Discovery::addresses_of_peer` must be returning addresses to ensure that we - // don't return unwanted addresses. - Vec::new() + fn handle_established_outbound_connection( + &mut self, + connection_id: ConnectionId, + peer: PeerId, + addr: &Multiaddr, + role_override: Endpoint, + ) -> Result, ConnectionDenied> { + self.behaviour.handle_established_outbound_connection( + connection_id, + peer, + addr, + role_override, + ) + } + + fn handle_pending_outbound_connection( + &mut self, + _connection_id: ConnectionId, + _maybe_peer: Option, + _addresses: &[Multiaddr], + _effective_role: Endpoint, + ) -> Result, ConnectionDenied> { + // Only `Discovery::handle_pending_outbound_connection` must be returning addresses to + // ensure that we don't return unwanted addresses. + Ok(Vec::new()) } fn on_swarm_event(&mut self, event: FromSwarm) { @@ -386,8 +418,7 @@ impl NetworkBehaviour for Protocol { &mut self, peer_id: PeerId, connection_id: ConnectionId, - event: <::Handler as - ConnectionHandler>::OutEvent, + event: THandlerOutEvent, ) { self.behaviour.on_connection_handler_event(peer_id, connection_id, event); } @@ -396,26 +427,29 @@ impl NetworkBehaviour for Protocol { &mut self, cx: &mut std::task::Context, params: &mut impl PollParameters, - ) -> Poll> { + ) -> Poll>> { if let Some(message) = self.pending_messages.pop_front() { - return Poll::Ready(NetworkBehaviourAction::GenerateEvent(message)) + return Poll::Ready(ToSwarm::GenerateEvent(message)) } let event = match self.behaviour.poll(cx, params) { Poll::Pending => return Poll::Pending, - Poll::Ready(NetworkBehaviourAction::GenerateEvent(ev)) => ev, - Poll::Ready(NetworkBehaviourAction::Dial { opts, handler }) => - return Poll::Ready(NetworkBehaviourAction::Dial { opts, handler }), - Poll::Ready(NetworkBehaviourAction::NotifyHandler { peer_id, handler, event }) => - return Poll::Ready(NetworkBehaviourAction::NotifyHandler { - peer_id, - handler, - event, - }), - 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 }), + Poll::Ready(ToSwarm::GenerateEvent(ev)) => ev, + Poll::Ready(ToSwarm::Dial { opts }) => return Poll::Ready(ToSwarm::Dial { opts }), + Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, event }) => + return Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, event }), + Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }) => + return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), + Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)) => + return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), + Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)) => + return Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)), + Poll::Ready(ToSwarm::ExternalAddrExpired(addr)) => + return Poll::Ready(ToSwarm::ExternalAddrExpired(addr)), + Poll::Ready(ToSwarm::ListenOn { opts }) => + return Poll::Ready(ToSwarm::ListenOn { opts }), + Poll::Ready(ToSwarm::RemoveListener { id }) => + return Poll::Ready(ToSwarm::RemoveListener { id }), }; let outcome = match event { @@ -569,11 +603,11 @@ impl NetworkBehaviour for Protocol { }; if !matches!(outcome, CustomMessageOutcome::None) { - return Poll::Ready(NetworkBehaviourAction::GenerateEvent(outcome)) + return Poll::Ready(ToSwarm::GenerateEvent(outcome)) } if let Some(message) = self.pending_messages.pop_front() { - return Poll::Ready(NetworkBehaviourAction::GenerateEvent(message)) + return Poll::Ready(ToSwarm::GenerateEvent(message)) } // This block can only be reached if an event was pulled from the behaviour and that diff --git a/client/network/src/protocol/notifications/behaviour.rs b/client/network/src/protocol/notifications/behaviour.rs index 74e27fa17c602..b8cdbdab9a3e4 100644 --- a/client/network/src/protocol/notifications/behaviour.rs +++ b/client/network/src/protocol/notifications/behaviour.rs @@ -18,7 +18,7 @@ use crate::{ protocol::notifications::handler::{ - self, NotificationsSink, NotifsHandlerIn, NotifsHandlerOut, NotifsHandlerProto, + self, NotificationsSink, NotifsHandler, NotifsHandlerIn, NotifsHandlerOut, }, types::ProtocolName, }; @@ -27,13 +27,13 @@ use bytes::BytesMut; use fnv::FnvHashMap; use futures::prelude::*; use libp2p::{ - core::{connection::ConnectionId, Multiaddr, PeerId}, + core::{ConnectedPoint, Endpoint, Multiaddr}, swarm::{ behaviour::{ConnectionClosed, ConnectionEstablished, DialFailure, FromSwarm}, - handler::ConnectionHandler, - DialError, IntoConnectionHandler, NetworkBehaviour, NetworkBehaviourAction, NotifyHandler, - PollParameters, + ConnectionDenied, ConnectionId, DialError, NetworkBehaviour, NotifyHandler, PollParameters, + THandler, THandlerInEvent, THandlerOutEvent, ToSwarm, }, + PeerId, }; use log::{error, trace, warn}; use parking_lot::RwLock; @@ -136,7 +136,7 @@ pub struct Notifications { next_incoming_index: sc_peerset::IncomingIndex, /// Events to produce from `poll()`. - events: VecDeque>, + events: VecDeque>, } /// Configuration for a notifications protocol. @@ -454,14 +454,14 @@ impl Notifications { trace!(target: "sub-libp2p", "External API <= Closed({}, {:?})", peer_id, set_id); let event = NotificationsOut::CustomProtocolClosed { peer_id: *peer_id, set_id }; - self.events.push_back(NetworkBehaviourAction::GenerateEvent(event)); + self.events.push_back(ToSwarm::GenerateEvent(event)); } for (connec_id, connec_state) in connections.iter_mut().filter(|(_, s)| matches!(s, ConnectionState::Open(_))) { trace!(target: "sub-libp2p", "Handler({:?}, {:?}) <= Close({:?})", peer_id, *connec_id, set_id); - self.events.push_back(NetworkBehaviourAction::NotifyHandler { + self.events.push_back(ToSwarm::NotifyHandler { peer_id: *peer_id, handler: NotifyHandler::One(*connec_id), event: NotifsHandlerIn::Close { protocol_index: set_id.into() }, @@ -473,7 +473,7 @@ impl Notifications { connections.iter_mut().filter(|(_, s)| matches!(s, ConnectionState::Opening)) { trace!(target: "sub-libp2p", "Handler({:?}, {:?}) <= Close({:?})", peer_id, *connec_id, set_id); - self.events.push_back(NetworkBehaviourAction::NotifyHandler { + self.events.push_back(ToSwarm::NotifyHandler { peer_id: *peer_id, handler: NotifyHandler::One(*connec_id), event: NotifsHandlerIn::Close { protocol_index: set_id.into() }, @@ -515,7 +515,7 @@ impl Notifications { .filter(|(_, s)| matches!(s, ConnectionState::OpenDesiredByRemote)) { trace!(target: "sub-libp2p", "Handler({:?}, {:?}) <= Close({:?})", peer_id, *connec_id, set_id); - self.events.push_back(NetworkBehaviourAction::NotifyHandler { + self.events.push_back(ToSwarm::NotifyHandler { peer_id: *peer_id, handler: NotifyHandler::One(*connec_id), event: NotifsHandlerIn::Close { protocol_index: set_id.into() }, @@ -548,7 +548,6 @@ impl Notifications { /// Function that is called when the peerset wants us to connect to a peer. fn peerset_report_connect(&mut self, peer_id: PeerId, set_id: sc_peerset::SetId) { // If `PeerId` is unknown to us, insert an entry, start dialing, and return early. - let handler = self.new_handler(); let mut occ_entry = match self.peers.entry((peer_id, set_id)) { Entry::Occupied(entry) => entry, Entry::Vacant(entry) => { @@ -560,10 +559,7 @@ impl Notifications { set_id, ); trace!(target: "sub-libp2p", "Libp2p <= Dial {}", entry.key().0); - self.events.push_back(NetworkBehaviourAction::Dial { - opts: entry.key().0.into(), - handler, - }); + self.events.push_back(ToSwarm::Dial { opts: entry.key().0.into() }); entry.insert(PeerState::Requested); return }, @@ -595,10 +591,7 @@ impl Notifications { set_id, ); trace!(target: "sub-libp2p", "Libp2p <= Dial {:?}", occ_entry.key()); - self.events.push_back(NetworkBehaviourAction::Dial { - opts: occ_entry.key().0.into(), - handler, - }); + self.events.push_back(ToSwarm::Dial { opts: occ_entry.key().0.into() }); *occ_entry.into_mut() = PeerState::Requested; }, @@ -646,7 +639,7 @@ impl Notifications { trace!(target: "sub-libp2p", "PSM => Connect({}, {:?}): Enabling connections.", occ_entry.key().0, set_id); trace!(target: "sub-libp2p", "Handler({:?}, {:?}) <= Open({:?})", peer_id, *connec_id, set_id); - self.events.push_back(NetworkBehaviourAction::NotifyHandler { + self.events.push_back(ToSwarm::NotifyHandler { peer_id, handler: NotifyHandler::One(*connec_id), event: NotifsHandlerIn::Open { protocol_index: set_id.into() }, @@ -720,7 +713,7 @@ impl Notifications { { trace!(target: "sub-libp2p", "Handler({:?}, {:?}) <= Open({:?})", occ_entry.key(), *connec_id, set_id); - self.events.push_back(NetworkBehaviourAction::NotifyHandler { + self.events.push_back(ToSwarm::NotifyHandler { peer_id: occ_entry.key().0, handler: NotifyHandler::One(*connec_id), event: NotifsHandlerIn::Open { protocol_index: set_id.into() }, @@ -803,7 +796,7 @@ impl Notifications { trace!(target: "sub-libp2p", "External API <= Closed({}, {:?})", entry.key().0, set_id); let event = NotificationsOut::CustomProtocolClosed { peer_id: entry.key().0, set_id }; - self.events.push_back(NetworkBehaviourAction::GenerateEvent(event)); + self.events.push_back(ToSwarm::GenerateEvent(event)); } for (connec_id, connec_state) in @@ -811,7 +804,7 @@ impl Notifications { { trace!(target: "sub-libp2p", "Handler({:?}, {:?}) <= Close({:?})", entry.key(), *connec_id, set_id); - self.events.push_back(NetworkBehaviourAction::NotifyHandler { + self.events.push_back(ToSwarm::NotifyHandler { peer_id: entry.key().0, handler: NotifyHandler::One(*connec_id), event: NotifsHandlerIn::Close { protocol_index: set_id.into() }, @@ -824,7 +817,7 @@ impl Notifications { { trace!(target: "sub-libp2p", "Handler({:?}, {:?}) <= Close({:?})", entry.key(), *connec_id, set_id); - self.events.push_back(NetworkBehaviourAction::NotifyHandler { + self.events.push_back(ToSwarm::NotifyHandler { peer_id: entry.key().0, handler: NotifyHandler::One(*connec_id), event: NotifsHandlerIn::Close { protocol_index: set_id.into() }, @@ -915,7 +908,7 @@ impl Notifications { { trace!(target: "sub-libp2p", "Handler({:?}, {:?}) <= Open({:?})", incoming.peer_id, *connec_id, incoming.set_id); - self.events.push_back(NetworkBehaviourAction::NotifyHandler { + self.events.push_back(ToSwarm::NotifyHandler { peer_id: incoming.peer_id, handler: NotifyHandler::One(*connec_id), event: NotifsHandlerIn::Open { protocol_index: incoming.set_id.into() }, @@ -975,7 +968,7 @@ impl Notifications { { trace!(target: "sub-libp2p", "Handler({:?}, {:?}) <= Close({:?})", incoming.peer_id, connec_id, incoming.set_id); - self.events.push_back(NetworkBehaviourAction::NotifyHandler { + self.events.push_back(ToSwarm::NotifyHandler { peer_id: incoming.peer_id, handler: NotifyHandler::One(*connec_id), event: NotifsHandlerIn::Close { protocol_index: incoming.set_id.into() }, @@ -993,15 +986,57 @@ impl Notifications { } impl NetworkBehaviour for Notifications { - type ConnectionHandler = NotifsHandlerProto; - type OutEvent = NotificationsOut; + type ConnectionHandler = NotifsHandler; + type ToSwarm = NotificationsOut; - fn new_handler(&mut self) -> Self::ConnectionHandler { - NotifsHandlerProto::new(self.notif_protocols.clone()) + fn handle_pending_inbound_connection( + &mut self, + _connection_id: ConnectionId, + _local_addr: &Multiaddr, + _remote_addr: &Multiaddr, + ) -> Result<(), ConnectionDenied> { + Ok(()) + } + + fn handle_pending_outbound_connection( + &mut self, + _connection_id: ConnectionId, + _maybe_peer: Option, + _addresses: &[Multiaddr], + _effective_role: Endpoint, + ) -> Result, ConnectionDenied> { + Ok(Vec::new()) + } + + fn handle_established_inbound_connection( + &mut self, + _connection_id: ConnectionId, + peer: PeerId, + local_addr: &Multiaddr, + remote_addr: &Multiaddr, + ) -> Result, ConnectionDenied> { + Ok(NotifsHandler::new( + peer, + ConnectedPoint::Listener { + local_addr: local_addr.clone(), + send_back_addr: remote_addr.clone(), + }, + self.notif_protocols.clone(), + )) } - fn addresses_of_peer(&mut self, _: &PeerId) -> Vec { - Vec::new() + fn handle_established_outbound_connection( + &mut self, + _connection_id: ConnectionId, + peer: PeerId, + addr: &Multiaddr, + role_override: Endpoint, + ) -> Result, ConnectionDenied> { + Ok(NotifsHandler::new( + peer, + ConnectedPoint::Dialer { address: addr.clone(), role_override }, + self.notif_protocols.clone(), + )) } fn on_swarm_event(&mut self, event: FromSwarm) { @@ -1022,7 +1057,7 @@ impl NetworkBehaviour for Notifications { peer_id, set_id, endpoint ); trace!(target: "sub-libp2p", "Handler({:?}, {:?}) <= Open({:?})", peer_id, connection_id, set_id); - self.events.push_back(NetworkBehaviourAction::NotifyHandler { + self.events.push_back(ToSwarm::NotifyHandler { peer_id, handler: NotifyHandler::One(connection_id), event: NotifsHandlerIn::Open { protocol_index: set_id.into() }, @@ -1276,9 +1311,7 @@ impl NetworkBehaviour for Notifications { set_id, notifications_sink: replacement_sink, }; - self.events.push_back( - NetworkBehaviourAction::GenerateEvent(event), - ); + self.events.push_back(ToSwarm::GenerateEvent(event)); } } else { trace!( @@ -1289,9 +1322,7 @@ impl NetworkBehaviour for Notifications { peer_id, set_id, }; - self.events.push_back( - NetworkBehaviourAction::GenerateEvent(event), - ); + self.events.push_back(ToSwarm::GenerateEvent(event)); } } } else { @@ -1421,10 +1452,11 @@ impl NetworkBehaviour for Notifications { FromSwarm::ListenerClosed(_) => {}, FromSwarm::ListenFailure(_) => {}, FromSwarm::ListenerError(_) => {}, - FromSwarm::ExpiredExternalAddr(_) => {}, + FromSwarm::ExternalAddrExpired(_) => {}, FromSwarm::NewListener(_) => {}, FromSwarm::ExpiredListenAddr(_) => {}, - FromSwarm::NewExternalAddr(_) => {}, + FromSwarm::NewExternalAddrCandidate(_) => {}, + FromSwarm::ExternalAddrConfirmed(_) => {}, FromSwarm::AddressChange(_) => {}, FromSwarm::NewListenAddr(_) => {}, } @@ -1434,8 +1466,7 @@ impl NetworkBehaviour for Notifications { &mut self, peer_id: PeerId, connection_id: ConnectionId, - event: <::Handler as - ConnectionHandler>::OutEvent, + event: THandlerOutEvent, ) { match event { NotifsHandlerOut::OpenDesiredByRemote { protocol_index } => { @@ -1502,7 +1533,7 @@ impl NetworkBehaviour for Notifications { if let ConnectionState::Closed = *connec_state { trace!(target: "sub-libp2p", "Handler({:?}, {:?}) <= Open({:?})", peer_id, connection_id, set_id); - self.events.push_back(NetworkBehaviourAction::NotifyHandler { + self.events.push_back(ToSwarm::NotifyHandler { peer_id, handler: NotifyHandler::One(connection_id), event: NotifsHandlerIn::Open { protocol_index: set_id.into() }, @@ -1583,7 +1614,7 @@ impl NetworkBehaviour for Notifications { if let ConnectionState::Closed = *connec_state { trace!(target: "sub-libp2p", "Handler({:?}, {:?}) <= Open({:?})", peer_id, connection_id, set_id); - self.events.push_back(NetworkBehaviourAction::NotifyHandler { + self.events.push_back(ToSwarm::NotifyHandler { peer_id, handler: NotifyHandler::One(connection_id), event: NotifsHandlerIn::Open { protocol_index: set_id.into() }, @@ -1668,7 +1699,7 @@ impl NetworkBehaviour for Notifications { connections[pos].1 = ConnectionState::Closing; trace!(target: "sub-libp2p", "Handler({}, {:?}) <= Close({:?})", peer_id, connection_id, set_id); - self.events.push_back(NetworkBehaviourAction::NotifyHandler { + self.events.push_back(ToSwarm::NotifyHandler { peer_id, handler: NotifyHandler::One(connection_id), event: NotifsHandlerIn::Close { protocol_index: set_id.into() }, @@ -1686,7 +1717,7 @@ impl NetworkBehaviour for Notifications { set_id, notifications_sink: replacement_sink, }; - self.events.push_back(NetworkBehaviourAction::GenerateEvent(event)); + self.events.push_back(ToSwarm::GenerateEvent(event)); } *entry.into_mut() = PeerState::Enabled { connections }; @@ -1706,7 +1737,7 @@ impl NetworkBehaviour for Notifications { trace!(target: "sub-libp2p", "External API <= Closed({}, {:?})", peer_id, set_id); let event = NotificationsOut::CustomProtocolClosed { peer_id, set_id }; - self.events.push_back(NetworkBehaviourAction::GenerateEvent(event)); + self.events.push_back(ToSwarm::GenerateEvent(event)); } }, @@ -1790,7 +1821,7 @@ impl NetworkBehaviour for Notifications { received_handshake, notifications_sink: notifications_sink.clone(), }; - self.events.push_back(NetworkBehaviourAction::GenerateEvent(event)); + self.events.push_back(ToSwarm::GenerateEvent(event)); } *connec_state = ConnectionState::Open(notifications_sink); } else if let Some((_, connec_state)) = @@ -1937,7 +1968,7 @@ impl NetworkBehaviour for Notifications { ); let event = NotificationsOut::Notification { peer_id, set_id, message }; - self.events.push_back(NetworkBehaviourAction::GenerateEvent(event)); + self.events.push_back(ToSwarm::GenerateEvent(event)); } else { trace!( target: "sub-libp2p", @@ -1956,7 +1987,7 @@ impl NetworkBehaviour for Notifications { &mut self, cx: &mut Context, _params: &mut impl PollParameters, - ) -> Poll> { + ) -> Poll>> { if let Some(event) = self.events.pop_front() { return Poll::Ready(event) } @@ -1988,8 +2019,6 @@ impl NetworkBehaviour for Notifications { while let Poll::Ready(Some((delay_id, peer_id, set_id))) = Pin::new(&mut self.delays).poll_next(cx) { - let handler = self.new_handler(); - let peer_state = match self.peers.get_mut(&(peer_id, set_id)) { Some(s) => s, // We intentionally never remove elements from `delays`, and it may @@ -2005,8 +2034,7 @@ impl NetworkBehaviour for Notifications { PeerState::PendingRequest { timer, .. } if *timer == delay_id => { trace!(target: "sub-libp2p", "Libp2p <= Dial {:?} now that ban has expired", peer_id); - self.events - .push_back(NetworkBehaviourAction::Dial { opts: peer_id.into(), handler }); + self.events.push_back(ToSwarm::Dial { opts: peer_id.into() }); *peer_state = PeerState::Requested; }, @@ -2019,7 +2047,7 @@ impl NetworkBehaviour for Notifications { { trace!(target: "sub-libp2p", "Handler({}, {:?}) <= Open({:?}) (ban expired)", peer_id, *connec_id, set_id); - self.events.push_back(NetworkBehaviourAction::NotifyHandler { + self.events.push_back(ToSwarm::NotifyHandler { peer_id, handler: NotifyHandler::One(*connec_id), event: NotifsHandlerIn::Open { protocol_index: set_id.into() }, @@ -2055,13 +2083,10 @@ impl NetworkBehaviour for Notifications { } #[cfg(test)] +#[allow(deprecated)] mod tests { use super::*; use crate::protocol::notifications::handler::tests::*; - use libp2p::{ - core::ConnectedPoint, - swarm::{behaviour::FromSwarm, AddressRecord}, - }; use std::{collections::HashSet, iter}; impl PartialEq for ConnectionState { @@ -2080,31 +2105,14 @@ mod tests { } #[derive(Clone)] - struct MockPollParams { - peer_id: PeerId, - addr: Multiaddr, - } + struct MockPollParams {} impl PollParameters for MockPollParams { type SupportedProtocolsIter = std::vec::IntoIter>; - type ListenedAddressesIter = std::vec::IntoIter; - type ExternalAddressesIter = std::vec::IntoIter; fn supported_protocols(&self) -> Self::SupportedProtocolsIter { vec![].into_iter() } - - fn listened_addresses(&self) -> Self::ListenedAddressesIter { - vec![self.addr.clone()].into_iter() - } - - fn external_addresses(&self) -> Self::ExternalAddressesIter { - vec![].into_iter() - } - - fn local_peer_id(&self) -> &PeerId { - &self.peer_id - } } fn development_notifs() -> (Notifications, sc_peerset::PeersetHandle) { @@ -2223,7 +2231,7 @@ mod tests { fn remote_opens_connection_and_substream() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -2273,7 +2281,7 @@ mod tests { async fn disconnect_remote_substream_before_handled_by_peerset() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -2310,7 +2318,7 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let set_id = sc_peerset::SetId::from(0); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -2344,8 +2352,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -2374,7 +2382,7 @@ mod tests { fn peerset_connect_incoming() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -2409,7 +2417,7 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let set_id = sc_peerset::SetId::from(0); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -2455,7 +2463,7 @@ mod tests { fn peerset_disconnect_enabled() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -2505,7 +2513,7 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let set_id = sc_peerset::SetId::from(0); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -2534,8 +2542,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -2557,7 +2565,7 @@ mod tests { fn peerset_accept_peer_not_alive() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -2604,8 +2612,8 @@ mod tests { fn secondary_connection_peer_state_incoming() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); - let conn2 = ConnectionId::new(1usize); + let conn = ConnectionId::new_unchecked(0); + let conn2 = ConnectionId::new_unchecked(1); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -2661,7 +2669,7 @@ mod tests { fn close_connection_for_disabled_peer() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -2683,8 +2691,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -2695,7 +2703,7 @@ mod tests { fn close_connection_for_incoming_peer_one_connection() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -2724,8 +2732,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -2740,8 +2748,8 @@ mod tests { fn close_connection_for_incoming_peer_two_connections() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); - let conn1 = ConnectionId::new(1usize); + let conn = ConnectionId::new_unchecked(0); + let conn1 = ConnectionId::new_unchecked(1); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -2791,8 +2799,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -2810,7 +2818,7 @@ mod tests { fn connection_and_substream_open() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -2854,7 +2862,7 @@ mod tests { assert!(std::matches!( notif.events[notif.events.len() - 1], - NetworkBehaviourAction::GenerateEvent(NotificationsOut::CustomProtocolOpen { .. }) + ToSwarm::GenerateEvent(NotificationsOut::CustomProtocolOpen { .. }) )); } @@ -2862,8 +2870,8 @@ mod tests { fn connection_closed_sink_replaced() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn1 = ConnectionId::new(0usize); - let conn2 = ConnectionId::new(1usize); + let conn1 = ConnectionId::new_unchecked(0); + let conn2 = ConnectionId::new_unchecked(1); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -2936,8 +2944,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn1, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -2952,7 +2960,7 @@ mod tests { assert!(std::matches!( notif.events[notif.events.len() - 1], - NetworkBehaviourAction::GenerateEvent(NotificationsOut::CustomProtocolReplaced { .. }) + ToSwarm::GenerateEvent(NotificationsOut::CustomProtocolReplaced { .. }) )); } @@ -2968,8 +2976,8 @@ mod tests { notif.on_swarm_event(FromSwarm::DialFailure(libp2p::swarm::behaviour::DialFailure { peer_id: Some(peer), - handler: NotifsHandlerProto::new(vec![]), - error: &libp2p::swarm::DialError::Banned, + error: &libp2p::swarm::DialError::Aborted, + connection_id: ConnectionId::new_unchecked(1337), })); if let Some(PeerState::Backoff { timer_deadline, .. }) = notif.peers.get(&(peer, set_id)) { @@ -2983,7 +2991,7 @@ mod tests { async fn write_notification() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -3033,7 +3041,7 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let set_id = sc_peerset::SetId::from(0); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -3062,8 +3070,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -3081,7 +3089,7 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); let set_id = sc_peerset::SetId::from(0); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -3107,7 +3115,7 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let set_id = sc_peerset::SetId::from(0); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -3136,8 +3144,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -3153,8 +3161,8 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let set_id = sc_peerset::SetId::from(0); let peer = PeerId::random(); - let conn1 = ConnectionId::new(0usize); - let conn2 = ConnectionId::new(0usize); + let conn1 = ConnectionId::new_unchecked(0); + let conn2 = ConnectionId::new_unchecked(1); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -3199,8 +3207,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn1, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected.clone(), vec![]), remaining_established: 0usize, }, )); @@ -3213,8 +3221,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn2, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -3226,7 +3234,7 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); let set_id = sc_peerset::SetId::from(0); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -3264,8 +3272,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -3276,8 +3284,8 @@ mod tests { fn two_connections_inactive_connection_gets_closed_peer_state_is_still_incoming() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn1 = ConnectionId::new(0usize); - let conn2 = ConnectionId::new(1usize); + let conn1 = ConnectionId::new_unchecked(0); + let conn2 = ConnectionId::new_unchecked(1); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -3320,8 +3328,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn2, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -3332,8 +3340,8 @@ mod tests { fn two_connections_active_connection_gets_closed_peer_state_is_disabled() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn1 = ConnectionId::new(0usize); - let conn2 = ConnectionId::new(1usize); + let conn1 = ConnectionId::new_unchecked(0); + let conn2 = ConnectionId::new_unchecked(1); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -3379,8 +3387,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn1, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -3391,8 +3399,8 @@ mod tests { fn inject_connection_closed_for_active_connection() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn1 = ConnectionId::new(0usize); - let conn2 = ConnectionId::new(1usize); + let conn1 = ConnectionId::new_unchecked(0); + let conn2 = ConnectionId::new_unchecked(1); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -3450,8 +3458,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn1, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -3462,7 +3470,7 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let set_id = sc_peerset::SetId::from(0); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -3491,8 +3499,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -3509,8 +3517,8 @@ mod tests { let now = Instant::now(); notif.on_swarm_event(FromSwarm::DialFailure(libp2p::swarm::behaviour::DialFailure { peer_id: Some(peer), - handler: NotifsHandlerProto::new(vec![]), - error: &libp2p::swarm::DialError::Banned, + error: &libp2p::swarm::DialError::Aborted, + connection_id: ConnectionId::new_unchecked(0), })); if let Some(PeerState::PendingRequest { ref timer_deadline, .. }) = @@ -3525,8 +3533,8 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); let set_id = sc_peerset::SetId::from(0); - let conn1 = ConnectionId::new(0usize); - let conn2 = ConnectionId::new(1usize); + let conn1 = ConnectionId::new_unchecked(0); + let conn2 = ConnectionId::new_unchecked(1); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -3579,7 +3587,7 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); let set_id = sc_peerset::SetId::from(0); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -3608,8 +3616,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -3629,7 +3637,7 @@ mod tests { assert!(notif.peers.get(&(peer, set_id)).is_some()); if tokio::time::timeout(Duration::from_secs(5), async { - let mut params = MockPollParams { peer_id: PeerId::random(), addr: Multiaddr::empty() }; + let mut params = MockPollParams {}; loop { futures::future::poll_fn(|cx| { @@ -3656,7 +3664,7 @@ mod tests { async fn reschedule_disabled_pending_enable_when_connection_not_closed() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -3736,7 +3744,7 @@ mod tests { // verify that the code continues to keep the peer disabled by resetting the timer // after the first one expired. if tokio::time::timeout(Duration::from_secs(5), async { - let mut params = MockPollParams { peer_id: PeerId::random(), addr: Multiaddr::empty() }; + let mut params = MockPollParams {}; loop { futures::future::poll_fn(|cx| { @@ -3772,7 +3780,7 @@ mod tests { fn peerset_report_connect_with_enabled_peer() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -3824,7 +3832,7 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let set_id = sc_peerset::SetId::from(0); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -3881,7 +3889,7 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let set_id = sc_peerset::SetId::from(0); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -3910,8 +3918,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -3934,7 +3942,7 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); let set_id = sc_peerset::SetId::from(0); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -3969,7 +3977,7 @@ mod tests { fn peerset_report_accept_incoming_peer() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -4010,7 +4018,7 @@ mod tests { fn peerset_report_accept_not_incoming_peer() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -4067,9 +4075,9 @@ mod tests { notif.on_swarm_event(FromSwarm::ConnectionClosed( libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, - connection_id: ConnectionId::new(0usize), - endpoint: &endpoint, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &endpoint), + connection_id: ConnectionId::new_unchecked(0), + endpoint: &endpoint.clone(), + handler: NotifsHandler::new(peer, endpoint, vec![]), remaining_established: 0usize, }, )); @@ -4111,7 +4119,7 @@ mod tests { fn reject_non_active_connection() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -4149,7 +4157,7 @@ mod tests { fn reject_non_existent_peer_but_alive_connection() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -4189,7 +4197,7 @@ mod tests { fn inject_non_existent_connection_closed_for_incoming_peer() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -4218,9 +4226,9 @@ mod tests { notif.on_swarm_event(FromSwarm::ConnectionClosed( libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, - connection_id: ConnectionId::new(1337usize), - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + connection_id: ConnectionId::new_unchecked(1337), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -4233,7 +4241,7 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let set_id = sc_peerset::SetId::from(0); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -4253,9 +4261,9 @@ mod tests { notif.on_swarm_event(FromSwarm::ConnectionClosed( libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, - connection_id: ConnectionId::new(1337usize), - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + connection_id: ConnectionId::new_unchecked(1337), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -4268,7 +4276,7 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let set_id = sc_peerset::SetId::from(0); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -4304,9 +4312,9 @@ mod tests { notif.on_swarm_event(FromSwarm::ConnectionClosed( libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, - connection_id: ConnectionId::new(1337usize), - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + connection_id: ConnectionId::new_unchecked(1337), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -4318,7 +4326,7 @@ mod tests { fn inject_connection_closed_for_incoming_peer_state_mismatch() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -4349,8 +4357,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -4362,7 +4370,7 @@ mod tests { fn inject_connection_closed_for_enabled_state_mismatch() { let (mut notif, _peerset) = development_notifs(); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let set_id = sc_peerset::SetId::from(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), @@ -4395,9 +4403,9 @@ mod tests { notif.on_swarm_event(FromSwarm::ConnectionClosed( libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, - connection_id: ConnectionId::new(1337usize), - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + connection_id: ConnectionId::new_unchecked(1337), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -4410,7 +4418,7 @@ mod tests { let (mut notif, _peerset) = development_notifs(); let set_id = sc_peerset::SetId::from(0); let peer = PeerId::random(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), @@ -4439,8 +4447,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected.clone(), vec![]), remaining_established: 0usize, }, )); @@ -4450,8 +4458,8 @@ mod tests { libp2p::swarm::behaviour::ConnectionClosed { peer_id: peer, connection_id: conn, - endpoint: &connected, - handler: NotifsHandlerProto::new(vec![]).into_handler(&peer, &connected), + endpoint: &connected.clone(), + handler: NotifsHandler::new(peer, connected, vec![]), remaining_established: 0usize, }, )); @@ -4462,7 +4470,7 @@ mod tests { #[cfg(debug_assertions)] fn open_result_ok_non_existent_peer() { let (mut notif, _peerset) = development_notifs(); - let conn = ConnectionId::new(0usize); + let conn = ConnectionId::new_unchecked(0); let connected = ConnectedPoint::Listener { local_addr: Multiaddr::empty(), send_back_addr: Multiaddr::empty(), diff --git a/client/network/src/protocol/notifications/handler.rs b/client/network/src/protocol/notifications/handler.rs index 9d8d98fd8cf27..398996fbea8dd 100644 --- a/client/network/src/protocol/notifications/handler.rs +++ b/client/network/src/protocol/notifications/handler.rs @@ -72,11 +72,12 @@ use futures::{ prelude::*, }; use libp2p::{ - core::{ConnectedPoint, PeerId}, + core::ConnectedPoint, swarm::{ - handler::ConnectionEvent, ConnectionHandler, ConnectionHandlerEvent, IntoConnectionHandler, - KeepAlive, NegotiatedSubstream, SubstreamProtocol, + handler::ConnectionEvent, ConnectionHandler, ConnectionHandlerEvent, KeepAlive, Stream, + SubstreamProtocol, }, + PeerId, }; use log::error; use parking_lot::{Mutex, RwLock}; @@ -105,19 +106,6 @@ const OPEN_TIMEOUT: Duration = Duration::from_secs(10); /// open substreams. const INITIAL_KEEPALIVE_TIME: Duration = Duration::from_secs(5); -/// Implements the `IntoConnectionHandler` trait of libp2p. -/// -/// Every time a connection with a remote starts, an instance of this struct is created and -/// sent to a background task dedicated to this connection. Once the connection is established, -/// it is turned into a [`NotifsHandler`]. -/// -/// See the documentation at the module level for more information. -pub struct NotifsHandlerProto { - /// Name of protocols, prototypes for upgrades for inbound substreams, and the message we - /// send or respond with in the handshake. - protocols: Vec, -} - /// The actual handler once the connection has been established. /// /// See the documentation at the module level for more information. @@ -140,6 +128,30 @@ pub struct NotifsHandler { >, } +impl NotifsHandler { + /// Creates new [`NotifsHandler`]. + pub fn new(peer_id: PeerId, endpoint: ConnectedPoint, protocols: Vec) -> Self { + Self { + protocols: protocols + .into_iter() + .map(|config| { + let in_upgrade = NotificationsIn::new( + config.name.clone(), + config.fallback_names.clone(), + config.max_notification_size, + ); + + Protocol { config, in_upgrade, state: State::Closed { pending_opening: false } } + }) + .collect(), + peer_id, + endpoint, + when_connection_open: Instant::now(), + events_queue: VecDeque::with_capacity(16), + } + } +} + /// Configuration for a notifications protocol. #[derive(Debug, Clone)] pub struct ProtocolConfig { @@ -177,7 +189,7 @@ enum State { /// emitted. OpenDesiredByRemote { /// Substream opened by the remote and that hasn't been accepted/rejected yet. - in_substream: NotificationsInSubstream, + in_substream: NotificationsInSubstream, /// See [`State::Closed::pending_opening`]. pending_opening: bool, @@ -190,7 +202,7 @@ enum State { /// be emitted when transitionning to respectively [`State::Open`] or [`State::Closed`]. Opening { /// Substream opened by the remote. If `Some`, has been accepted. - in_substream: Option>, + in_substream: Option>, }, /// Protocol is in the "Open" state. @@ -212,56 +224,17 @@ enum State { /// Always `Some` on transition to [`State::Open`]. Switched to `None` only if the remote /// closed the substream. If `None`, a [`NotifsHandlerOut::CloseDesired`] event has been /// emitted. - out_substream: Option>, + out_substream: Option>, /// Substream opened by the remote. /// /// Contrary to the `out_substream` field, operations continue as normal even if the /// substream has been closed by the remote. A `None` is treated the same way as if there /// was an idle substream. - in_substream: Option>, + in_substream: Option>, }, } -impl IntoConnectionHandler for NotifsHandlerProto { - type Handler = NotifsHandler; - - fn inbound_protocol(&self) -> UpgradeCollec { - self.protocols - .iter() - .map(|cfg| { - NotificationsIn::new( - cfg.name.clone(), - cfg.fallback_names.clone(), - cfg.max_notification_size, - ) - }) - .collect::>() - } - - fn into_handler(self, peer_id: &PeerId, connected_point: &ConnectedPoint) -> Self::Handler { - NotifsHandler { - protocols: self - .protocols - .into_iter() - .map(|config| { - let in_upgrade = NotificationsIn::new( - config.name.clone(), - config.fallback_names.clone(), - config.max_notification_size, - ); - - Protocol { config, in_upgrade, state: State::Closed { pending_opening: false } } - }) - .collect(), - peer_id: *peer_id, - endpoint: connected_point.clone(), - when_connection_open: Instant::now(), - events_queue: VecDeque::with_capacity(16), - } - } -} - /// Event that can be received by a `NotifsHandler`. #[derive(Debug, Clone)] pub enum NotifsHandlerIn { @@ -461,21 +434,9 @@ pub enum NotifsHandlerError { SyncNotificationsClogged, } -impl NotifsHandlerProto { - /// Builds a new handler. - /// - /// `list` is a list of notification protocols names, the message to send as part of the - /// handshake, and the maximum allowed size of a notification. At the moment, the message - /// is always the same whether we open a substream ourselves or respond to handshake from - /// the remote. - pub fn new(list: impl Into>) -> Self { - Self { protocols: list.into() } - } -} - impl ConnectionHandler for NotifsHandler { - type InEvent = NotifsHandlerIn; - type OutEvent = NotifsHandlerOut; + type FromBehaviour = NotifsHandlerIn; + type ToBehaviour = NotifsHandlerOut; type Error = NotifsHandlerError; type InboundProtocol = UpgradeCollec; type OutboundProtocol = NotificationsOut; @@ -510,7 +471,7 @@ impl ConnectionHandler for NotifsHandler { match protocol_info.state { State::Closed { pending_opening } => { - self.events_queue.push_back(ConnectionHandlerEvent::Custom( + self.events_queue.push_back(ConnectionHandlerEvent::NotifyBehaviour( NotifsHandlerOut::OpenDesiredByRemote { protocol_index }, )); @@ -575,7 +536,7 @@ impl ConnectionHandler for NotifsHandler { in_substream: in_substream.take(), }; - self.events_queue.push_back(ConnectionHandlerEvent::Custom( + self.events_queue.push_back(ConnectionHandlerEvent::NotifyBehaviour( NotifsHandlerOut::OpenResultOk { protocol_index, negotiated_fallback: new_open.negotiated_fallback, @@ -588,6 +549,8 @@ impl ConnectionHandler for NotifsHandler { } }, ConnectionEvent::AddressChange(_address_change) => {}, + ConnectionEvent::LocalProtocolsChange(_protocols_change) => {}, + ConnectionEvent::RemoteProtocolsChange(_protocols_change) => {}, ConnectionEvent::DialUpgradeError(dial_upgrade_error) => match self.protocols [dial_upgrade_error.info] .state @@ -602,7 +565,7 @@ impl ConnectionHandler for NotifsHandler { self.protocols[dial_upgrade_error.info].state = State::Closed { pending_opening: false }; - self.events_queue.push_back(ConnectionHandlerEvent::Custom( + self.events_queue.push_back(ConnectionHandlerEvent::NotifyBehaviour( NotifsHandlerOut::OpenResultErr { protocol_index: dial_upgrade_error.info }, )); }, @@ -688,7 +651,7 @@ impl ConnectionHandler for NotifsHandler { self.protocols[protocol_index].state = State::Closed { pending_opening: true }; - self.events_queue.push_back(ConnectionHandlerEvent::Custom( + self.events_queue.push_back(ConnectionHandlerEvent::NotifyBehaviour( NotifsHandlerOut::OpenResultErr { protocol_index }, )); }, @@ -698,7 +661,7 @@ impl ConnectionHandler for NotifsHandler { State::Closed { .. } => {}, } - self.events_queue.push_back(ConnectionHandlerEvent::Custom( + self.events_queue.push_back(ConnectionHandlerEvent::NotifyBehaviour( NotifsHandlerOut::CloseResult { protocol_index }, )); }, @@ -723,7 +686,7 @@ impl ConnectionHandler for NotifsHandler { ConnectionHandlerEvent< Self::OutboundProtocol, Self::OutboundOpenInfo, - Self::OutEvent, + Self::ToBehaviour, Self::Error, >, > { @@ -792,7 +755,7 @@ impl ConnectionHandler for NotifsHandler { Poll::Ready(Err(_)) => { *out_substream = None; let event = NotifsHandlerOut::CloseDesired { protocol_index }; - return Poll::Ready(ConnectionHandlerEvent::Custom(event)) + return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour(event)) }, }; }, @@ -814,11 +777,14 @@ impl ConnectionHandler for NotifsHandler { State::Opening { in_substream: None } => {}, State::Open { in_substream: in_substream @ Some(_), .. } => - match Stream::poll_next(Pin::new(in_substream.as_mut().unwrap()), cx) { + match futures::prelude::Stream::poll_next( + Pin::new(in_substream.as_mut().unwrap()), + cx, + ) { Poll::Pending => {}, Poll::Ready(Some(Ok(message))) => { let event = NotifsHandlerOut::Notification { protocol_index, message }; - return Poll::Ready(ConnectionHandlerEvent::Custom(event)) + return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour(event)) }, Poll::Ready(None) | Poll::Ready(Some(Err(_))) => *in_substream = None, }, @@ -830,7 +796,7 @@ impl ConnectionHandler for NotifsHandler { Poll::Ready(Err(_)) => { self.protocols[protocol_index].state = State::Closed { pending_opening: *pending_opening }; - return Poll::Ready(ConnectionHandlerEvent::Custom( + return Poll::Ready(ConnectionHandlerEvent::NotifyBehaviour( NotifsHandlerOut::CloseDesired { protocol_index }, )) }, @@ -858,22 +824,18 @@ impl ConnectionHandler for NotifsHandler { #[cfg(test)] pub mod tests { use super::*; - use crate::protocol::notifications::upgrade::{ - NotificationsInOpen, NotificationsInSubstreamHandshake, NotificationsOutOpen, - }; - use asynchronous_codec::Framed; - use libp2p::{ - core::muxing::SubstreamBox, - swarm::{handler, ConnectionHandlerUpgrErr}, - Multiaddr, - }; - use multistream_select::{dialer_select_proto, listener_select_proto, Negotiated, Version}; + // use crate::protocol::notifications::upgrade::{ + // NotificationsInOpen, NotificationsInSubstreamHandshake, NotificationsOutOpen, + // }; + // use asynchronous_codec::Framed; + // use libp2p::Multiaddr; + // use multistream_select::{dialer_select_proto, listener_select_proto, Negotiated, Version}; use std::{ collections::HashMap, io::{Error, IoSlice, IoSliceMut}, }; use tokio::sync::mpsc; - use unsigned_varint::codec::UviBytes; + // use unsigned_varint::codec::UviBytes; struct OpenSubstream { notifications: stream::Peekable< @@ -954,7 +916,6 @@ pub mod tests { .await } } - struct MockSubstream { pub rx: mpsc::Receiver>, pub tx: mpsc::Sender>, @@ -973,20 +934,20 @@ pub mod tests { ) } - /// Create new negotiated substream pair. - pub async fn negotiated() -> (Negotiated, Negotiated) { - let (socket1, socket2) = Self::new(); - let socket1 = SubstreamBox::new(socket1); - let socket2 = SubstreamBox::new(socket2); + // /// Create new negotiated substream pair. + // pub async fn negotiated() -> (Negotiated, Negotiated) { + // let (socket1, socket2) = Self::new(); + // let socket1 = SubstreamBox::new(socket1); + // let socket2 = SubstreamBox::new(socket2); - let protos = vec![b"/echo/1.0.0", b"/echo/2.5.0"]; - let (res1, res2) = tokio::join!( - dialer_select_proto(socket1, protos.clone(), Version::V1), - listener_select_proto(socket2, protos), - ); + // let protos = vec![b"/echo/1.0.0", b"/echo/2.5.0"]; + // let (res1, res2) = tokio::join!( + // dialer_select_proto(socket1, protos.clone(), Version::V1), + // listener_select_proto(socket2, protos), + // ); - (res1.unwrap().1, res2.unwrap().1) - } + // (res1.unwrap().1, res2.unwrap().1) + // } } impl AsyncWrite for MockSubstream { @@ -1051,596 +1012,596 @@ pub mod tests { } } - /// Create new [`NotifsHandler`]. - fn notifs_handler() -> NotifsHandler { - let proto = Protocol { - config: ProtocolConfig { - name: "/foo".into(), - fallback_names: vec![], - handshake: Arc::new(RwLock::new(b"hello, world".to_vec())), - max_notification_size: u64::MAX, - }, - in_upgrade: NotificationsIn::new("/foo", Vec::new(), u64::MAX), - state: State::Closed { pending_opening: false }, - }; - - NotifsHandler { - protocols: vec![proto], - when_connection_open: Instant::now(), - endpoint: ConnectedPoint::Listener { - local_addr: Multiaddr::empty(), - send_back_addr: Multiaddr::empty(), - }, - peer_id: PeerId::random(), - events_queue: VecDeque::new(), - } - } - - // verify that if another substream is attempted to be opened by remote while an inbound - // substream already exists, the new inbound stream is rejected and closed by the local node. - #[tokio::test] - async fn second_open_desired_by_remote_rejected() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // attempt to open another inbound substream and verify that it is rejected - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the new substream is rejected and closed - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - - if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { - assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof,); - } - - Poll::Ready(()) - }) - .await; - } - - #[tokio::test] - async fn open_rejected_if_substream_is_opening() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // move the handler state to 'Opening' - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - // remote now tries to open another substream, verify that it is rejected and closed - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the new substream is rejected and closed but that the first substream is - // still in correct state - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - - if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { - assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof,); - } else { - panic!("unexpected result"); - } - - Poll::Ready(()) - }) - .await; - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - } - - #[tokio::test] - async fn open_rejected_if_substream_already_open() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // move the handler state to 'Opening' - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - // accept the substream and move its state to `Open` - let (io, _io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_out = NotificationsOutOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsOutSubstream::new(Framed::new(io, codec)), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( - handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, - )); - - assert!(std::matches!( - handler.protocols[0].state, - State::Open { in_substream: Some(_), .. } - )); - - // remote now tries to open another substream, verify that it is rejected and closed - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the new substream is rejected and closed but that the first substream is - // still in correct state - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - - if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { - assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof); - } else { - panic!("unexpected result"); - } - - Poll::Ready(()) - }) - .await; - assert!(std::matches!( - handler.protocols[0].state, - State::Open { in_substream: Some(_), .. } - )); - } - - #[tokio::test] - async fn fully_negotiated_resets_state_for_closed_substream() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // first instruct the handler to open a connection and then close it right after - // so the handler is in state `Closed { pending_opening: true }` - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); - assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); - - // verify that if the the outbound substream is successfully negotiated, the state is not - // changed as the substream was commanded to be closed by the handler. - let (io, _io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_out = NotificationsOutOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsOutSubstream::new(Framed::new(io, codec)), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( - handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, - )); - - assert!(std::matches!( - handler.protocols[0].state, - State::Closed { pending_opening: false } - )); - } - - #[tokio::test] - async fn fully_negotiated_resets_state_for_open_desired_substream() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // first instruct the handler to open a connection and then close it right after - // so the handler is in state `Closed { pending_opening: true }` - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); - assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); - - // attempt to open another inbound substream and verify that it is rejected - let (io, _io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - assert!(std::matches!( - handler.protocols[0].state, - State::OpenDesiredByRemote { pending_opening: true, .. } - )); - - // verify that if the the outbound substream is successfully negotiated, the state is not - // changed as the substream was commanded to be closed by the handler. - let (io, _io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_out = NotificationsOutOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsOutSubstream::new(Framed::new(io, codec)), - }; - - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( - handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, - )); - - assert!(std::matches!( - handler.protocols[0].state, - State::OpenDesiredByRemote { pending_opening: false, .. } - )); - } - - #[tokio::test] - async fn dial_upgrade_error_resets_closed_outbound_state() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // first instruct the handler to open a connection and then close it right after - // so the handler is in state `Closed { pending_opening: true }` - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); - assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); - - // inject dial failure to an already closed substream and verify outbound state is reset - handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( - handler::DialUpgradeError { info: 0, error: ConnectionHandlerUpgrErr::Timeout }, - )); - assert!(std::matches!( - handler.protocols[0].state, - State::Closed { pending_opening: false } - )); - } - - #[tokio::test] - async fn dial_upgrade_error_resets_open_desired_state() { - let mut handler = notifs_handler(); - let (io, mut io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - // verify that the substream is in (partly) opened state - assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); - futures::future::poll_fn(|cx| { - let mut buf = Vec::with_capacity(512); - assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); - Poll::Ready(()) - }) - .await; - - // first instruct the handler to open a connection and then close it right after - // so the handler is in state `Closed { pending_opening: true }` - handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); - assert!(std::matches!( - handler.protocols[0].state, - State::Opening { in_substream: Some(_) } - )); - - handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); - assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); - - let (io, _io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::NotSent, - ), - }; - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - - assert!(std::matches!( - handler.protocols[0].state, - State::OpenDesiredByRemote { pending_opening: true, .. } - )); - - // inject dial failure to an already closed substream and verify outbound state is reset - handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( - handler::DialUpgradeError { info: 0, error: ConnectionHandlerUpgrErr::Timeout }, - )); - assert!(std::matches!( - handler.protocols[0].state, - State::OpenDesiredByRemote { pending_opening: false, .. } - )); - } - - #[tokio::test] - async fn sync_notifications_clogged() { - let mut handler = notifs_handler(); - let (io, _) = MockSubstream::negotiated().await; - let codec = UviBytes::default(); - - let (async_tx, async_rx) = futures::channel::mpsc::channel(ASYNC_NOTIFICATIONS_BUFFER_SIZE); - let (sync_tx, sync_rx) = futures::channel::mpsc::channel(1); - let notifications_sink = NotificationsSink { - inner: Arc::new(NotificationsSinkInner { - peer_id: PeerId::random(), - async_channel: FuturesMutex::new(async_tx), - sync_channel: Mutex::new(Some(sync_tx)), - }), - }; - - handler.protocols[0].state = State::Open { - notifications_sink_rx: stream::select(async_rx.fuse(), sync_rx.fuse()).peekable(), - out_substream: Some(NotificationsOutSubstream::new(Framed::new(io, codec))), - in_substream: None, - }; - - notifications_sink.send_sync_notification(vec![1, 3, 3, 7]); - notifications_sink.send_sync_notification(vec![1, 3, 3, 8]); - notifications_sink.send_sync_notification(vec![1, 3, 3, 9]); - notifications_sink.send_sync_notification(vec![1, 3, 4, 0]); - - futures::future::poll_fn(|cx| { - assert!(std::matches!( - handler.poll(cx), - Poll::Ready(ConnectionHandlerEvent::Close( - NotifsHandlerError::SyncNotificationsClogged, - )) - )); - Poll::Ready(()) - }) - .await; - } - - #[tokio::test] - async fn close_desired_by_remote() { - let mut handler = notifs_handler(); - let (io, io2) = MockSubstream::negotiated().await; - let mut codec = UviBytes::default(); - codec.set_max_len(usize::MAX); - - let notif_in = NotificationsInOpen { - handshake: b"hello, world".to_vec(), - negotiated_fallback: None, - substream: NotificationsInSubstream::new( - Framed::new(io, codec), - NotificationsInSubstreamHandshake::PendingSend(vec![1, 2, 3, 4]), - ), - }; - - // add new inbound substream but close it immediately and verify that correct events are - // emitted - handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( - handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, - )); - drop(io2); - - futures::future::poll_fn(|cx| { - assert!(std::matches!( - handler.poll(cx), - Poll::Ready(ConnectionHandlerEvent::Custom( - NotifsHandlerOut::OpenDesiredByRemote { protocol_index: 0 }, - )) - )); - assert!(std::matches!( - handler.poll(cx), - Poll::Ready(ConnectionHandlerEvent::Custom(NotifsHandlerOut::CloseDesired { - protocol_index: 0 - },)) - )); - Poll::Ready(()) - }) - .await; - } + // /// Create new [`NotifsHandler`]. + // fn notifs_handler() -> NotifsHandler { + // let proto = Protocol { + // config: ProtocolConfig { + // name: "/foo".into(), + // fallback_names: vec![], + // handshake: Arc::new(RwLock::new(b"hello, world".to_vec())), + // max_notification_size: u64::MAX, + // }, + // in_upgrade: NotificationsIn::new("/foo", Vec::new(), u64::MAX), + // state: State::Closed { pending_opening: false }, + // }; + + // NotifsHandler { + // protocols: vec![proto], + // when_connection_open: Instant::now(), + // endpoint: ConnectedPoint::Listener { + // local_addr: Multiaddr::empty(), + // send_back_addr: Multiaddr::empty(), + // }, + // peer_id: PeerId::random(), + // events_queue: VecDeque::new(), + // } + // } + + // // verify that if another substream is attempted to be opened by remote while an inbound + // // substream already exists, the new inbound stream is rejected and closed by the local node. + // #[tokio::test] + // async fn second_open_desired_by_remote_rejected() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // attempt to open another inbound substream and verify that it is rejected + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the new substream is rejected and closed + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + + // if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { + // assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof,); + // } + + // Poll::Ready(()) + // }) + // .await; + // } + + // #[tokio::test] + // async fn open_rejected_if_substream_is_opening() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // move the handler state to 'Opening' + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_), .. } + // )); + + // // remote now tries to open another substream, verify that it is rejected and closed + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the new substream is rejected and closed but that the first substream is + // // still in correct state + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + + // if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { + // assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof,); + // } else { + // panic!("unexpected result"); + // } + + // Poll::Ready(()) + // }) + // .await; + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_), .. } + // )); + // } + + // #[tokio::test] + // async fn open_rejected_if_substream_already_open() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // move the handler state to 'Opening' + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_), .. } + // )); + + // // accept the substream and move its state to `Open` + // let (io, _io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_out = NotificationsOutOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsOutSubstream::new(Framed::new(io, codec)), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( + // handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, + // )); + + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Open { in_substream: Some(_), .. } + // )); + + // // remote now tries to open another substream, verify that it is rejected and closed + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the new substream is rejected and closed but that the first substream is + // // still in correct state + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + + // if let Poll::Ready(Err(err)) = Pin::new(&mut io2).poll_read(cx, &mut buf) { + // assert_eq!(err.kind(), std::io::ErrorKind::UnexpectedEof); + // } else { + // panic!("unexpected result"); + // } + + // Poll::Ready(()) + // }) + // .await; + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Open { in_substream: Some(_), .. } + // )); + // } + + // #[tokio::test] + // async fn fully_negotiated_resets_state_for_closed_substream() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // first instruct the handler to open a connection and then close it right after + // // so the handler is in state `Closed { pending_opening: true }` + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_), .. } + // )); + + // handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); + // assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); + + // // verify that if the the outbound substream is successfully negotiated, the state is not + // // changed as the substream was commanded to be closed by the handler. + // let (io, _io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_out = NotificationsOutOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsOutSubstream::new(Framed::new(io, codec)), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( + // handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, + // )); + + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Closed { pending_opening: false } + // )); + // } + + // #[tokio::test] + // async fn fully_negotiated_resets_state_for_open_desired_substream() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // first instruct the handler to open a connection and then close it right after + // // so the handler is in state `Closed { pending_opening: true }` + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_), .. } + // )); + + // handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); + // assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); + + // // attempt to open another inbound substream and verify that it is rejected + // let (io, _io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // assert!(std::matches!( + // handler.protocols[0].state, + // State::OpenDesiredByRemote { pending_opening: true, .. } + // )); + + // // verify that if the the outbound substream is successfully negotiated, the state is not + // // changed as the substream was commanded to be closed by the handler. + // let (io, _io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_out = NotificationsOutOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsOutSubstream::new(Framed::new(io, codec)), + // }; + + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedOutbound( + // handler::FullyNegotiatedOutbound { protocol: notif_out, info: 0 }, + // )); + + // assert!(std::matches!( + // handler.protocols[0].state, + // State::OpenDesiredByRemote { pending_opening: false, .. } + // )); + // } + + // #[tokio::test] + // async fn dial_upgrade_error_resets_closed_outbound_state() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // first instruct the handler to open a connection and then close it right after + // // so the handler is in state `Closed { pending_opening: true }` + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_), .. } + // )); + + // handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); + // assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); + + // // inject dial failure to an already closed substream and verify outbound state is reset + // handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( + // handler::DialUpgradeError { info: 0, error: ConnectionHandlerUpgrErr::Timeout }, + // )); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Closed { pending_opening: false } + // )); + // } + + // #[tokio::test] + // async fn dial_upgrade_error_resets_open_desired_state() { + // let mut handler = notifs_handler(); + // let (io, mut io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // // verify that the substream is in (partly) opened state + // assert!(std::matches!(handler.protocols[0].state, State::OpenDesiredByRemote { .. })); + // futures::future::poll_fn(|cx| { + // let mut buf = Vec::with_capacity(512); + // assert!(std::matches!(Pin::new(&mut io2).poll_read(cx, &mut buf), Poll::Pending)); + // Poll::Ready(()) + // }) + // .await; + + // // first instruct the handler to open a connection and then close it right after + // // so the handler is in state `Closed { pending_opening: true }` + // handler.on_behaviour_event(NotifsHandlerIn::Open { protocol_index: 0 }); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::Opening { in_substream: Some(_), .. } + // )); + + // handler.on_behaviour_event(NotifsHandlerIn::Close { protocol_index: 0 }); + // assert!(std::matches!(handler.protocols[0].state, State::Closed { pending_opening: true })); + + // let (io, _io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::NotSent, + // ), + // }; + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + + // assert!(std::matches!( + // handler.protocols[0].state, + // State::OpenDesiredByRemote { pending_opening: true, .. } + // )); + + // // inject dial failure to an already closed substream and verify outbound state is reset + // handler.on_connection_event(handler::ConnectionEvent::DialUpgradeError( + // handler::DialUpgradeError { info: 0, error: ConnectionHandlerUpgrErr::Timeout }, + // )); + // assert!(std::matches!( + // handler.protocols[0].state, + // State::OpenDesiredByRemote { pending_opening: false, .. } + // )); + // } + + // #[tokio::test] + // async fn sync_notifications_clogged() { + // let mut handler = notifs_handler(); + // let (io, _) = MockSubstream::negotiated().await; + // let codec = UviBytes::default(); + + // let (async_tx, async_rx) = futures::channel::mpsc::channel(ASYNC_NOTIFICATIONS_BUFFER_SIZE); + // let (sync_tx, sync_rx) = futures::channel::mpsc::channel(1); + // let notifications_sink = NotificationsSink { + // inner: Arc::new(NotificationsSinkInner { + // peer_id: PeerId::random(), + // async_channel: FuturesMutex::new(async_tx), + // sync_channel: Mutex::new(Some(sync_tx)), + // }), + // }; + + // handler.protocols[0].state = State::Open { + // notifications_sink_rx: stream::select(async_rx.fuse(), sync_rx.fuse()).peekable(), + // out_substream: Some(NotificationsOutSubstream::new(Framed::new(io, codec))), + // in_substream: None, + // }; + + // notifications_sink.send_sync_notification(vec![1, 3, 3, 7]); + // notifications_sink.send_sync_notification(vec![1, 3, 3, 8]); + // notifications_sink.send_sync_notification(vec![1, 3, 3, 9]); + // notifications_sink.send_sync_notification(vec![1, 3, 4, 0]); + + // futures::future::poll_fn(|cx| { + // assert!(std::matches!( + // handler.poll(cx), + // Poll::Ready(ConnectionHandlerEvent::Close( + // NotifsHandlerError::SyncNotificationsClogged, + // )) + // )); + // Poll::Ready(()) + // }) + // .await; + // } + + // #[tokio::test] + // async fn close_desired_by_remote() { + // let mut handler = notifs_handler(); + // let (io, io2) = MockSubstream::negotiated().await; + // let mut codec = UviBytes::default(); + // codec.set_max_len(usize::MAX); + + // let notif_in = NotificationsInOpen { + // handshake: b"hello, world".to_vec(), + // negotiated_fallback: None, + // substream: NotificationsInSubstream::new( + // Framed::new(io, codec), + // NotificationsInSubstreamHandshake::PendingSend(vec![1, 2, 3, 4]), + // ), + // }; + + // // add new inbound substream but close it immediately and verify that correct events are + // // emitted + // handler.on_connection_event(handler::ConnectionEvent::FullyNegotiatedInbound( + // handler::FullyNegotiatedInbound { protocol: (notif_in, 0), info: () }, + // )); + // drop(io2); + + // futures::future::poll_fn(|cx| { + // assert!(std::matches!( + // handler.poll(cx), + // Poll::Ready(ConnectionHandlerEvent::Custom( + // NotifsHandlerOut::OpenDesiredByRemote { protocol_index: 0 }, + // )) + // )); + // assert!(std::matches!( + // handler.poll(cx), + // Poll::Ready(ConnectionHandlerEvent::Custom(NotifsHandlerOut::CloseDesired { + // protocol_index: 0 + // },)) + // )); + // Poll::Ready(()) + // }) + // .await; + // } } diff --git a/client/network/src/protocol/notifications/tests.rs b/client/network/src/protocol/notifications/tests.rs index 9ca6974e4cdde..92a20f8eb8726 100644 --- a/client/network/src/protocol/notifications/tests.rs +++ b/client/network/src/protocol/notifications/tests.rs @@ -22,11 +22,11 @@ use crate::protocol::notifications::{Notifications, NotificationsOut, ProtocolCo use futures::prelude::*; use libp2p::{ - core::{connection::ConnectionId, transport::MemoryTransport, upgrade}, + core::{transport::MemoryTransport, upgrade, Endpoint}, identity, noise, swarm::{ - behaviour::FromSwarm, ConnectionHandler, Executor, IntoConnectionHandler, NetworkBehaviour, - NetworkBehaviourAction, PollParameters, Swarm, SwarmEvent, + self, behaviour::FromSwarm, ConnectionDenied, ConnectionId, Executor, NetworkBehaviour, + PollParameters, Swarm, SwarmEvent, THandler, THandlerInEvent, THandlerOutEvent, ToSwarm, }, yamux, Multiaddr, PeerId, Transport, }; @@ -57,13 +57,10 @@ fn build_nodes() -> (Swarm, Swarm) { for index in 0..2 { let keypair = keypairs[index].clone(); - let noise_keys = - noise::Keypair::::new().into_authentic(&keypair).unwrap(); - let transport = MemoryTransport::new() .upgrade(upgrade::Version::V1) - .authenticate(noise::NoiseConfig::xx(noise_keys).into_authenticated()) - .multiplex(yamux::YamuxConfig::default()) + .authenticate(noise::Config::new(&keypair).unwrap()) + .multiplex(yamux::Config::default()) .timeout(Duration::from_secs(20)) .boxed(); @@ -105,12 +102,12 @@ fn build_nodes() -> (Swarm, Swarm) { }; let runtime = tokio::runtime::Runtime::new().unwrap(); - let mut swarm = Swarm::with_executor( + let mut swarm = Swarm::new( transport, behaviour, keypairs[index].public().to_peer_id(), - TokioExecutor(runtime), - ); + swarm::Config::with_executor(TokioExecutor(runtime)), + ); swarm.listen_on(addrs[index].clone()).unwrap(); out.push(swarm); } @@ -144,20 +141,65 @@ impl std::ops::DerefMut for CustomProtoWithAddr { impl NetworkBehaviour for CustomProtoWithAddr { type ConnectionHandler = ::ConnectionHandler; - type OutEvent = ::OutEvent; + type ToSwarm = ::ToSwarm; - fn new_handler(&mut self) -> Self::ConnectionHandler { - self.inner.new_handler() + fn handle_pending_inbound_connection( + &mut self, + connection_id: ConnectionId, + local_addr: &Multiaddr, + remote_addr: &Multiaddr, + ) -> Result<(), ConnectionDenied> { + self.inner + .handle_pending_inbound_connection(connection_id, local_addr, remote_addr) } - fn addresses_of_peer(&mut self, peer_id: &PeerId) -> Vec { - let mut list = self.inner.addresses_of_peer(peer_id); - for (p, a) in self.addrs.iter() { - if p == peer_id { - list.push(a.clone()); + fn handle_pending_outbound_connection( + &mut self, + connection_id: ConnectionId, + maybe_peer: Option, + addresses: &[Multiaddr], + effective_role: Endpoint, + ) -> Result, ConnectionDenied> { + let mut list = self.inner.handle_pending_outbound_connection( + connection_id, + maybe_peer, + addresses, + effective_role, + )?; + if let Some(peer_id) = maybe_peer { + for (p, a) in self.addrs.iter() { + if *p == peer_id { + list.push(a.clone()); + } } } - list + Ok(list) + } + + fn handle_established_inbound_connection( + &mut self, + connection_id: ConnectionId, + peer: PeerId, + local_addr: &Multiaddr, + remote_addr: &Multiaddr, + ) -> Result, ConnectionDenied> { + self.inner.handle_established_inbound_connection( + connection_id, + peer, + local_addr, + remote_addr, + ) + } + + fn handle_established_outbound_connection( + &mut self, + connection_id: ConnectionId, + peer: PeerId, + addr: &Multiaddr, + role_override: Endpoint, + ) -> Result, ConnectionDenied> { + self.inner + .handle_established_outbound_connection(connection_id, peer, addr, role_override) } fn on_swarm_event(&mut self, event: FromSwarm) { @@ -168,8 +210,7 @@ impl NetworkBehaviour for CustomProtoWithAddr { &mut self, peer_id: PeerId, connection_id: ConnectionId, - event: <::Handler as - ConnectionHandler>::OutEvent, + event: THandlerOutEvent, ) { self.inner.on_connection_handler_event(peer_id, connection_id, event); } @@ -178,7 +219,7 @@ impl NetworkBehaviour for CustomProtoWithAddr { &mut self, cx: &mut Context, params: &mut impl PollParameters, - ) -> Poll> { + ) -> Poll>> { self.inner.poll(cx, params) } } diff --git a/client/network/src/protocol/notifications/upgrade/collec.rs b/client/network/src/protocol/notifications/upgrade/collec.rs index 791821b3f75da..2b26410fbe8b6 100644 --- a/client/network/src/protocol/notifications/upgrade/collec.rs +++ b/client/network/src/protocol/notifications/upgrade/collec.rs @@ -17,7 +17,7 @@ // along with this program. If not, see . use futures::prelude::*; -use libp2p::core::upgrade::{InboundUpgrade, ProtocolName, UpgradeInfo}; +use libp2p::core::upgrade::{InboundUpgrade, UpgradeInfo}; use std::{ iter::FromIterator, pin::Pin, @@ -76,9 +76,9 @@ where #[derive(Debug, Clone, PartialEq)] pub struct ProtoNameWithUsize(T, usize); -impl ProtocolName for ProtoNameWithUsize { - fn protocol_name(&self) -> &[u8] { - self.0.protocol_name() +impl> AsRef for ProtoNameWithUsize { + fn as_ref(&self) -> &str { + self.0.as_ref() } } @@ -104,13 +104,13 @@ impl>, O, E> Future for FutWithUsize { mod tests { use super::*; use crate::types::ProtocolName as ProtoName; - use libp2p::core::upgrade::{ProtocolName, UpgradeInfo}; + use libp2p::core::upgrade::UpgradeInfo; // TODO: move to mocks mockall::mock! { pub ProtocolUpgrade {} - impl UpgradeInfo for ProtocolUpgrade { + impl> UpgradeInfo for ProtocolUpgrade { type Info = T; type InfoIter = vec::IntoIter; fn protocol_info(&self) -> vec::IntoIter; diff --git a/client/network/src/protocol/notifications/upgrade/notifications.rs b/client/network/src/protocol/notifications/upgrade/notifications.rs index 4e1c033f33b68..0148fd22bd883 100644 --- a/client/network/src/protocol/notifications/upgrade/notifications.rs +++ b/client/network/src/protocol/notifications/upgrade/notifications.rs @@ -114,13 +114,6 @@ pub struct NotificationsOutSubstream { socket: Framed>>>, } -#[cfg(test)] -impl NotificationsOutSubstream { - pub fn new(socket: Framed>>>) -> Self { - Self { socket } - } -} - impl NotificationsIn { /// Builds a new potential upgrade. pub fn new( @@ -203,13 +196,13 @@ impl NotificationsInSubstream where TSubstream: AsyncRead + AsyncWrite + Unpin, { - #[cfg(test)] - pub fn new( - socket: Framed>>>, - handshake: NotificationsInSubstreamHandshake, - ) -> Self { - Self { socket, handshake } - } + // #[cfg(test)] + // pub fn new( + // socket: Framed>>>, + // handshake: NotificationsInSubstreamHandshake, + // ) -> Self { + // Self { socket, handshake } + // } /// Sends the handshake in order to inform the remote that we accept the substream. pub fn send_handshake(&mut self, message: impl Into>) { @@ -498,41 +491,92 @@ pub enum NotificationsOutError { #[cfg(test)] mod tests { - use super::{NotificationsIn, NotificationsInOpen, NotificationsOut, NotificationsOutOpen}; - use futures::{channel::oneshot, prelude::*}; - use libp2p::core::upgrade; + use super::*; + use futures::channel::oneshot; + use libp2p::core::{upgrade, InboundUpgrade, OutboundUpgrade, UpgradeInfo}; use tokio::net::{TcpListener, TcpStream}; use tokio_util::compat::TokioAsyncReadCompatExt; + /// Opens a substream to the given address, negotiates the protocol, and returns the substream + /// along with the handshake message. + async fn dial( + addr: std::net::SocketAddr, + handshake: impl Into>, + ) -> Result< + ( + Vec, + NotificationsOutSubstream< + multistream_select::Negotiated>, + >, + ), + NotificationsHandshakeError, + > { + let socket = TcpStream::connect(addr).await.unwrap(); + let notifs_out = NotificationsOut::new("/test/proto/1", Vec::new(), handshake, 1024 * 1024); + let (_, substream) = multistream_select::dialer_select_proto( + socket.compat(), + notifs_out.protocol_info().into_iter(), + upgrade::Version::V1, + ) + .await + .unwrap(); + let NotificationsOutOpen { handshake, substream, .. } = + >::upgrade_outbound( + notifs_out, + substream, + "/test/proto/1".into(), + ) + .await?; + Ok((handshake, substream)) + } + + /// Listens on a localhost, negotiates the protocol, and returns the substream along with the + /// handshake message. + /// + /// Also sends the listener address through the given channel. + async fn listen_on_localhost( + listener_addr_tx: oneshot::Sender, + ) -> Result< + ( + Vec, + NotificationsInSubstream< + multistream_select::Negotiated>, + >, + ), + NotificationsHandshakeError, + > { + let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); + listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); + + let (socket, _) = listener.accept().await.unwrap(); + let notifs_in = NotificationsIn::new("/test/proto/1", Vec::new(), 1024 * 1024); + let (_, substream) = + multistream_select::listener_select_proto(socket.compat(), notifs_in.protocol_info()) + .await + .unwrap(); + let NotificationsInOpen { handshake, substream, .. } = + >::upgrade_inbound( + notifs_in, + substream, + "/test/proto/1".into(), + ) + .await?; + Ok((handshake, substream)) + } + #[tokio::test] async fn basic_works() { - const PROTO_NAME: &str = "/test/proto/1"; let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); let client = tokio::spawn(async move { - let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); - let NotificationsOutOpen { handshake, mut substream, .. } = upgrade::apply_outbound( - socket.compat(), - NotificationsOut::new(PROTO_NAME, Vec::new(), &b"initial message"[..], 1024 * 1024), - upgrade::Version::V1, - ) - .await - .unwrap(); + let (handshake, mut substream) = + dial(listener_addr_rx.await.unwrap(), &b"initial message"[..]).await.unwrap(); assert_eq!(handshake, b"hello world"); substream.send(b"test message".to_vec()).await.unwrap(); }); - let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); - listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - - let (socket, _) = listener.accept().await.unwrap(); - let NotificationsInOpen { handshake, mut substream, .. } = upgrade::apply_inbound( - socket.compat(), - NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), - ) - .await - .unwrap(); + let (handshake, mut substream) = listen_on_localhost(listener_addr_tx).await.unwrap(); assert_eq!(handshake, b"initial message"); substream.send_handshake(&b"hello world"[..]); @@ -547,33 +591,17 @@ mod tests { async fn empty_handshake() { // Check that everything still works when the handshake messages are empty. - const PROTO_NAME: &str = "/test/proto/1"; let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); let client = tokio::spawn(async move { - let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); - let NotificationsOutOpen { handshake, mut substream, .. } = upgrade::apply_outbound( - socket.compat(), - NotificationsOut::new(PROTO_NAME, Vec::new(), vec![], 1024 * 1024), - upgrade::Version::V1, - ) - .await - .unwrap(); + let (handshake, mut substream) = + dial(listener_addr_rx.await.unwrap(), vec![]).await.unwrap(); assert!(handshake.is_empty()); substream.send(Default::default()).await.unwrap(); }); - let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); - listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - - let (socket, _) = listener.accept().await.unwrap(); - let NotificationsInOpen { handshake, mut substream, .. } = upgrade::apply_inbound( - socket.compat(), - NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), - ) - .await - .unwrap(); + let (handshake, mut substream) = listen_on_localhost(listener_addr_tx).await.unwrap(); assert!(handshake.is_empty()); substream.send_handshake(vec![]); @@ -586,17 +614,10 @@ mod tests { #[tokio::test] async fn refused() { - const PROTO_NAME: &str = "/test/proto/1"; let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); let client = tokio::spawn(async move { - let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); - let outcome = upgrade::apply_outbound( - socket.compat(), - NotificationsOut::new(PROTO_NAME, Vec::new(), &b"hello"[..], 1024 * 1024), - upgrade::Version::V1, - ) - .await; + let outcome = dial(listener_addr_rx.await.unwrap(), &b"hello"[..]).await; // Despite the protocol negotiation being successfully conducted on the listener // side, we have to receive an error here because the listener didn't send the @@ -604,16 +625,7 @@ mod tests { assert!(outcome.is_err()); }); - let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); - listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - - let (socket, _) = listener.accept().await.unwrap(); - let NotificationsInOpen { handshake, substream, .. } = upgrade::apply_inbound( - socket.compat(), - NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), - ) - .await - .unwrap(); + let (handshake, substream) = listen_on_localhost(listener_addr_tx).await.unwrap(); assert_eq!(handshake, b"hello"); @@ -625,35 +637,16 @@ mod tests { #[tokio::test] async fn large_initial_message_refused() { - const PROTO_NAME: &str = "/test/proto/1"; let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); let client = tokio::spawn(async move { - let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); - let ret = upgrade::apply_outbound( - socket.compat(), - // We check that an initial message that is too large gets refused. - NotificationsOut::new( - PROTO_NAME, - Vec::new(), - (0..32768).map(|_| 0).collect::>(), - 1024 * 1024, - ), - upgrade::Version::V1, - ) - .await; + let ret = + dial(listener_addr_rx.await.unwrap(), (0..32768).map(|_| 0).collect::>()) + .await; assert!(ret.is_err()); }); - let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); - listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - - let (socket, _) = listener.accept().await.unwrap(); - let ret = upgrade::apply_inbound( - socket.compat(), - NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), - ) - .await; + let ret = listen_on_localhost(listener_addr_tx).await; assert!(ret.is_err()); client.await.unwrap(); @@ -661,30 +654,14 @@ mod tests { #[tokio::test] async fn large_handshake_refused() { - const PROTO_NAME: &str = "/test/proto/1"; let (listener_addr_tx, listener_addr_rx) = oneshot::channel(); let client = tokio::spawn(async move { - let socket = TcpStream::connect(listener_addr_rx.await.unwrap()).await.unwrap(); - let ret = upgrade::apply_outbound( - socket.compat(), - NotificationsOut::new(PROTO_NAME, Vec::new(), &b"initial message"[..], 1024 * 1024), - upgrade::Version::V1, - ) - .await; + let ret = dial(listener_addr_rx.await.unwrap(), &b"initial message"[..]).await; assert!(ret.is_err()); }); - let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); - listener_addr_tx.send(listener.local_addr().unwrap()).unwrap(); - - let (socket, _) = listener.accept().await.unwrap(); - let NotificationsInOpen { handshake, mut substream, .. } = upgrade::apply_inbound( - socket.compat(), - NotificationsIn::new(PROTO_NAME, Vec::new(), 1024 * 1024), - ) - .await - .unwrap(); + let (handshake, mut substream) = listen_on_localhost(listener_addr_tx).await.unwrap(); assert_eq!(handshake, b"initial message"); // We check that a handshake that is too large gets refused. diff --git a/client/network/src/request_responses.rs b/client/network/src/request_responses.rs index 4628b0191a2e8..fe28503d361b0 100644 --- a/client/network/src/request_responses.rs +++ b/client/network/src/request_responses.rs @@ -18,8 +18,8 @@ //! Collection of request-response protocols. //! -//! The [`RequestResponse`] struct defined in this module provides support for zero or more -//! so-called "request-response" protocols. +//! The [`RequestResponsesBehaviour`] struct defined in this module provides support for zero or +//! more so-called "request-response" protocols. //! //! A request-response protocol works in the following way: //! @@ -41,17 +41,15 @@ use futures::{ prelude::*, }; use libp2p::{ - core::{connection::ConnectionId, Multiaddr, PeerId}, - request_response::{ - handler::RequestResponseHandler, ProtocolSupport, RequestResponse, RequestResponseCodec, - RequestResponseEvent, RequestResponseMessage, ResponseChannel, - }, + core::{Endpoint, Multiaddr}, + request_response::{self, Behaviour, Codec, Message, ProtocolSupport, ResponseChannel}, swarm::{ - behaviour::{ConnectionClosed, DialFailure, FromSwarm, ListenFailure}, + behaviour::{ConnectionClosed, FromSwarm}, handler::multi::MultiHandler, - ConnectionHandler, IntoConnectionHandler, NetworkBehaviour, NetworkBehaviourAction, - PollParameters, + ConnectionDenied, ConnectionId, NetworkBehaviour, PollParameters, THandler, + THandlerInEvent, THandlerOutEvent, ToSwarm, }, + PeerId, }; use sc_peerset::{PeersetHandle, BANNED_THRESHOLD}; @@ -64,9 +62,7 @@ use std::{ time::{Duration, Instant}, }; -pub use libp2p::request_response::{ - InboundFailure, OutboundFailure, RequestId, RequestResponseConfig, -}; +pub use libp2p::request_response::{Config, InboundFailure, OutboundFailure, RequestId}; /// Error in a request. #[derive(Debug, thiserror::Error)] @@ -260,14 +256,13 @@ impl From<(ProtocolName, RequestId)> for ProtocolRequestId { /// Implementation of `NetworkBehaviour` that provides support for request-response protocols. pub struct RequestResponsesBehaviour { /// The multiple sub-protocols, by name. - /// Contains the underlying libp2p `RequestResponse` behaviour, plus an optional + /// + /// Contains the underlying libp2p request-response [`Behaviour`], plus an optional /// "response builder" used to build responses for incoming requests. - protocols: HashMap< - ProtocolName, - (RequestResponse, Option>), - >, + protocols: + HashMap, Option>)>, - /// Pending requests, passed down to a [`RequestResponse`] behaviour, awaiting a reply. + /// Pending requests, passed down to a request-response [`Behaviour`], awaiting a reply. pending_requests: HashMap, RequestFailure>>)>, @@ -324,7 +319,7 @@ impl RequestResponsesBehaviour { ) -> Result { let mut protocols = HashMap::new(); for protocol in list { - let mut cfg = RequestResponseConfig::default(); + let mut cfg = Config::default(); cfg.set_connection_keep_alive(Duration::from_secs(10)); cfg.set_request_timeout(protocol.request_timeout); @@ -334,13 +329,13 @@ impl RequestResponsesBehaviour { ProtocolSupport::Outbound }; - let rq_rp = RequestResponse::new( + let rq_rp = Behaviour::with_codec( GenericCodec { max_request_size: protocol.max_request_size, max_response_size: protocol.max_response_size, }, - iter::once(protocol.name.as_bytes().to_vec()) - .chain(protocol.fallback_names.iter().map(|name| name.as_bytes().to_vec())) + iter::once(protocol.name.clone()) + .chain(protocol.fallback_names) .zip(iter::repeat(protocol_support)), cfg, ); @@ -401,50 +396,79 @@ impl RequestResponsesBehaviour { ); } } +} - fn new_handler_with_replacement( +impl NetworkBehaviour for RequestResponsesBehaviour { + type ConnectionHandler = + MultiHandler as NetworkBehaviour>::ConnectionHandler>; + type ToSwarm = Event; + + fn handle_pending_inbound_connection( &mut self, - protocol: String, - handler: RequestResponseHandler, - ) -> ::ConnectionHandler { - let mut handlers: HashMap<_, _> = self - .protocols - .iter_mut() - .map(|(p, (r, _))| (p.to_string(), NetworkBehaviour::new_handler(r))) - .collect(); - - if let Some(h) = handlers.get_mut(&protocol) { - *h = handler - } + _connection_id: ConnectionId, + _local_addr: &Multiaddr, + _remote_addr: &Multiaddr, + ) -> Result<(), ConnectionDenied> { + Ok(()) + } - MultiHandler::try_from_iter(handlers).expect( - "Protocols are in a HashMap and there can be at most one handler per protocol name, \ - which is the only possible error; qed", - ) + fn handle_pending_outbound_connection( + &mut self, + _connection_id: ConnectionId, + _maybe_peer: Option, + _addresses: &[Multiaddr], + _effective_role: Endpoint, + ) -> Result, ConnectionDenied> { + Ok(Vec::new()) } -} -impl NetworkBehaviour for RequestResponsesBehaviour { - type ConnectionHandler = MultiHandler< - String, - as NetworkBehaviour>::ConnectionHandler, - >; - type OutEvent = Event; - - fn new_handler(&mut self) -> Self::ConnectionHandler { - let iter = self - .protocols - .iter_mut() - .map(|(p, (r, _))| (p.to_string(), NetworkBehaviour::new_handler(r))); - - MultiHandler::try_from_iter(iter).expect( + fn handle_established_inbound_connection( + &mut self, + connection_id: ConnectionId, + peer: PeerId, + local_addr: &Multiaddr, + remote_addr: &Multiaddr, + ) -> Result, ConnectionDenied> { + let iter = self.protocols.iter_mut().filter_map(|(p, (r, _))| { + if let Ok(handler) = r.handle_established_inbound_connection( + connection_id, + peer, + local_addr, + remote_addr, + ) { + Some((p.to_string(), handler)) + } else { + None + } + }); + + Ok(MultiHandler::try_from_iter(iter).expect( "Protocols are in a HashMap and there can be at most one handler per protocol name, \ which is the only possible error; qed", - ) + )) } - fn addresses_of_peer(&mut self, _: &PeerId) -> Vec { - Vec::new() + fn handle_established_outbound_connection( + &mut self, + connection_id: ConnectionId, + peer: PeerId, + addr: &Multiaddr, + role_override: Endpoint, + ) -> Result, ConnectionDenied> { + let iter = self.protocols.iter_mut().filter_map(|(p, (r, _))| { + if let Ok(handler) = + r.handle_established_outbound_connection(connection_id, peer, addr, role_override) + { + Some((p.to_string(), handler)) + } else { + None + } + }); + + Ok(MultiHandler::try_from_iter(iter).expect( + "Protocols are in a HashMap and there can be at most one handler per protocol name, \ + which is the only possible error; qed", + )) } fn on_swarm_event(&mut self, event: FromSwarm) { @@ -477,50 +501,25 @@ impl NetworkBehaviour for RequestResponsesBehaviour { ) } }, - FromSwarm::DialFailure(DialFailure { peer_id, error, handler }) => { - for (p_name, p_handler) in handler.into_iter() { - if let Some((proto, _)) = self.protocols.get_mut(p_name.as_str()) { - proto.on_swarm_event(FromSwarm::DialFailure(DialFailure { - peer_id, - handler: p_handler, - error, - })); - } else { - log::error!( - target: "sub-libp2p", - "on_swarm_event/dial_failure: no request-response instance registered for protocol {:?}", - p_name, - ) - } - } - }, + FromSwarm::DialFailure(e) => + for (p, _) in self.protocols.values_mut() { + NetworkBehaviour::on_swarm_event(p, FromSwarm::DialFailure(e)); + }, FromSwarm::ListenerClosed(e) => for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ListenerClosed(e)); }, - FromSwarm::ListenFailure(ListenFailure { local_addr, send_back_addr, handler }) => - for (p_name, p_handler) in handler.into_iter() { - if let Some((proto, _)) = self.protocols.get_mut(p_name.as_str()) { - proto.on_swarm_event(FromSwarm::ListenFailure(ListenFailure { - local_addr, - send_back_addr, - handler: p_handler, - })); - } else { - log::error!( - target: "sub-libp2p", - "on_swarm_event/listen_failure: no request-response instance registered for protocol {:?}", - p_name, - ) - } + FromSwarm::ListenFailure(e) => + for (p, _) in self.protocols.values_mut() { + NetworkBehaviour::on_swarm_event(p, FromSwarm::ListenFailure(e)); }, FromSwarm::ListenerError(e) => for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ListenerError(e)); }, - FromSwarm::ExpiredExternalAddr(e) => + FromSwarm::ExternalAddrExpired(e) => for (p, _) in self.protocols.values_mut() { - NetworkBehaviour::on_swarm_event(p, FromSwarm::ExpiredExternalAddr(e)); + NetworkBehaviour::on_swarm_event(p, FromSwarm::ExternalAddrExpired(e)); }, FromSwarm::NewListener(e) => for (p, _) in self.protocols.values_mut() { @@ -530,9 +529,13 @@ impl NetworkBehaviour for RequestResponsesBehaviour { for (p, _) in self.protocols.values_mut() { NetworkBehaviour::on_swarm_event(p, FromSwarm::ExpiredListenAddr(e)); }, - FromSwarm::NewExternalAddr(e) => + FromSwarm::NewExternalAddrCandidate(e) => for (p, _) in self.protocols.values_mut() { - NetworkBehaviour::on_swarm_event(p, FromSwarm::NewExternalAddr(e)); + NetworkBehaviour::on_swarm_event(p, FromSwarm::NewExternalAddrCandidate(e)); + }, + FromSwarm::ExternalAddrConfirmed(e) => + for (p, _) in self.protocols.values_mut() { + NetworkBehaviour::on_swarm_event(p, FromSwarm::ExternalAddrConfirmed(e)); }, FromSwarm::AddressChange(e) => for (p, _) in self.protocols.values_mut() { @@ -549,25 +552,25 @@ impl NetworkBehaviour for RequestResponsesBehaviour { &mut self, peer_id: PeerId, connection_id: ConnectionId, - (p_name, event): <::Handler as - ConnectionHandler>::OutEvent, + event: THandlerOutEvent, ) { - if let Some((proto, _)) = self.protocols.get_mut(&*p_name) { - return proto.on_connection_handler_event(peer_id, connection_id, event) + let p_name = event.0; + if let Some((proto, _)) = self.protocols.get_mut(p_name.as_str()) { + return proto.on_connection_handler_event(peer_id, connection_id, event.1) + } else { + log::warn!( + target: "sub-libp2p", + "on_connection_handler_event: no request-response instance registered for protocol {:?}", + p_name + ); } - - log::warn!( - target: "sub-libp2p", - "on_connection_handler_event: no request-response instance registered for protocol {:?}", - p_name - ); } fn poll( &mut self, cx: &mut Context, params: &mut impl PollParameters, - ) -> Poll> { + ) -> Poll>> { 'poll_all: loop { if let Some(message_request) = self.message_request.take() { // Now we can can poll `MessageRequest` until we get the reputation @@ -621,8 +624,8 @@ impl NetworkBehaviour for RequestResponsesBehaviour { // initialization. if let Some(mut resp_builder) = resp_builder { // If the response builder is too busy, silently drop `tx`. This - // will be reported by the corresponding `RequestResponse` through - // an `InboundFailure::Omission` event. + // will be reported by the corresponding request-response [`Behaviour`] + // through an `InboundFailure::Omission` event. let _ = resp_builder.try_send(IncomingRequest { peer, payload: request, @@ -674,7 +677,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { if let Some((protocol, _)) = self.protocols.get_mut(&*protocol_name) { if protocol.send_response(inner_channel, Ok(payload)).is_err() { // Note: Failure is handled further below when receiving - // `InboundFailure` event from `RequestResponse` behaviour. + // `InboundFailure` event from request-response [`Behaviour`]. log::debug!( target: "sub-libp2p", "Failed to send response for {:?} on protocol {:?} due to a \ @@ -690,9 +693,10 @@ impl NetworkBehaviour for RequestResponsesBehaviour { } if !reputation_changes.is_empty() { - return Poll::Ready(NetworkBehaviourAction::GenerateEvent( - Event::ReputationChanges { peer, changes: reputation_changes }, - )) + return Poll::Ready(ToSwarm::GenerateEvent(Event::ReputationChanges { + peer, + changes: reputation_changes, + })) } } @@ -701,44 +705,43 @@ impl NetworkBehaviour for RequestResponsesBehaviour { while let Poll::Ready(ev) = behaviour.poll(cx, params) { let ev = match ev { // Main events we are interested in. - NetworkBehaviourAction::GenerateEvent(ev) => ev, + ToSwarm::GenerateEvent(ev) => ev, // Other events generated by the underlying behaviour are transparently // passed through. - NetworkBehaviourAction::Dial { opts, handler } => { + ToSwarm::Dial { opts } => { if opts.get_peer_id().is_none() { log::error!( "The request-response isn't supposed to start dialing addresses" ); } - let protocol = protocol.to_string(); - let handler = self.new_handler_with_replacement(protocol, handler); - return Poll::Ready(NetworkBehaviourAction::Dial { opts, handler }) + return Poll::Ready(ToSwarm::Dial { opts }) }, - NetworkBehaviourAction::NotifyHandler { peer_id, handler, event } => - return Poll::Ready(NetworkBehaviourAction::NotifyHandler { + ToSwarm::NotifyHandler { peer_id, handler, event } => + return Poll::Ready(ToSwarm::NotifyHandler { peer_id, handler, event: ((*protocol).to_string(), event), }), - NetworkBehaviourAction::ReportObservedAddr { address, score } => - return Poll::Ready(NetworkBehaviourAction::ReportObservedAddr { - address, - score, - }), - NetworkBehaviourAction::CloseConnection { peer_id, connection } => - return Poll::Ready(NetworkBehaviourAction::CloseConnection { - peer_id, - connection, - }), + ToSwarm::CloseConnection { peer_id, connection } => + return Poll::Ready(ToSwarm::CloseConnection { peer_id, connection }), + ToSwarm::NewExternalAddrCandidate(observed) => + return Poll::Ready(ToSwarm::NewExternalAddrCandidate(observed)), + ToSwarm::ExternalAddrConfirmed(addr) => + return Poll::Ready(ToSwarm::ExternalAddrConfirmed(addr)), + ToSwarm::ExternalAddrExpired(addr) => + return Poll::Ready(ToSwarm::ExternalAddrExpired(addr)), + ToSwarm::ListenOn { opts } => + return Poll::Ready(ToSwarm::ListenOn { opts }), + ToSwarm::RemoveListener { id } => + return Poll::Ready(ToSwarm::RemoveListener { id }), }; match ev { // Received a request from a remote. - RequestResponseEvent::Message { + request_response::Event::Message { peer, - message: - RequestResponseMessage::Request { request_id, request, channel, .. }, + message: Message::Request { request_id, request, channel, .. }, } => { self.pending_responses_arrival_time .insert((protocol.clone(), request_id).into(), Instant::now()); @@ -765,9 +768,9 @@ impl NetworkBehaviour for RequestResponsesBehaviour { }, // Received a response from a remote to one of our requests. - RequestResponseEvent::Message { + request_response::Event::Message { peer, - message: RequestResponseMessage::Response { request_id, response }, + message: Message::Response { request_id, response }, .. } => { let (started, delivered) = match self @@ -798,12 +801,15 @@ impl NetworkBehaviour for RequestResponsesBehaviour { result: delivered, }; - return Poll::Ready(NetworkBehaviourAction::GenerateEvent(out)) + return Poll::Ready(ToSwarm::GenerateEvent(out)) }, // One of our requests has failed. - RequestResponseEvent::OutboundFailure { - peer, request_id, error, .. + request_response::Event::OutboundFailure { + peer, + request_id, + error, + .. } => { let started = match self .pending_requests @@ -841,12 +847,12 @@ impl NetworkBehaviour for RequestResponsesBehaviour { result: Err(RequestFailure::Network(error)), }; - return Poll::Ready(NetworkBehaviourAction::GenerateEvent(out)) + return Poll::Ready(ToSwarm::GenerateEvent(out)) }, // An inbound request failed, either while reading the request or due to // failing to send a response. - RequestResponseEvent::InboundFailure { + request_response::Event::InboundFailure { request_id, peer, error, .. } => { self.pending_responses_arrival_time @@ -857,11 +863,11 @@ impl NetworkBehaviour for RequestResponsesBehaviour { protocol: protocol.clone(), result: Err(ResponseFailure::Network(error)), }; - return Poll::Ready(NetworkBehaviourAction::GenerateEvent(out)) + return Poll::Ready(ToSwarm::GenerateEvent(out)) }, // A response to an inbound request has been sent. - RequestResponseEvent::ResponseSent { request_id, peer } => { + request_response::Event::ResponseSent { request_id, peer } => { let arrival_time = self .pending_responses_arrival_time .remove(&(protocol.clone(), request_id).into()) @@ -886,7 +892,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour { result: Ok(arrival_time), }; - return Poll::Ready(NetworkBehaviourAction::GenerateEvent(out)) + return Poll::Ready(ToSwarm::GenerateEvent(out)) }, }; } @@ -913,7 +919,7 @@ pub enum ResponseFailure { Network(InboundFailure), } -/// Implements the libp2p [`RequestResponseCodec`] trait. Defines how streams of bytes are turned +/// Implements the libp2p [`Codec`] trait. Defines how streams of bytes are turned /// into requests and responses and vice-versa. #[derive(Debug, Clone)] #[doc(hidden)] // Needs to be public in order to satisfy the Rust compiler. @@ -923,8 +929,8 @@ pub struct GenericCodec { } #[async_trait::async_trait] -impl RequestResponseCodec for GenericCodec { - type Protocol = Vec; +impl Codec for GenericCodec { + type Protocol = ProtocolName; type Request = Vec; type Response = Result, ()>; @@ -1054,7 +1060,7 @@ mod tests { }, identity::Keypair, noise, - swarm::{Executor, Swarm, SwarmEvent}, + swarm::{Executor, Swarm, SwarmBuilder, SwarmEvent}, Multiaddr, }; use sc_peerset::{Peerset, PeersetConfig, SetConfig}; @@ -1072,13 +1078,10 @@ mod tests { ) -> (Swarm, Multiaddr, Peerset) { let keypair = Keypair::generate_ed25519(); - let noise_keys = - noise::Keypair::::new().into_authentic(&keypair).unwrap(); - let transport = MemoryTransport::new() .upgrade(upgrade::Version::V1) - .authenticate(noise::NoiseConfig::xx(noise_keys).into_authenticated()) - .multiplex(libp2p::yamux::YamuxConfig::default()) + .authenticate(noise::Config::new(&keypair).unwrap()) + .multiplex(libp2p::yamux::Config::default()) .boxed(); let config = PeersetConfig { @@ -1096,12 +1099,13 @@ mod tests { let behaviour = RequestResponsesBehaviour::new(list, handle).unwrap(); let runtime = tokio::runtime::Runtime::new().unwrap(); - let mut swarm = Swarm::with_executor( + let mut swarm = SwarmBuilder::with_executor( transport, behaviour, keypair.public().to_peer_id(), TokioExecutor(runtime), - ); + ) + .build(); let listen_addr: Multiaddr = format!("/memory/{}", rand::random::()).parse().unwrap(); swarm.listen_on(listen_addr.clone()).unwrap(); @@ -1117,7 +1121,7 @@ mod tests { let protocol_name = "/test/req-resp/1"; let mut pool = LocalPool::new(); - // Build swarms whose behaviour is `RequestResponsesBehaviour`. + // Build swarms whose behaviour is [`RequestResponsesBehaviour`]. let mut swarms = (0..2) .map(|_| { let (tx, mut rx) = mpsc::channel::(64); @@ -1220,7 +1224,7 @@ mod tests { let protocol_name = "/test/req-resp/1"; let mut pool = LocalPool::new(); - // Build swarms whose behaviour is `RequestResponsesBehaviour`. + // Build swarms whose behaviour is [`RequestResponsesBehaviour`]. let mut swarms = (0..2) .map(|_| { let (tx, mut rx) = mpsc::channel::(64); @@ -1322,10 +1326,10 @@ mod tests { } /// A [`RequestId`] is a unique identifier among either all inbound or all outbound requests for - /// a single [`RequestResponse`] behaviour. It is not guaranteed to be unique across multiple - /// [`RequestResponse`] behaviours. Thus when handling [`RequestId`] in the context of multiple - /// [`RequestResponse`] behaviours, one needs to couple the protocol name with the [`RequestId`] - /// to get a unique request identifier. + /// a single [`RequestResponsesBehaviour`] behaviour. It is not guaranteed to be unique across + /// multiple [`RequestResponsesBehaviour`] behaviours. Thus when handling [`RequestId`] in the + /// context of multiple [`RequestResponsesBehaviour`] behaviours, one needs to couple the + /// protocol name with the [`RequestId`] to get a unique request identifier. /// /// This test ensures that two requests on different protocols can be handled concurrently /// without a [`RequestId`] collision. diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 6dc00b36ceb53..f9f9cab87f141 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -52,17 +52,17 @@ use crate::{ ReputationChange, }; +use either::Either; use futures::{channel::oneshot, prelude::*}; use libp2p::{ - core::{either::EitherError, upgrade, ConnectedPoint}, + connection_limits::{ConnectionLimits, Exceeded}, + core::{upgrade, ConnectedPoint, Endpoint}, identify::Info as IdentifyInfo, kad::record::Key as KademliaKey, multiaddr, - ping::Failure as PingFailure, swarm::{ - AddressScore, ConnectionError, ConnectionHandler, ConnectionLimits, DialError, Executor, - IntoConnectionHandler, NetworkBehaviour, PendingConnectionError, Swarm, SwarmBuilder, - SwarmEvent, + Config as SwarmConfig, ConnectionError, ConnectionId, DialError, Executor, ListenError, + NetworkBehaviour, Swarm, SwarmEvent, THandlerErr, }, Multiaddr, PeerId, }; @@ -91,7 +91,7 @@ use std::{ }; pub use behaviour::{InboundFailure, OutboundFailure, ResponseFailure}; -pub use libp2p::identity::{error::DecodingError, Keypair, PublicKey}; +pub use libp2p::identity::{DecodingError, Keypair, PublicKey}; mod metrics; mod out_events; @@ -99,12 +99,6 @@ mod out_events; pub mod signature; pub mod traits; -/// Custom error that can be produced by the [`ConnectionHandler`] of the [`NetworkBehaviour`]. -/// Used as a template parameter of [`SwarmEvent`] below. -type ConnectionHandlerErr = - <<::ConnectionHandler as IntoConnectionHandler> - ::Handler as ConnectionHandler>::Error; - /// Substrate network service. Handles network IO and manages connectivity. pub struct NetworkService { /// Number of peers we're connected to. @@ -272,7 +266,7 @@ where ); let discovery_config = { - let mut config = DiscoveryConfig::new(local_public.clone()); + let mut config = DiscoveryConfig::new(local_public.to_peer_id()); config.with_permanent_addresses(known_addresses); config.discovery_limit( u64::from(params.network_config.default_peers_set.out_peers) + 15, @@ -367,6 +361,11 @@ where discovery_config, params.network_config.request_response_protocols, peerset_handle.clone(), + ConnectionLimits::default() + .with_max_established_per_peer(Some(crate::MAX_CONNECTIONS_PER_PEER as u32)) + .with_max_established_incoming(Some( + crate::MAX_CONNECTIONS_ESTABLISHED_INCOMING, + )), ); match result { @@ -376,34 +375,26 @@ where } }; - let builder = { + let swarm = { struct SpawnImpl(F); impl + Send>>)> Executor for SpawnImpl { fn exec(&self, f: Pin + Send>>) { (self.0)(f) } } - SwarmBuilder::with_executor( - transport, - behaviour, - local_peer_id, - SpawnImpl(params.executor), - ) + + let config = SwarmConfig::with_executor(SpawnImpl(params.executor)) + .with_substream_upgrade_protocol_override(upgrade::Version::V1) + .with_notify_handler_buffer_size(NonZeroUsize::new(32).expect("32 != 0; qed")) + // NOTE: 24 is somewhat arbitrary and should be tuned in the future if necessary. + // See + .with_per_connection_event_buffer_size(24) + .with_max_negotiating_inbound_streams(2048); + + Swarm::new(transport, behaviour, local_peer_id, config) }; - let builder = builder - .connection_limits( - ConnectionLimits::default() - .with_max_established_per_peer(Some(crate::MAX_CONNECTIONS_PER_PEER as u32)) - .with_max_established_incoming(Some( - crate::MAX_CONNECTIONS_ESTABLISHED_INCOMING, - )), - ) - .substream_upgrade_protocol_override(upgrade::Version::V1Lazy) - .notify_handler_buffer_size(NonZeroUsize::new(32).expect("32 != 0; qed")) - .connection_event_buffer_size(1024) - .max_negotiating_inbound_streams(2048); - (builder.build(), bandwidth) + (swarm, bandwidth) }; // Initialize the metrics. @@ -427,11 +418,7 @@ where // Add external addresses. for addr in ¶ms.network_config.public_addresses { - Swarm::>::add_external_address( - &mut swarm, - addr.clone(), - AddressScore::Infinite, - ); + Swarm::>::add_external_address(&mut swarm, addr.clone()); } let external_addresses = Arc::new(Mutex::new(Vec::new())); @@ -525,15 +512,23 @@ where pub fn network_state(&mut self) -> NetworkState { let swarm = &mut self.network_service; let open = swarm.behaviour_mut().user_protocol().open_peers().cloned().collect::>(); - let connected_peers = { let swarm = &mut *swarm; open.iter() .filter_map(move |peer_id| { - let known_addresses = - NetworkBehaviour::addresses_of_peer(swarm.behaviour_mut(), peer_id) - .into_iter() - .collect(); + let known_addresses = if let Ok(addrs) = + NetworkBehaviour::handle_pending_outbound_connection( + swarm.behaviour_mut(), + ConnectionId::new_unchecked(0), // dummy value + Some(*peer_id), + &vec![], + Endpoint::Listener, + ) { + addrs.into_iter().collect() + } else { + error!(target: "sub-libp2p", "Was not able to get known addresses for {:?}", peer_id); + return None + }; let endpoint = if let Some(e) = swarm.behaviour_mut().node(peer_id).and_then(|i| i.endpoint()) @@ -572,6 +567,20 @@ where .into_iter() .filter(|p| open.iter().all(|n| n != p)) .map(move |peer_id| { + let known_addresses = if let Ok(addrs) = + NetworkBehaviour::handle_pending_outbound_connection( + swarm.behaviour_mut(), + ConnectionId::new_unchecked(0), // dummy value + Some(peer_id), + &vec![], + Endpoint::Listener, + ) { + addrs.into_iter().collect() + } else { + error!(target: "sub-libp2p", "Was not able to get known addresses for {:?}", peer_id); + Default::default() + }; + ( peer_id.to_base58(), NetworkStateNotConnectedPeer { @@ -583,12 +592,7 @@ where .behaviour_mut() .node(&peer_id) .and_then(|i| i.latest_ping()), - known_addresses: NetworkBehaviour::addresses_of_peer( - swarm.behaviour_mut(), - &peer_id, - ) - .into_iter() - .collect(), + known_addresses, }, ) }) @@ -597,7 +601,7 @@ where let peer_id = Swarm::>::local_peer_id(swarm).to_base58(); let listened_addresses = swarm.listeners().cloned().collect(); - let external_addresses = swarm.external_addresses().map(|r| &r.addr).cloned().collect(); + let external_addresses = swarm.external_addresses().cloned().collect(); NetworkState { peer_id, @@ -672,8 +676,7 @@ impl NetworkService { .into_iter() .map(|mut addr| { let peer = match addr.pop() { - Some(multiaddr::Protocol::P2p(key)) => PeerId::from_multihash(key) - .map_err(|_| "Invalid PeerId format".to_string())?, + Some(multiaddr::Protocol::P2p(peer_id)) => peer_id, _ => return Err("Missing PeerId from address".to_string()), }; @@ -1223,8 +1226,7 @@ where self.network_service.behaviour_mut().user_protocol_mut().num_connected_peers(); self.num_connected.store(num_connected_peers, Ordering::Relaxed); { - let external_addresses = - self.network_service.external_addresses().map(|r| &r.addr).cloned().collect(); + let external_addresses = self.network_service.external_addresses().cloned().collect(); *self.external_addresses.lock() = external_addresses; let listen_addresses = @@ -1356,10 +1358,7 @@ where } /// Process the next event coming from `Swarm`. - fn handle_swarm_event( - &mut self, - event: SwarmEvent>>, - ) { + fn handle_swarm_event(&mut self, event: SwarmEvent>>) { match event { SwarmEvent::Behaviour(BehaviourOut::InboundRequest { protocol, result, .. }) => { if let Some(metrics) = self.metrics.as_ref() { @@ -1441,7 +1440,12 @@ where peer_id, info: IdentifyInfo { - protocol_version, agent_version, mut listen_addrs, protocols, .. + protocol_version, + agent_version, + mut listen_addrs, + protocols, + observed_addr, + .. }, }) => { if listen_addrs.len() > 30 { @@ -1453,14 +1457,20 @@ where listen_addrs.truncate(30); } for addr in listen_addrs { - self.network_service - .behaviour_mut() - .add_self_reported_address_to_dht(&peer_id, &protocols, addr); + self.network_service.behaviour_mut().add_self_reported_address_to_dht( + &peer_id, + &protocols, + addr.clone(), + ); } self.network_service .behaviour_mut() .user_protocol_mut() .add_default_set_discovered_nodes(iter::once(peer_id)); + // Confirm the observed address manually since they are no longer trusted by + // default (libp2p >= 0.52) + // TODO: remove this when/if AutoNAT is implemented. + self.network_service.add_external_address(observed_addr); }, SwarmEvent::Behaviour(BehaviourOut::Discovered(peer_id)) => { self.network_service @@ -1588,6 +1598,7 @@ where endpoint, num_established, concurrent_dial_errors, + .. } => { if let Some(errors) = concurrent_dial_errors { debug!(target: "sub-libp2p", "Libp2p => Connected({:?}) with errors: {:?}", peer_id, errors); @@ -1607,8 +1618,14 @@ where } } }, - SwarmEvent::ConnectionClosed { peer_id, cause, endpoint, num_established } => { - debug!(target: "sub-libp2p", "Libp2p => Disconnected({:?}, {:?})", peer_id, cause); + SwarmEvent::ConnectionClosed { + connection_id, + peer_id, + cause, + endpoint, + num_established, + } => { + debug!(target: "sub-libp2p", "Libp2p => Disconnected({:?} via {:?}: {:?})", peer_id, connection_id, cause); if let Some(metrics) = self.metrics.as_ref() { let direction = match endpoint { ConnectedPoint::Dialer { .. } => "out", @@ -1616,11 +1633,13 @@ where }; let reason = match cause { Some(ConnectionError::IO(_)) => "transport-error", - Some(ConnectionError::Handler(EitherError::A(EitherError::A( - EitherError::B(EitherError::A(PingFailure::Timeout)), + Some(ConnectionError::Handler(Either::Left(Either::Left( + Either::Left(Either::Right(_)), )))) => "ping-timeout", - Some(ConnectionError::Handler(EitherError::A(EitherError::A( - EitherError::A(NotifsHandlerError::SyncNotificationsClogged), + Some(ConnectionError::Handler(Either::Left(Either::Left( + Either::Left(Either::Left( + NotifsHandlerError::SyncNotificationsClogged, + )), )))) => "sync-notifications-clogged", Some(ConnectionError::Handler(_)) => "protocol-error", Some(ConnectionError::KeepAliveTimeout) => "keep-alive-timeout", @@ -1646,12 +1665,12 @@ where metrics.listeners_local_addresses.dec(); } }, - SwarmEvent::OutgoingConnectionError { peer_id, error } => { + SwarmEvent::OutgoingConnectionError { connection_id, peer_id, error } => { if let Some(peer_id) = peer_id { trace!( target: "sub-libp2p", - "Libp2p => Failed to reach {:?}: {}", - peer_id, error, + "Libp2p => Failed to reach {:?} via {:?}: {}", + peer_id, connection_id, error, ); if self.boot_node_ids.contains(&peer_id) { @@ -1669,16 +1688,19 @@ where } if let Some(metrics) = self.metrics.as_ref() { + #[allow(deprecated)] let reason = match error { - DialError::ConnectionLimit(_) => Some("limit-reached"), - DialError::InvalidPeerId(_) => Some("invalid-peer-id"), - DialError::Transport(_) | DialError::ConnectionIo(_) => - Some("transport-error"), - DialError::Banned | - DialError::LocalPeerId | + DialError::Denied { cause } => + if cause.downcast::().is_ok() { + Some("limit-reached") + } else { + None + }, + DialError::WrongPeerId { .. } | DialError::LocalPeerId { .. } => + Some("invalid-peer-id"), + DialError::Transport(_) => Some("transport-error"), DialError::NoAddresses | DialError::DialPeerConditionFalse(_) | - DialError::WrongPeerId { .. } | DialError::Aborted => None, // ignore them }; if let Some(reason) = reason { @@ -1686,29 +1708,40 @@ where } } }, - SwarmEvent::Dialing(peer_id) => { - trace!(target: "sub-libp2p", "Libp2p => Dialing({:?})", peer_id) + SwarmEvent::Dialing { peer_id, connection_id } => { + trace!(target: "sub-libp2p", "Libp2p => Dialing({:?} via {:?})", peer_id, connection_id) }, - SwarmEvent::IncomingConnection { local_addr, send_back_addr } => { - trace!(target: "sub-libp2p", "Libp2p => IncomingConnection({},{}))", - local_addr, send_back_addr); + SwarmEvent::IncomingConnection { connection_id, local_addr, send_back_addr } => { + trace!(target: "sub-libp2p", "Libp2p => IncomingConnection({},{} via {:?}))", + local_addr, send_back_addr, connection_id); if let Some(metrics) = self.metrics.as_ref() { metrics.incoming_connections_total.inc(); } }, - SwarmEvent::IncomingConnectionError { local_addr, send_back_addr, error } => { + SwarmEvent::IncomingConnectionError { + connection_id, + local_addr, + send_back_addr, + error, + } => { debug!( target: "sub-libp2p", - "Libp2p => IncomingConnectionError({},{}): {}", - local_addr, send_back_addr, error, + "Libp2p => IncomingConnectionError({},{} via {:?}): {}", + local_addr, send_back_addr, connection_id, error, ); if let Some(metrics) = self.metrics.as_ref() { + #[allow(deprecated)] let reason = match error { - PendingConnectionError::ConnectionLimit(_) => Some("limit-reached"), - PendingConnectionError::WrongPeerId { .. } => Some("invalid-peer-id"), - PendingConnectionError::Transport(_) | PendingConnectionError::IO(_) => - Some("transport-error"), - PendingConnectionError::Aborted => None, // ignore it + ListenError::Denied { cause } => + if cause.downcast::().is_ok() { + Some("limit-reached") + } else { + None + }, + ListenError::WrongPeerId { .. } | ListenError::LocalPeerId { .. } => + Some("invalid-peer-id"), + ListenError::Transport(_) => Some("transport-error"), + ListenError::Aborted => None, // ignore it }; if let Some(reason) = reason { @@ -1719,16 +1752,6 @@ where } } }, - SwarmEvent::BannedPeer { peer_id, endpoint } => { - debug!( - target: "sub-libp2p", - "Libp2p => BannedPeer({}). Connected via {:?}.", - peer_id, endpoint, - ); - if let Some(metrics) = self.metrics.as_ref() { - metrics.incoming_connections_errors_total.with_label_values(&["banned"]).inc(); - } - }, SwarmEvent::ListenerClosed { reason, addresses, .. } => { if let Some(metrics) = self.metrics.as_ref() { metrics.listeners_local_addresses.sub(addresses.len() as u64); diff --git a/client/network/src/service/signature.rs b/client/network/src/service/signature.rs index e52dd6b1d2a29..024f60e4c466b 100644 --- a/client/network/src/service/signature.rs +++ b/client/network/src/service/signature.rs @@ -23,7 +23,7 @@ use libp2p::{ PeerId, }; -pub use libp2p::identity::error::SigningError; +pub use libp2p::identity::SigningError; /// A result of signing a message with a network identity. Since `PeerId` is potentially a hash of a /// `PublicKey`, you need to reveal the `PublicKey` next to the signature, so the verifier can check diff --git a/client/network/src/service/traits.rs b/client/network/src/service/traits.rs index 3f9b7e552027b..787ef4b5ae445 100644 --- a/client/network/src/service/traits.rs +++ b/client/network/src/service/traits.rs @@ -33,7 +33,7 @@ use sc_peerset::ReputationChange; use std::{collections::HashSet, future::Future, pin::Pin, sync::Arc}; -pub use libp2p::{identity::error::SigningError, kad::record::Key as KademliaKey}; +pub use libp2p::{identity::SigningError, kad::record::Key as KademliaKey}; /// Signer with network identity pub trait NetworkSigner { diff --git a/client/network/src/transport.rs b/client/network/src/transport.rs index 3aa0bb48dec53..6ce3f591225de 100644 --- a/client/network/src/transport.rs +++ b/client/network/src/transport.rs @@ -16,20 +16,18 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +use either::Either; use libp2p::{ - bandwidth, core::{ - self, - either::EitherTransport, muxing::StreamMuxerBox, transport::{Boxed, OptionalTransport}, upgrade, }, - dns, identity, mplex, noise, tcp, websocket, PeerId, Transport, + dns, identity, noise, tcp, websocket, PeerId, Transport, TransportExt, }; use std::{sync::Arc, time::Duration}; -pub use self::bandwidth::BandwidthSinks; +pub use libp2p::bandwidth::BandwidthSinks; /// Builds the transport that serves as a common ground for all connections. /// @@ -57,58 +55,32 @@ pub fn build_transport( // Main transport: DNS(TCP) let tcp_config = tcp::Config::new().nodelay(true); let tcp_trans = tcp::tokio::Transport::new(tcp_config.clone()); - let dns_init = dns::TokioDnsConfig::system(tcp_trans); + let dns_init = dns::tokio::Transport::system(tcp_trans); - EitherTransport::Left(if let Ok(dns) = dns_init { + Either::Left(if let Ok(dns) = dns_init { // WS + WSS transport // // Main transport can't be used for `/wss` addresses because WSS transport needs // unresolved addresses (BUT WSS transport itself needs an instance of DNS transport to // resolve and dial addresses). let tcp_trans = tcp::tokio::Transport::new(tcp_config); - let dns_for_wss = dns::TokioDnsConfig::system(tcp_trans) + let dns_for_wss = dns::tokio::Transport::system(tcp_trans) .expect("same system_conf & resolver to work"); - EitherTransport::Left(websocket::WsConfig::new(dns_for_wss).or_transport(dns)) + Either::Left(websocket::WsConfig::new(dns_for_wss).or_transport(dns)) } else { // In case DNS can't be constructed, fallback to TCP + WS (WSS won't work) let tcp_trans = tcp::tokio::Transport::new(tcp_config.clone()); let desktop_trans = websocket::WsConfig::new(tcp_trans) .or_transport(tcp::tokio::Transport::new(tcp_config)); - EitherTransport::Right(desktop_trans) + Either::Right(desktop_trans) }) } else { - EitherTransport::Right(OptionalTransport::some( - libp2p::core::transport::MemoryTransport::default(), - )) + Either::Right(OptionalTransport::some(libp2p::core::transport::MemoryTransport::default())) }; - let (transport, bandwidth) = bandwidth::BandwidthLogging::new(transport); - - let authentication_config = - { - // For more information about these two panics, see in "On the Importance of - // Checking Cryptographic Protocols for Faults" by Dan Boneh, Richard A. DeMillo, - // and Richard J. Lipton. - let noise_keypair = noise::Keypair::::new().into_authentic(&keypair) - .expect("can only fail in case of a hardware bug; since this signing is performed only \ - once and at initialization, we're taking the bet that the inconvenience of a very \ - rare panic here is basically zero"); - - // Legacy noise configurations for backward compatibility. - let noise_legacy = - noise::LegacyConfig { recv_legacy_handshake: true, ..Default::default() }; - - let mut xx_config = noise::NoiseConfig::xx(noise_keypair); - xx_config.set_legacy_config(noise_legacy); - xx_config.into_authenticated() - }; - + let authentication_config = noise::Config::new(&keypair).expect("Can create noise config. qed"); let multiplexing_config = { - let mut mplex_config = mplex::MplexConfig::new(); - mplex_config.set_max_buffer_behaviour(mplex::MaxBufferBehaviour::Block); - mplex_config.set_max_buffer_size(usize::MAX); - - let mut yamux_config = libp2p::yamux::YamuxConfig::default(); + let mut yamux_config = libp2p::yamux::Config::default(); // Enable proper flow-control: window updates are only sent when // buffered data has been consumed. yamux_config.set_window_update_mode(libp2p::yamux::WindowUpdateMode::on_read()); @@ -118,7 +90,7 @@ pub fn build_transport( yamux_config.set_receive_window_size(yamux_window_size); } - core::upgrade::SelectUpgrade::new(yamux_config, mplex_config) + yamux_config }; let transport = transport @@ -128,5 +100,5 @@ pub fn build_transport( .timeout(Duration::from_secs(20)) .boxed(); - (transport, bandwidth) + transport.with_bandwidth_logging() } diff --git a/client/network/src/types.rs b/client/network/src/types.rs index b0e32ae109149..5444a1e060311 100644 --- a/client/network/src/types.rs +++ b/client/network/src/types.rs @@ -18,8 +18,6 @@ //! `sc-network` type definitions -use libp2p::core::upgrade; - use std::{ borrow::Borrow, fmt, @@ -92,9 +90,9 @@ impl fmt::Display for ProtocolName { } } -impl upgrade::ProtocolName for ProtocolName { - fn protocol_name(&self) -> &[u8] { - (self as &str).as_bytes() +impl AsRef for ProtocolName { + fn as_ref(&self) -> &str { + self as &str } } diff --git a/client/network/sync/Cargo.toml b/client/network/sync/Cargo.toml index 298cbf1801f2e..8dc11a5fa1e7f 100644 --- a/client/network/sync/Cargo.toml +++ b/client/network/sync/Cargo.toml @@ -21,12 +21,12 @@ async-trait = "0.1.58" codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } futures = "0.3.21" futures-timer = "3.0.2" -libp2p = "0.50.0" +libp2p = "0.52.4" log = "0.4.17" lru = "0.8.1" mockall = "0.11.3" prost = "0.11" -smallvec = "1.8.0" +smallvec = "1.11.0" thiserror = "1.0" fork-tree = { version = "3.0.0", path = "../../../utils/fork-tree" } prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../../utils/prometheus" } @@ -44,7 +44,7 @@ sp-consensus-grandpa = { version = "4.0.0-dev", path = "../../../primitives/cons sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } [dev-dependencies] -tokio = { version = "1.22.0", features = ["macros"] } +tokio = { version = "1.28.0", features = ["macros"] } quickcheck = { version = "1.0.3", default-features = false } sc-block-builder = { version = "0.10.0-dev", path = "../../block-builder" } sp-test-primitives = { version = "2.0.0", path = "../../../primitives/test-primitives" } diff --git a/client/network/test/Cargo.toml b/client/network/test/Cargo.toml index 8368fa278712a..8f2ee627b8194 100644 --- a/client/network/test/Cargo.toml +++ b/client/network/test/Cargo.toml @@ -13,11 +13,11 @@ repository = "https://github.com/paritytech/substrate/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -tokio = "1.22.0" +tokio = "1.28.0" async-trait = "0.1.57" futures = "0.3.21" futures-timer = "3.0.1" -libp2p = "0.50.0" +libp2p = "0.52.4" log = "0.4.17" parking_lot = "0.12.1" rand = "0.8.5" diff --git a/client/network/transactions/Cargo.toml b/client/network/transactions/Cargo.toml index 3616473d3baed..c60a899d40a07 100644 --- a/client/network/transactions/Cargo.toml +++ b/client/network/transactions/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] array-bytes = "4.1" codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] } futures = "0.3.21" -libp2p = "0.50.0" +libp2p = "0.52.3" log = "0.4.17" pin-project = "1.0.12" prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../../utils/prometheus" } diff --git a/client/network/transactions/src/lib.rs b/client/network/transactions/src/lib.rs index 381dd654b600b..91a34aae41e1d 100644 --- a/client/network/transactions/src/lib.rs +++ b/client/network/transactions/src/lib.rs @@ -329,8 +329,8 @@ where fn handle_sync_event(&mut self, event: SyncEvent) { match event { SyncEvent::PeerConnected(remote) => { - let addr = iter::once(multiaddr::Protocol::P2p(remote.into())) - .collect::(); + let addr = + iter::once(multiaddr::Protocol::P2p(remote)).collect::(); let result = self.network.add_peers_to_reserved_set( self.protocol_name.clone(), iter::once(addr).collect(), diff --git a/client/offchain/Cargo.toml b/client/offchain/Cargo.toml index 0307e3125f3ee..7be1e16568af2 100644 --- a/client/offchain/Cargo.toml +++ b/client/offchain/Cargo.toml @@ -21,7 +21,7 @@ futures = "0.3.21" futures-timer = "3.0.2" hyper = { version = "0.14.16", features = ["stream", "http2"] } hyper-rustls = { version = "0.23.0", features = ["http2"] } -libp2p = "0.50.0" +libp2p = "0.52.4" num_cpus = "1.13" once_cell = "1.8" parking_lot = "0.12.1" @@ -40,7 +40,7 @@ sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" } [dev-dependencies] lazy_static = "1.4.0" -tokio = "1.22.0" +tokio = "1.28.0" sc-block-builder = { version = "0.10.0-dev", path = "../block-builder" } sc-client-db = { version = "0.10.0-dev", default-features = true, path = "../db" } sc-transaction-pool = { version = "4.0.0-dev", path = "../transaction-pool" } diff --git a/client/peerset/Cargo.toml b/client/peerset/Cargo.toml index a09508c831189..1caf931aed8cf 100644 --- a/client/peerset/Cargo.toml +++ b/client/peerset/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] futures = "0.3.21" -libp2p = "0.50.0" +libp2p-identity = { version = "0.2.0", features = ["peerid", "ed25519"] } log = "0.4.17" serde_json = "1.0.85" wasm-timer = "0.2" diff --git a/client/peerset/src/lib.rs b/client/peerset/src/lib.rs index e5393acbaa32f..e169be8e8ed5b 100644 --- a/client/peerset/src/lib.rs +++ b/client/peerset/src/lib.rs @@ -46,7 +46,7 @@ use std::{ }; use wasm_timer::Delay; -pub use libp2p::PeerId; +pub use libp2p_identity::PeerId; /// We don't accept nodes whose reputation is under this value. pub const BANNED_THRESHOLD: i32 = 82 * (i32::MIN / 100); @@ -781,7 +781,7 @@ mod tests { BANNED_THRESHOLD, }; use futures::prelude::*; - use libp2p::PeerId; + use libp2p_identity::PeerId; use std::{pin::Pin, task::Poll, thread, time::Duration}; fn assert_messages(mut peerset: Peerset, messages: Vec) -> Peerset { diff --git a/client/peerset/src/peersstate.rs b/client/peerset/src/peersstate.rs index 84907ac914b45..2d4a9295c24c9 100644 --- a/client/peerset/src/peersstate.rs +++ b/client/peerset/src/peersstate.rs @@ -28,7 +28,7 @@ //! > for example connecting to some nodes in priority should be added outside of this //! > module, rather than inside. -use libp2p::PeerId; +use libp2p_identity::PeerId; use log::error; use std::{ borrow::Cow, @@ -626,7 +626,7 @@ impl<'a> Drop for Reputation<'a> { #[cfg(test)] mod tests { use super::{Peer, PeersState, SetConfig}; - use libp2p::PeerId; + use libp2p_identity::PeerId; use std::iter; #[test] diff --git a/client/peerset/tests/fuzz.rs b/client/peerset/tests/fuzz.rs index 1f4bd053b553a..122f17062577d 100644 --- a/client/peerset/tests/fuzz.rs +++ b/client/peerset/tests/fuzz.rs @@ -17,7 +17,7 @@ // along with this program. If not, see . use futures::prelude::*; -use libp2p::PeerId; +use libp2p_identity::PeerId; use rand::{ distributions::{Distribution, Uniform, WeightedIndex}, seq::IteratorRandom, diff --git a/client/rpc-servers/Cargo.toml b/client/rpc-servers/Cargo.toml index c6228d739048d..8614fb60a8574 100644 --- a/client/rpc-servers/Cargo.toml +++ b/client/rpc-servers/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] jsonrpsee = { version = "0.16.2", features = ["server"] } log = "0.4.17" serde_json = "1.0.85" -tokio = { version = "1.22.0", features = ["parking_lot"] } +tokio = { version = "1.28.0", features = ["parking_lot"] } prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" } tower-http = { version = "0.3.4", features = ["cors"] } tower = "0.4.13" diff --git a/client/rpc-spec-v2/Cargo.toml b/client/rpc-spec-v2/Cargo.toml index 43fb189081bae..b46c3220bc3f2 100644 --- a/client/rpc-spec-v2/Cargo.toml +++ b/client/rpc-spec-v2/Cargo.toml @@ -37,7 +37,7 @@ futures-util = { version = "0.3.19", default-features = false } [dev-dependencies] serde_json = "1.0" -tokio = { version = "1.22.0", features = ["macros"] } +tokio = { version = "1.28.0", features = ["macros"] } substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" } substrate-test-runtime = { version = "2.0.0", path = "../../test-utils/runtime" } sp-consensus = { version = "0.10.0-dev", path = "../../primitives/consensus/common" } diff --git a/client/rpc/Cargo.toml b/client/rpc/Cargo.toml index a22f657878812..9c02f96a4c014 100644 --- a/client/rpc/Cargo.toml +++ b/client/rpc/Cargo.toml @@ -36,7 +36,7 @@ sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" } sp-session = { version = "4.0.0-dev", path = "../../primitives/session" } sp-version = { version = "5.0.0", path = "../../primitives/version" } -tokio = "1.22.0" +tokio = "1.28.0" [dev-dependencies] env_logger = "0.9" @@ -46,7 +46,7 @@ sc-network = { version = "0.10.0-dev", path = "../network" } sc-network-common = { version = "0.10.0-dev", path = "../network/common" } sc-transaction-pool = { version = "4.0.0-dev", path = "../transaction-pool" } sp-consensus = { version = "0.10.0-dev", path = "../../primitives/consensus/common" } -tokio = "1.22.0" +tokio = "1.28.0" sp-io = { version = "7.0.0", path = "../../primitives/io" } substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" } diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index b4ce3bbbb7f1c..ae6447fa8c514 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -77,7 +77,7 @@ sc-storage-monitor = { version = "0.1.0", path = "../storage-monitor" } tracing = "0.1.29" tracing-futures = { version = "0.2.4" } async-trait = "0.1.57" -tokio = { version = "1.22.0", features = ["time", "rt-multi-thread", "parking_lot"] } +tokio = { version = "1.28.0", features = ["time", "rt-multi-thread", "parking_lot"] } tempfile = "3.1.0" directories = "4.0.1" static_init = "1.0.3" diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 54f11ec25a02a..379c2f850eeb7 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -255,7 +255,7 @@ async fn build_system_rpc_future< let _ = sender.send(network_service.local_peer_id().to_base58()); }, sc_rpc::system::Request::LocalListenAddresses(sender) => { - let peer_id = (network_service.local_peer_id()).into(); + let peer_id = network_service.local_peer_id(); let p2p_proto_suffix = sc_network::multiaddr::Protocol::P2p(peer_id); let addresses = network_service .listen_addresses() diff --git a/client/service/test/Cargo.toml b/client/service/test/Cargo.toml index 94a844aa7dc0d..3d6f7caedda29 100644 --- a/client/service/test/Cargo.toml +++ b/client/service/test/Cargo.toml @@ -20,7 +20,7 @@ log = "0.4.17" parity-scale-codec = "3.2.2" parking_lot = "0.12.1" tempfile = "3.1.0" -tokio = { version = "1.22.0", features = ["time"] } +tokio = { version = "1.28.0", features = ["time"] } sc-block-builder = { version = "0.10.0-dev", path = "../../block-builder" } sc-client-api = { version = "4.0.0-dev", path = "../../api" } sc-client-db = { version = "0.10.0-dev", default-features = false, path = "../../db" } diff --git a/client/storage-monitor/Cargo.toml b/client/storage-monitor/Cargo.toml index 52f34a2967654..7c1c4337db9c2 100644 --- a/client/storage-monitor/Cargo.toml +++ b/client/storage-monitor/Cargo.toml @@ -16,5 +16,5 @@ fs4 = "0.6.3" sc-client-db = { version = "0.10.0-dev", default-features = false, path = "../db" } sc-utils = { version = "4.0.0-dev", path = "../utils" } sp-core = { version = "7.0.0", path = "../../primitives/core" } -tokio = "1.22.0" +tokio = "1.28.0" thiserror = "1.0.30" diff --git a/client/telemetry/Cargo.toml b/client/telemetry/Cargo.toml index 4d09a28370e6d..2f34cb4b37ea3 100644 --- a/client/telemetry/Cargo.toml +++ b/client/telemetry/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] chrono = "0.4.19" futures = "0.3.21" -libp2p = { version = "0.50.0", features = ["dns", "tcp", "tokio", "wasm-ext", "websocket"] } +libp2p = { version = "0.52.4", features = ["dns", "tcp", "tokio", "wasm-ext", "websocket"] } log = "0.4.17" parking_lot = "0.12.1" pin-project = "1.0.12" diff --git a/client/telemetry/src/transport.rs b/client/telemetry/src/transport.rs index a82626caac2d3..ca6ceecbed63b 100644 --- a/client/telemetry/src/transport.rs +++ b/client/telemetry/src/transport.rs @@ -31,7 +31,7 @@ const CONNECT_TIMEOUT: Duration = Duration::from_secs(20); pub(crate) fn initialize_transport() -> Result { let transport = { let tcp_transport = libp2p::tcp::tokio::Transport::new(libp2p::tcp::Config::new()); - let inner = libp2p::dns::TokioDnsConfig::system(tcp_transport)?; + let inner = libp2p::dns::tokio::Transport::system(tcp_transport)?; libp2p::websocket::framed::WsConfig::new(inner).and_then(|connec, _| { let connec = connec .with(|item| { diff --git a/frame/babe/src/lib.rs b/frame/babe/src/lib.rs index 61284267b07e7..5848f56469145 100644 --- a/frame/babe/src/lib.rs +++ b/frame/babe/src/lib.rs @@ -45,7 +45,7 @@ use sp_session::{GetSessionNumber, GetValidatorCount}; use sp_staking::{offence::OffenceReportSystem, SessionIndex}; use sp_std::prelude::*; -pub use sp_consensus_babe::{AuthorityId, PUBLIC_KEY_LENGTH, RANDOMNESS_LENGTH, VRF_OUTPUT_LENGTH}; +pub use sp_consensus_babe::{AuthorityId, PUBLIC_KEY_LENGTH, RANDOMNESS_LENGTH, VRF_PREOUT_LENGTH}; const LOG_TARGET: &str = "runtime::babe"; @@ -995,7 +995,7 @@ fn compute_randomness( rho: impl Iterator, rho_size_hint: Option, ) -> schnorrkel::Randomness { - let mut s = Vec::with_capacity(40 + rho_size_hint.unwrap_or(0) * VRF_OUTPUT_LENGTH); + let mut s = Vec::with_capacity(40 + rho_size_hint.unwrap_or(0) * VRF_PREOUT_LENGTH); s.extend_from_slice(&last_epoch_randomness); s.extend_from_slice(&epoch_index.to_le_bytes()); diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 9b832bfffdb69..03b227b39cbde 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -26,7 +26,7 @@ use frame_support::{ }; use pallet_session::historical as pallet_session_historical; use sp_consensus_babe::{AuthorityId, AuthorityPair, Slot}; -use sp_consensus_vrf::schnorrkel::{VRFOutput, VRFProof}; +use sp_consensus_vrf::schnorrkel::{VRFPreOut, VRFProof}; use sp_core::{ crypto::{IsWrappedBy, KeyTypeId, Pair}, H256, U256, @@ -279,7 +279,7 @@ pub fn start_era(era_index: EraIndex) { pub fn make_primary_pre_digest( authority_index: sp_consensus_babe::AuthorityIndex, slot: sp_consensus_babe::Slot, - vrf_output: VRFOutput, + vrf_output: VRFPreOut, vrf_proof: VRFProof, ) -> Digest { let digest_data = sp_consensus_babe::digests::PreDigest::Primary( @@ -308,7 +308,7 @@ pub fn make_secondary_plain_pre_digest( pub fn make_secondary_vrf_pre_digest( authority_index: sp_consensus_babe::AuthorityIndex, slot: sp_consensus_babe::Slot, - vrf_output: VRFOutput, + vrf_output: VRFPreOut, vrf_proof: VRFProof, ) -> Digest { let digest_data = sp_consensus_babe::digests::PreDigest::SecondaryVRF( @@ -326,13 +326,13 @@ pub fn make_secondary_vrf_pre_digest( pub fn make_vrf_output( slot: Slot, pair: &sp_consensus_babe::AuthorityPair, -) -> (VRFOutput, VRFProof, [u8; 32]) { +) -> (VRFPreOut, VRFProof, [u8; 32]) { let pair = sp_core::sr25519::Pair::from_ref(pair).as_ref(); let transcript = sp_consensus_babe::make_transcript(&Babe::randomness(), slot, 0); let vrf_inout = pair.vrf_sign(transcript); let vrf_randomness: sp_consensus_vrf::schnorrkel::Randomness = vrf_inout.0.make_bytes::<[u8; 32]>(&sp_consensus_babe::BABE_VRF_INOUT_CONTEXT); - let vrf_output = VRFOutput(vrf_inout.0.to_output()); + let vrf_output = VRFPreOut(vrf_inout.0.to_preout()); let vrf_proof = VRFProof(vrf_inout.1); (vrf_output, vrf_proof, vrf_randomness) diff --git a/frame/babe/src/randomness.rs b/frame/babe/src/randomness.rs index b223df6804c0b..ec89df97f2ec2 100644 --- a/frame/babe/src/randomness.rs +++ b/frame/babe/src/randomness.rs @@ -19,7 +19,7 @@ //! randomness collected from VRF outputs. use super::{ - AuthorVrfRandomness, Config, EpochStart, NextRandomness, Randomness, VRF_OUTPUT_LENGTH, + AuthorVrfRandomness, Config, EpochStart, NextRandomness, Randomness, VRF_PREOUT_LENGTH, }; use frame_support::traits::Randomness as RandomnessT; use sp_runtime::traits::{Hash, One, Saturating}; @@ -132,7 +132,7 @@ pub struct CurrentBlockRandomness(sp_std::marker::PhantomData); impl RandomnessT for RandomnessFromTwoEpochsAgo { fn random(subject: &[u8]) -> (T::Hash, T::BlockNumber) { let mut subject = subject.to_vec(); - subject.reserve(VRF_OUTPUT_LENGTH); + subject.reserve(VRF_PREOUT_LENGTH); subject.extend_from_slice(&Randomness::::get()[..]); (T::Hashing::hash(&subject[..]), EpochStart::::get().0) @@ -142,7 +142,7 @@ impl RandomnessT for RandomnessFromTwoEpochs impl RandomnessT for RandomnessFromOneEpochAgo { fn random(subject: &[u8]) -> (T::Hash, T::BlockNumber) { let mut subject = subject.to_vec(); - subject.reserve(VRF_OUTPUT_LENGTH); + subject.reserve(VRF_PREOUT_LENGTH); subject.extend_from_slice(&NextRandomness::::get()[..]); (T::Hashing::hash(&subject[..]), EpochStart::::get().1) @@ -153,7 +153,7 @@ impl RandomnessT, T::BlockNumber> for ParentBlockRand fn random(subject: &[u8]) -> (Option, T::BlockNumber) { let random = AuthorVrfRandomness::::get().map(|random| { let mut subject = subject.to_vec(); - subject.reserve(VRF_OUTPUT_LENGTH); + subject.reserve(VRF_PREOUT_LENGTH); subject.extend_from_slice(&random); T::Hashing::hash(&subject[..]) diff --git a/frame/babe/src/tests.rs b/frame/babe/src/tests.rs index 8b63f41b37b74..f8dade638c1f3 100644 --- a/frame/babe/src/tests.rs +++ b/frame/babe/src/tests.rs @@ -26,7 +26,7 @@ use frame_support::{ use mock::*; use pallet_session::ShouldEndSession; use sp_consensus_babe::{AllowedSlots, BabeEpochConfiguration, Slot}; -use sp_consensus_vrf::schnorrkel::{VRFOutput, VRFProof}; +use sp_consensus_vrf::schnorrkel::{VRFPreOut, VRFProof}; use sp_core::crypto::Pair; const EMPTY_RANDOMNESS: [u8; 32] = [ @@ -134,7 +134,7 @@ fn current_slot_is_processed_on_initialization() { fn test_author_vrf_output(make_pre_digest: F) where - F: Fn(sp_consensus_babe::AuthorityIndex, Slot, VRFOutput, VRFProof) -> sp_runtime::Digest, + F: Fn(sp_consensus_babe::AuthorityIndex, Slot, VRFPreOut, VRFProof) -> sp_runtime::Digest, { let (pairs, mut ext) = new_test_ext_with_pairs(1); diff --git a/frame/state-trie-migration/Cargo.toml b/frame/state-trie-migration/Cargo.toml index 36b5912a60302..6c595eed3b815 100644 --- a/frame/state-trie-migration/Cargo.toml +++ b/frame/state-trie-migration/Cargo.toml @@ -30,7 +30,7 @@ substrate-state-trie-migration-rpc = { optional = true, path = "../../utils/fram [dev-dependencies] parking_lot = "0.12.1" -tokio = { version = "1.22.0", features = ["macros"] } +tokio = { version = "1.28.0", features = ["macros"] } pallet-balances = { path = "../balances" } sp-tracing = { path = "../../primitives/tracing" } diff --git a/frame/support/Cargo.toml b/frame/support/Cargo.toml index 008d4b3f26015..a9a12b4022760 100644 --- a/frame/support/Cargo.toml +++ b/frame/support/Cargo.toml @@ -34,10 +34,10 @@ once_cell = { version = "1", default-features = false, optional = true } sp-state-machine = { version = "0.13.0", default-features = false, optional = true, path = "../../primitives/state-machine" } bitflags = "1.3" impl-trait-for-tuples = "0.2.2" -smallvec = "1.8.0" +smallvec = "1.11.0" log = { version = "0.4.17", default-features = false } sp-core-hashing-proc-macro = { version = "5.0.0", path = "../../primitives/core/hashing/proc-macro" } -k256 = { version = "0.11.5", default-features = false, features = ["ecdsa"] } +k256 = { version = "0.13.1", default-features = false, features = ["ecdsa"] } environmental = { version = "1.1.4", default-features = false } [dev-dependencies] diff --git a/primitives/consensus/babe/Cargo.toml b/primitives/consensus/babe/Cargo.toml index 334fff2811941..bf1ec9aafcf60 100644 --- a/primitives/consensus/babe/Cargo.toml +++ b/primitives/consensus/babe/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] async-trait = { version = "0.1.57", optional = true } codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } -merlin = { version = "2.0", default-features = false } +merlin = { version = "3.0", default-features = false } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", features = ["derive"], optional = true } sp-api = { version = "4.0.0-dev", default-features = false, path = "../../api" } diff --git a/primitives/consensus/babe/src/digests.rs b/primitives/consensus/babe/src/digests.rs index 4364057a4b478..ec83594845ccd 100644 --- a/primitives/consensus/babe/src/digests.rs +++ b/primitives/consensus/babe/src/digests.rs @@ -26,7 +26,7 @@ use scale_info::TypeInfo; use sp_runtime::{DigestItem, RuntimeDebug}; use sp_std::vec::Vec; -use sp_consensus_vrf::schnorrkel::{Randomness, VRFOutput, VRFProof}; +use sp_consensus_vrf::schnorrkel::{Randomness, VRFPreOut, VRFProof}; /// Raw BABE primary slot assignment pre-digest. #[derive(Clone, RuntimeDebug, Encode, Decode, MaxEncodedLen, TypeInfo)] @@ -36,7 +36,7 @@ pub struct PrimaryPreDigest { /// Slot pub slot: Slot, /// VRF output - pub vrf_output: VRFOutput, + pub vrf_output: VRFPreOut, /// VRF proof pub vrf_proof: VRFProof, } @@ -63,7 +63,7 @@ pub struct SecondaryVRFPreDigest { /// Slot pub slot: Slot, /// VRF output - pub vrf_output: VRFOutput, + pub vrf_output: VRFPreOut, /// VRF proof pub vrf_proof: VRFProof, } @@ -118,7 +118,7 @@ impl PreDigest { } /// Returns the VRF output and proof, if they exist. - pub fn vrf(&self) -> Option<(&VRFOutput, &VRFProof)> { + pub fn vrf(&self) -> Option<(&VRFPreOut, &VRFProof)> { match self { PreDigest::Primary(primary) => Some((&primary.vrf_output, &primary.vrf_proof)), PreDigest::SecondaryVRF(secondary) => diff --git a/primitives/consensus/babe/src/lib.rs b/primitives/consensus/babe/src/lib.rs index e7747ac4c204a..da5dc91892e08 100644 --- a/primitives/consensus/babe/src/lib.rs +++ b/primitives/consensus/babe/src/lib.rs @@ -25,7 +25,7 @@ pub mod inherents; pub use merlin::Transcript; pub use sp_consensus_vrf::schnorrkel::{ - Randomness, RANDOMNESS_LENGTH, VRF_OUTPUT_LENGTH, VRF_PROOF_LENGTH, + Randomness, RANDOMNESS_LENGTH, VRF_PREOUT_LENGTH, VRF_PROOF_LENGTH, }; use codec::{Decode, Encode, MaxEncodedLen}; @@ -355,7 +355,7 @@ pub struct Epoch { /// The authorities and their weights. pub authorities: Vec<(AuthorityId, BabeAuthorityWeight)>, /// Randomness for this epoch. - pub randomness: [u8; VRF_OUTPUT_LENGTH], + pub randomness: [u8; VRF_PREOUT_LENGTH], /// Configuration of the epoch. pub config: BabeEpochConfiguration, } diff --git a/primitives/consensus/vrf/Cargo.toml b/primitives/consensus/vrf/Cargo.toml index a4f92c30cca03..6428842b8e213 100644 --- a/primitives/consensus/vrf/Cargo.toml +++ b/primitives/consensus/vrf/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false } scale-info = { version = "2.1.1", default-features = false } -schnorrkel = { version = "0.9.1", default-features = false, features = ["preaudit_deprecated", "u64_backend"] } +schnorrkel = { version = "0.11.4", default-features = false, features = ["preaudit_deprecated"] } sp-core = { version = "7.0.0", default-features = false, path = "../../core" } sp-runtime = { version = "7.0.0", default-features = false, path = "../../runtime" } sp-std = { version = "5.0.0", default-features = false, path = "../../std" } diff --git a/primitives/consensus/vrf/src/schnorrkel.rs b/primitives/consensus/vrf/src/schnorrkel.rs index be145c5b12096..5f3fd14117eb5 100644 --- a/primitives/consensus/vrf/src/schnorrkel.rs +++ b/primitives/consensus/vrf/src/schnorrkel.rs @@ -27,64 +27,64 @@ use sp_std::{ }; pub use schnorrkel::{ - vrf::{VRF_OUTPUT_LENGTH, VRF_PROOF_LENGTH}, + vrf::{VRF_PREOUT_LENGTH, VRF_PROOF_LENGTH}, PublicKey, SignatureError, }; /// The length of the Randomness. -pub const RANDOMNESS_LENGTH: usize = VRF_OUTPUT_LENGTH; +pub const RANDOMNESS_LENGTH: usize = VRF_PREOUT_LENGTH; /// VRF output type available for `std` environment, suitable for schnorrkel operations. #[derive(Clone, Debug, PartialEq, Eq)] -pub struct VRFOutput(pub schnorrkel::vrf::VRFOutput); +pub struct VRFPreOut(pub schnorrkel::vrf::VRFPreOut); -impl Deref for VRFOutput { - type Target = schnorrkel::vrf::VRFOutput; +impl Deref for VRFPreOut { + type Target = schnorrkel::vrf::VRFPreOut; fn deref(&self) -> &Self::Target { &self.0 } } -impl DerefMut for VRFOutput { +impl DerefMut for VRFPreOut { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } -impl Encode for VRFOutput { +impl Encode for VRFPreOut { fn encode(&self) -> Vec { self.0.as_bytes().encode() } } -impl EncodeLike for VRFOutput {} +impl EncodeLike for VRFPreOut {} -impl Decode for VRFOutput { +impl Decode for VRFPreOut { fn decode(i: &mut R) -> Result { - let decoded = <[u8; VRF_OUTPUT_LENGTH]>::decode(i)?; - Ok(Self(schnorrkel::vrf::VRFOutput::from_bytes(&decoded).map_err(convert_error)?)) + let decoded = <[u8; VRF_PREOUT_LENGTH]>::decode(i)?; + Ok(Self(schnorrkel::vrf::VRFPreOut::from_bytes(&decoded).map_err(convert_error)?)) } } -impl MaxEncodedLen for VRFOutput { +impl MaxEncodedLen for VRFPreOut { fn max_encoded_len() -> usize { - <[u8; VRF_OUTPUT_LENGTH]>::max_encoded_len() + <[u8; VRF_PREOUT_LENGTH]>::max_encoded_len() } } -impl TypeInfo for VRFOutput { - type Identity = [u8; VRF_OUTPUT_LENGTH]; +impl TypeInfo for VRFPreOut { + type Identity = [u8; VRF_PREOUT_LENGTH]; fn type_info() -> scale_info::Type { Self::Identity::type_info() } } -impl TryFrom<[u8; VRF_OUTPUT_LENGTH]> for VRFOutput { +impl TryFrom<[u8; VRF_PREOUT_LENGTH]> for VRFPreOut { type Error = SignatureError; - fn try_from(raw: [u8; VRF_OUTPUT_LENGTH]) -> Result { - schnorrkel::vrf::VRFOutput::from_bytes(&raw).map(VRFOutput) + fn try_from(raw: [u8; VRF_PREOUT_LENGTH]) -> Result { + schnorrkel::vrf::VRFPreOut::from_bytes(&raw).map(VRFPreOut) } } @@ -162,6 +162,7 @@ fn convert_error(e: SignatureError) -> codec::Error { PointDecompressionError => "Signature error: `PointDecompressionError`".into(), ScalarFormatError => "Signature error: `ScalarFormatError`".into(), NotMarkedSchnorrkel => "Signature error: `NotMarkedSchnorrkel`".into(), + InvalidKey => "Signature error: `InvalidKey`".into(), BytesLengthError { .. } => "Signature error: `BytesLengthError`".into(), MuSigAbsent { musig_stage: Commitment } => "Signature error: `MuSigAbsent` at stage `Commitment`".into(), @@ -184,5 +185,5 @@ fn convert_error(e: SignatureError) -> codec::Error { } } -/// Schnorrkel randomness value. Same size as `VRFOutput`. +/// Schnorrkel randomness value. Same size as `VRFPreOut`. pub type Randomness = [u8; RANDOMNESS_LENGTH]; diff --git a/primitives/core/Cargo.toml b/primitives/core/Cargo.toml index 092baeeda95f8..63bdaf3513ca7 100644 --- a/primitives/core/Cargo.toml +++ b/primitives/core/Cargo.toml @@ -27,7 +27,7 @@ hash-db = { version = "0.16.0", default-features = false } hash256-std-hasher = { version = "0.15.2", default-features = false } base58 = { version = "0.2.0", optional = true } rand = { version = "0.8.5", features = ["small_rng"], optional = true } -substrate-bip39 = { version = "0.4.4", optional = true } +substrate-bip39 = { version = "0.4.6", optional = true } tiny-bip39 = { version = "1.0.0", optional = true } regex = { version = "1.6.0", optional = true } zeroize = { version = "1.4.3", default-features = false } @@ -45,14 +45,13 @@ bitflags = "1.3" # full crypto array-bytes = { version = "4.1", optional = true } -ed25519-zebra = { version = "3.1.0", default-features = false, optional = true } +ed25519-zebra = { version = "4.0.3", default-features = false, optional = true } blake2 = { version = "0.10.4", default-features = false, optional = true } -schnorrkel = { version = "0.9.1", features = [ +schnorrkel = { version = "0.11.4", features = [ "preaudit_deprecated", - "u64_backend", ], default-features = false, optional = true } libsecp256k1 = { version = "0.7", default-features = false, features = ["static-context"], optional = true } -merlin = { version = "2.0", default-features = false, optional = true } +merlin = { version = "3.0", default-features = false, optional = true } secp256k1 = { version = "0.24.0", default-features = false, features = ["recovery", "alloc"], optional = true } ss58-registry = { version = "1.34.0", default-features = false } sp-core-hashing = { version = "5.0.0", path = "./hashing", default-features = false, optional = true } diff --git a/primitives/core/hashing/Cargo.toml b/primitives/core/hashing/Cargo.toml index a77aaaa7aebc6..d01ef7cb02e99 100644 --- a/primitives/core/hashing/Cargo.toml +++ b/primitives/core/hashing/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] blake2b_simd = { version = "1.0.1", default-features = false } byteorder = { version = "1.3.2", default-features = false } digest = { version = "0.10.3", default-features = false } -sha2 = { version = "0.10.2", default-features = false } +sha2 = { version = "0.10.7", default-features = false } sha3 = { version = "0.10.0", default-features = false } twox-hash = { version = "1.6.3", default-features = false, features = ["digest_0_10"] } sp-std = { version = "5.0.0", default-features = false, path = "../../std" } diff --git a/primitives/io/Cargo.toml b/primitives/io/Cargo.toml index e56bfcf56041a..c3c35bf7e8a94 100644 --- a/primitives/io/Cargo.toml +++ b/primitives/io/Cargo.toml @@ -33,9 +33,7 @@ tracing = { version = "0.1.29", default-features = false } tracing-core = { version = "0.1.28", default-features = false} # Required for backwards compatibility reason, but only used for verifying when `UseDalekExt` is set. -ed25519-dalek = { version = "1.0.1", default-features = false, optional = true } -# Force the usage of ed25519, this is being used in `ed25519-dalek`. -ed25519 = { version = "1.5.2", optional = true } +ed25519-dalek = { version = "2.1", default-features = false, optional = true } [features] default = ["std"] @@ -57,7 +55,6 @@ std = [ "log", "futures", "ed25519-dalek", - "ed25519", ] with-tracing = [ diff --git a/primitives/io/src/lib.rs b/primitives/io/src/lib.rs index 8c3cdc668cba3..b2ec0a72a89f7 100644 --- a/primitives/io/src/lib.rs +++ b/primitives/io/src/lib.rs @@ -783,13 +783,11 @@ pub trait Crypto { { use ed25519_dalek::Verifier; - let Ok(public_key) = ed25519_dalek::PublicKey::from_bytes(&pub_key.0) else { + let Ok(public_key) = ed25519_dalek::VerifyingKey::from_bytes(&pub_key.0) else { return false }; - let Ok(sig) = ed25519_dalek::Signature::from_bytes(&sig.0) else { - return false - }; + let sig = ed25519_dalek::Signature::from_bytes(&sig.0); public_key.verify(msg, &sig).is_ok() } else { diff --git a/primitives/keystore/Cargo.toml b/primitives/keystore/Cargo.toml index 9386cb5d104d2..f8ee55495441f 100644 --- a/primitives/keystore/Cargo.toml +++ b/primitives/keystore/Cargo.toml @@ -16,9 +16,9 @@ targets = ["x86_64-unknown-linux-gnu"] async-trait = "0.1.57" codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } futures = "0.3.21" -merlin = { version = "2.0", default-features = false } +merlin = { version = "3.0", default-features = false } parking_lot = { version = "0.12.1", default-features = false } -schnorrkel = { version = "0.9.1", default-features = false, features = ["preaudit_deprecated", "u64_backend"] } +schnorrkel = { version = "0.11.4", default-features = false, features = ["preaudit_deprecated"] } serde = { version = "1.0", optional = true } thiserror = "1.0" sp-core = { version = "7.0.0", default-features = false, path = "../core" } diff --git a/primitives/keystore/src/lib.rs b/primitives/keystore/src/lib.rs index 17c435483bae5..8397cccf1f866 100644 --- a/primitives/keystore/src/lib.rs +++ b/primitives/keystore/src/lib.rs @@ -177,7 +177,7 @@ pub trait CryptoStore: Send + Sync { /// is, in turn, used for signing the provided transcript. /// /// Returns a result containing the signature data. - /// Namely, VRFOutput and VRFProof which are returned + /// Namely, VRFPreOut and VRFProof which are returned /// inside the `VRFSignature` container struct. /// /// This function will return `None` if the given `key_type` and `public` combination @@ -352,7 +352,7 @@ pub trait SyncCryptoStore: CryptoStore + Send + Sync { /// is, in turn, used for signing the provided transcript. /// /// Returns a result containing the signature data. - /// Namely, VRFOutput and VRFProof which are returned + /// Namely, VRFPreOut and VRFProof which are returned /// inside the `VRFSignature` container struct. /// /// This function will return `None` if the given `key_type` and `public` combination diff --git a/primitives/keystore/src/testing.rs b/primitives/keystore/src/testing.rs index 5058a06508eac..9fbf86d3bb005 100644 --- a/primitives/keystore/src/testing.rs +++ b/primitives/keystore/src/testing.rs @@ -372,7 +372,7 @@ impl SyncCryptoStore for KeyStore { if let Some(k) = self.sr25519_key_pair(key_type, public) { k } else { return Ok(None) }; let (inout, proof, _) = pair.as_ref().vrf_sign(transcript); - Ok(Some(VRFSignature { output: inout.to_output(), proof })) + Ok(Some(VRFSignature { output: inout.to_preout(), proof })) } fn ecdsa_sign_prehashed( diff --git a/primitives/keystore/src/vrf.rs b/primitives/keystore/src/vrf.rs index e089336c1485b..f105392a0fd14 100644 --- a/primitives/keystore/src/vrf.rs +++ b/primitives/keystore/src/vrf.rs @@ -19,7 +19,7 @@ use codec::Encode; use merlin::Transcript; -use schnorrkel::vrf::{VRFOutput, VRFProof}; +use schnorrkel::vrf::{VRFPreOut, VRFProof}; /// An enum whose variants represent possible /// accepted values to construct the VRF transcript @@ -41,8 +41,8 @@ pub struct VRFTranscriptData { } /// VRF signature data pub struct VRFSignature { - /// The VRFOutput serialized - pub output: VRFOutput, + /// The VRFPreOut serialized + pub output: VRFPreOut, /// The calculated VRFProof pub proof: VRFProof, } diff --git a/primitives/state-machine/Cargo.toml b/primitives/state-machine/Cargo.toml index 9759547d7f384..ffb622dd90b2e 100644 --- a/primitives/state-machine/Cargo.toml +++ b/primitives/state-machine/Cargo.toml @@ -19,7 +19,7 @@ hash-db = { version = "0.16.0", default-features = false } log = { version = "0.4.17", default-features = false } parking_lot = { version = "0.12.1", optional = true } rand = { version = "0.8.5", optional = true } -smallvec = "1.8.0" +smallvec = "1.11.0" thiserror = { version = "1.0.30", optional = true } tracing = { version = "0.1.29", optional = true } sp-core = { version = "7.0.0", default-features = false, path = "../core" } diff --git a/primitives/weights/Cargo.toml b/primitives/weights/Cargo.toml index 2368b913b3b2f..199df90e46c20 100644 --- a/primitives/weights/Cargo.toml +++ b/primitives/weights/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.1.1", default-features = false, features = ["derive"] } serde = { version = "1.0.136", optional = true, features = ["derive"] } -smallvec = "1.8.0" +smallvec = "1.11.0" sp-arithmetic = { version = "6.0.0", default-features = false, path = "../arithmetic" } sp-core = { version = "7.0.0", default-features = false, path = "../core" } sp-debug-derive = { version = "5.0.0", default-features = false, path = "../debug-derive" } diff --git a/test-utils/Cargo.toml b/test-utils/Cargo.toml index 1b98b23e0b254..1563f25f7eeb8 100644 --- a/test-utils/Cargo.toml +++ b/test-utils/Cargo.toml @@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] futures = "0.3.16" -tokio = { version = "1.22.0", features = ["macros", "time"] } +tokio = { version = "1.28.0", features = ["macros", "time"] } substrate-test-utils-derive = { version = "0.10.0-dev", path = "./derive" } [dev-dependencies] diff --git a/test-utils/test-crate/Cargo.toml b/test-utils/test-crate/Cargo.toml index 67966dd2b6015..c790b7a2207f9 100644 --- a/test-utils/test-crate/Cargo.toml +++ b/test-utils/test-crate/Cargo.toml @@ -12,6 +12,6 @@ publish = false targets = ["x86_64-unknown-linux-gnu"] [dev-dependencies] -tokio = { version = "1.22.0", features = ["macros"] } +tokio = { version = "1.28.0", features = ["macros"] } sc-service = { version = "0.10.0-dev", path = "../../client/service" } test-utils = { package = "substrate-test-utils", version = "4.0.0-dev", path = ".." } diff --git a/utils/frame/remote-externalities/Cargo.toml b/utils/frame/remote-externalities/Cargo.toml index 8611ae4980f12..e1937102192a2 100644 --- a/utils/frame/remote-externalities/Cargo.toml +++ b/utils/frame/remote-externalities/Cargo.toml @@ -19,7 +19,7 @@ frame-support = { version = "4.0.0-dev", optional = true, path = "../../../frame sp-core = { version = "7.0.0", path = "../../../primitives/core" } sp-io = { version = "7.0.0", path = "../../../primitives/io" } sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" } -tokio = { version = "1.22.0", features = ["macros", "rt-multi-thread"] } +tokio = { version = "1.28.0", features = ["macros", "rt-multi-thread"] } substrate-rpc-client = { path = "../rpc/client" } futures = "0.3" diff --git a/utils/frame/rpc/client/Cargo.toml b/utils/frame/rpc/client/Cargo.toml index ee9982971cee3..34282cb543dfd 100644 --- a/utils/frame/rpc/client/Cargo.toml +++ b/utils/frame/rpc/client/Cargo.toml @@ -20,5 +20,5 @@ sp-runtime = { version = "7.0.0", path = "../../../../primitives/runtime" } log = "0.4" [dev-dependencies] -tokio = { version = "1.22.0", features = ["macros", "rt-multi-thread", "sync"] } +tokio = { version = "1.28.0", features = ["macros", "rt-multi-thread", "sync"] } sp-core = { path = "../../../../primitives/core" } diff --git a/utils/frame/rpc/support/Cargo.toml b/utils/frame/rpc/support/Cargo.toml index d75d3a5af5da4..5b390fb5d1624 100644 --- a/utils/frame/rpc/support/Cargo.toml +++ b/utils/frame/rpc/support/Cargo.toml @@ -25,7 +25,7 @@ sp-storage = { version = "7.0.0", path = "../../../../primitives/storage" } [dev-dependencies] scale-info = "2.1.1" jsonrpsee = { version = "0.16.2", features = ["ws-client", "jsonrpsee-types"] } -tokio = "1.22.0" +tokio = "1.28.0" sp-core = { version = "7.0.0", path = "../../../../primitives/core" } sp-runtime = { version = "7.0.0", path = "../../../../primitives/runtime" } frame-system = { version = "4.0.0-dev", path = "../../../../frame/system" } diff --git a/utils/frame/rpc/system/Cargo.toml b/utils/frame/rpc/system/Cargo.toml index b6848ceb2911e..a8ea762308828 100644 --- a/utils/frame/rpc/system/Cargo.toml +++ b/utils/frame/rpc/system/Cargo.toml @@ -28,7 +28,7 @@ sp-runtime = { version = "7.0.0", path = "../../../../primitives/runtime" } [dev-dependencies] sc-transaction-pool = { version = "4.0.0-dev", path = "../../../../client/transaction-pool" } -tokio = "1.22.0" +tokio = "1.28.0" assert_matches = "1.3.0" sp-tracing = { version = "6.0.0", path = "../../../../primitives/tracing" } substrate-test-runtime-client = { version = "2.0.0", path = "../../../../test-utils/runtime/client" } diff --git a/utils/frame/try-runtime/cli/Cargo.toml b/utils/frame/try-runtime/cli/Cargo.toml index a220289542464..66515c66f92d0 100644 --- a/utils/frame/try-runtime/cli/Cargo.toml +++ b/utils/frame/try-runtime/cli/Cargo.toml @@ -45,7 +45,7 @@ serde_json = "1.0.85" zstd = { version = "0.11.2", default-features = false } [dev-dependencies] -tokio = "1.22.0" +tokio = "1.28.0" [features] try-runtime = [ diff --git a/utils/prometheus/Cargo.toml b/utils/prometheus/Cargo.toml index e84a6f4b30341..ff5ac0c72a68f 100644 --- a/utils/prometheus/Cargo.toml +++ b/utils/prometheus/Cargo.toml @@ -17,8 +17,8 @@ hyper = { version = "0.14.16", default-features = false, features = ["http1", "s log = "0.4.17" prometheus = { version = "0.13.0", default-features = false } thiserror = "1.0" -tokio = { version = "1.22.0", features = ["parking_lot"] } +tokio = { version = "1.28.0", features = ["parking_lot"] } [dev-dependencies] hyper = { version = "0.14.16", features = ["client"] } -tokio = { version = "1.22.0", features = ["rt-multi-thread"] } +tokio = { version = "1.28.0", features = ["rt-multi-thread"] }