Skip to content

Commit 7c27978

Browse files
authored
Merge branch 'unstable' into simple-peer-mapping
2 parents 0130b97 + 7105442 commit 7c27978

File tree

3 files changed

+152
-146
lines changed

3 files changed

+152
-146
lines changed

beacon_node/lighthouse_network/gossipsub/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
- Remove the beta tag from the v1.2 upgrade.
33
See [PR 6344](https://github.com/sigp/lighthouse/pull/6344)
44

5+
- Correct state inconsistencies with the mesh and connected peers due to the fanout mapping.
6+
See [PR 6244](https://github.com/sigp/lighthouse/pull/6244)
7+
58
- Implement IDONTWANT messages as per [spec](https://github.com/libp2p/specs/pull/548).
69
See [PR 5422](https://github.com/sigp/lighthouse/pull/5422)
710

beacon_node/lighthouse_network/gossipsub/src/behaviour.rs

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ where
764764
}
765765
} else {
766766
tracing::error!(peer_id = %peer_id,
767-
"Could not PUBLISH, peer doesn't exist in connected peer list");
767+
"Could not send PUBLISH, peer doesn't exist in connected peer list");
768768
}
769769
}
770770

@@ -1066,7 +1066,7 @@ where
10661066
});
10671067
} else {
10681068
tracing::error!(peer = %peer_id,
1069-
"Could not GRAFT, peer doesn't exist in connected peer list");
1069+
"Could not send GRAFT, peer doesn't exist in connected peer list");
10701070
}
10711071

10721072
// If the peer did not previously exist in any mesh, inform the handler
@@ -1165,7 +1165,7 @@ where
11651165
peer.sender.prune(prune);
11661166
} else {
11671167
tracing::error!(peer = %peer_id,
1168-
"Could not PRUNE, peer doesn't exist in connected peer list");
1168+
"Could not send PRUNE, peer doesn't exist in connected peer list");
11691169
}
11701170

11711171
// If the peer did not previously exist in any mesh, inform the handler
@@ -1344,7 +1344,7 @@ where
13441344
}
13451345
} else {
13461346
tracing::error!(peer = %peer_id,
1347-
"Could not IWANT, peer doesn't exist in connected peer list");
1347+
"Could not send IWANT, peer doesn't exist in connected peer list");
13481348
}
13491349
}
13501350
tracing::trace!(peer=%peer_id, "Completed IHAVE handling for peer");
@@ -1367,7 +1367,7 @@ where
13671367

13681368
for id in iwant_msgs {
13691369
// If we have it and the IHAVE count is not above the threshold,
1370-
// foward the message.
1370+
// forward the message.
13711371
if let Some((msg, count)) = self
13721372
.mcache
13731373
.get_with_iwant_counts(&id, peer_id)
@@ -1407,7 +1407,7 @@ where
14071407
}
14081408
} else {
14091409
tracing::error!(peer = %peer_id,
1410-
"Could not IWANT, peer doesn't exist in connected peer list");
1410+
"Could not send IWANT, peer doesn't exist in connected peer list");
14111411
}
14121412
}
14131413
}
@@ -2050,8 +2050,11 @@ where
20502050
}
20512051
}
20522052

2053-
// remove unsubscribed peers from the mesh if it exists
2053+
// remove unsubscribed peers from the mesh and fanout if they exist there.
20542054
for (peer_id, topic_hash) in unsubscribed_peers {
2055+
self.fanout
2056+
.get_mut(&topic_hash)
2057+
.map(|peers| peers.remove(&peer_id));
20552058
self.remove_peer_from_mesh(&peer_id, &topic_hash, None, false, Churn::Unsub);
20562059
}
20572060

@@ -2075,7 +2078,7 @@ where
20752078
}
20762079
} else {
20772080
tracing::error!(peer = %propagation_source,
2078-
"Could not GRAFT, peer doesn't exist in connected peer list");
2081+
"Could not send GRAFT, peer doesn't exist in connected peer list");
20792082
}
20802083

20812084
// Notify the application of the subscriptions
@@ -2093,9 +2096,12 @@ where
20932096
fn apply_iwant_penalties(&mut self) {
20942097
if let Some((peer_score, ..)) = &mut self.peer_score {
20952098
for (peer, count) in self.gossip_promises.get_broken_promises() {
2096-
peer_score.add_penalty(&peer, count);
2097-
if let Some(metrics) = self.metrics.as_mut() {
2098-
metrics.register_score_penalty(Penalty::BrokenPromise);
2099+
// We do not apply penalties to nodes that have disconnected.
2100+
if self.connected_peers.contains_key(&peer) {
2101+
peer_score.add_penalty(&peer, count);
2102+
if let Some(metrics) = self.metrics.as_mut() {
2103+
metrics.register_score_penalty(Penalty::BrokenPromise);
2104+
}
20992105
}
21002106
}
21012107
}
@@ -2590,7 +2596,7 @@ where
25902596
}
25912597
} else {
25922598
tracing::error!(peer = %peer_id,
2593-
"Could not IHAVE, peer doesn't exist in connected peer list");
2599+
"Could not send IHAVE, peer doesn't exist in connected peer list");
25942600
}
25952601
}
25962602
}
@@ -2676,7 +2682,7 @@ where
26762682
peer.sender.prune(prune);
26772683
} else {
26782684
tracing::error!(peer = %peer_id,
2679-
"Could not PRUNE, peer doesn't exist in connected peer list");
2685+
"Could not send PRUNE, peer doesn't exist in connected peer list");
26802686
}
26812687

26822688
// inform the handler
@@ -2713,8 +2719,8 @@ where
27132719

27142720
for peer_id in recipient_peers {
27152721
let Some(peer) = self.connected_peers.get_mut(peer_id) else {
2716-
tracing::error!(peer = %peer_id,
2717-
"Could not IDONTWANT, peer doesn't exist in connected peer list");
2722+
// It can be the case that promises to disconnected peers appear here. In this case
2723+
// we simply ignore the peer-id.
27182724
continue;
27192725
};
27202726

@@ -2979,7 +2985,7 @@ where
29792985
}
29802986
} else {
29812987
tracing::error!(peer = %peer_id,
2982-
"Could not SUBSCRIBE, peer doesn't exist in connected peer list");
2988+
"Could not send SUBSCRIBE, peer doesn't exist in connected peer list");
29832989
}
29842990
}
29852991

0 commit comments

Comments
 (0)