Implement gossipsub IDONTWANT (#5422)

* move gossipsub into a separate crate

* Merge branch 'unstable' of github.com:sigp/lighthouse into separate-gossipsub

* update rpc.proto and generate rust bindings

* gossipsub: implement IDONTWANT messages

* address review

* move GossipPromises out of PeerScore

* impl PeerKind::is_gossipsub

that returns true if peer speaks any version of gossipsub

* address review 2

* Merge branch 'separate-gossipsub' of github.com:sigp/lighthouse into impl-gossipsub-idontwant

* Merge branch 'unstable' of github.com:sigp/lighthouse into impl-gossipsub-idontwant

* add metrics

* add tests

* make 1.2 beta before spec is merged

* Merge branch 'unstable' of github.com:sigp/lighthouse into impl-gossipsub-idontwant

* cargo clippy

* Collect decoded IDONTWANT messages

* Use the beta tag in most places to simplify the transition

* Fix failed test by using fresh message-ids

* Gossipsub v1.2-beta

* Merge latest unstable

* Cargo update

* Merge pull request #5 from ackintosh/impl-gossipsub-idontwant-ackintosh-fix-test

Fix `test_ignore_too_many_messages_in_ihave` test

* Merge branch 'unstable' of github.com:sigp/lighthouse into impl-gossipsub-idontwant

* update CHANGELOG.md

* remove beta for 1.2 IDONTWANT spec has been merged

* Merge branch 'unstable' of github.com:sigp/lighthouse into impl-gossipsub-idontwant

* Merge branch 'impl-gossipsub-idontwant' of github.com:jxs/lighthouse into impl-gossipsub-idontwant

* Merge branch 'unstable' of github.com:sigp/lighthouse into impl-gossipsub-idontwant

* improve comments wording

* Merge branch 'impl-gossipsub-idontwant' of github.com:jxs/lighthouse into impl-gossipsub-idontwant
This commit is contained in:
João Oliveira
2024-07-09 06:37:19 +01:00
committed by GitHub
parent 2e2ccec9b5
commit d46ac6c3d3
13 changed files with 533 additions and 48 deletions

View File

@@ -179,6 +179,12 @@ pub(crate) struct Metrics {
/// topic. A very high metric might indicate an underperforming network.
topic_iwant_msgs: Family<TopicHash, Counter>,
/// The number of times we have received an IDONTWANT control message.
idontwant_msgs: Counter,
/// The number of msg_id's we have received in every IDONTWANT control message.
idontwant_msgs_ids: Counter,
/// The size of the priority queue.
priority_queue_size: Histogram,
/// The size of the non-priority queue.
@@ -311,6 +317,27 @@ impl Metrics {
"topic_iwant_msgs",
"Number of times we have decided an IWANT is required for this topic"
);
let idontwant_msgs = {
let metric = Counter::default();
registry.register(
"idontwant_msgs",
"The number of times we have received an IDONTWANT control message",
metric.clone(),
);
metric
};
let idontwant_msgs_ids = {
let metric = Counter::default();
registry.register(
"idontwant_msgs_ids",
"The number of msg_id's we have received in every IDONTWANT control message.",
metric.clone(),
);
metric
};
let memcache_misses = {
let metric = Counter::default();
registry.register(
@@ -362,6 +389,8 @@ impl Metrics {
heartbeat_duration,
memcache_misses,
topic_iwant_msgs,
idontwant_msgs,
idontwant_msgs_ids,
priority_queue_size,
non_priority_queue_size,
}
@@ -560,6 +589,12 @@ impl Metrics {
}
}
/// Register receiving an IDONTWANT msg for this topic.
pub(crate) fn register_idontwant(&mut self, msgs: usize) {
self.idontwant_msgs.inc();
self.idontwant_msgs_ids.inc_by(msgs as u64);
}
/// Observes a heartbeat duration.
pub(crate) fn observe_heartbeat_duration(&mut self, millis: u64) {
self.heartbeat_duration.observe(millis as f64);