Skip to content

Commit 1f220e4

Browse files
committed
Added log if initial peers are invalid
1 parent 2731abd commit 1f220e4

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3636
Dashboard, documenting all endpoints and specific data fields used by the
3737
frontend ([#1566](https://github.com/o1-labs/mina-rust/issues/1566))
3838

39+
- **Feature**: Add logging if initial peers are invalid
40+
([#1703](https://github.com/o1-labs/mina-rust/pull/1703))
41+
3942
### Fixed
4043

4144
- **Docker Compose**: Fix frontend black screen issue by changing environment

node/src/reducer.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,32 @@ pub fn reducer(
1717
let meta = action.meta().clone();
1818
match action.action() {
1919
Action::CheckTimeouts(_) => {
20-
if state.p2p.ready().is_some() {
20+
if let Some(p2p) = state.p2p.ready() {
21+
if let Some(kad_state) = &p2p.network.scheduler.discovery_state {
22+
if p2p.ready_peers().is_empty() && kad_state.has_bootstraped {
23+
if let Some(tip) = &state.transition_frontier.best_tip_breadcrumb() {
24+
// TODO: this might need to change in future
25+
if tip.height() == 296372 {
26+
let initial_peers = state
27+
.p2p
28+
.config()
29+
.initial_peers
30+
.iter()
31+
.map(|opts| opts.to_string())
32+
.collect::<Vec<_>>()
33+
.join(", ");
34+
35+
crate::core::error!(
36+
crate::core::log::system_time();
37+
summary = "Exiting",
38+
error = "Invalid initial peers",
39+
initial_peers = initial_peers
40+
);
41+
}
42+
}
43+
}
44+
}
45+
2146
if let Err(error) =
2247
P2pState::p2p_timeout_dispatch(Substate::new(state, dispatcher), &meta)
2348
{

p2p/src/network/kad/p2p_network_kad_reducer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ impl super::P2pNetworkKadState {
133133
time: meta.time(),
134134
stats: bootstrap_state.stats.clone(),
135135
};
136+
state.has_bootstraped = true;
136137
Ok(())
137138
}
138139
(_, P2pNetworkKademliaAction::UpdateRoutingTable { peer_id, addrs }) => {

p2p/src/network/kad/p2p_network_kad_state.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub struct P2pNetworkKadState {
6060
pub streams: StreamState<P2pNetworkKadStreamState>,
6161
pub status: P2pNetworkKadStatus,
6262
pub filter_addrs: bool,
63+
pub has_bootstraped: bool,
6364
}
6465

6566
impl Default for P2pNetworkKadState {
@@ -74,6 +75,7 @@ impl Default for P2pNetworkKadState {
7475
.ok()
7576
.and_then(|s| s.parse().ok())
7677
.unwrap_or(true),
78+
has_bootstraped: false,
7779
}
7880
}
7981
}

0 commit comments

Comments
 (0)