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

@@ -23,8 +23,8 @@ use super::handler::HandlerEvent;
use super::rpc_proto::proto;
use super::topic::TopicHash;
use super::types::{
ControlAction, Graft, IHave, IWant, MessageId, PeerInfo, PeerKind, Prune, RawMessage, Rpc,
Subscription, SubscriptionAction,
ControlAction, Graft, IDontWant, IHave, IWant, MessageId, PeerInfo, PeerKind, Prune,
RawMessage, Rpc, Subscription, SubscriptionAction,
};
use super::ValidationError;
use asynchronous_codec::{Decoder, Encoder, Framed};
@@ -40,6 +40,10 @@ use void::Void;
pub(crate) const SIGNING_PREFIX: &[u8] = b"libp2p-pubsub:";
pub(crate) const GOSSIPSUB_1_2_0_BETA_PROTOCOL: ProtocolId = ProtocolId {
protocol: StreamProtocol::new("/meshsub/1.2.0"),
kind: PeerKind::Gossipsubv1_2_beta,
};
pub(crate) const GOSSIPSUB_1_1_0_PROTOCOL: ProtocolId = ProtocolId {
protocol: StreamProtocol::new("/meshsub/1.1.0"),
kind: PeerKind::Gossipsubv1_1,
@@ -69,7 +73,11 @@ impl Default for ProtocolConfig {
Self {
max_transmit_size: 65536,
validation_mode: ValidationMode::Strict,
protocol_ids: vec![GOSSIPSUB_1_1_0_PROTOCOL, GOSSIPSUB_1_0_0_PROTOCOL],
protocol_ids: vec![
GOSSIPSUB_1_2_0_BETA_PROTOCOL,
GOSSIPSUB_1_1_0_PROTOCOL,
GOSSIPSUB_1_0_0_PROTOCOL,
],
}
}
}
@@ -476,10 +484,25 @@ impl Decoder for GossipsubCodec {
}));
}
let idontwant_msgs: Vec<ControlAction> = rpc_control
.idontwant
.into_iter()
.map(|idontwant| {
ControlAction::IDontWant(IDontWant {
message_ids: idontwant
.message_ids
.into_iter()
.map(MessageId::from)
.collect::<Vec<_>>(),
})
})
.collect();
control_msgs.extend(ihave_msgs);
control_msgs.extend(iwant_msgs);
control_msgs.extend(graft_msgs);
control_msgs.extend(prune_msgs);
control_msgs.extend(idontwant_msgs);
}
Ok(Some(HandlerEvent::Message {