Switch libp2p sigp gossipsub fork (#4999)

* switch libp2p source to sigp fork

* Shift the connection closing inside RPC behaviour

* Tag specific commits

* Add slow peer scoring

* Fix test

* Use default yamux config

* Pin discv5 to our libp2p fork and cargo update

* Upgrade libp2p to enable yamux gains

* Add a comment specifying the branch being used

* cleanup build output from within container
(prevents CI warnings related to fs permissions)

* Remove revision tags add branches for testing, will revert back once we're happy

* Update to latest rust-libp2p version

* Pin forks

* Update cargo.lock

* Re-pin to panic-free rust

---------

Co-authored-by: Age Manning <Age@AgeManning.com>
Co-authored-by: Pawan Dhananjay <pawandhananjay@gmail.com>
Co-authored-by: antondlr <anton@delaruelle.net>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
João Oliveira
2024-01-10 05:26:52 +00:00
committed by GitHub
parent be79f74c6d
commit 38df87c3c5
17 changed files with 1057 additions and 987 deletions

View File

@@ -10,11 +10,8 @@ pub mod enr_ext;
use crate::service::TARGET_SUBNET_PEERS;
use crate::{error, Enr, NetworkConfig, NetworkGlobals, Subnet, SubnetDiscovery};
use crate::{metrics, ClearDialError};
use discv5::{enr::NodeId, Discv5, Discv5Event};
pub use enr::{
build_enr, create_enr_builder_from_config, load_enr_from_disk, use_or_load_enr, CombinedKey,
Eth2Enr,
};
use discv5::{enr::NodeId, Discv5};
pub use enr::{build_enr, load_enr_from_disk, use_or_load_enr, CombinedKey, Eth2Enr};
pub use enr_ext::{peer_id_to_node_id, CombinedKeyExt, EnrExt};
pub use libp2p::identity::{Keypair, PublicKey};
@@ -147,15 +144,10 @@ enum EventStream {
/// Awaiting an event stream to be generated. This is required due to the poll nature of
/// `Discovery`
Awaiting(
Pin<
Box<
dyn Future<Output = Result<mpsc::Receiver<Discv5Event>, discv5::Discv5Error>>
+ Send,
>,
>,
Pin<Box<dyn Future<Output = Result<mpsc::Receiver<discv5::Event>, discv5::Error>> + Send>>,
),
/// The future has completed.
Present(mpsc::Receiver<Discv5Event>),
Present(mpsc::Receiver<discv5::Event>),
// The future has failed or discv5 has been disabled. There are no events from discv5.
InActive,
}
@@ -996,7 +988,7 @@ impl<TSpec: EthSpec> NetworkBehaviour for Discovery<TSpec> {
match event {
// We filter out unwanted discv5 events here and only propagate useful results to
// the peer manager.
Discv5Event::Discovered(_enr) => {
discv5::Event::Discovered(_enr) => {
// Peers that get discovered during a query but are not contactable or
// don't match a predicate can end up here. For debugging purposes we
// log these to see if we are unnecessarily dropping discovered peers
@@ -1009,7 +1001,7 @@ impl<TSpec: EthSpec> NetworkBehaviour for Discovery<TSpec> {
}
*/
}
Discv5Event::SocketUpdated(socket_addr) => {
discv5::Event::SocketUpdated(socket_addr) => {
info!(self.log, "Address updated"; "ip" => %socket_addr.ip(), "udp_port" => %socket_addr.port());
metrics::inc_counter(&metrics::ADDRESS_UPDATE_COUNT);
metrics::check_nat();
@@ -1030,10 +1022,10 @@ impl<TSpec: EthSpec> NetworkBehaviour for Discovery<TSpec> {
// NOTE: We assume libp2p itself can keep track of IP changes and we do
// not inform it about IP changes found via discovery.
}
Discv5Event::EnrAdded { .. }
| Discv5Event::TalkRequest(_)
| Discv5Event::NodeInserted { .. }
| Discv5Event::SessionEstablished { .. } => {} // Ignore all other discv5 server events
discv5::Event::EnrAdded { .. }
| discv5::Event::TalkRequest(_)
| discv5::Event::NodeInserted { .. }
| discv5::Event::SessionEstablished { .. } => {} // Ignore all other discv5 server events
}
}
}
@@ -1144,7 +1136,6 @@ impl<TSpec: EthSpec> Discovery<TSpec> {
mod tests {
use super::*;
use crate::rpc::methods::{MetaData, MetaDataV2};
use enr::EnrBuilder;
use libp2p::identity::secp256k1;
use slog::{o, Drain};
use types::{BitVector, MinimalEthSpec, SubnetId};
@@ -1227,7 +1218,7 @@ mod tests {
}
fn make_enr(subnet_ids: Vec<usize>) -> Enr {
let mut builder = EnrBuilder::new("v4");
let mut builder = Enr::builder();
let keypair = secp256k1::Keypair::generate();
let enr_key: CombinedKey = CombinedKey::from_secp256k1(&keypair);