Skip to content

Commit e013ba5

Browse files
committed
using fork to fix mem and cpu issues
1 parent 7c2888c commit e013ba5

File tree

6 files changed

+67
-43
lines changed

6 files changed

+67
-43
lines changed

Cargo.lock

Lines changed: 34 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "dkn-compute"
3-
version = "0.1.4"
3+
version = "0.1.5"
44
edition = "2021"
55
license = "Apache-2.0"
66
readme = "README.md"
@@ -19,6 +19,7 @@ async-trait = "0.1.81"
1919
reqwest = "0.12.5"
2020

2121
# utilities
22+
dotenvy = "0.15.7"
2223
base64 = "0.22.0"
2324
hex = "0.4.3"
2425
hex-literal = "0.4.1"
@@ -42,14 +43,30 @@ fastbloom-rs = "0.5.9"
4243
ollama-workflows = { git = "https://github.com/andthattoo/ollama-workflows", rev = "25467d2" }
4344

4445
# peer-to-peer
45-
libp2p = { git = "https://github.com/anilaltuner/rust-libp2p.git", rev = "eb0e57b", features = ["dcutr", "ping", "relay", "autonat", "identify", "tokio", "gossipsub", "mdns", "noise", "macros", "tcp", "yamux", "quic", "kad"] }
46+
libp2p = { git = "https://github.com/anilaltuner/rust-libp2p.git", rev = "84b6d6f", features = [
47+
"dcutr",
48+
"ping",
49+
"relay",
50+
"autonat",
51+
"identify",
52+
"tokio",
53+
"gossipsub",
54+
"mdns",
55+
"noise",
56+
"macros",
57+
"tcp",
58+
"yamux",
59+
"quic",
60+
"kad",
61+
] }
4662

4763
libp2p-identity = { version = "0.2.9", features = ["secp256k1", "ed25519"] }
4864
tracing = { version = "0.1.40" }
4965
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
5066
public-ip = "0.2.2"
51-
dotenvy = "0.15.7"
52-
getrandom = "0.2.15"
67+
68+
# TODO: solves ecies dependency issue
69+
# getrandom = "0.2.15"
5370

5471

5572
[dev-dependencies]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ launch:
1111

1212
.PHONY: run # | Run with INFO log-level
1313
run:
14-
RUST_LOG=warn,dkn_compute=info cargo run
14+
RUST_LOG=none,dkn_compute=info cargo run
1515

1616
.PHONY: debug # | Run with DEBUG log-level with INFO log-level workflows
1717
debug:

src/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl DriaComputeNode {
136136
// handle message w.r.t topic
137137
if std::matches!(topic_str, PINGPONG_LISTEN_TOPIC | WORKFLOW_LISTEN_TOPIC) {
138138
// ensure that the message is from a valid source (origin)
139-
let source_peer_id = message.source.clone();
139+
let source_peer_id = message.source;
140140
// let source_peer_id = match message.source.clone() {
141141
// Some(peer) => peer,
142142
// None => {

src/p2p/behaviour.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ impl DriaBehaviour {
3838
fn create_kademlia_behavior(local_peer_id: PeerId) -> kad::Behaviour<MemoryStore> {
3939
use kad::{Behaviour, Config};
4040

41-
let mut cfg = Config::default();
42-
cfg.set_protocol_names(vec![DRIA_PROTO_NAME])
43-
.set_query_timeout(Duration::from_secs(5 * 60));
41+
const QUERY_TIMEOUT_SECS: u64 = 5 * 60; // 5 minutes
42+
43+
let mut cfg = Config::new(DRIA_PROTO_NAME);
44+
cfg.set_query_timeout(Duration::from_secs(QUERY_TIMEOUT_SECS));
4445

4546
Behaviour::with_config(local_peer_id, MemoryStore::new(local_peer_id), cfg)
4647
}
@@ -79,9 +80,7 @@ fn create_autonat_behavior(key: PublicKey) -> autonat::Behaviour {
7980
/// Configures the Gossipsub behavior for pub/sub messaging across peers.
8081
#[inline]
8182
fn create_gossipsub_behavior(id_keys: Keypair) -> gossipsub::Behaviour {
82-
use gossipsub::{
83-
Behaviour, ConfigBuilder, Message, MessageAuthenticity, MessageId, ValidationMode,
84-
};
83+
use gossipsub::{Behaviour, ConfigBuilder, Message, MessageAuthenticity, MessageId};
8584

8685
/// Message TTL in seconds
8786
const MESSAGE_TTL: u64 = 100;
@@ -107,8 +106,9 @@ fn create_gossipsub_behavior(id_keys: Keypair) -> gossipsub::Behaviour {
107106
.message_id_fn(message_id_fn)
108107
.message_ttl(Duration::from_secs(MESSAGE_TTL))
109108
.message_capacity(MESSAGE_CAPACITY)
109+
.max_ihave_length(100)
110110
.build()
111111
.expect("Valid config"), // TODO: better error handling
112112
)
113-
.expect("Valid behaviour") // TODO: better error handling
113+
.expect("Valid behaviour") // TODO: better error handling
114114
}

src/p2p/client.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl P2PClient {
4242
let mut swarm = SwarmBuilder::with_existing_identity(keypair)
4343
.with_tokio()
4444
.with_tcp(
45-
tcp::Config::default().port_reuse(true),
45+
tcp::Config::default(),
4646
noise::Config::new,
4747
yamux::Config::default,
4848
)
@@ -237,7 +237,8 @@ impl P2PClient {
237237
)) => self.handle_closest_peers_result(result),
238238
SwarmEvent::Behaviour(DriaBehaviourEvent::Identify(identify::Event::Received {
239239
peer_id,
240-
info, connection_id
240+
info,
241+
..
241242
})) => self.handle_identify_event(peer_id, info),
242243
SwarmEvent::Behaviour(DriaBehaviourEvent::Gossipsub(gossipsub::Event::Message {
243244
propagation_source: peer_id,

0 commit comments

Comments
 (0)