mirror of
https://github.com/serai-dex/serai.git
synced 2025-03-12 09:26:51 +00:00
libp2p 0.52.4
Adds several packages into tree, deprecates an API we use. This commit does update accordingly. While this may not be preferable, it is inevitable.
This commit is contained in:
parent
a29c410caf
commit
057c3b7cf1
2 changed files with 162 additions and 46 deletions
176
Cargo.lock
generated
176
Cargo.lock
generated
|
@ -343,6 +343,17 @@ dependencies = [
|
|||
"pin-project-lite 0.2.13",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "attohttpc"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d9a9bf8b79a749ee0b911b91b671cc2b6c670bdbc7e3dfd537576ddc94bb2a2"
|
||||
dependencies = [
|
||||
"http",
|
||||
"log",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "auto_impl"
|
||||
version = "1.1.0"
|
||||
|
@ -2028,6 +2039,18 @@ dependencies = [
|
|||
"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.38",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.10.0"
|
||||
|
@ -2895,6 +2918,16 @@ 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.28"
|
||||
|
@ -3512,6 +3545,25 @@ dependencies = [
|
|||
"windows 0.51.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "igd-next"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57e065e90a518ab5fedf79aa1e4b784e10f8e484a834f6bda85c42633a2cb7af"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"attohttpc",
|
||||
"bytes",
|
||||
"futures",
|
||||
"http",
|
||||
"hyper",
|
||||
"log",
|
||||
"rand",
|
||||
"tokio",
|
||||
"url",
|
||||
"xmltree",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "impl-codec"
|
||||
version = "0.6.0"
|
||||
|
@ -3966,11 +4018,12 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
|
|||
|
||||
[[package]]
|
||||
name = "libp2p"
|
||||
version = "0.52.3"
|
||||
version = "0.52.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32d07d1502a027366d55afe187621c2d7895dc111a3df13b35fed698049681d7"
|
||||
checksum = "e94495eb319a85b70a68b85e2389a95bb3555c71c49025b78c691a854a7e6464"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"either",
|
||||
"futures",
|
||||
"futures-timer",
|
||||
"getrandom",
|
||||
|
@ -3991,11 +4044,14 @@ dependencies = [
|
|||
"libp2p-request-response",
|
||||
"libp2p-swarm",
|
||||
"libp2p-tcp",
|
||||
"libp2p-upnp",
|
||||
"libp2p-wasm-ext",
|
||||
"libp2p-websocket",
|
||||
"libp2p-yamux",
|
||||
"multiaddr",
|
||||
"pin-project",
|
||||
"rw-stream-sink",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -4052,10 +4108,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libp2p-dns"
|
||||
version = "0.40.0"
|
||||
version = "0.40.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd4394c81c0c06d7b4a60f3face7e8e8a9b246840f98d2c80508d0721b032147"
|
||||
checksum = "e6a18db73084b4da2871438f6239fef35190b05023de7656e877c18a00541a3b"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"futures",
|
||||
"libp2p-core",
|
||||
"libp2p-identity",
|
||||
|
@ -4067,9 +4124,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libp2p-gossipsub"
|
||||
version = "0.45.1"
|
||||
version = "0.45.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d157562dba6017193e5285acf6b1054759e83540bfd79f75b69d6ce774c88da"
|
||||
checksum = "f1f9624e2a843b655f1c1b8262b8d5de6f309413fca4d66f01bb0662429f84dc"
|
||||
dependencies = [
|
||||
"asynchronous-codec",
|
||||
"base64 0.21.4",
|
||||
|
@ -4099,13 +4156,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libp2p-identify"
|
||||
version = "0.43.0"
|
||||
version = "0.43.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a29675a32dbcc87790db6cf599709e64308f1ae9d5ecea2d259155889982db8"
|
||||
checksum = "45a96638a0a176bec0a4bcaebc1afa8cf909b114477209d7456ade52c61cd9cd"
|
||||
dependencies = [
|
||||
"asynchronous-codec",
|
||||
"either",
|
||||
"futures",
|
||||
"futures-bounded",
|
||||
"futures-timer",
|
||||
"libp2p-core",
|
||||
"libp2p-identity",
|
||||
|
@ -4121,9 +4179,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libp2p-identity"
|
||||
version = "0.2.5"
|
||||
version = "0.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57bf6e730ec5e7022958da53ffb03b326e681b7316939012ae9b3c7449a812d4"
|
||||
checksum = "cdd6317441f361babc74c2989c6484eb0726045399b6648de039e1805ea96972"
|
||||
dependencies = [
|
||||
"bs58",
|
||||
"ed25519-dalek",
|
||||
|
@ -4139,9 +4197,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libp2p-kad"
|
||||
version = "0.44.5"
|
||||
version = "0.44.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41c5c483b1e90e79409711f515c5bea5de9c4d772a245b1ac01a2233fbcb67fe"
|
||||
checksum = "16ea178dabba6dde6ffc260a8e0452ccdc8f79becf544946692fff9d412fc29d"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"asynchronous-codec",
|
||||
|
@ -4183,7 +4241,7 @@ dependencies = [
|
|||
"smallvec",
|
||||
"socket2 0.5.4",
|
||||
"tokio",
|
||||
"trust-dns-proto",
|
||||
"trust-dns-proto 0.22.0",
|
||||
"void",
|
||||
]
|
||||
|
||||
|
@ -4250,9 +4308,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libp2p-quic"
|
||||
version = "0.9.2"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4cb763e88f9a043546bfebd3575f340e7dd3d6c1b2cf2629600ec8965360c63a"
|
||||
checksum = "130d451d83f21b81eb7b35b360bc7972aeafb15177784adc56528db082e6b927"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures",
|
||||
|
@ -4265,6 +4323,7 @@ dependencies = [
|
|||
"parking_lot 0.12.1",
|
||||
"quinn",
|
||||
"rand",
|
||||
"ring",
|
||||
"rustls",
|
||||
"socket2 0.5.4",
|
||||
"thiserror",
|
||||
|
@ -4273,9 +4332,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libp2p-request-response"
|
||||
version = "0.25.1"
|
||||
version = "0.25.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49e2cb9befb57e55f53d9463a6ea9b1b8a09a48174ad7be149c9cbebaa5e8e9b"
|
||||
checksum = "c772216645a224da196588418bf562e99a87413c6f49d74b4a1e3b4f5c8add3d"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"futures",
|
||||
|
@ -4291,9 +4350,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libp2p-swarm"
|
||||
version = "0.43.5"
|
||||
version = "0.43.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab94183f8fc2325817835b57946deb44340c99362cd4606c0a5717299b2ba369"
|
||||
checksum = "48ff0e918a45fec0b6f27b30b0547a57c6c214aa8b13be3647b7701bfd8b8797"
|
||||
dependencies = [
|
||||
"either",
|
||||
"fnv",
|
||||
|
@ -4327,9 +4386,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libp2p-tcp"
|
||||
version = "0.40.0"
|
||||
version = "0.40.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09bfdfb6f945c5c014b87872a0bdb6e0aef90e92f380ef57cd9013f118f9289d"
|
||||
checksum = "b558dd40d1bcd1aaaed9de898e9ec6a436019ecc2420dd0016e712fbb61c5508"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"futures-timer",
|
||||
|
@ -4361,6 +4420,22 @@ dependencies = [
|
|||
"yasna",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-upnp"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82775a47b34f10f787ad3e2a22e2c1541e6ebef4fe9f28f3ac553921554c94c1"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"futures-timer",
|
||||
"igd-next",
|
||||
"libp2p-core",
|
||||
"libp2p-swarm",
|
||||
"log",
|
||||
"tokio",
|
||||
"void",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libp2p-wasm-ext"
|
||||
version = "0.40.0"
|
||||
|
@ -4511,11 +4586,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "lru"
|
||||
version = "0.10.1"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670"
|
||||
checksum = "1efa59af2ddfad1854ae27d75009d538d0998b4b2fd47083e743ac1a10e46c60"
|
||||
dependencies = [
|
||||
"hashbrown 0.13.2",
|
||||
"hashbrown 0.14.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -10359,7 +10434,7 @@ dependencies = [
|
|||
"async-trait",
|
||||
"cfg-if",
|
||||
"data-encoding",
|
||||
"enum-as-inner",
|
||||
"enum-as-inner 0.5.1",
|
||||
"futures-channel",
|
||||
"futures-io",
|
||||
"futures-util",
|
||||
|
@ -10377,23 +10452,49 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "trust-dns-resolver"
|
||||
version = "0.22.0"
|
||||
name = "trust-dns-proto"
|
||||
version = "0.23.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aff21aa4dcefb0a1afbfac26deb0adc93888c7d295fb63ab273ef276ba2b7cfe"
|
||||
checksum = "559ac980345f7f5020883dd3bcacf176355225e01916f8c2efecad7534f682c6"
|
||||
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",
|
||||
"smallvec",
|
||||
"thiserror",
|
||||
"tinyvec",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "trust-dns-resolver"
|
||||
version = "0.23.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c723b0e608b24ad04c73b2607e0241b2c98fd79795a95e98b068b6966138a29d"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"futures-util",
|
||||
"ipconfig",
|
||||
"lazy_static",
|
||||
"lru-cache",
|
||||
"once_cell",
|
||||
"parking_lot 0.12.1",
|
||||
"rand",
|
||||
"resolv-conf",
|
||||
"smallvec",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"trust-dns-proto",
|
||||
"trust-dns-proto 0.23.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -11214,6 +11315,21 @@ dependencies = [
|
|||
"time",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xml-rs"
|
||||
version = "0.8.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a"
|
||||
|
||||
[[package]]
|
||||
name = "xmltree"
|
||||
version = "0.10.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7d8a75eaf6557bb84a65ace8609883db44a29951042ada9b393151532e41fcb"
|
||||
dependencies = [
|
||||
"xml-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yamux"
|
||||
version = "0.12.0"
|
||||
|
|
|
@ -18,16 +18,16 @@ use tokio::{
|
|||
use libp2p::{
|
||||
futures::StreamExt,
|
||||
identity::Keypair,
|
||||
PeerId, Transport,
|
||||
core::upgrade,
|
||||
tcp::{Config, tokio as libp2p_tokio},
|
||||
PeerId,
|
||||
tcp::Config as TcpConfig,
|
||||
noise, yamux,
|
||||
gossipsub::{
|
||||
IdentTopic, FastMessageId, MessageId, MessageAuthenticity, ValidationMode, ConfigBuilder,
|
||||
IdentityTransform, AllowAllSubscriptionFilter, Event as GsEvent, PublishError,
|
||||
Behaviour as GsBehavior,
|
||||
},
|
||||
swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent, Swarm},
|
||||
swarm::{NetworkBehaviour, SwarmEvent, Swarm},
|
||||
SwarmBuilder,
|
||||
};
|
||||
|
||||
pub(crate) use tributary::{ReadWrite, P2p as TributaryP2p};
|
||||
|
@ -181,15 +181,6 @@ impl LibP2p {
|
|||
let throwaway_key_pair = Keypair::generate_ed25519();
|
||||
let throwaway_peer_id = PeerId::from(throwaway_key_pair.public());
|
||||
|
||||
// Uses noise for authentication, yamux for multiplexing
|
||||
// TODO: Do we want to add a custom authentication protocol to only accept connections from
|
||||
// fellow validators? Doing so would reduce the potential for spam
|
||||
let transport = libp2p_tokio::Transport::new(Config::default().nodelay(true))
|
||||
.upgrade(upgrade::Version::V1)
|
||||
.authenticate(noise::Config::new(&throwaway_key_pair).unwrap())
|
||||
.multiplex(yamux::Config::default())
|
||||
.boxed();
|
||||
|
||||
let behavior = Behavior {
|
||||
gossipsub: {
|
||||
// Block size limit + 1 KB of space for signatures/metadata
|
||||
|
@ -222,7 +213,7 @@ impl LibP2p {
|
|||
})
|
||||
.build();
|
||||
let mut gossipsub = GsBehavior::<IdentityTransform, AllowAllSubscriptionFilter>::new(
|
||||
MessageAuthenticity::Signed(throwaway_key_pair),
|
||||
MessageAuthenticity::Signed(throwaway_key_pair.clone()),
|
||||
config.unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
@ -245,8 +236,17 @@ impl LibP2p {
|
|||
},
|
||||
};
|
||||
|
||||
let mut swarm =
|
||||
SwarmBuilder::with_tokio_executor(transport, behavior, throwaway_peer_id).build();
|
||||
// Uses noise for authentication, yamux for multiplexing
|
||||
// TODO: Do we want to add a custom authentication protocol to only accept connections from
|
||||
// fellow validators? Doing so would reduce the potential for spam
|
||||
// TODO: Relay client?
|
||||
let mut swarm = SwarmBuilder::with_existing_identity(throwaway_key_pair)
|
||||
.with_tokio()
|
||||
.with_tcp(TcpConfig::default().nodelay(true), noise::Config::new, yamux::Config::default)
|
||||
.unwrap()
|
||||
.with_behaviour(|_| behavior)
|
||||
.unwrap()
|
||||
.build();
|
||||
const PORT: u16 = 30563; // 5132 ^ (('c' << 8) | 'o')
|
||||
swarm.listen_on(format!("/ip4/0.0.0.0/tcp/{PORT}").parse().unwrap()).unwrap();
|
||||
|
||||
|
|
Loading…
Reference in a new issue