Skip to content

Commit b3645c7

Browse files
committed
chore: more debug output
1 parent 99f0736 commit b3645c7

File tree

1 file changed

+59
-55
lines changed

1 file changed

+59
-55
lines changed

stackslib/src/net/p2p.rs

Lines changed: 59 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -644,11 +644,9 @@ impl PeerNetwork {
644644
let (p2p_handle, bound_p2p_addr) = net.bind(my_addr)?;
645645
let (http_handle, bound_http_addr) = net.bind(http_addr)?;
646646

647-
test_debug!(
647+
debug!(
648648
"{:?}: bound on p2p {:?}, http {:?}",
649-
&self.local_peer,
650-
bound_p2p_addr,
651-
bound_http_addr
649+
&self.local_peer, bound_p2p_addr, bound_http_addr
652650
);
653651

654652
self.network = Some(net);
@@ -898,6 +896,12 @@ impl PeerNetwork {
898896
return Err(e);
899897
}
900898
Ok(sz) => {
899+
if sz > 0 {
900+
debug!(
901+
"Sent {} bytes on p2p socket {:?} for conversation {:?}",
902+
sz, client_sock, convo
903+
);
904+
}
901905
total_sent += sz;
902906
if sz == 0 {
903907
break;
@@ -1185,7 +1189,7 @@ impl PeerNetwork {
11851189

11861190
let next_event_id = match self.network {
11871191
None => {
1188-
test_debug!("{:?}: network not connected", &self.local_peer);
1192+
debug!("{:?}: network not connected", &self.local_peer);
11891193
return Err(net_error::NotConnected);
11901194
}
11911195
Some(ref mut network) => {
@@ -1481,7 +1485,7 @@ impl PeerNetwork {
14811485
(convo.to_neighbor_key(), Some(neighbor))
14821486
}
14831487
None => {
1484-
test_debug!(
1488+
debug!(
14851489
"No such neighbor in peer DB, but will ban nevertheless: {:?}",
14861490
convo.to_neighbor_key()
14871491
);
@@ -1645,11 +1649,9 @@ impl PeerNetwork {
16451649

16461650
// already connected?
16471651
if let Some(event_id) = self.get_event_id(&neighbor_key) {
1648-
test_debug!(
1652+
debug!(
16491653
"{:?}: already connected to {:?} on event {}",
1650-
&self.local_peer,
1651-
&neighbor_key,
1652-
event_id
1654+
&self.local_peer, &neighbor_key, event_id
16531655
);
16541656
return Err(net_error::AlreadyConnected(event_id, neighbor_key.clone()));
16551657
}
@@ -1927,7 +1929,7 @@ impl PeerNetwork {
19271929
match self.events.get(&peer_key) {
19281930
None => {
19291931
// not connected
1930-
test_debug!("Could not sign for peer {:?}: not connected", peer_key);
1932+
debug!("Could not sign for peer {:?}: not connected", peer_key);
19311933
Err(net_error::PeerNotConnected)
19321934
}
19331935
Some(event_id) => self.sign_for_p2p(*event_id, message_payload),
@@ -1947,7 +1949,7 @@ impl PeerNetwork {
19471949
message_payload,
19481950
);
19491951
}
1950-
test_debug!("Could not sign for peer {}: not connected", event_id);
1952+
debug!("Could not sign for peer {}: not connected", event_id);
19511953
Err(net_error::PeerNotConnected)
19521954
}
19531955

@@ -1968,7 +1970,7 @@ impl PeerNetwork {
19681970
message_payload,
19691971
);
19701972
}
1971-
test_debug!("Could not sign for peer {}: not connected", event_id);
1973+
debug!("Could not sign for peer {}: not connected", event_id);
19721974
Err(net_error::PeerNotConnected)
19731975
}
19741976

@@ -2042,7 +2044,7 @@ impl PeerNetwork {
20422044
match (self.peers.remove(&event_id), self.sockets.remove(&event_id)) {
20432045
(Some(convo), Some(sock)) => (convo, sock),
20442046
(Some(convo), None) => {
2045-
test_debug!("{:?}: Rogue socket event {}", &self.local_peer, event_id);
2047+
debug!("{:?}: Rogue socket event {}", &self.local_peer, event_id);
20462048
self.peers.insert(event_id, convo);
20472049
return Err(net_error::PeerNotConnected);
20482050
}
@@ -2055,7 +2057,7 @@ impl PeerNetwork {
20552057
return Err(net_error::PeerNotConnected);
20562058
}
20572059
(None, None) => {
2058-
test_debug!("{:?}: Rogue socket event {}", &self.local_peer, event_id);
2060+
debug!("{:?}: Rogue socket event {}", &self.local_peer, event_id);
20592061
return Err(net_error::PeerNotConnected);
20602062
}
20612063
};
@@ -2184,7 +2186,7 @@ impl PeerNetwork {
21842186
) {
21852187
Ok((convo_unhandled, alive)) => (convo_unhandled, alive),
21862188
Err(_e) => {
2187-
test_debug!(
2189+
debug!(
21882190
"{:?}: Connection to {:?} failed: {:?}",
21892191
&self.local_peer,
21902192
self.get_p2p_convo(*event_id),
@@ -2196,7 +2198,7 @@ impl PeerNetwork {
21962198
};
21972199

21982200
if !alive {
2199-
test_debug!(
2201+
debug!(
22002202
"{:?}: Connection to {:?} is no longer alive",
22012203
&self.local_peer,
22022204
self.get_p2p_convo(*event_id),
@@ -2383,11 +2385,9 @@ impl PeerNetwork {
23832385
}
23842386
};
23852387
if neighbor.allowed < 0 || (neighbor.allowed as u64) > now {
2386-
test_debug!(
2388+
debug!(
23872389
"{:?}: event {} is allowed: {:?}",
2388-
&self.local_peer,
2389-
event_id,
2390-
&nk
2390+
&self.local_peer, event_id, &nk
23912391
);
23922392
safe.insert(*event_id);
23932393
}
@@ -2474,17 +2474,19 @@ impl PeerNetwork {
24742474
let mut relay_handles = std::mem::replace(&mut self.relay_handles, HashMap::new());
24752475
for (event_id, handle_list) in relay_handles.iter_mut() {
24762476
if handle_list.len() == 0 {
2477+
debug!("No handles for event {}", event_id);
24772478
drained.push(*event_id);
24782479
continue;
24792480
}
24802481

2481-
test_debug!(
2482+
debug!(
24822483
"Flush {} relay handles to event {}",
24832484
handle_list.len(),
24842485
event_id
24852486
);
24862487

24872488
while handle_list.len() > 0 {
2489+
debug!("Flush {} relay handles", handle_list.len());
24882490
let res = self.with_p2p_convo(*event_id, |_network, convo, client_sock| {
24892491
if let Some(handle) = handle_list.front_mut() {
24902492
let (num_sent, flushed) =
@@ -2496,12 +2498,9 @@ impl PeerNetwork {
24962498
}
24972499
};
24982500

2499-
test_debug!(
2501+
debug!(
25002502
"Flushed relay handle to {:?} ({:?}): sent={}, flushed={}",
2501-
client_sock,
2502-
convo,
2503-
num_sent,
2504-
flushed
2503+
client_sock, convo, num_sent, flushed
25052504
);
25062505
return Ok((num_sent, flushed));
25072506
}
@@ -2512,14 +2511,15 @@ impl PeerNetwork {
25122511
Ok(Ok(x)) => x,
25132512
Ok(Err(_)) | Err(_) => {
25142513
// connection broken; next list
2514+
debug!("Relay handle broken to event {}", event_id);
25152515
broken.push(*event_id);
25162516
break;
25172517
}
25182518
};
25192519

25202520
if !flushed && num_sent == 0 {
25212521
// blocked on this peer's socket
2522-
test_debug!("Relay handle to event {} is blocked", event_id);
2522+
debug!("Relay handle to event {} is blocked", event_id);
25232523
break;
25242524
}
25252525

@@ -2553,7 +2553,7 @@ impl PeerNetwork {
25532553
/// Return true if we finish, and true if we're throttled
25542554
fn do_network_neighbor_walk(&mut self, ibd: bool) -> bool {
25552555
if cfg!(test) && self.connection_opts.disable_neighbor_walk {
2556-
test_debug!("neighbor walk is disabled");
2556+
debug!("neighbor walk is disabled");
25572557
return true;
25582558
}
25592559

@@ -2800,15 +2800,15 @@ impl PeerNetwork {
28002800
fn need_public_ip(&mut self) -> bool {
28012801
if !self.public_ip_learned {
28022802
// IP was given, not learned. nothing to do
2803-
test_debug!("{:?}: IP address was given to us", &self.local_peer);
2803+
debug!("{:?}: IP address was given to us", &self.local_peer);
28042804
return false;
28052805
}
28062806
if self.local_peer.public_ip_address.is_some()
28072807
&& self.public_ip_learned_at + self.connection_opts.public_ip_timeout
28082808
>= get_epoch_time_secs()
28092809
{
28102810
// still fresh
2811-
test_debug!("{:?}: learned IP address is still fresh", &self.local_peer);
2811+
debug!("{:?}: learned IP address is still fresh", &self.local_peer);
28122812
return false;
28132813
}
28142814
let throttle_timeout = if self.local_peer.public_ip_address.is_none() {
@@ -2871,7 +2871,7 @@ impl PeerNetwork {
28712871
match self.do_learn_public_ip() {
28722872
Ok(b) => {
28732873
if !b {
2874-
test_debug!("{:?}: try do_learn_public_ip again", &self.local_peer);
2874+
debug!("{:?}: try do_learn_public_ip again", &self.local_peer);
28752875
return false;
28762876
}
28772877
}
@@ -2958,15 +2958,15 @@ impl PeerNetwork {
29582958

29592959
for (_, block, _) in network_result.blocks.iter() {
29602960
if block_set.contains(&block.block_hash()) {
2961-
test_debug!("Duplicate block {}", block.block_hash());
2961+
debug!("Duplicate block {}", block.block_hash());
29622962
}
29632963
block_set.insert(block.block_hash());
29642964
}
29652965

29662966
for (_, mblocks, _) in network_result.confirmed_microblocks.iter() {
29672967
for mblock in mblocks.iter() {
29682968
if microblock_set.contains(&mblock.block_hash()) {
2969-
test_debug!("Duplicate microblock {}", mblock.block_hash());
2969+
debug!("Duplicate microblock {}", mblock.block_hash());
29702970
}
29712971
microblock_set.insert(mblock.block_hash());
29722972
}
@@ -4209,7 +4209,7 @@ impl PeerNetwork {
42094209
}
42104210
None => {
42114211
// skip this step -- no DNS client available
4212-
test_debug!(
4212+
debug!(
42134213
"{:?}: no DNS client provided; skipping block download",
42144214
&self.local_peer
42154215
);
@@ -4315,7 +4315,7 @@ impl PeerNetwork {
43154315
}
43164316
None => {
43174317
// skip this step -- no DNS client available
4318-
test_debug!(
4318+
debug!(
43194319
"{:?}: no DNS client provided; skipping block download",
43204320
&self.local_peer
43214321
);
@@ -4364,7 +4364,11 @@ impl PeerNetwork {
43644364
convo.to_neighbor_key(),
43654365
),
43664366
None => {
4367-
test_debug!("No such neighbor event={}", event_id);
4367+
debug!(
4368+
"{:?}: No such neighbor event={}",
4369+
self.get_local_peer(),
4370+
event_id
4371+
);
43684372
return None;
43694373
}
43704374
};
@@ -4373,10 +4377,9 @@ impl PeerNetwork {
43734377
let reciprocal_event_id = match self.find_reciprocal_event(event_id) {
43744378
Some(re) => re,
43754379
None => {
4376-
test_debug!(
4380+
debug!(
43774381
"{:?}: no reciprocal conversation for {:?}",
4378-
&self.local_peer,
4379-
&neighbor_key
4382+
&self.local_peer, &neighbor_key
43804383
);
43814384
return None;
43824385
}
@@ -4390,32 +4393,26 @@ impl PeerNetwork {
43904393
convo.to_neighbor_key(),
43914394
),
43924395
None => {
4393-
test_debug!(
4396+
debug!(
43944397
"{:?}: No reciprocal conversation for {} (event={})",
4395-
&self.local_peer,
4396-
&neighbor_key,
4397-
event_id
4398+
&self.local_peer, &neighbor_key, event_id
43984399
);
43994400
return None;
44004401
}
44014402
};
44024403

44034404
if !is_authenticated && !reciprocal_is_authenticated {
4404-
test_debug!(
4405+
debug!(
44054406
"{:?}: {:?} and {:?} are not authenticated",
4406-
&self.local_peer,
4407-
&neighbor_key,
4408-
&reciprocal_neighbor_key
4407+
&self.local_peer, &neighbor_key, &reciprocal_neighbor_key
44094408
);
44104409
return None;
44114410
}
44124411

44134412
if !is_outbound && !reciprocal_is_outbound {
4414-
test_debug!(
4413+
debug!(
44154414
"{:?}: {:?} and {:?} are not outbound",
4416-
&self.local_peer,
4417-
&neighbor_key,
4418-
&reciprocal_neighbor_key
4415+
&self.local_peer, &neighbor_key, &reciprocal_neighbor_key
44194416
);
44204417
return None;
44214418
}
@@ -5196,7 +5193,7 @@ impl PeerNetwork {
51965193
/// for. Add them to our network pingbacks
51975194
fn schedule_network_pingbacks(&mut self, event_ids: Vec<usize>) {
51985195
if cfg!(test) && self.connection_opts.disable_pingbacks {
5199-
test_debug!("{:?}: pingbacks are disabled for testing", &self.local_peer);
5196+
debug!("{:?}: pingbacks are disabled for testing", &self.local_peer);
52005197
return;
52015198
}
52025199

@@ -5278,7 +5275,7 @@ impl PeerNetwork {
52785275
}
52795276
}
52805277

5281-
test_debug!(
5278+
debug!(
52825279
"{:?}: have {} pingbacks scheduled",
52835280
&self.local_peer,
52845281
self.walk_pingbacks.len()
@@ -5580,6 +5577,13 @@ impl PeerNetwork {
55805577
};
55815578

55825579
// update cached burnchain view for /v2/info
5580+
debug!(
5581+
"{:?}: chain view for burn block {} has stacks tip consensus {}",
5582+
&self.local_peer,
5583+
new_chain_view.burn_block_height,
5584+
&new_chain_view.rc_consensus_hash
5585+
);
5586+
55835587
self.chain_view = new_chain_view;
55845588
self.chain_view_stable_consensus_hash = new_chain_view_stable_consensus_hash;
55855589
}
@@ -5649,7 +5653,7 @@ impl PeerNetwork {
56495653
.get_last_selected_anchor_block_txid()?
56505654
.unwrap_or(Txid([0x00; 32]));
56515655

5652-
test_debug!(
5656+
debug!(
56535657
"{:?}: chain view is {:?}",
56545658
&self.get_local_peer(),
56555659
&self.chain_view

0 commit comments

Comments
 (0)