diff --git a/Cargo.lock b/Cargo.lock index 6e7ca51..86a805b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -209,9 +209,9 @@ checksum = "155a5a185e42c6b77ac7b88a15143d930a9e9727a5b7b77eed417404ab15c247" [[package]] name = "async-io" -version = "2.3.4" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "444b0228950ee6501b3568d3c93bf1176a1fdbc3b758dcd9475046d30f4dc7e8" +checksum = "43a2b323ccce0a1d90b449fd71f2a06ca7faa7c54c2751f06c9bd851fc061059" dependencies = [ "async-lock", "cfg-if 1.0.0", @@ -466,9 +466,9 @@ checksum = "7b02b629252fe8ef6460461409564e2c21d0c8e77e0944f3d189ff06c4e932ad" [[package]] name = "cc" -version = "1.1.36" +version = "1.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baee610e9452a8f6f0a1b6194ec09ff9e2d85dea54432acdae41aa0761c95d70" +checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf" dependencies = [ "shlex", ] @@ -913,7 +913,7 @@ dependencies = [ [[package]] name = "dkn-compute" -version = "0.2.19" +version = "0.2.20" dependencies = [ "async-trait", "base64 0.22.1", @@ -936,7 +936,7 @@ dependencies = [ "serde_json", "sha2 0.10.8", "sha3", - "tokio 1.41.0", + "tokio 1.41.1", "tokio-util 0.7.12", "url", "urlencoding", @@ -945,19 +945,19 @@ dependencies = [ [[package]] name = "dkn-p2p" -version = "0.2.19" +version = "0.2.20" dependencies = [ "env_logger 0.11.5", "eyre", "libp2p", "libp2p-identity", "log", - "tokio 1.41.0", + "tokio 1.41.1", ] [[package]] name = "dkn-workflows" -version = "0.2.19" +version = "0.2.20" dependencies = [ "dotenvy", "env_logger 0.11.5", @@ -968,7 +968,7 @@ dependencies = [ "reqwest 0.12.9", "serde", "serde_json", - "tokio 1.41.0", + "tokio 1.41.1", "tokio-util 0.7.12", ] @@ -1191,9 +1191,9 @@ checksum = "2d7e9bc68be4cdabbb8938140b01a8b5bc1191937f2c7e7ecc2fcebbe2d749df" [[package]] name = "fastrand" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "fiat-crypto" @@ -1324,9 +1324,9 @@ checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f1fa2f9765705486b33fd2acf1577f8ec449c2ba1f318ae5447697b7c08d210" +checksum = "cef40d21ae2c515b51041df9ed313ed21e572df340ea58a922a0aefe7e8891a1" dependencies = [ "futures-core", "pin-project-lite 0.2.15", @@ -1426,7 +1426,7 @@ dependencies = [ "serde", "serde_json", "sha256", - "tokio 1.41.0", + "tokio 1.41.1", ] [[package]] @@ -1522,7 +1522,7 @@ dependencies = [ "http 0.2.12", "indexmap 2.6.0", "slab", - "tokio 1.41.0", + "tokio 1.41.1", "tokio-util 0.7.12", "tracing", ] @@ -1541,7 +1541,7 @@ dependencies = [ "http 1.1.0", "indexmap 2.6.0", "slab", - "tokio 1.41.0", + "tokio 1.41.1", "tokio-util 0.7.12", "tracing", ] @@ -1634,7 +1634,7 @@ dependencies = [ "socket2 0.5.7", "thiserror", "tinyvec", - "tokio 1.41.0", + "tokio 1.41.1", "tracing", "url", ] @@ -1656,7 +1656,7 @@ dependencies = [ "resolv-conf", "smallvec", "thiserror", - "tokio 1.41.0", + "tokio 1.41.1", "tracing", ] @@ -1883,7 +1883,7 @@ dependencies = [ "itoa 1.0.11", "pin-project-lite 0.2.15", "socket2 0.5.7", - "tokio 1.41.0", + "tokio 1.41.1", "tower-service", "tracing", "want", @@ -1905,7 +1905,7 @@ dependencies = [ "itoa 1.0.11", "pin-project-lite 0.2.15", "smallvec", - "tokio 1.41.0", + "tokio 1.41.1", "want", ] @@ -1921,7 +1921,7 @@ dependencies = [ "hyper-util", "rustls", "rustls-pki-types", - "tokio 1.41.0", + "tokio 1.41.1", "tokio-rustls", "tower-service", "webpki-roots", @@ -1951,7 +1951,7 @@ dependencies = [ "hyper 1.5.0", "hyper-util", "native-tls", - "tokio 1.41.0", + "tokio 1.41.1", "tokio-native-tls", "tower-service", ] @@ -1970,7 +1970,7 @@ dependencies = [ "hyper 1.5.0", "pin-project-lite 0.2.15", "socket2 0.5.7", - "tokio 1.41.0", + "tokio 1.41.1", "tower-service", "tracing", ] @@ -2178,7 +2178,7 @@ dependencies = [ "log", "rtnetlink", "system-configuration 0.5.1", - "tokio 1.41.0", + "tokio 1.41.1", "windows", ] @@ -2196,7 +2196,7 @@ dependencies = [ "hyper 0.14.31", "log", "rand 0.8.5", - "tokio 1.41.0", + "tokio 1.41.1", "url", "xmltree", ] @@ -2346,9 +2346,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.161" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "libp2p" @@ -2614,7 +2614,7 @@ dependencies = [ "rand 0.8.5", "smallvec", "socket2 0.5.7", - "tokio 1.41.0", + "tokio 1.41.1", "tracing", "void", ] @@ -2700,7 +2700,7 @@ dependencies = [ "rustls", "socket2 0.5.7", "thiserror", - "tokio 1.41.0", + "tokio 1.41.1", "tracing", ] @@ -2764,7 +2764,7 @@ dependencies = [ "once_cell", "rand 0.8.5", "smallvec", - "tokio 1.41.0", + "tokio 1.41.1", "tracing", "void", "web-time", @@ -2793,7 +2793,7 @@ dependencies = [ "libp2p-core", "libp2p-identity", "socket2 0.5.7", - "tokio 1.41.0", + "tokio 1.41.1", "tracing", ] @@ -2825,7 +2825,7 @@ dependencies = [ "igd-next", "libp2p-core", "libp2p-swarm", - "tokio 1.41.0", + "tokio 1.41.1", "tracing", "void", ] @@ -3219,7 +3219,7 @@ dependencies = [ "netlink-packet-core", "netlink-sys", "thiserror", - "tokio 1.41.0", + "tokio 1.41.1", ] [[package]] @@ -3232,7 +3232,7 @@ dependencies = [ "futures", "libc", "log", - "tokio 1.41.0", + "tokio 1.41.1", ] [[package]] @@ -3356,7 +3356,7 @@ dependencies = [ [[package]] name = "ollama-workflows" version = "0.1.0" -source = "git+https://github.com/andthattoo/ollama-workflows#47df3be4853a0b35c172d13787f7d24fe6e0ba41" +source = "git+https://github.com/andthattoo/ollama-workflows#7dde4dc1c82484ede4f01b14c8e77d1f898c8219" dependencies = [ "async-trait", "base64 0.22.1", @@ -3378,7 +3378,7 @@ dependencies = [ "serde_json", "simsimd", "text-splitter", - "tokio 1.41.0", + "tokio 1.41.1", "tokio-util 0.7.12", ] @@ -3396,16 +3396,16 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openai_dive" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "311f110be1c6910150a9dbc2d0f98722a1c4aabcf9a35a5e55255e7a2adeb656" +checksum = "c3145b6053780214d0d872f204c92e2cf65706b8b78aa304d76567a8d3764d15" dependencies = [ "bytes 1.8.0", "derive_builder", "reqwest 0.12.9", "serde", "serde_json", - "tokio 1.41.0", + "tokio 1.41.1", "tokio-util 0.7.12", ] @@ -3714,9 +3714,9 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "polling" -version = "3.7.3" +version = "3.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2790cd301dec6cd3b7a025e4815cf825724a51c98dccfe6a3e55f05ffb6511" +checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f" dependencies = [ "cfg-if 1.0.0", "concurrent-queue", @@ -3867,7 +3867,7 @@ dependencies = [ "rustls", "socket2 0.5.7", "thiserror", - "tokio 1.41.0", + "tokio 1.41.1", "tracing", ] @@ -4114,7 +4114,7 @@ dependencies = [ "serde_urlencoded", "sync_wrapper", "system-configuration 0.6.1", - "tokio 1.41.0", + "tokio 1.41.1", "tokio-native-tls", "tokio-rustls", "tokio-util 0.7.12", @@ -4141,7 +4141,7 @@ dependencies = [ "reqwest 0.12.9", "serde", "serde_json", - "tokio 1.41.0", + "tokio 1.41.1", "tokio-util 0.7.12", ] @@ -4197,7 +4197,7 @@ dependencies = [ "netlink-proto", "nix", "thiserror", - "tokio 1.41.0", + "tokio 1.41.1", ] [[package]] @@ -4551,7 +4551,7 @@ dependencies = [ "bytes 1.8.0", "hex", "sha2 0.10.8", - "tokio 1.41.0", + "tokio 1.41.1", ] [[package]] @@ -4836,9 +4836,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if 1.0.0", "fastrand", @@ -4996,9 +4996,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.41.0" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145f3413504347a2be84393cc8a7d2fb4d863b375909ea59f2158261aa258bbb" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" dependencies = [ "backtrace", "bytes 1.8.0", @@ -5030,7 +5030,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" dependencies = [ "native-tls", - "tokio 1.41.0", + "tokio 1.41.1", ] [[package]] @@ -5041,7 +5041,7 @@ checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ "rustls", "rustls-pki-types", - "tokio 1.41.0", + "tokio 1.41.1", ] [[package]] @@ -5080,7 +5080,7 @@ dependencies = [ "futures-util", "hashbrown 0.14.5", "pin-project-lite 0.2.15", - "tokio 1.41.0", + "tokio 1.41.1", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 7f4233b..a56e33e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ default-members = ["compute"] [workspace.package] edition = "2021" -version = "0.2.19" +version = "0.2.20" license = "Apache-2.0" readme = "README.md" diff --git a/compute/src/node.rs b/compute/src/node.rs index 2fbcb25..1726fe5 100644 --- a/compute/src/node.rs +++ b/compute/src/node.rs @@ -147,10 +147,16 @@ impl DriaComputeNode { // refresh admin rpc peer ids if self.available_nodes_last_refreshed.elapsed() > Duration::from_secs(RPC_PEER_ID_REFRESH_INTERVAL_SECS) { log::info!("Refreshing available nodes."); + self.available_nodes = AvailableNodes::get_available_nodes().await.unwrap_or_default().join(self.available_nodes.clone()).sort_dedup(); self.available_nodes_last_refreshed = tokio::time::Instant::now(); + + // also print network info + log::debug!("{:?}", self.p2p.network_info().connection_counters()); } + + let (peer_id, message_id, message) = event; let topic = message.topic.clone(); let topic_str = topic.as_str(); diff --git a/p2p/src/behaviour.rs b/p2p/src/behaviour.rs index 7100907..a487cf9 100644 --- a/p2p/src/behaviour.rs +++ b/p2p/src/behaviour.rs @@ -6,7 +6,7 @@ use eyre::{eyre, Context, Result}; use libp2p::identity::{Keypair, PeerId, PublicKey}; use libp2p::kad::store::MemoryStore; use libp2p::StreamProtocol; -use libp2p::{autonat, dcutr, gossipsub, identify, kad, relay}; +use libp2p::{autonat, connection_limits, dcutr, gossipsub, identify, kad, relay}; #[derive(libp2p::swarm::NetworkBehaviour)] pub struct DriaBehaviour { @@ -16,6 +16,7 @@ pub struct DriaBehaviour { pub identify: identify::Behaviour, pub autonat: autonat::Behaviour, pub dcutr: dcutr::Behaviour, + pub connection_limits: connection_limits::Behaviour, } impl DriaBehaviour { @@ -36,10 +37,26 @@ impl DriaBehaviour { autonat: create_autonat_behaviour(peer_id), dcutr: create_dcutr_behaviour(peer_id), identify: create_identify_behaviour(public_key, identity_protocol), + connection_limits: create_connection_limits_behaviour(), }) } } +/// Configures the connection limits. +#[inline] +fn create_connection_limits_behaviour() -> connection_limits::Behaviour { + use connection_limits::{Behaviour, ConnectionLimits}; + + /// Number of established outgoing connections limit, this is directly correlated to peer count + /// so limiting this will cause a limitation on peers as well. + const EST_OUTGOING_LIMIT: u32 = 450; + + let limits = + ConnectionLimits::default().with_max_established_outgoing(Some(EST_OUTGOING_LIMIT)); + + Behaviour::new(limits) +} + /// Configures the Kademlia DHT behavior for the node. #[inline] fn create_kademlia_behaviour(