Skip to content

Commit 8b1eadc

Browse files
committed
rpc check re-enabled, better logs
1 parent 6ed9be6 commit 8b1eadc

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

src/node.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -136,31 +136,30 @@ 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;
140-
// let source_peer_id = match message.source.clone() {
141-
// Some(peer) => peer,
142-
// None => {
143-
// log::warn!("Received {} message from {} without source.", topic_str, peer_id);
144-
// log::debug!("Allowed sources: {:#?}", self.available_nodes.rpc_nodes);
145-
// self.p2p.validate_message(&message_id, &peer_id, gossipsub::MessageAcceptance::Ignore)?;
146-
// continue;
147-
// }
148-
// };
139+
let source_peer_id = match message.source.clone() {
140+
Some(peer) => peer,
141+
None => {
142+
log::warn!("Received {} message from {} without source.", topic_str, peer_id);
143+
self.p2p.validate_message(&message_id, &peer_id, gossipsub::MessageAcceptance::Ignore)?;
144+
continue;
145+
}
146+
};
149147

150148
log::info!(
151-
"Received {} message ({})\nFrom: {}\nOrigin: {}",
149+
"Received {} message ({})\nFrom: {}\nSource: {}",
152150
topic_str,
153151
message_id,
154152
peer_id,
155-
source_peer_id.map(|p| p.to_string()).unwrap_or("None".to_string())
153+
source_peer_id
156154
);
157155

158156
// ensure that message is from the static RPCs
159-
// if !self.available_nodes.rpc_nodes.contains(&source_peer_id) {
160-
// log::warn!("Received message from unauthorized origin: {}", source_peer_id);
161-
// self.p2p.validate_message(&message_id, &peer_id, gossipsub::MessageAcceptance::Ignore)?;
162-
// continue;
163-
// }
157+
if !self.available_nodes.rpc_nodes.contains(&source_peer_id) {
158+
log::warn!("Received message from unauthorized source: {}", source_peer_id);
159+
log::debug!("Allowed sources: {:#?}", self.available_nodes.rpc_nodes);
160+
self.p2p.validate_message(&message_id, &peer_id, gossipsub::MessageAcceptance::Ignore)?;
161+
continue;
162+
}
164163

165164
// first, parse the raw gossipsub message to a prepared message
166165
// if unparseable,

src/p2p/behaviour.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ fn create_kademlia_behavior(local_peer_id: PeerId) -> kad::Behaviour<MemoryStore
5656
fn create_identify_behavior(local_public_key: PublicKey) -> identify::Behaviour {
5757
use identify::{Behaviour, Config};
5858

59+
// TODO: can we use a different protocol version, e.g. `dria/CRATE_VERSION`
5960
let cfg = Config::new(DRIA_PROTO_NAME.to_string(), local_public_key);
6061

6162
Behaviour::new(cfg)

src/p2p/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl P2PClient {
237237
for addr in info.listen_addrs {
238238
if protocol_match {
239239
// if it matches our protocol, add it to the Kademlia routing table
240-
log::info!("Identify: Received address {}. PeerID is {}", addr, peer_id);
240+
log::info!("Identify: Peer {} identified at {}", peer_id, addr);
241241

242242
self.swarm
243243
.behaviour_mut()

start.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ COMPOSE_DOWN="${COMPOSE_PROFILES} ${COMPUTE_ENVS} ${OLLAMA_ENVS} ${COMPOSE_COMMA
297297
echo ""
298298
echo "Starting in ${START_MODE} mode..."
299299
echo "Log level: ${RUST_LOG}"
300-
echo "Using models: ${DKN_MODELS}"
300+
echo "Models: ${DKN_MODELS}"
301+
echo "${COMPOSE_PROFILES}"
301302
echo ""
302303
eval "${COMPOSE_UP}"
303304

0 commit comments

Comments
 (0)