Skip to content

Commit

Permalink
fix: remove some logs and greylisting that were too harsh
Browse files Browse the repository at this point in the history
  • Loading branch information
stringhandler committed Dec 20, 2024
1 parent a68936d commit 8994c35
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
12 changes: 6 additions & 6 deletions log4rs_sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ loggers:
appenders:
- new_tip_notify
additive: false
tari::p2pool::server::p2p:
level: info
appenders:
- p2p
- stdout
additive: false
# tari::p2pool::server::p2p:
# level: info
# appenders:
# - p2p
# - stdout
# additive: false
# For debugging only
# tari::p2pool::message_logging:
# level: debug
Expand Down
33 changes: 23 additions & 10 deletions src/server/p2p/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use libp2p::{
swarm::{
behaviour::toggle::Toggle,
dial_opts::{DialOpts, PeerCondition},
DialError,
NetworkBehaviour,
SwarmEvent,
},
Expand Down Expand Up @@ -1225,11 +1226,19 @@ where S: ShareChain
error,
..
} => {
warn!(target: LOG_TARGET, squad = &self.config.squad; "Outgoing connection error: {peer_id:?} -> {error:?}");
self.network_peer_store
.write()
.await
.move_to_grey_list(peer_id, format!("Outgoing connection error: {error}"));
match error {
DialError::Transport(transport_error) => {
// There are a lot of cancelled errors, so ignore them
debug!(target: LOG_TARGET, "Outgoing connection error, ignoring: {peer_id:?} -> {transport_error:?}");
},
_ => {
warn!(target: LOG_TARGET, squad = &self.config.squad; "Outgoing connection error: {peer_id:?} -> {error:?}");
self.network_peer_store
.write()
.await
.move_to_grey_list(peer_id, format!("Outgoing connection error: {error}"));
},
};
},
SwarmEvent::Behaviour(event) => match event {
ServerNetworkBehaviourEvent::Mdns(mdns_event) => match mdns_event {
Expand Down Expand Up @@ -1958,14 +1967,15 @@ where S: ShareChain
let mut addresses = relay.addresses.clone();
addresses.truncate(8);

// Try dial, this should already be happening though
if let Err(err) = self.swarm.dial(
DialOpts::peer_id(relay.peer_id)
.addresses(relay.addresses.clone())
.condition(PeerCondition::NotDialing)
// .condition(PeerCondition::NotDialing)
.build(),
) {
warn!(target: LOG_TARGET, "🚨 Failed to dial relay: {}", err);
return;
debug!(target: LOG_TARGET, "🚨 Failed to dial relay: {}", err);
// return;
}

addresses.iter().for_each(|addr| {
Expand Down Expand Up @@ -2147,7 +2157,10 @@ where S: ShareChain
/// Main loop of the service that drives the events and libp2p swarm forward.
#[allow(clippy::too_many_lines)]
async fn main_loop(&mut self) -> Result<(), Error> {
let mut publish_peer_info_interval = tokio::time::interval(self.config.peer_info_publish_interval);
let mut publish_peer_info_interval = tokio::time::interval_at(
tokio::time::Instant::now() + self.config.peer_info_publish_interval,
self.config.peer_info_publish_interval,
);
publish_peer_info_interval.set_missed_tick_behavior(MissedTickBehavior::Skip);

let mut grey_list_clear_interval = tokio::time::interval(self.config.grey_list_clear_interval);
Expand Down Expand Up @@ -2276,7 +2289,7 @@ where S: ShareChain
},
_ = publish_peer_info_interval.tick() => {
let timer = Instant::now();
info!(target: LOG_TARGET, "pub peer info");
info!(target: LOG_TARGET, "Publishing peer info");

// broadcast peer info
if let Err(error) = self.broadcast_peer_info().await {
Expand Down
6 changes: 3 additions & 3 deletions src/sharechain/p2chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ impl ChainAddResult {
impl Display for ChainAddResult {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
if let Some(tip) = self.new_tip {
writeln!(
write!(
f,
"Added new tip {}({:x}{:x}{:x}{:x})",
tip.1, tip.0[0], tip.0[1], tip.0[2], tip.0[3]
)?;
} else {
writeln!(f, "No new tip added")?;
write!(f, "No new tip added")?;
}
if !self.missing_blocks.is_empty() {
let mut missing_blocks: Vec<String> = Vec::new();
Expand All @@ -118,7 +118,7 @@ impl Display for ChainAddResult {
height, hash[0], hash[1], hash[2], hash[3]
));
}
writeln!(f, "Missing blocks: {:?}", missing_blocks)?;
write!(f, "Missing blocks: {:?}", missing_blocks)?;
}
Ok(())
}
Expand Down

0 comments on commit 8994c35

Please sign in to comment.