mirror of
https://github.com/sigp/gossipsub-testground.git
synced 2026-01-09 05:28:04 -05:00
Switch target crate to sigp's gossipsub implementation (#17)
* Bump the Rust version * Update smoke plan * Update scoring plan * Update censoring plan * Fix wrong file name * Update eth-consensus plan * Fix clippy warnings * cargo fmt
This commit is contained in:
2420
censoring/Cargo.lock
generated
2420
censoring/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -6,12 +6,12 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
# unstable branch
|
||||
gossipsub = { git = "https://github.com/sigp/lighthouse.git", rev = "f8fdb71f50851bf7792e68a4ee31125bd645e19a" }
|
||||
|
||||
chrono = { version = "0.4.19", default-features = false, features = ["clock"] }
|
||||
delay_map = "0.1.1"
|
||||
|
||||
# TODO: Update libp2p once the next version, which includes prometheus-client v0.20, has been released.
|
||||
# See https://github.com/ackintosh/rust-libp2p/commit/df09870c8c2294cbaeb881f58d4f9752125562bc
|
||||
libp2p = { git = "https://github.com/ackintosh/rust-libp2p.git", branch = "prometheus-client-0.20.0", default-features = false, features = ["gossipsub", "dns", "tcp", "tokio", "noise", "mplex", "yamux", "serde"] }
|
||||
libp2p = { version = "0.53.2", default-features = false, features = ["dns", "tcp", "tokio", "noise", "yamux", "serde"] }
|
||||
|
||||
# This is a fork of `libp2p` in order to implement malicious behaviour in the `attacker` module.
|
||||
# This `libp2p-testground` is used in `attacker` module instead of `libp2p`.
|
||||
@@ -26,9 +26,5 @@ testground = { git = "https://github.com/testground/sdk-rust.git", rev = "1fd032
|
||||
tokio = { version = "1.20.0", features = ["macros"] }
|
||||
tracing = "0.1.35"
|
||||
tracing-subscriber = { version = "0.3.14", features = ["env-filter"] }
|
||||
|
||||
# TODO: Update prometheus-client once the next version, which includes the fix, has been released.
|
||||
# See https://github.com/prometheus/client_rust/pull/123
|
||||
prometheus-client = { git = "https://github.com/ackintosh/client_rust.git", branch = "fix/protobuf-labels", features = ["protobuf"] }
|
||||
|
||||
prometheus-client = { version = "0.22.2", features = ["protobuf"] }
|
||||
prost = "0.11"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# This Dockerfile is for the `docker:generic` builder.
|
||||
# See https://docs.testground.ai/builder-library/docker-generic for details about the builder.
|
||||
FROM rust:1.67-bullseye as builder
|
||||
FROM rust:1.77-bullseye as builder
|
||||
WORKDIR /usr/src/test-plan
|
||||
|
||||
# * `prost-build`, a dependency of `libp2p-gossipsub`, requires cmake.
|
||||
|
||||
@@ -59,9 +59,10 @@ pub(crate) async fn run(
|
||||
// Start libp2p
|
||||
// ////////////////////////////////////////////////////////////////////////
|
||||
let mut swarm = build_swarm(keypair);
|
||||
swarm.listen_on(instance_info.multiaddr.clone())?;
|
||||
swarm.listen_on(recreate_multiaddr(&instance_info.multiaddr))?;
|
||||
match swarm.next().await.unwrap() {
|
||||
SwarmEvent::NewListenAddr { address, .. } if address == instance_info.multiaddr => {}
|
||||
SwarmEvent::NewListenAddr { address, .. }
|
||||
if address == recreate_multiaddr(&instance_info.multiaddr) => {}
|
||||
e => panic!("Unexpected event {:?}", e),
|
||||
}
|
||||
|
||||
@@ -79,7 +80,7 @@ pub(crate) async fn run(
|
||||
};
|
||||
client.record_message(format!("Victim: {:?}", victim));
|
||||
|
||||
swarm.dial(victim.multiaddr)?;
|
||||
swarm.dial(recreate_multiaddr(&victim.multiaddr))?;
|
||||
|
||||
barrier_and_drive_swarm(&client, &mut swarm, BARRIER_WARMUP).await?;
|
||||
|
||||
@@ -119,6 +120,12 @@ fn build_transport(
|
||||
.boxed()
|
||||
}
|
||||
|
||||
// We are recreating from `libp2p::Multiaddr` to `libp2p_testground::Multiaddr` because we use two
|
||||
// different versions of libp2p.
|
||||
fn recreate_multiaddr(addr: &libp2p::Multiaddr) -> libp2p_testground::Multiaddr {
|
||||
libp2p_testground::Multiaddr::try_from(addr.to_vec()).unwrap()
|
||||
}
|
||||
|
||||
type GossipsubNetworkBehaviourAction =
|
||||
NetworkBehaviourAction<GossipsubEvent, GossipsubHandler, GossipsubHandlerIn>;
|
||||
|
||||
|
||||
@@ -4,26 +4,16 @@ use crate::utils::{
|
||||
};
|
||||
use crate::{InstanceInfo, Role};
|
||||
use chrono::Local;
|
||||
use libp2p::core::muxing::StreamMuxerBox;
|
||||
use libp2p::core::upgrade::{SelectUpgrade, Version};
|
||||
use libp2p::dns::TokioDnsConfig;
|
||||
use libp2p::futures::StreamExt;
|
||||
use libp2p::gossipsub::metrics::Config;
|
||||
use libp2p::gossipsub::subscription_filter::AllowAllSubscriptionFilter;
|
||||
use libp2p::gossipsub::{
|
||||
Behaviour, ConfigBuilder, IdentTopic, IdentityTransform, MessageAuthenticity, PeerScoreParams,
|
||||
PeerScoreThresholds, Topic, TopicScoreParams,
|
||||
use gossipsub::{
|
||||
AllowAllSubscriptionFilter, Behaviour, ConfigBuilder, IdentTopic, IdentityTransform,
|
||||
MessageAuthenticity, MetricsConfig, PeerScoreParams, PeerScoreThresholds, Topic,
|
||||
TopicScoreParams,
|
||||
};
|
||||
use libp2p::core::muxing::StreamMuxerBox;
|
||||
use libp2p::futures::StreamExt;
|
||||
use libp2p::identity::Keypair;
|
||||
use libp2p::mplex::MplexConfig;
|
||||
use libp2p::noise::NoiseConfig;
|
||||
use libp2p::swarm::{DialError, SwarmBuilder, SwarmEvent};
|
||||
use libp2p::tcp::tokio::Transport as TcpTransport;
|
||||
use libp2p::tcp::Config as TcpConfig;
|
||||
use libp2p::yamux::YamuxConfig;
|
||||
use libp2p::PeerId;
|
||||
use libp2p::Transport;
|
||||
use libp2p::{Multiaddr, Swarm};
|
||||
use libp2p::swarm::{DialError, SwarmEvent};
|
||||
use libp2p::{noise, yamux, Multiaddr, PeerId, Swarm, SwarmBuilder, Transport};
|
||||
use prometheus_client::registry::Registry;
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::SeedableRng;
|
||||
@@ -289,20 +279,17 @@ pub(crate) async fn run(
|
||||
|
||||
/// Set up an encrypted TCP transport over the Mplex and Yamux protocols.
|
||||
fn build_transport(keypair: &Keypair) -> libp2p::core::transport::Boxed<(PeerId, StreamMuxerBox)> {
|
||||
let transport = TokioDnsConfig::system(TcpTransport::new(TcpConfig::default().nodelay(true)))
|
||||
.expect("DNS config");
|
||||
|
||||
let noise_keys = libp2p::noise::Keypair::<libp2p::noise::X25519Spec>::new()
|
||||
.into_authentic(keypair)
|
||||
.expect("Signing libp2p-noise static DH keypair failed.");
|
||||
let tcp = libp2p::tcp::tokio::Transport::new(libp2p::tcp::Config::default().nodelay(true));
|
||||
let transport = libp2p::dns::tokio::Transport::system(tcp)
|
||||
.expect("DNS")
|
||||
.boxed();
|
||||
|
||||
transport
|
||||
.upgrade(Version::V1)
|
||||
.authenticate(NoiseConfig::xx(noise_keys).into_authenticated())
|
||||
.multiplex(SelectUpgrade::new(
|
||||
YamuxConfig::default(),
|
||||
MplexConfig::default(),
|
||||
))
|
||||
.upgrade(libp2p::core::upgrade::Version::V1)
|
||||
.authenticate(
|
||||
noise::Config::new(keypair).expect("signing can fail only once during starting a node"),
|
||||
)
|
||||
.multiplex(yamux::Config::default())
|
||||
.timeout(Duration::from_secs(20))
|
||||
.boxed()
|
||||
}
|
||||
@@ -354,7 +341,7 @@ impl HonestNetwork {
|
||||
let mut gs = Behaviour::new_with_subscription_filter_and_transform(
|
||||
MessageAuthenticity::Signed(keypair.clone()),
|
||||
gossipsub_config,
|
||||
Some((registry, Config::default())),
|
||||
Some((registry, MetricsConfig::default())),
|
||||
AllowAllSubscriptionFilter {},
|
||||
IdentityTransform {},
|
||||
)
|
||||
@@ -371,12 +358,14 @@ impl HonestNetwork {
|
||||
gs
|
||||
};
|
||||
|
||||
let swarm = SwarmBuilder::with_tokio_executor(
|
||||
build_transport(&keypair),
|
||||
gossipsub,
|
||||
PeerId::from(keypair.public()),
|
||||
)
|
||||
.build();
|
||||
let transport = build_transport(&keypair);
|
||||
let swarm = SwarmBuilder::with_existing_identity(keypair)
|
||||
.with_tokio()
|
||||
.with_other_transport(|_| transport)
|
||||
.expect("infallible")
|
||||
.with_behaviour(|_| gossipsub)
|
||||
.expect("infallible")
|
||||
.build();
|
||||
|
||||
let mut peer_to_instance_name = HashMap::new();
|
||||
for info in participants {
|
||||
|
||||
2628
eth_consensus/Cargo.lock
generated
2628
eth_consensus/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
# Get chef
|
||||
FROM rust:1.67-bullseye as chef
|
||||
FROM rust:1.77-bullseye as chef
|
||||
WORKDIR test-plan
|
||||
RUN cargo install cargo-chef
|
||||
|
||||
|
||||
@@ -6,15 +6,13 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
# unstable branch
|
||||
gossipsub = { git = "https://github.com/sigp/lighthouse.git", rev = "f8fdb71f50851bf7792e68a4ee31125bd645e19a" }
|
||||
|
||||
libp2p = { version = "0.53.2", default-features = false, features = ["dns", "tcp", "tokio", "noise", "yamux", "serde"] }
|
||||
chrono = { version = "0.4.19", features = [ "std" ]}
|
||||
delay_map = "0.1.1"
|
||||
|
||||
# TODO: Update prometheus-client once the next version, which includes the fix, has been released.
|
||||
# See https://github.com/prometheus/client_rust/pull/123
|
||||
prometheus-client = { git = "https://github.com/ackintosh/client_rust.git", branch = "fix/protobuf-labels", features = ["protobuf"] }
|
||||
# TODO: Update libp2p once the next version, which includes prometheus-client v0.20, has been released.
|
||||
# See https://github.com/ackintosh/rust-libp2p/commit/df09870c8c2294cbaeb881f58d4f9752125562bc
|
||||
libp2p = { git = "https://github.com/ackintosh/rust-libp2p.git", branch = "prometheus-client-0.20.0", default-features = false, features = ["gossipsub", "dns", "tcp", "tokio", "noise", "mplex", "yamux", "serde"] }
|
||||
prometheus-client = { version = "0.22.2", features = ["protobuf"] }
|
||||
serde_json = "1.0"
|
||||
serde = "1.0"
|
||||
testground.workspace = true
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
use crate::InstanceInfo;
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use futures::stream::FuturesUnordered;
|
||||
use libp2p::gossipsub::{
|
||||
Behaviour, Event, HandlerError, IdentTopic, MessageId, Topic as GossipTopic,
|
||||
};
|
||||
use gossipsub::{Behaviour, Event, IdentTopic, MessageId, Topic as GossipTopic};
|
||||
use libp2p::swarm::SwarmEvent;
|
||||
use libp2p::PeerId;
|
||||
use libp2p::Swarm;
|
||||
use libp2p::{PeerId, Swarm};
|
||||
use npg::Generator;
|
||||
use prometheus_client::registry::Registry;
|
||||
use rand::Rng;
|
||||
@@ -118,7 +115,7 @@ impl Network {
|
||||
topic: Topic,
|
||||
validator: u64,
|
||||
mut payload: Vec<u8>,
|
||||
) -> Result<libp2p::gossipsub::MessageId, libp2p::gossipsub::PublishError> {
|
||||
) -> Result<MessageId, gossipsub::PublishError> {
|
||||
// Plain binary as messages, coupled with the validator
|
||||
payload.append(&mut validator.to_be_bytes().to_vec());
|
||||
|
||||
@@ -135,7 +132,7 @@ impl Network {
|
||||
}
|
||||
|
||||
// An inbound event or swarm event gets sent here
|
||||
fn handle_swarm_event(&mut self, event: SwarmEvent<Event, HandlerError>) {
|
||||
fn handle_swarm_event(&mut self, event: SwarmEvent<Event>) {
|
||||
match event {
|
||||
SwarmEvent::Behaviour(Event::Message {
|
||||
propagation_source,
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::utils::{
|
||||
};
|
||||
use crate::InstanceInfo;
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use libp2p::gossipsub::IdentTopic;
|
||||
use gossipsub::IdentTopic;
|
||||
use prometheus_client::encoding::protobuf::openmetrics_data_model::MetricSet;
|
||||
use std::sync::Arc;
|
||||
use testground::client::Client;
|
||||
@@ -133,6 +133,9 @@ pub(crate) async fn record_metrics(info: RecordMetricsInfo) {
|
||||
| "rejected_messages_per_topic" => {
|
||||
queries_for_counter(¤t, family, node_id, &info.instance_info, run_id)
|
||||
}
|
||||
"publish_messages_dropped_per_topic" | "forward_messages_dropped_per_topic" => {
|
||||
continue;
|
||||
}
|
||||
// ///////////////////////////////////
|
||||
// Metrics regarding mesh state
|
||||
// ///////////////////////////////////
|
||||
@@ -193,6 +196,12 @@ pub(crate) async fn record_metrics(info: RecordMetricsInfo) {
|
||||
"memcache_misses" => {
|
||||
queries_for_counter(¤t, family, info.node_id, &info.instance_info, run_id)
|
||||
}
|
||||
// ///////////////////////////////////
|
||||
// The size of the priority queue.
|
||||
// ///////////////////////////////////
|
||||
"priority_queue_size" | "non_priority_queue_size" => {
|
||||
continue;
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
|
||||
@@ -2,25 +2,17 @@ use crate::utils::{record_instance_info, BARRIER_LIBP2P_READY, BARRIER_TOPOLOGY_
|
||||
use crate::InstanceInfo;
|
||||
use futures::stream::FuturesUnordered;
|
||||
use gen_topology::Params;
|
||||
use libp2p::core::muxing::StreamMuxerBox;
|
||||
use libp2p::core::upgrade::{SelectUpgrade, Version};
|
||||
use libp2p::dns::TokioDnsConfig;
|
||||
use libp2p::futures::StreamExt;
|
||||
use libp2p::gossipsub::metrics::Config;
|
||||
use libp2p::gossipsub::subscription_filter::AllowAllSubscriptionFilter;
|
||||
use libp2p::gossipsub::{
|
||||
Behaviour, ConfigBuilder, IdentityTransform, Message as GossipsubMessage, MessageAuthenticity,
|
||||
MessageId, PeerScoreParams, PeerScoreThresholds, ValidationMode,
|
||||
use gossipsub::{
|
||||
AllowAllSubscriptionFilter, Behaviour, ConfigBuilder, IdentityTransform,
|
||||
Message as GossipsubMessage, MessageAuthenticity, MessageId, MetricsConfig, PeerScoreParams,
|
||||
PeerScoreThresholds, ValidationMode,
|
||||
};
|
||||
use libp2p::core::muxing::StreamMuxerBox;
|
||||
use libp2p::futures::StreamExt;
|
||||
use libp2p::identity::Keypair;
|
||||
use libp2p::mplex::MplexConfig;
|
||||
use libp2p::noise::NoiseConfig;
|
||||
use libp2p::swarm::{SwarmBuilder, SwarmEvent};
|
||||
use libp2p::tcp::tokio::Transport as TcpTransport;
|
||||
use libp2p::tcp::Config as TcpConfig;
|
||||
use libp2p::yamux::YamuxConfig;
|
||||
use libp2p::PeerId;
|
||||
use libp2p::swarm::SwarmEvent;
|
||||
use libp2p::Transport;
|
||||
use libp2p::{noise, yamux, PeerId, SwarmBuilder};
|
||||
use npg::slot_generator::{Subnet, ValId};
|
||||
use npg::Generator;
|
||||
use npg::Message;
|
||||
@@ -121,7 +113,7 @@ pub fn setup_gossipsub(registry: &mut Registry) -> Behaviour {
|
||||
let mut gs = Behaviour::new_with_subscription_filter_and_transform(
|
||||
MessageAuthenticity::Anonymous,
|
||||
gossipsub_config,
|
||||
Some((registry, Config::default())),
|
||||
Some((registry, MetricsConfig::default())),
|
||||
AllowAllSubscriptionFilter {},
|
||||
IdentityTransform {},
|
||||
)
|
||||
@@ -217,20 +209,17 @@ pub(crate) async fn run(
|
||||
pub fn build_transport(
|
||||
keypair: &Keypair,
|
||||
) -> libp2p::core::transport::Boxed<(PeerId, StreamMuxerBox)> {
|
||||
let transport = TokioDnsConfig::system(TcpTransport::new(TcpConfig::default().nodelay(true)))
|
||||
.expect("DNS config");
|
||||
|
||||
let noise_keys = libp2p::noise::Keypair::<libp2p::noise::X25519Spec>::new()
|
||||
.into_authentic(keypair)
|
||||
.expect("Signing libp2p-noise static DH keypair failed.");
|
||||
let tcp = libp2p::tcp::tokio::Transport::new(libp2p::tcp::Config::default().nodelay(true));
|
||||
let transport = libp2p::dns::tokio::Transport::system(tcp)
|
||||
.expect("DNS")
|
||||
.boxed();
|
||||
|
||||
transport
|
||||
.upgrade(Version::V1)
|
||||
.authenticate(NoiseConfig::xx(noise_keys).into_authenticated())
|
||||
.multiplex(SelectUpgrade::new(
|
||||
YamuxConfig::default(),
|
||||
MplexConfig::default(),
|
||||
))
|
||||
.upgrade(libp2p::core::upgrade::Version::V1)
|
||||
.authenticate(
|
||||
noise::Config::new(keypair).expect("signing can fail only once during starting a node"),
|
||||
)
|
||||
.multiplex(yamux::Config::default())
|
||||
.timeout(Duration::from_secs(20))
|
||||
.boxed()
|
||||
}
|
||||
@@ -250,12 +239,14 @@ impl Network {
|
||||
) -> Self {
|
||||
let gossipsub = setup_gossipsub(&mut registry);
|
||||
|
||||
let swarm = SwarmBuilder::with_tokio_executor(
|
||||
build_transport(&keypair),
|
||||
gossipsub,
|
||||
PeerId::from(keypair.public()),
|
||||
)
|
||||
.build();
|
||||
let transport = build_transport(&keypair);
|
||||
let swarm = SwarmBuilder::with_existing_identity(keypair)
|
||||
.with_tokio()
|
||||
.with_other_transport(|_| transport)
|
||||
.expect("infallible")
|
||||
.with_behaviour(|_| gossipsub)
|
||||
.expect("infallible")
|
||||
.build();
|
||||
|
||||
info!(
|
||||
"[{}] running with {} validators",
|
||||
@@ -373,7 +364,7 @@ impl Network {
|
||||
event = self.swarm.select_next_some() => self.handle_swarm_event(event),
|
||||
Some(x) = self.messages_to_validate.next(), if !self.messages_to_validate.is_empty() => { // Message needs validation
|
||||
let (message_id, peer_id) = x.into_inner();
|
||||
if let Err(e) = self.swarm.behaviour_mut().report_message_validation_result(&message_id, &peer_id, libp2p::gossipsub::MessageAcceptance::Accept) {
|
||||
if let Err(e) = self.swarm.behaviour_mut().report_message_validation_result(&message_id, &peer_id, gossipsub::MessageAcceptance::Accept) {
|
||||
warn!("Could not publish message: {} {}", message_id, e);
|
||||
}
|
||||
}
|
||||
|
||||
2454
scoring/Cargo.lock
generated
2454
scoring/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -11,16 +11,12 @@ delay_map = "0.1.1"
|
||||
futures = "0.3.24"
|
||||
gen_topology = { git = "https://github.com/sigp/gossipsub-testground", rev = "4084d26b9210bc932f4aaa45f9506ecfe5f2bb04" }
|
||||
|
||||
# TODO: Update libp2p once the next version, which includes prometheus-client v0.20, has been released.
|
||||
# See https://github.com/ackintosh/rust-libp2p/commit/df09870c8c2294cbaeb881f58d4f9752125562bc
|
||||
libp2p = { git = "https://github.com/ackintosh/rust-libp2p.git", branch = "prometheus-client-0.20.0", default-features = false, features = ["gossipsub", "dns", "tcp", "tokio", "noise", "mplex", "yamux", "serde"] }
|
||||
# unstable branch
|
||||
gossipsub = { git = "https://github.com/sigp/lighthouse.git", rev = "f8fdb71f50851bf7792e68a4ee31125bd645e19a" }
|
||||
|
||||
libp2p = { version = "0.53.2", default-features = false, features = ["dns", "tcp", "tokio", "noise", "yamux", "serde"] }
|
||||
npg = { git = "https://github.com/sigp/eth-npg", rev = "6118cdd63eb34ffa4b230d17e88c8adf7057e138" }
|
||||
|
||||
# TODO: Update prometheus-client once the next version, which includes the fix, has been released.
|
||||
# See https://github.com/prometheus/client_rust/pull/123
|
||||
prometheus-client = { git = "https://github.com/ackintosh/client_rust.git", branch = "fix/protobuf-labels", features = ["protobuf"] }
|
||||
|
||||
prometheus-client = { version = "0.22.2", features = ["protobuf"] }
|
||||
prost = "0.11"
|
||||
rand = "0.8.5"
|
||||
serde_json = "1.0"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# This Dockerfile is for the `docker:generic` builder.
|
||||
# See https://docs.testground.ai/builder-library/docker-generic for details about the builder.
|
||||
FROM rust:1.67-bullseye as builder
|
||||
FROM rust:1.77-bullseye as builder
|
||||
WORKDIR /usr/src/test-plan
|
||||
|
||||
# * `prost-build`, a dependency of `libp2p-gossipsub`, requires cmake.
|
||||
|
||||
@@ -98,7 +98,9 @@ pub(crate) async fn run(client: Client) -> Result<(), Box<dyn std::error::Error>
|
||||
record_victim_id(&client, target).await;
|
||||
record_topology_edge(&client, peer_id.to_string(), target.peer_id().to_string()).await;
|
||||
|
||||
swarm.dial(target.multiaddr().clone())?;
|
||||
// We are recreating the target multiaddr because we use two different versions of libp2p.
|
||||
let target_addr = Multiaddr::try_from(target.multiaddr().to_vec()).unwrap();
|
||||
swarm.dial(target_addr)?;
|
||||
barrier_and_drive_swarm(&client, &mut swarm, BARRIER_TOPOLOGY_READY).await?;
|
||||
|
||||
barrier_and_drive_swarm(&client, &mut swarm, BARRIER_SIMULATION_COMPLETED).await?;
|
||||
|
||||
@@ -9,26 +9,17 @@ use crate::utils::{
|
||||
use chrono::TimeZone;
|
||||
use chrono::{DateTime, Local};
|
||||
use gen_topology::Params;
|
||||
use libp2p::core::muxing::StreamMuxerBox;
|
||||
use libp2p::core::upgrade::{SelectUpgrade, Version};
|
||||
use libp2p::dns::TokioDnsConfig;
|
||||
use libp2p::futures::StreamExt;
|
||||
use libp2p::gossipsub::metrics::Config;
|
||||
use libp2p::gossipsub::subscription_filter::AllowAllSubscriptionFilter;
|
||||
use libp2p::gossipsub::{
|
||||
Behaviour, ConfigBuilder, Event, FastMessageId, IdentTopic, IdentityTransform,
|
||||
Message as GossipsubMessage, MessageAuthenticity, MessageId, PublishError, RawMessage,
|
||||
use gossipsub::{
|
||||
AllowAllSubscriptionFilter, Behaviour, ConfigBuilder, Event, IdentTopic, IdentityTransform,
|
||||
Message as GossipsubMessage, MessageAuthenticity, MessageId, MetricsConfig, PublishError,
|
||||
ValidationMode,
|
||||
};
|
||||
use libp2p::core::muxing::StreamMuxerBox;
|
||||
use libp2p::futures::StreamExt;
|
||||
use libp2p::identity::Keypair;
|
||||
use libp2p::mplex::MplexConfig;
|
||||
use libp2p::multiaddr::Protocol;
|
||||
use libp2p::noise::NoiseConfig;
|
||||
use libp2p::swarm::{SwarmBuilder, SwarmEvent};
|
||||
use libp2p::tcp::tokio::Transport as TcpTransport;
|
||||
use libp2p::tcp::Config as TcpConfig;
|
||||
use libp2p::yamux::YamuxConfig;
|
||||
use libp2p::{Multiaddr, Transport};
|
||||
use libp2p::swarm::SwarmEvent;
|
||||
use libp2p::{noise, yamux, Multiaddr, SwarmBuilder, Transport};
|
||||
use libp2p::{PeerId, Swarm};
|
||||
use npg::slot_generator::Subnet;
|
||||
use npg::slot_generator::ValId;
|
||||
@@ -212,22 +203,19 @@ pub(crate) async fn run(client: Client) -> Result<(), Box<dyn std::error::Error>
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set up an encrypted TCP transport over the Mplex and Yamux protocols.
|
||||
// Set up an encrypted TCP transport.
|
||||
fn build_transport(keypair: &Keypair) -> libp2p::core::transport::Boxed<(PeerId, StreamMuxerBox)> {
|
||||
let transport = TokioDnsConfig::system(TcpTransport::new(TcpConfig::default().nodelay(true)))
|
||||
.expect("DNS config");
|
||||
|
||||
let noise_keys = libp2p::noise::Keypair::<libp2p::noise::X25519Spec>::new()
|
||||
.into_authentic(keypair)
|
||||
.expect("Signing libp2p-noise static DH keypair failed.");
|
||||
let tcp = libp2p::tcp::tokio::Transport::new(libp2p::tcp::Config::default().nodelay(true));
|
||||
let transport = libp2p::dns::tokio::Transport::system(tcp)
|
||||
.expect("DNS")
|
||||
.boxed();
|
||||
|
||||
transport
|
||||
.upgrade(Version::V1)
|
||||
.authenticate(NoiseConfig::xx(noise_keys).into_authenticated())
|
||||
.multiplex(SelectUpgrade::new(
|
||||
YamuxConfig::default(),
|
||||
MplexConfig::default(),
|
||||
))
|
||||
.upgrade(libp2p::core::upgrade::Version::V1)
|
||||
.authenticate(
|
||||
noise::Config::new(keypair).expect("signing can fail only once during starting a node"),
|
||||
)
|
||||
.multiplex(yamux::Config::default())
|
||||
.timeout(Duration::from_secs(20))
|
||||
.boxed()
|
||||
}
|
||||
@@ -310,8 +298,6 @@ impl Network {
|
||||
[..20],
|
||||
)
|
||||
};
|
||||
let fast_gossip_message_id =
|
||||
|message: &RawMessage| FastMessageId::from(&Sha256::digest(&message.data)[..8]);
|
||||
|
||||
let gossipsub_config = ConfigBuilder::default()
|
||||
// Following params are set based on lighthouse.
|
||||
@@ -324,7 +310,6 @@ impl Network {
|
||||
.validation_mode(ValidationMode::Anonymous)
|
||||
.duplicate_cache_time(Duration::from_secs(33 * SLOT + 1))
|
||||
.message_id_fn(gossip_message_id)
|
||||
.fast_message_id_fn(fast_gossip_message_id)
|
||||
.allow_self_origin(true)
|
||||
// Following params are set based on `NetworkLoad: 4 Average` which defined at lighthouse.
|
||||
.heartbeat_interval(Duration::from_millis(700))
|
||||
@@ -340,7 +325,7 @@ impl Network {
|
||||
let mut gs = Behaviour::new_with_subscription_filter_and_transform(
|
||||
MessageAuthenticity::Anonymous,
|
||||
gossipsub_config,
|
||||
Some((registry, Config::default())),
|
||||
Some((registry, MetricsConfig::default())),
|
||||
AllowAllSubscriptionFilter {},
|
||||
IdentityTransform {},
|
||||
)
|
||||
@@ -357,12 +342,14 @@ impl Network {
|
||||
gs
|
||||
};
|
||||
|
||||
let swarm = SwarmBuilder::with_tokio_executor(
|
||||
build_transport(&keypair),
|
||||
gossipsub,
|
||||
PeerId::from(keypair.public()),
|
||||
)
|
||||
.build();
|
||||
let transport = build_transport(&keypair);
|
||||
let swarm = SwarmBuilder::with_existing_identity(keypair)
|
||||
.with_tokio()
|
||||
.with_other_transport(|_| transport)
|
||||
.expect("infallible")
|
||||
.with_behaviour(|_| gossipsub)
|
||||
.expect("infallible")
|
||||
.build();
|
||||
|
||||
info!(
|
||||
"[{}] running with {} validators",
|
||||
@@ -865,6 +852,9 @@ async fn record_metrics(metrics_info: RecordMetricsInfo) {
|
||||
&metrics_info.peer_id,
|
||||
&run_id,
|
||||
),
|
||||
"publish_messages_dropped_per_topic" | "forward_messages_dropped_per_topic" => {
|
||||
continue;
|
||||
}
|
||||
// ///////////////////////////////////
|
||||
// Metrics regarding mesh state
|
||||
// ///////////////////////////////////
|
||||
@@ -933,6 +923,12 @@ async fn record_metrics(metrics_info: RecordMetricsInfo) {
|
||||
&metrics_info.peer_id,
|
||||
&run_id,
|
||||
),
|
||||
// ///////////////////////////////////
|
||||
// The size of the priority queue.
|
||||
// ///////////////////////////////////
|
||||
"priority_queue_size" | "non_priority_queue_size" => {
|
||||
continue;
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
queries.extend(q);
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
use crate::beacon_node::{ATTESTATION_SUBNETS, SLOT, SLOTS_PER_EPOCH, SYNC_SUBNETS};
|
||||
use crate::topic::Topic;
|
||||
use gen_topology::Params;
|
||||
use libp2p::gossipsub::{
|
||||
IdentTopic, PeerScoreParams, PeerScoreThresholds, TopicHash, TopicScoreParams,
|
||||
};
|
||||
use gossipsub::{IdentTopic, PeerScoreParams, PeerScoreThresholds, TopicHash, TopicScoreParams};
|
||||
use rand::Rng;
|
||||
use std::collections::HashMap;
|
||||
use std::str::FromStr;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use libp2p::gossipsub::{IdentTopic, Topic as GossipTopic};
|
||||
use gossipsub::{IdentTopic, Topic as GossipTopic};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
|
||||
3206
smoke/Cargo.lock
generated
3206
smoke/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -6,9 +6,10 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
# TODO: Update libp2p once the next version, which includes prometheus-client v0.20, has been released.
|
||||
# See https://github.com/ackintosh/rust-libp2p/commit/df09870c8c2294cbaeb881f58d4f9752125562bc
|
||||
libp2p = { git = "https://github.com/ackintosh/rust-libp2p.git", branch = "prometheus-client-0.20.0", default-features = false, features = ["gossipsub", "dns", "tcp", "tokio", "noise", "mplex", "yamux", "serde"] }
|
||||
# unstable branch
|
||||
gossipsub = { git = "https://github.com/sigp/lighthouse.git", rev = "f8fdb71f50851bf7792e68a4ee31125bd645e19a" }
|
||||
|
||||
libp2p = { version = "0.53.2", default-features = false, features = ["dns", "tcp", "tokio", "noise", "yamux", "serde"] }
|
||||
rand = "0.8.5"
|
||||
serde = "1.0.137"
|
||||
serde_json = "1.0.81"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# This Dockerfile is for the `docker:generic` builder.
|
||||
# See https://docs.testground.ai/builder-library/docker-generic for details about the builder.
|
||||
FROM rust:1.67-bullseye as builder
|
||||
FROM rust:1.77-bullseye as builder
|
||||
WORKDIR /usr/src/test-plan
|
||||
|
||||
# * `prost-build`, a dependency of `libp2p-gossipsub`, requires cmake.
|
||||
@@ -36,6 +36,6 @@ FROM debian:bullseye-slim
|
||||
COPY --from=builder /usr/src/test-plan/plan/target/release/smoke /usr/local/bin/smoke
|
||||
|
||||
# Configure Logging
|
||||
# ENV RUST_LOG=libp2p_gossipsub=debug
|
||||
ENV RUST_LOG=libp2p_gossipsub=debug
|
||||
|
||||
ENTRYPOINT ["smoke"]
|
||||
|
||||
@@ -1,24 +1,17 @@
|
||||
extern crate core;
|
||||
|
||||
use libp2p::core::muxing::StreamMuxerBox;
|
||||
use libp2p::core::upgrade::{SelectUpgrade, Version};
|
||||
use libp2p::core::ConnectedPoint;
|
||||
use libp2p::dns::TokioDnsConfig;
|
||||
use libp2p::futures::FutureExt;
|
||||
use libp2p::futures::StreamExt;
|
||||
use libp2p::gossipsub::subscription_filter::AllowAllSubscriptionFilter;
|
||||
use libp2p::gossipsub::{
|
||||
use gossipsub::AllowAllSubscriptionFilter;
|
||||
use gossipsub::{
|
||||
Behaviour, ConfigBuilder, Event, IdentTopic as Topic, IdentityTransform, MessageAuthenticity,
|
||||
};
|
||||
use libp2p::core::muxing::StreamMuxerBox;
|
||||
use libp2p::core::ConnectedPoint;
|
||||
use libp2p::futures::FutureExt;
|
||||
use libp2p::futures::StreamExt;
|
||||
use libp2p::identity::Keypair;
|
||||
use libp2p::mplex::MplexConfig;
|
||||
use libp2p::multiaddr::Protocol;
|
||||
use libp2p::noise::NoiseConfig;
|
||||
use libp2p::swarm::{SwarmBuilder, SwarmEvent};
|
||||
use libp2p::tcp::tokio::Transport as TcpTransport;
|
||||
use libp2p::tcp::Config as TcpConfig;
|
||||
use libp2p::yamux::YamuxConfig;
|
||||
use libp2p::{Multiaddr, PeerId, Swarm, Transport};
|
||||
use libp2p::swarm::SwarmEvent;
|
||||
use libp2p::{noise, yamux, Multiaddr, PeerId, Swarm, SwarmBuilder, Transport};
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::SeedableRng;
|
||||
use serde::de::DeserializeOwned;
|
||||
@@ -26,6 +19,7 @@ use serde::Serialize;
|
||||
use serde_json::Value;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashSet;
|
||||
use std::time::Duration;
|
||||
use testground::client::Client;
|
||||
use tracing::{debug, info, warn};
|
||||
|
||||
@@ -69,8 +63,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
IdentityTransform {},
|
||||
)
|
||||
.expect("Valid configuration");
|
||||
|
||||
SwarmBuilder::with_tokio_executor(build_transport(&local_key), gossipsub, local_peer_id)
|
||||
let transport = build_transport(&local_key);
|
||||
SwarmBuilder::with_existing_identity(local_key)
|
||||
.with_tokio()
|
||||
.with_other_transport(|_| transport)
|
||||
.expect("infallible")
|
||||
.with_behaviour(|_| gossipsub)
|
||||
.expect("infallible")
|
||||
.build()
|
||||
};
|
||||
|
||||
@@ -256,23 +255,20 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// Set up an encrypted TCP transport over the Mplex and Yamux protocols.
|
||||
// Set up an encrypted TCP transport.
|
||||
fn build_transport(keypair: &Keypair) -> libp2p::core::transport::Boxed<(PeerId, StreamMuxerBox)> {
|
||||
let transport = TokioDnsConfig::system(TcpTransport::new(TcpConfig::default().nodelay(true)))
|
||||
.expect("DNS config");
|
||||
|
||||
let noise_keys = libp2p::noise::Keypair::<libp2p::noise::X25519Spec>::new()
|
||||
.into_authentic(keypair)
|
||||
.expect("Signing libp2p-noise static DH keypair failed.");
|
||||
let tcp = libp2p::tcp::tokio::Transport::new(libp2p::tcp::Config::default().nodelay(true));
|
||||
let transport = libp2p::dns::tokio::Transport::system(tcp)
|
||||
.expect("DNS")
|
||||
.boxed();
|
||||
|
||||
transport
|
||||
.upgrade(Version::V1)
|
||||
.authenticate(NoiseConfig::xx(noise_keys).into_authenticated())
|
||||
.multiplex(SelectUpgrade::new(
|
||||
YamuxConfig::default(),
|
||||
MplexConfig::default(),
|
||||
))
|
||||
.timeout(std::time::Duration::from_secs(20))
|
||||
.upgrade(libp2p::core::upgrade::Version::V1)
|
||||
.authenticate(
|
||||
noise::Config::new(keypair).expect("signing can fail only once during starting a node"),
|
||||
)
|
||||
.multiplex(yamux::Config::default())
|
||||
.timeout(Duration::from_secs(20))
|
||||
.boxed()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user