Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase peerdas on main branch #3

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ discv5 = { workspace = true }
either = { workspace = true }
eip_7594 = { workspace = true }
enum-iterator = { workspace = true }
ethereum-types = { workspace = true }
fnv = { workspace = true }
futures = { workspace = true }
futures-timer = { workspace = true }
gossipsub = { workspace = true }
grandine_version = { workspace = true }
helper_functions = { workspace = true }
hex = { workspace = true }
hex_fmt = { workspace = true }
itertools = { workspace = true }
libp2p = { workspace = true }
libp2p-mplex = { workspace = true }
lru = { workspace = true }
Expand Down
5 changes: 5 additions & 0 deletions gossipsub/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## 0.5 Sigma Prime fork
- Remove the beta tag from the v1.2 upgrade.
See [PR 6344](https://github.com/sigp/lighthouse/pull/6344)

- Implement IDONTWANT messages as per [spec](https://github.com/libp2p/specs/pull/548).
See [PR 5422](https://github.com/sigp/lighthouse/pull/5422)

- Implement IDONTWANT messages as per [spec](https://github.com/libp2p/specs/pull/548).
See [PR 5422](https://github.com/sigp/lighthouse/pull/5422)
Expand Down
2 changes: 1 addition & 1 deletion gossipsub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ futures-timer = "3.0.2"
getrandom = "0.2.12"
hashlink = "0.9.1"
hex_fmt = "0.3.0"
libp2p = { version = "0.53", default-features = false }
libp2p = { version = "0.54", default-features = false }
quick-protobuf = "0.8"
quick-protobuf-codec = "0.3"
rand = "0.8"
Expand Down
10 changes: 8 additions & 2 deletions gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ use hashlink::LinkedHashMap;
use prometheus_client::registry::Registry;
use rand::{seq::SliceRandom, thread_rng};

use libp2p::core::{multiaddr::Protocol::Ip4, multiaddr::Protocol::Ip6, Endpoint, Multiaddr};
use libp2p::core::{
multiaddr::Protocol::{Ip4, Ip6},
transport::PortUse,
Endpoint, Multiaddr,
};
use libp2p::identity::Keypair;
use libp2p::identity::PeerId;
use libp2p::swarm::{
Expand Down Expand Up @@ -1720,6 +1724,7 @@ where
);
self.gossip_promises
.reject_message(msg_id, &RejectReason::BlackListedPeer);

if let Some((peer_score, ..)) = &mut self.peer_score {
peer_score.reject_message(
propagation_source,
Expand Down Expand Up @@ -2712,7 +2717,7 @@ where
};

// Only gossipsub 1.2 peers support IDONTWANT.
if peer.kind != PeerKind::Gossipsubv1_2_beta {
if peer.kind != PeerKind::Gossipsubv1_2 {
continue;
}

Expand Down Expand Up @@ -3161,6 +3166,7 @@ where
peer_id: PeerId,
_: &Multiaddr,
_: Endpoint,
_: PortUse,
) -> Result<THandler<Self>, ConnectionDenied> {
// By default we assume a peer is only a floodsub peer.
//
Expand Down
15 changes: 11 additions & 4 deletions gossipsub/src/behaviour/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ where
ConnectedPoint::Dialer {
address,
role_override: Endpoint::Dialer,
port_use: PortUse::Reuse,
}
} else {
ConnectedPoint::Listener {
Expand Down Expand Up @@ -284,6 +285,7 @@ where
let fake_endpoint = ConnectedPoint::Dialer {
address: Multiaddr::empty(),
role_override: Endpoint::Dialer,
port_use: PortUse::Reuse,
}; // this is not relevant
// peer_connections.connections should never be empty.

Expand All @@ -296,6 +298,7 @@ where
connection_id,
endpoint: &fake_endpoint,
remaining_established: active_connections,
cause: None,
}));
}
}
Expand Down Expand Up @@ -635,6 +638,7 @@ fn test_join() {
endpoint: &ConnectedPoint::Dialer {
address,
role_override: Endpoint::Dialer,
port_use: PortUse::Reuse,
},
failed_addresses: &[],
other_established: 0,
Expand Down Expand Up @@ -4181,6 +4185,7 @@ fn test_scoring_p6() {
endpoint: &ConnectedPoint::Dialer {
address: addr.clone(),
role_override: Endpoint::Dialer,
port_use: PortUse::Reuse,
},
failed_addresses: &[],
other_established: 0,
Expand All @@ -4202,6 +4207,7 @@ fn test_scoring_p6() {
endpoint: &ConnectedPoint::Dialer {
address: addr2.clone(),
role_override: Endpoint::Dialer,
port_use: PortUse::Reuse,
},
failed_addresses: &[],
other_established: 1,
Expand Down Expand Up @@ -4232,6 +4238,7 @@ fn test_scoring_p6() {
endpoint: &ConnectedPoint::Dialer {
address: addr,
role_override: Endpoint::Dialer,
port_use: PortUse::Reuse,
},
failed_addresses: &[],
other_established: 2,
Expand Down Expand Up @@ -5252,7 +5259,7 @@ fn sends_idontwant() {
.to_subscribe(true)
.gs_config(Config::default())
.explicit(1)
.peer_kind(PeerKind::Gossipsubv1_2_beta)
.peer_kind(PeerKind::Gossipsubv1_2)
.create_network();

let local_id = PeerId::random();
Expand Down Expand Up @@ -5337,7 +5344,7 @@ fn doesnt_forward_idontwant() {
.to_subscribe(true)
.gs_config(Config::default())
.explicit(1)
.peer_kind(PeerKind::Gossipsubv1_2_beta)
.peer_kind(PeerKind::Gossipsubv1_2)
.create_network();

let local_id = PeerId::random();
Expand Down Expand Up @@ -5386,7 +5393,7 @@ fn parses_idontwant() {
.to_subscribe(true)
.gs_config(Config::default())
.explicit(1)
.peer_kind(PeerKind::Gossipsubv1_2_beta)
.peer_kind(PeerKind::Gossipsubv1_2)
.create_network();

let message_id = MessageId::new(&[0, 1, 2, 3]);
Expand Down Expand Up @@ -5418,7 +5425,7 @@ fn clear_stale_idontwant() {
.to_subscribe(true)
.gs_config(Config::default())
.explicit(1)
.peer_kind(PeerKind::Gossipsubv1_2_beta)
.peer_kind(PeerKind::Gossipsubv1_2)
.create_network();

let peer = gs.connected_peers.get_mut(&peers[2]).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions gossipsub/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ use void::Void;

pub(crate) const SIGNING_PREFIX: &[u8] = b"libp2p-pubsub:";

pub(crate) const GOSSIPSUB_1_2_0_BETA_PROTOCOL: ProtocolId = ProtocolId {
pub(crate) const GOSSIPSUB_1_2_0_PROTOCOL: ProtocolId = ProtocolId {
protocol: StreamProtocol::new("/meshsub/1.2.0"),
kind: PeerKind::Gossipsubv1_2_beta,
kind: PeerKind::Gossipsubv1_2,
};
pub(crate) const GOSSIPSUB_1_1_0_PROTOCOL: ProtocolId = ProtocolId {
protocol: StreamProtocol::new("/meshsub/1.1.0"),
Expand Down Expand Up @@ -74,7 +74,7 @@ impl Default for ProtocolConfig {
max_transmit_size: 65536,
validation_mode: ValidationMode::Strict,
protocol_ids: vec![
GOSSIPSUB_1_2_0_BETA_PROTOCOL,
GOSSIPSUB_1_2_0_PROTOCOL,
GOSSIPSUB_1_1_0_PROTOCOL,
GOSSIPSUB_1_0_0_PROTOCOL,
],
Expand Down
6 changes: 3 additions & 3 deletions gossipsub/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ pub(crate) struct PeerConnections {
#[allow(non_camel_case_types)]
pub enum PeerKind {
/// A gossipsub 1.2 peer.
Gossipsubv1_2_beta,
Gossipsubv1_2,
/// A gossipsub 1.1 peer.
Gossipsubv1_1,
/// A gossipsub 1.0 peer.
Expand All @@ -148,7 +148,7 @@ impl PeerKind {
pub(crate) fn is_gossipsub(&self) -> bool {
matches!(
self,
Self::Gossipsubv1_2_beta | Self::Gossipsubv1_1 | Self::Gossipsub
Self::Gossipsubv1_2 | Self::Gossipsubv1_1 | Self::Gossipsub
)
}
}
Expand Down Expand Up @@ -623,7 +623,7 @@ impl PeerKind {
Self::Floodsub => "Floodsub",
Self::Gossipsub => "Gossipsub v1.0",
Self::Gossipsubv1_1 => "Gossipsub v1.1",
Self::Gossipsubv1_2_beta => "Gossipsub v1.2-beta",
Self::Gossipsubv1_2 => "Gossipsub v1.2",
}
}
}
Expand Down
Loading