Skip to content

Commit 646bd40

Browse files
committed
move gossipsub into a separate crate
1 parent 2a3c709 commit 646bd40

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+656
-379
lines changed

Cargo.lock

Lines changed: 41 additions & 316 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ members = [
88
"beacon_node/builder_client",
99
"beacon_node/client",
1010
"beacon_node/eth1",
11+
"beacon_node/gossipsub",
1112
"beacon_node/lighthouse_network",
1213
"beacon_node/execution_layer",
1314
"beacon_node/http_api",

beacon_node/gossipsub/Cargo.toml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[package]
2+
name = "gossipsub"
3+
edition = "2021"
4+
description = "Sigma prime's version of Gossipsub protocol for libp2p"
5+
version = "0.5.0"
6+
authors = ["Age Manning <[email protected]>"]
7+
license = "MIT"
8+
repository = "https://github.com/sigp/lighthouse/"
9+
keywords = ["peer-to-peer", "libp2p", "networking"]
10+
categories = ["network-programming", "asynchronous"]
11+
12+
[features]
13+
wasm-bindgen = ["getrandom/js", "instant/wasm-bindgen"]
14+
15+
[dependencies]
16+
async-channel = { workspace = true }
17+
asynchronous-codec = "0.7.0"
18+
base64 = "0.21.7"
19+
byteorder = "1.5.0"
20+
bytes = "1.5"
21+
either = "1.9"
22+
fnv = "1.0.7"
23+
futures = "0.3.30"
24+
futures-ticker = "0.0.3"
25+
futures-timer = "3.0.2"
26+
getrandom = "0.2.12"
27+
hex_fmt = "0.3.0"
28+
instant = "0.1.12"
29+
libp2p = { version = "0.53", default-features = false, features = ["identify", "yamux", "noise", "dns", "tcp", "tokio", "plaintext", "secp256k1", "macros", "ecdsa", "metrics", "quic", "upnp"]}
30+
quick-protobuf = "0.8"
31+
quick-protobuf-codec = "0.3"
32+
rand = "0.8"
33+
regex = "1.10.3"
34+
serde = { version = "1", optional = true, features = ["derive"] }
35+
sha2 = "0.10.8"
36+
smallvec = "1.13.1"
37+
tracing = "0.1.37"
38+
void = "1.0.2"
39+
40+
prometheus-client = "0.22.0"
41+
42+
[dev-dependencies]
43+
quickcheck = { workspace = true }
44+
45+
# Passing arguments to the docsrs builder in order to properly document cfg's.
46+
# More information: https://docs.rs/about/builds#cross-compiling
47+
[package.metadata.docs.rs]
48+
all-features = true
49+
rustdoc-args = ["--cfg", "docsrs"]
50+
rustc-args = ["--cfg", "docsrs"]

beacon_node/lighthouse_network/src/gossipsub/backoff.rs renamed to beacon_node/gossipsub/src/backoff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// DEALINGS IN THE SOFTWARE.
2020

2121
//! Data structure for efficiently storing known back-off's when pruning peers.
22-
use crate::gossipsub::topic::TopicHash;
22+
use crate::topic::TopicHash;
2323
use instant::Instant;
2424
use libp2p::identity::PeerId;
2525
use std::collections::{

beacon_node/lighthouse_network/src/gossipsub/behaviour.rs renamed to beacon_node/gossipsub/src/behaviour.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,16 @@ use super::time_cache::DuplicateCache;
5757
use super::topic::{Hasher, Topic, TopicHash};
5858
use super::transform::{DataTransform, IdentityTransform};
5959
use super::types::{
60-
ControlAction, Message, MessageAcceptance, MessageId, PeerInfo, RawMessage, Subscription,
61-
SubscriptionAction,
60+
ControlAction, FailedMessages, Message, MessageAcceptance, MessageId, PeerInfo, RawMessage,
61+
Subscription, SubscriptionAction,
6262
};
6363
use super::types::{Graft, IHave, IWant, PeerConnections, PeerKind, Prune};
6464
use super::{backoff::BackoffStorage, types::RpcSender};
6565
use super::{
6666
config::{Config, ValidationMode},
6767
types::RpcOut,
6868
};
69-
use super::{FailedMessages, PublishError, SubscriptionError, TopicScoreParams, ValidationError};
69+
use super::{PublishError, SubscriptionError, TopicScoreParams, ValidationError};
7070
use instant::SystemTime;
7171
use quick_protobuf::{MessageWrite, Writer};
7272
use std::{cmp::Ordering::Equal, fmt::Debug};

beacon_node/lighthouse_network/src/gossipsub/behaviour/tests.rs renamed to beacon_node/gossipsub/src/behaviour/tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121
// Collection of tests for the gossipsub network behaviour
2222

2323
use super::*;
24-
use crate::gossipsub::subscription_filter::WhitelistSubscriptionFilter;
25-
use crate::gossipsub::transform::{DataTransform, IdentityTransform};
26-
use crate::gossipsub::types::{RpcOut, RpcReceiver};
27-
use crate::gossipsub::ValidationError;
28-
use crate::gossipsub::{
24+
use crate::subscription_filter::WhitelistSubscriptionFilter;
25+
use crate::transform::{DataTransform, IdentityTransform};
26+
use crate::types::{RpcOut, RpcReceiver};
27+
use crate::ValidationError;
28+
use crate::{
2929
config::Config, config::ConfigBuilder, types::Rpc, IdentTopic as Topic, TopicScoreParams,
3030
};
31-
use async_std::net::Ipv4Addr;
3231
use byteorder::{BigEndian, ByteOrder};
3332
use libp2p::core::{ConnectedPoint, Endpoint};
3433
use rand::Rng;
34+
use std::net::Ipv4Addr;
3535
use std::thread::sleep;
3636
use std::time::Duration;
3737

beacon_node/lighthouse_network/src/gossipsub/config.rs renamed to beacon_node/gossipsub/src/config.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub enum ValidationMode {
3636
/// be present as well as the sequence number. All messages must have valid signatures.
3737
///
3838
/// NOTE: This setting will reject messages from nodes using
39-
/// [`crate::gossipsub::behaviour::MessageAuthenticity::Anonymous`] and all messages that do not have
39+
/// [`crate::behaviour::MessageAuthenticity::Anonymous`] and all messages that do not have
4040
/// signatures.
4141
Strict,
4242
/// This setting permits messages that have no author, sequence number or signature. If any of
@@ -195,7 +195,7 @@ impl Config {
195195

196196
/// When set to `true`, prevents automatic forwarding of all received messages. This setting
197197
/// allows a user to validate the messages before propagating them to their peers. If set to
198-
/// true, the user must manually call [`crate::gossipsub::Behaviour::report_message_validation_result()`]
198+
/// true, the user must manually call [`crate::Behaviour::report_message_validation_result()`]
199199
/// on the behaviour to forward message once validated (default is `false`).
200200
/// The default is `false`.
201201
pub fn validate_messages(&self) -> bool {
@@ -611,7 +611,7 @@ impl ConfigBuilder {
611611

612612
/// When set, prevents automatic forwarding of all received messages. This setting
613613
/// allows a user to validate the messages before propagating them to their peers. If set,
614-
/// the user must manually call [`crate::gossipsub::Behaviour::report_message_validation_result()`] on the
614+
/// the user must manually call [`crate::Behaviour::report_message_validation_result()`] on the
615615
/// behaviour to forward a message once validated.
616616
pub fn validate_messages(&mut self) -> &mut Self {
617617
self.config.validate_messages = true;
@@ -902,9 +902,9 @@ impl std::fmt::Debug for Config {
902902
#[cfg(test)]
903903
mod test {
904904
use super::*;
905-
use crate::gossipsub::topic::IdentityHash;
906-
use crate::gossipsub::types::PeerKind;
907-
use crate::gossipsub::Topic;
905+
use crate::topic::IdentityHash;
906+
use crate::types::PeerKind;
907+
use crate::Topic;
908908
use libp2p::core::UpgradeInfo;
909909
use libp2p::swarm::StreamProtocol;
910910
use std::collections::hash_map::DefaultHasher;

0 commit comments

Comments
 (0)