From df40700ddd2dcc3c73859cc3f8e315eab899d87c Mon Sep 17 00:00:00 2001 From: Age Manning Date: Tue, 19 Oct 2021 00:30:39 +0000 Subject: [PATCH] Rename eth2_libp2p to lighthouse_network (#2702) ## Description The `eth2_libp2p` crate was originally named and designed to incorporate a simple libp2p integration into lighthouse. Since its origins the crates purpose has expanded dramatically. It now houses a lot more sophistication that is specific to lighthouse and no longer just a libp2p integration. As of this writing it currently houses the following high-level lighthouse-specific logic: - Lighthouse's implementation of the eth2 RPC protocol and specific encodings/decodings - Integration and handling of ENRs with respect to libp2p and eth2 - Lighthouse's discovery logic, its integration with discv5 and logic about searching and handling peers. - Lighthouse's peer manager - This is a large module handling various aspects of Lighthouse's network, such as peer scoring, handling pings and metadata, connection maintenance and recording, etc. - Lighthouse's peer database - This is a collection of information stored for each individual peer which is specific to lighthouse. We store connection state, sync state, last seen ips and scores etc. The data stored for each peer is designed for various elements of the lighthouse code base such as syncing and the http api. - Gossipsub scoring - This stores a collection of gossipsub 1.1 scoring mechanisms that are continuously analyssed and updated based on the ethereum 2 networks and how Lighthouse performs on these networks. - Lighthouse specific types for managing gossipsub topics, sync status and ENR fields - Lighthouse's network HTTP API metrics - A collection of metrics for lighthouse network monitoring - Lighthouse's custom configuration of all networking protocols, RPC, gossipsub, discovery, identify and libp2p. Therefore it makes sense to rename the crate to be more akin to its current purposes, simply that it manages the majority of Lighthouse's network stack. This PR renames this crate to `lighthouse_network` Co-authored-by: Paul Hauner --- Cargo.lock | 108 +++++++++--------- Cargo.toml | 2 +- beacon_node/Cargo.toml | 2 +- beacon_node/client/Cargo.toml | 2 +- beacon_node/client/src/builder.rs | 2 +- beacon_node/client/src/lib.rs | 2 +- beacon_node/client/src/notifier.rs | 2 +- beacon_node/http_api/Cargo.toml | 2 +- beacon_node/http_api/src/lib.rs | 13 ++- beacon_node/http_api/src/sync_committees.rs | 2 +- beacon_node/http_api/tests/common.rs | 4 +- beacon_node/http_api/tests/tests.rs | 2 +- beacon_node/http_metrics/Cargo.toml | 2 +- beacon_node/http_metrics/src/metrics.rs | 2 +- .../Cargo.toml | 2 +- .../behaviour/gossipsub_scoring_parameters.rs | 0 .../src/behaviour/mod.rs | 0 .../src/config.rs | 0 .../src/discovery/enr.rs | 0 .../src/discovery/enr_ext.rs | 0 .../src/discovery/mod.rs | 0 .../src/discovery/subnet_predicate.rs | 0 .../src/lib.rs | 0 .../src/metrics.rs | 0 .../src/peer_manager/mod.rs | 0 .../src/peer_manager/peerdb.rs | 0 .../src/peer_manager/peerdb/client.rs | 0 .../src/peer_manager/peerdb/peer_info.rs | 0 .../src/peer_manager/peerdb/score.rs | 0 .../src/peer_manager/peerdb/sync_status.rs | 0 .../src/rpc/codec/base.rs | 0 .../src/rpc/codec/mod.rs | 0 .../src/rpc/codec/ssz_snappy.rs | 0 .../src/rpc/handler.rs | 0 .../src/rpc/methods.rs | 0 .../src/rpc/mod.rs | 0 .../src/rpc/outbound.rs | 0 .../src/rpc/protocol.rs | 0 .../src/rpc/rate_limiter.rs | 0 .../src/service.rs | 0 .../src/types/error.rs | 0 .../src/types/globals.rs | 0 .../src/types/mod.rs | 0 .../src/types/pubsub.rs | 0 .../src/types/subnet.rs | 0 .../src/types/sync_state.rs | 0 .../src/types/topics.rs | 0 .../tests/common/mod.rs | 10 +- .../tests/gossipsub_tests.rs | 2 +- .../tests/rpc_tests.rs | 4 +- beacon_node/network/Cargo.toml | 2 +- .../network/src/beacon_processor/mod.rs | 6 +- .../network/src/beacon_processor/tests.rs | 2 +- .../work_reprocessing_queue.rs | 2 +- .../beacon_processor/worker/gossip_methods.rs | 2 +- .../beacon_processor/worker/rpc_methods.rs | 6 +- .../beacon_processor/worker/sync_methods.rs | 2 +- beacon_node/network/src/error.rs | 2 +- beacon_node/network/src/lib.rs | 2 +- beacon_node/network/src/metrics.rs | 8 +- beacon_node/network/src/persisted_dht.rs | 4 +- beacon_node/network/src/router/mod.rs | 4 +- beacon_node/network/src/router/processor.rs | 6 +- beacon_node/network/src/service.rs | 14 +-- beacon_node/network/src/service/tests.rs | 2 +- beacon_node/network/src/status.rs | 2 +- .../src/subnet_service/attestation_subnets.rs | 2 +- beacon_node/network/src/subnet_service/mod.rs | 2 +- .../src/subnet_service/sync_subnets.rs | 2 +- .../network/src/subnet_service/tests/mod.rs | 2 +- .../network/src/sync/backfill_sync/mod.rs | 4 +- beacon_node/network/src/sync/manager.rs | 8 +- .../network/src/sync/network_context.rs | 6 +- .../network/src/sync/peer_sync_info.rs | 2 +- .../network/src/sync/range_sync/batch.rs | 4 +- .../network/src/sync/range_sync/chain.rs | 2 +- .../src/sync/range_sync/chain_collection.rs | 4 +- .../network/src/sync/range_sync/range.rs | 4 +- .../network/src/sync/range_sync/sync_type.rs | 2 +- beacon_node/src/config.rs | 2 +- beacon_node/src/lib.rs | 2 +- boot_node/Cargo.toml | 2 +- boot_node/src/config.rs | 4 +- boot_node/src/server.rs | 2 +- common/eth2/Cargo.toml | 2 +- common/eth2/src/lib.rs | 2 +- common/eth2/src/lighthouse.rs | 2 +- common/eth2/src/types.rs | 2 +- lcli/Cargo.toml | 2 +- lcli/src/generate_bootnode_enr.rs | 2 +- lighthouse/Cargo.toml | 2 +- lighthouse/tests/beacon_node.rs | 2 +- slasher/service/Cargo.toml | 2 +- slasher/service/src/service.rs | 2 +- 94 files changed, 157 insertions(+), 150 deletions(-) rename beacon_node/{eth2_libp2p => lighthouse_network}/Cargo.toml (98%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/behaviour/gossipsub_scoring_parameters.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/behaviour/mod.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/config.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/discovery/enr.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/discovery/enr_ext.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/discovery/mod.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/discovery/subnet_predicate.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/lib.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/metrics.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/peer_manager/mod.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/peer_manager/peerdb.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/peer_manager/peerdb/client.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/peer_manager/peerdb/peer_info.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/peer_manager/peerdb/score.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/peer_manager/peerdb/sync_status.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/rpc/codec/base.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/rpc/codec/mod.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/rpc/codec/ssz_snappy.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/rpc/handler.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/rpc/methods.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/rpc/mod.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/rpc/outbound.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/rpc/protocol.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/rpc/rate_limiter.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/service.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/types/error.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/types/globals.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/types/mod.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/types/pubsub.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/types/subnet.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/types/sync_state.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/src/types/topics.rs (100%) rename beacon_node/{eth2_libp2p => lighthouse_network}/tests/common/mod.rs (97%) rename beacon_node/{eth2_libp2p => lighthouse_network}/tests/gossipsub_tests.rs (99%) rename beacon_node/{eth2_libp2p => lighthouse_network}/tests/rpc_tests.rs (99%) diff --git a/Cargo.lock b/Cargo.lock index a51182b64..7813b5513 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -478,13 +478,13 @@ dependencies = [ "dirs", "environment", "eth2_config", - "eth2_libp2p", "eth2_network_config", "futures", "genesis", "hex", "http_api", "hyper", + "lighthouse_network", "lighthouse_version", "monitoring_api", "node_test_rig", @@ -624,9 +624,9 @@ version = "2.0.1" dependencies = [ "beacon_node", "clap", - "eth2_libp2p", "eth2_ssz", "hex", + "lighthouse_network", "log", "logging", "slog", @@ -856,12 +856,12 @@ dependencies = [ "eth1", "eth2", "eth2_config", - "eth2_libp2p", "genesis", "http_api", "http_metrics", "lazy_static", "lighthouse_metrics", + "lighthouse_network", "monitoring_api", "network", "parking_lot", @@ -1657,13 +1657,13 @@ dependencies = [ "account_utils", "bytes 1.1.0", "eth2_keystore", - "eth2_libp2p", "eth2_serde_utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "eth2_ssz", "eth2_ssz_derive", "futures", "futures-util", "libsecp256k1 0.6.0", + "lighthouse_network", "procinfo", "proto_array", "psutil", @@ -1757,50 +1757,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "eth2_libp2p" -version = "0.2.0" -dependencies = [ - "directory", - "dirs", - "discv5", - "error-chain", - "eth2_ssz", - "eth2_ssz_derive", - "eth2_ssz_types", - "exit-future", - "fnv", - "futures", - "hashset_delay", - "hex", - "lazy_static", - "libp2p", - "lighthouse_metrics", - "lighthouse_version", - "lru", - "parking_lot", - "rand 0.7.3", - "regex", - "serde", - "serde_derive", - "sha2", - "slog", - "slog-async", - "slog-term", - "smallvec", - "snap", - "strum", - "superstruct", - "task_executor", - "tempfile", - "tiny-keccak 2.0.2", - "tokio", - "tokio-io-timeout", - "tokio-util", - "types", - "unsigned-varint 0.6.0", -] - [[package]] name = "eth2_network_config" version = "0.2.0" @@ -2612,12 +2568,12 @@ dependencies = [ "environment", "eth1", "eth2", - "eth2_libp2p", "eth2_ssz", "futures", "hex", "lazy_static", "lighthouse_metrics", + "lighthouse_network", "lighthouse_version", "network", "sensitive_url", @@ -2640,8 +2596,8 @@ version = "0.1.0" dependencies = [ "beacon_chain", "environment", - "eth2_libp2p", "lighthouse_metrics", + "lighthouse_network", "lighthouse_version", "malloc_utils", "reqwest", @@ -2986,11 +2942,11 @@ dependencies = [ "environment", "eth1_test_rig", "eth2", - "eth2_libp2p", "eth2_network_config", "eth2_ssz", "eth2_wallet", "genesis", + "lighthouse_network", "lighthouse_version", "log", "sensitive_url", @@ -3609,11 +3565,11 @@ dependencies = [ "env_logger 0.9.0", "environment", "eth2_hashing 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "eth2_libp2p", "eth2_network_config", "futures", "lazy_static", "lighthouse_metrics", + "lighthouse_network", "lighthouse_version", "malloc_utils", "serde_json", @@ -3635,6 +3591,50 @@ dependencies = [ "prometheus", ] +[[package]] +name = "lighthouse_network" +version = "0.2.0" +dependencies = [ + "directory", + "dirs", + "discv5", + "error-chain", + "eth2_ssz", + "eth2_ssz_derive", + "eth2_ssz_types", + "exit-future", + "fnv", + "futures", + "hashset_delay", + "hex", + "lazy_static", + "libp2p", + "lighthouse_metrics", + "lighthouse_version", + "lru", + "parking_lot", + "rand 0.7.3", + "regex", + "serde", + "serde_derive", + "sha2", + "slog", + "slog-async", + "slog-term", + "smallvec", + "snap", + "strum", + "superstruct", + "task_executor", + "tempfile", + "tiny-keccak 2.0.2", + "tokio", + "tokio-io-timeout", + "tokio-util", + "types", + "unsigned-varint 0.6.0", +] + [[package]] name = "lighthouse_version" version = "0.1.0" @@ -4029,7 +4029,6 @@ dependencies = [ "beacon_chain", "environment", "error-chain", - "eth2_libp2p", "eth2_ssz", "eth2_ssz_types", "exit-future", @@ -4043,6 +4042,7 @@ dependencies = [ "itertools", "lazy_static", "lighthouse_metrics", + "lighthouse_network", "logging", "lru_cache", "matches", @@ -5572,7 +5572,7 @@ version = "0.1.0" dependencies = [ "beacon_chain", "directory", - "eth2_libp2p", + "lighthouse_network", "network", "slasher", "slog", diff --git a/Cargo.toml b/Cargo.toml index 3200b0226..63a417fe6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = [ "beacon_node/beacon_chain", "beacon_node/client", "beacon_node/eth1", - "beacon_node/eth2_libp2p", + "beacon_node/lighthouse_network", "beacon_node/http_api", "beacon_node/http_metrics", "beacon_node/network", diff --git a/beacon_node/Cargo.toml b/beacon_node/Cargo.toml index 78711366d..80f9182ef 100644 --- a/beacon_node/Cargo.toml +++ b/beacon_node/Cargo.toml @@ -29,7 +29,7 @@ environment = { path = "../lighthouse/environment" } task_executor = { path = "../common/task_executor" } genesis = { path = "genesis" } eth2_network_config = { path = "../common/eth2_network_config" } -eth2_libp2p = { path = "./eth2_libp2p" } +lighthouse_network = { path = "./lighthouse_network" } serde = "1.0.116" clap_utils = { path = "../common/clap_utils" } hyper = "0.14.4" diff --git a/beacon_node/client/Cargo.toml b/beacon_node/client/Cargo.toml index edbb191f1..f8d3356e2 100644 --- a/beacon_node/client/Cargo.toml +++ b/beacon_node/client/Cargo.toml @@ -12,7 +12,7 @@ beacon_chain = { path = "../beacon_chain" } store = { path = "../store" } network = { path = "../network" } timer = { path = "../timer" } -eth2_libp2p = { path = "../eth2_libp2p" } +lighthouse_network = { path = "../lighthouse_network" } parking_lot = "0.11.0" types = { path = "../../consensus/types" } eth2_config = { path = "../../common/eth2_config" } diff --git a/beacon_node/client/src/builder.rs b/beacon_node/client/src/builder.rs index 7f19dbb85..6661fa229 100644 --- a/beacon_node/client/src/builder.rs +++ b/beacon_node/client/src/builder.rs @@ -16,8 +16,8 @@ use eth2::{ types::{BlockId, StateId}, BeaconNodeHttpClient, Error as ApiError, Timeouts, }; -use eth2_libp2p::NetworkGlobals; use genesis::{interop_genesis_state, Eth1GenesisService}; +use lighthouse_network::NetworkGlobals; use monitoring_api::{MonitoringHttpClient, ProcessType}; use network::{NetworkConfig, NetworkMessage, NetworkService}; use slasher::Slasher; diff --git a/beacon_node/client/src/lib.rs b/beacon_node/client/src/lib.rs index a59b02538..24df87408 100644 --- a/beacon_node/client/src/lib.rs +++ b/beacon_node/client/src/lib.rs @@ -8,7 +8,7 @@ pub mod builder; pub mod error; use beacon_chain::BeaconChain; -use eth2_libp2p::{Enr, Multiaddr, NetworkGlobals}; +use lighthouse_network::{Enr, Multiaddr, NetworkGlobals}; use std::net::SocketAddr; use std::sync::Arc; diff --git a/beacon_node/client/src/notifier.rs b/beacon_node/client/src/notifier.rs index 31fb67406..380af2568 100644 --- a/beacon_node/client/src/notifier.rs +++ b/beacon_node/client/src/notifier.rs @@ -1,6 +1,6 @@ use crate::metrics; use beacon_chain::{BeaconChain, BeaconChainTypes}; -use eth2_libp2p::{types::SyncState, NetworkGlobals}; +use lighthouse_network::{types::SyncState, NetworkGlobals}; use parking_lot::Mutex; use slog::{debug, error, info, warn, Logger}; use slot_clock::SlotClock; diff --git a/beacon_node/http_api/Cargo.toml b/beacon_node/http_api/Cargo.toml index c5fa86e0e..770dc3efb 100644 --- a/beacon_node/http_api/Cargo.toml +++ b/beacon_node/http_api/Cargo.toml @@ -16,7 +16,7 @@ beacon_chain = { path = "../beacon_chain" } eth2 = { path = "../../common/eth2", features = ["lighthouse"] } slog = "2.5.2" network = { path = "../network" } -eth2_libp2p = { path = "../eth2_libp2p" } +lighthouse_network = { path = "../lighthouse_network" } eth1 = { path = "../eth1" } state_processing = { path = "../../consensus/state_processing" } lighthouse_version = { path = "../../common/lighthouse_version" } diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 3e6939146..d1beca9d4 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -24,7 +24,7 @@ use beacon_chain::{ }; use block_id::BlockId; use eth2::types::{self as api_types, EndpointVersion, ValidatorId}; -use eth2_libp2p::{types::SyncState, EnrExt, NetworkGlobals, PeerId, PubsubMessage}; +use lighthouse_network::{types::SyncState, EnrExt, NetworkGlobals, PeerId, PubsubMessage}; use lighthouse_version::version_with_platform; use network::NetworkMessage; use serde::{Deserialize, Serialize}; @@ -1635,8 +1635,10 @@ pub fn serve( if let Some(peer_info) = network_globals.peers.read().peer_info(&peer_id) { let address = if let Some(socket_addr) = peer_info.seen_addresses().next() { - let mut addr = eth2_libp2p::Multiaddr::from(socket_addr.ip()); - addr.push(eth2_libp2p::multiaddr::Protocol::Tcp(socket_addr.port())); + let mut addr = lighthouse_network::Multiaddr::from(socket_addr.ip()); + addr.push(lighthouse_network::multiaddr::Protocol::Tcp( + socket_addr.port(), + )); addr.to_string() } else if let Some(addr) = peer_info.listening_addresses().first() { addr.to_string() @@ -1682,8 +1684,9 @@ pub fn serve( .for_each(|(peer_id, peer_info)| { let address = if let Some(socket_addr) = peer_info.seen_addresses().next() { - let mut addr = eth2_libp2p::Multiaddr::from(socket_addr.ip()); - addr.push(eth2_libp2p::multiaddr::Protocol::Tcp( + let mut addr = + lighthouse_network::Multiaddr::from(socket_addr.ip()); + addr.push(lighthouse_network::multiaddr::Protocol::Tcp( socket_addr.port(), )); addr.to_string() diff --git a/beacon_node/http_api/src/sync_committees.rs b/beacon_node/http_api/src/sync_committees.rs index 75e3633fb..3ebc3c4ec 100644 --- a/beacon_node/http_api/src/sync_committees.rs +++ b/beacon_node/http_api/src/sync_committees.rs @@ -9,7 +9,7 @@ use beacon_chain::{ StateSkipConfig, MAXIMUM_GOSSIP_CLOCK_DISPARITY, }; use eth2::types::{self as api_types}; -use eth2_libp2p::PubsubMessage; +use lighthouse_network::PubsubMessage; use network::NetworkMessage; use slog::{error, warn, Logger}; use slot_clock::SlotClock; diff --git a/beacon_node/http_api/tests/common.rs b/beacon_node/http_api/tests/common.rs index a2298276c..95b37c2c0 100644 --- a/beacon_node/http_api/tests/common.rs +++ b/beacon_node/http_api/tests/common.rs @@ -3,13 +3,13 @@ use beacon_chain::{ BeaconChain, BeaconChainTypes, }; use eth2::{BeaconNodeHttpClient, Timeouts}; -use eth2_libp2p::{ +use http_api::{Config, Context}; +use lighthouse_network::{ discv5::enr::{CombinedKey, EnrBuilder}, rpc::methods::{MetaData, MetaDataV2}, types::{EnrAttestationBitfield, EnrSyncCommitteeBitfield, SyncState}, ConnectedPoint, Enr, NetworkConfig, NetworkGlobals, PeerId, PeerManager, }; -use http_api::{Config, Context}; use network::NetworkMessage; use sensitive_url::SensitiveUrl; use slog::Logger; diff --git a/beacon_node/http_api/tests/tests.rs b/beacon_node/http_api/tests/tests.rs index df7af8cc4..d6def5d19 100644 --- a/beacon_node/http_api/tests/tests.rs +++ b/beacon_node/http_api/tests/tests.rs @@ -8,9 +8,9 @@ use environment::null_logger; use eth2::Error; use eth2::StatusCode; use eth2::{types::*, BeaconNodeHttpClient, Timeouts}; -use eth2_libp2p::{Enr, EnrExt, PeerId}; use futures::stream::{Stream, StreamExt}; use futures::FutureExt; +use lighthouse_network::{Enr, EnrExt, PeerId}; use network::NetworkMessage; use sensitive_url::SensitiveUrl; use slot_clock::SlotClock; diff --git a/beacon_node/http_metrics/Cargo.toml b/beacon_node/http_metrics/Cargo.toml index 30291ef9b..97df28639 100644 --- a/beacon_node/http_metrics/Cargo.toml +++ b/beacon_node/http_metrics/Cargo.toml @@ -12,7 +12,7 @@ serde = { version = "1.0.116", features = ["derive"] } slog = "2.5.2" beacon_chain = { path = "../beacon_chain" } store = { path = "../store" } -eth2_libp2p = { path = "../eth2_libp2p" } +lighthouse_network = { path = "../lighthouse_network" } slot_clock = { path = "../../common/slot_clock" } lighthouse_metrics = { path = "../../common/lighthouse_metrics" } lighthouse_version = { path = "../../common/lighthouse_version" } diff --git a/beacon_node/http_metrics/src/metrics.rs b/beacon_node/http_metrics/src/metrics.rs index 4a870c889..c86211f31 100644 --- a/beacon_node/http_metrics/src/metrics.rs +++ b/beacon_node/http_metrics/src/metrics.rs @@ -38,7 +38,7 @@ pub fn gather_prometheus_metrics( store::scrape_for_metrics(db_path, freezer_db_path); } - eth2_libp2p::scrape_discovery_metrics(); + lighthouse_network::scrape_discovery_metrics(); warp_utils::metrics::scrape_health_metrics(); diff --git a/beacon_node/eth2_libp2p/Cargo.toml b/beacon_node/lighthouse_network/Cargo.toml similarity index 98% rename from beacon_node/eth2_libp2p/Cargo.toml rename to beacon_node/lighthouse_network/Cargo.toml index cdd9d5c13..ebe02f867 100644 --- a/beacon_node/eth2_libp2p/Cargo.toml +++ b/beacon_node/lighthouse_network/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "eth2_libp2p" +name = "lighthouse_network" version = "0.2.0" authors = ["Sigma Prime "] edition = "2018" diff --git a/beacon_node/eth2_libp2p/src/behaviour/gossipsub_scoring_parameters.rs b/beacon_node/lighthouse_network/src/behaviour/gossipsub_scoring_parameters.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/behaviour/gossipsub_scoring_parameters.rs rename to beacon_node/lighthouse_network/src/behaviour/gossipsub_scoring_parameters.rs diff --git a/beacon_node/eth2_libp2p/src/behaviour/mod.rs b/beacon_node/lighthouse_network/src/behaviour/mod.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/behaviour/mod.rs rename to beacon_node/lighthouse_network/src/behaviour/mod.rs diff --git a/beacon_node/eth2_libp2p/src/config.rs b/beacon_node/lighthouse_network/src/config.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/config.rs rename to beacon_node/lighthouse_network/src/config.rs diff --git a/beacon_node/eth2_libp2p/src/discovery/enr.rs b/beacon_node/lighthouse_network/src/discovery/enr.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/discovery/enr.rs rename to beacon_node/lighthouse_network/src/discovery/enr.rs diff --git a/beacon_node/eth2_libp2p/src/discovery/enr_ext.rs b/beacon_node/lighthouse_network/src/discovery/enr_ext.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/discovery/enr_ext.rs rename to beacon_node/lighthouse_network/src/discovery/enr_ext.rs diff --git a/beacon_node/eth2_libp2p/src/discovery/mod.rs b/beacon_node/lighthouse_network/src/discovery/mod.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/discovery/mod.rs rename to beacon_node/lighthouse_network/src/discovery/mod.rs diff --git a/beacon_node/eth2_libp2p/src/discovery/subnet_predicate.rs b/beacon_node/lighthouse_network/src/discovery/subnet_predicate.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/discovery/subnet_predicate.rs rename to beacon_node/lighthouse_network/src/discovery/subnet_predicate.rs diff --git a/beacon_node/eth2_libp2p/src/lib.rs b/beacon_node/lighthouse_network/src/lib.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/lib.rs rename to beacon_node/lighthouse_network/src/lib.rs diff --git a/beacon_node/eth2_libp2p/src/metrics.rs b/beacon_node/lighthouse_network/src/metrics.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/metrics.rs rename to beacon_node/lighthouse_network/src/metrics.rs diff --git a/beacon_node/eth2_libp2p/src/peer_manager/mod.rs b/beacon_node/lighthouse_network/src/peer_manager/mod.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/peer_manager/mod.rs rename to beacon_node/lighthouse_network/src/peer_manager/mod.rs diff --git a/beacon_node/eth2_libp2p/src/peer_manager/peerdb.rs b/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/peer_manager/peerdb.rs rename to beacon_node/lighthouse_network/src/peer_manager/peerdb.rs diff --git a/beacon_node/eth2_libp2p/src/peer_manager/peerdb/client.rs b/beacon_node/lighthouse_network/src/peer_manager/peerdb/client.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/peer_manager/peerdb/client.rs rename to beacon_node/lighthouse_network/src/peer_manager/peerdb/client.rs diff --git a/beacon_node/eth2_libp2p/src/peer_manager/peerdb/peer_info.rs b/beacon_node/lighthouse_network/src/peer_manager/peerdb/peer_info.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/peer_manager/peerdb/peer_info.rs rename to beacon_node/lighthouse_network/src/peer_manager/peerdb/peer_info.rs diff --git a/beacon_node/eth2_libp2p/src/peer_manager/peerdb/score.rs b/beacon_node/lighthouse_network/src/peer_manager/peerdb/score.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/peer_manager/peerdb/score.rs rename to beacon_node/lighthouse_network/src/peer_manager/peerdb/score.rs diff --git a/beacon_node/eth2_libp2p/src/peer_manager/peerdb/sync_status.rs b/beacon_node/lighthouse_network/src/peer_manager/peerdb/sync_status.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/peer_manager/peerdb/sync_status.rs rename to beacon_node/lighthouse_network/src/peer_manager/peerdb/sync_status.rs diff --git a/beacon_node/eth2_libp2p/src/rpc/codec/base.rs b/beacon_node/lighthouse_network/src/rpc/codec/base.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/rpc/codec/base.rs rename to beacon_node/lighthouse_network/src/rpc/codec/base.rs diff --git a/beacon_node/eth2_libp2p/src/rpc/codec/mod.rs b/beacon_node/lighthouse_network/src/rpc/codec/mod.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/rpc/codec/mod.rs rename to beacon_node/lighthouse_network/src/rpc/codec/mod.rs diff --git a/beacon_node/eth2_libp2p/src/rpc/codec/ssz_snappy.rs b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/rpc/codec/ssz_snappy.rs rename to beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs diff --git a/beacon_node/eth2_libp2p/src/rpc/handler.rs b/beacon_node/lighthouse_network/src/rpc/handler.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/rpc/handler.rs rename to beacon_node/lighthouse_network/src/rpc/handler.rs diff --git a/beacon_node/eth2_libp2p/src/rpc/methods.rs b/beacon_node/lighthouse_network/src/rpc/methods.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/rpc/methods.rs rename to beacon_node/lighthouse_network/src/rpc/methods.rs diff --git a/beacon_node/eth2_libp2p/src/rpc/mod.rs b/beacon_node/lighthouse_network/src/rpc/mod.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/rpc/mod.rs rename to beacon_node/lighthouse_network/src/rpc/mod.rs diff --git a/beacon_node/eth2_libp2p/src/rpc/outbound.rs b/beacon_node/lighthouse_network/src/rpc/outbound.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/rpc/outbound.rs rename to beacon_node/lighthouse_network/src/rpc/outbound.rs diff --git a/beacon_node/eth2_libp2p/src/rpc/protocol.rs b/beacon_node/lighthouse_network/src/rpc/protocol.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/rpc/protocol.rs rename to beacon_node/lighthouse_network/src/rpc/protocol.rs diff --git a/beacon_node/eth2_libp2p/src/rpc/rate_limiter.rs b/beacon_node/lighthouse_network/src/rpc/rate_limiter.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/rpc/rate_limiter.rs rename to beacon_node/lighthouse_network/src/rpc/rate_limiter.rs diff --git a/beacon_node/eth2_libp2p/src/service.rs b/beacon_node/lighthouse_network/src/service.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/service.rs rename to beacon_node/lighthouse_network/src/service.rs diff --git a/beacon_node/eth2_libp2p/src/types/error.rs b/beacon_node/lighthouse_network/src/types/error.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/types/error.rs rename to beacon_node/lighthouse_network/src/types/error.rs diff --git a/beacon_node/eth2_libp2p/src/types/globals.rs b/beacon_node/lighthouse_network/src/types/globals.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/types/globals.rs rename to beacon_node/lighthouse_network/src/types/globals.rs diff --git a/beacon_node/eth2_libp2p/src/types/mod.rs b/beacon_node/lighthouse_network/src/types/mod.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/types/mod.rs rename to beacon_node/lighthouse_network/src/types/mod.rs diff --git a/beacon_node/eth2_libp2p/src/types/pubsub.rs b/beacon_node/lighthouse_network/src/types/pubsub.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/types/pubsub.rs rename to beacon_node/lighthouse_network/src/types/pubsub.rs diff --git a/beacon_node/eth2_libp2p/src/types/subnet.rs b/beacon_node/lighthouse_network/src/types/subnet.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/types/subnet.rs rename to beacon_node/lighthouse_network/src/types/subnet.rs diff --git a/beacon_node/eth2_libp2p/src/types/sync_state.rs b/beacon_node/lighthouse_network/src/types/sync_state.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/types/sync_state.rs rename to beacon_node/lighthouse_network/src/types/sync_state.rs diff --git a/beacon_node/eth2_libp2p/src/types/topics.rs b/beacon_node/lighthouse_network/src/types/topics.rs similarity index 100% rename from beacon_node/eth2_libp2p/src/types/topics.rs rename to beacon_node/lighthouse_network/src/types/topics.rs diff --git a/beacon_node/eth2_libp2p/tests/common/mod.rs b/beacon_node/lighthouse_network/tests/common/mod.rs similarity index 97% rename from beacon_node/eth2_libp2p/tests/common/mod.rs rename to beacon_node/lighthouse_network/tests/common/mod.rs index 1023bbacd..9055da05b 100644 --- a/beacon_node/eth2_libp2p/tests/common/mod.rs +++ b/beacon_node/lighthouse_network/tests/common/mod.rs @@ -1,10 +1,10 @@ #![cfg(test)] -use eth2_libp2p::Enr; -use eth2_libp2p::EnrExt; -use eth2_libp2p::Multiaddr; -use eth2_libp2p::Service as LibP2PService; -use eth2_libp2p::{Libp2pEvent, NetworkConfig}; use libp2p::gossipsub::GossipsubConfigBuilder; +use lighthouse_network::Enr; +use lighthouse_network::EnrExt; +use lighthouse_network::Multiaddr; +use lighthouse_network::Service as LibP2PService; +use lighthouse_network::{Libp2pEvent, NetworkConfig}; use slog::{debug, error, o, Drain}; use std::net::{TcpListener, UdpSocket}; use std::sync::Arc; diff --git a/beacon_node/eth2_libp2p/tests/gossipsub_tests.rs b/beacon_node/lighthouse_network/tests/gossipsub_tests.rs similarity index 99% rename from beacon_node/eth2_libp2p/tests/gossipsub_tests.rs rename to beacon_node/lighthouse_network/tests/gossipsub_tests.rs index 809920a56..c5b661cf7 100644 --- a/beacon_node/eth2_libp2p/tests/gossipsub_tests.rs +++ b/beacon_node/lighthouse_network/tests/gossipsub_tests.rs @@ -5,7 +5,7 @@ #![cfg(test)] use crate::types::GossipEncoding; use ::types::{BeaconBlock, EthSpec, MinimalEthSpec, Signature, SignedBeaconBlock}; -use eth2_libp2p::*; +use lighthouse_network::*; use slog::{debug, Level}; type E = MinimalEthSpec; diff --git a/beacon_node/eth2_libp2p/tests/rpc_tests.rs b/beacon_node/lighthouse_network/tests/rpc_tests.rs similarity index 99% rename from beacon_node/eth2_libp2p/tests/rpc_tests.rs rename to beacon_node/lighthouse_network/tests/rpc_tests.rs index 1e5f1e4e1..565304a79 100644 --- a/beacon_node/eth2_libp2p/tests/rpc_tests.rs +++ b/beacon_node/lighthouse_network/tests/rpc_tests.rs @@ -1,6 +1,6 @@ #![cfg(test)] -use eth2_libp2p::rpc::methods::*; -use eth2_libp2p::{BehaviourEvent, Libp2pEvent, ReportSource, Request, Response}; +use lighthouse_network::rpc::methods::*; +use lighthouse_network::{BehaviourEvent, Libp2pEvent, ReportSource, Request, Response}; use slog::{debug, warn, Level}; use ssz_types::VariableList; use std::sync::Arc; diff --git a/beacon_node/network/Cargo.toml b/beacon_node/network/Cargo.toml index edb51b0c9..4c06880f3 100644 --- a/beacon_node/network/Cargo.toml +++ b/beacon_node/network/Cargo.toml @@ -17,7 +17,7 @@ environment = { path = "../../lighthouse/environment" } [dependencies] beacon_chain = { path = "../beacon_chain" } store = { path = "../store" } -eth2_libp2p = { path = "../eth2_libp2p" } +lighthouse_network = { path = "../lighthouse_network" } hashset_delay = { path = "../../common/hashset_delay" } types = { path = "../../consensus/types" } slot_clock = { path = "../../common/slot_clock" } diff --git a/beacon_node/network/src/beacon_processor/mod.rs b/beacon_node/network/src/beacon_processor/mod.rs index cb07f572b..06ce36c6b 100644 --- a/beacon_node/network/src/beacon_processor/mod.rs +++ b/beacon_node/network/src/beacon_processor/mod.rs @@ -40,12 +40,12 @@ use crate::{metrics, service::NetworkMessage, sync::SyncMessage}; use beacon_chain::{BeaconChain, BeaconChainTypes, BlockError, GossipVerifiedBlock}; -use eth2_libp2p::{ +use futures::stream::{Stream, StreamExt}; +use futures::task::Poll; +use lighthouse_network::{ rpc::{BlocksByRangeRequest, BlocksByRootRequest, StatusMessage}, Client, MessageId, NetworkGlobals, PeerId, PeerRequestId, }; -use futures::stream::{Stream, StreamExt}; -use futures::task::Poll; use slog::{crit, debug, error, trace, warn, Logger}; use std::cmp; use std::collections::VecDeque; diff --git a/beacon_node/network/src/beacon_processor/tests.rs b/beacon_node/network/src/beacon_processor/tests.rs index de5590144..2dbdb3269 100644 --- a/beacon_node/network/src/beacon_processor/tests.rs +++ b/beacon_node/network/src/beacon_processor/tests.rs @@ -9,7 +9,7 @@ use beacon_chain::test_utils::{ }; use beacon_chain::{BeaconChain, MAXIMUM_GOSSIP_CLOCK_DISPARITY}; use environment::{null_logger, Environment, EnvironmentBuilder}; -use eth2_libp2p::{ +use lighthouse_network::{ discv5::enr::{CombinedKey, EnrBuilder}, rpc::methods::{MetaData, MetaDataV2}, types::{EnrAttestationBitfield, EnrSyncCommitteeBitfield}, diff --git a/beacon_node/network/src/beacon_processor/work_reprocessing_queue.rs b/beacon_node/network/src/beacon_processor/work_reprocessing_queue.rs index daf7e9011..00b5c009a 100644 --- a/beacon_node/network/src/beacon_processor/work_reprocessing_queue.rs +++ b/beacon_node/network/src/beacon_processor/work_reprocessing_queue.rs @@ -13,10 +13,10 @@ use super::MAX_SCHEDULED_WORK_QUEUE_LEN; use crate::metrics; use beacon_chain::{BeaconChainTypes, GossipVerifiedBlock, MAXIMUM_GOSSIP_CLOCK_DISPARITY}; -use eth2_libp2p::{MessageId, PeerId}; use fnv::FnvHashMap; use futures::task::Poll; use futures::{Stream, StreamExt}; +use lighthouse_network::{MessageId, PeerId}; use slog::{crit, debug, error, warn, Logger}; use slot_clock::SlotClock; use std::collections::{HashMap, HashSet}; diff --git a/beacon_node/network/src/beacon_processor/worker/gossip_methods.rs b/beacon_node/network/src/beacon_processor/worker/gossip_methods.rs index 675544beb..d7d9482bd 100644 --- a/beacon_node/network/src/beacon_processor/worker/gossip_methods.rs +++ b/beacon_node/network/src/beacon_processor/worker/gossip_methods.rs @@ -7,7 +7,7 @@ use beacon_chain::{ validator_monitor::get_block_delay_ms, BeaconChainError, BeaconChainTypes, BlockError, ForkChoiceError, GossipVerifiedBlock, }; -use eth2_libp2p::{Client, MessageAcceptance, MessageId, PeerAction, PeerId, ReportSource}; +use lighthouse_network::{Client, MessageAcceptance, MessageId, PeerAction, PeerId, ReportSource}; use slog::{crit, debug, error, info, trace, warn}; use slot_clock::SlotClock; use ssz::Encode; diff --git a/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs b/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs index da66e89f5..7a5d483d9 100644 --- a/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs +++ b/beacon_node/network/src/beacon_processor/worker/rpc_methods.rs @@ -3,10 +3,10 @@ use crate::service::NetworkMessage; use crate::status::ToStatusMessage; use crate::sync::SyncMessage; use beacon_chain::{BeaconChainError, BeaconChainTypes, HistoricalBlockError, WhenSlotSkipped}; -use eth2_libp2p::rpc::StatusMessage; -use eth2_libp2p::rpc::*; -use eth2_libp2p::{PeerId, PeerRequestId, ReportSource, Response, SyncInfo}; use itertools::process_results; +use lighthouse_network::rpc::StatusMessage; +use lighthouse_network::rpc::*; +use lighthouse_network::{PeerId, PeerRequestId, ReportSource, Response, SyncInfo}; use slog::{debug, error, warn}; use slot_clock::SlotClock; use types::{Epoch, EthSpec, Hash256, Slot}; diff --git a/beacon_node/network/src/beacon_processor/worker/sync_methods.rs b/beacon_node/network/src/beacon_processor/worker/sync_methods.rs index ff2739d50..44009e27e 100644 --- a/beacon_node/network/src/beacon_processor/worker/sync_methods.rs +++ b/beacon_node/network/src/beacon_processor/worker/sync_methods.rs @@ -7,7 +7,7 @@ use crate::sync::{BatchProcessResult, ChainId}; use beacon_chain::{ BeaconChainError, BeaconChainTypes, BlockError, ChainSegmentResult, HistoricalBlockError, }; -use eth2_libp2p::PeerId; +use lighthouse_network::PeerId; use slog::{crit, debug, error, info, trace, warn}; use tokio::sync::mpsc; use types::{Epoch, Hash256, SignedBeaconBlock}; diff --git a/beacon_node/network/src/error.rs b/beacon_node/network/src/error.rs index e30ce4f43..1a964235e 100644 --- a/beacon_node/network/src/error.rs +++ b/beacon_node/network/src/error.rs @@ -3,6 +3,6 @@ use error_chain::error_chain; error_chain! { links { - Libp2p(eth2_libp2p::error::Error, eth2_libp2p::error::ErrorKind); + Libp2p(lighthouse_network::error::Error, lighthouse_network::error::ErrorKind); } } diff --git a/beacon_node/network/src/lib.rs b/beacon_node/network/src/lib.rs index 934442e12..283d8dfb9 100644 --- a/beacon_node/network/src/lib.rs +++ b/beacon_node/network/src/lib.rs @@ -17,5 +17,5 @@ mod subnet_service; #[allow(clippy::mutable_key_type)] // PeerId in hashmaps are no longer permitted by clippy mod sync; -pub use eth2_libp2p::NetworkConfig; +pub use lighthouse_network::NetworkConfig; pub use service::{NetworkMessage, NetworkService}; diff --git a/beacon_node/network/src/metrics.rs b/beacon_node/network/src/metrics.rs index e8a024a81..35c5b4dce 100644 --- a/beacon_node/network/src/metrics.rs +++ b/beacon_node/network/src/metrics.rs @@ -2,12 +2,12 @@ use beacon_chain::{ attestation_verification::Error as AttnError, sync_committee_verification::Error as SyncCommitteeError, }; -use eth2_libp2p::PubsubMessage; -use eth2_libp2p::{ - types::GossipKind, BandwidthSinks, GossipTopic, Gossipsub, NetworkGlobals, TopicHash, -}; use fnv::FnvHashMap; pub use lighthouse_metrics::*; +use lighthouse_network::PubsubMessage; +use lighthouse_network::{ + types::GossipKind, BandwidthSinks, GossipTopic, Gossipsub, NetworkGlobals, TopicHash, +}; use std::{collections::HashMap, sync::Arc}; use strum::AsStaticRef; use types::{ diff --git a/beacon_node/network/src/persisted_dht.rs b/beacon_node/network/src/persisted_dht.rs index 881be15a7..e69230c50 100644 --- a/beacon_node/network/src/persisted_dht.rs +++ b/beacon_node/network/src/persisted_dht.rs @@ -1,4 +1,4 @@ -use eth2_libp2p::Enr; +use lighthouse_network::Enr; use std::sync::Arc; use store::{DBColumn, Error as StoreError, HotColdDB, ItemStore, StoreItem}; use types::{EthSpec, Hash256}; @@ -60,7 +60,7 @@ impl StoreItem for PersistedDht { #[cfg(test)] mod tests { use super::*; - use eth2_libp2p::Enr; + use lighthouse_network::Enr; use sloggers::{null::NullLoggerBuilder, Build}; use std::str::FromStr; use store::config::StoreConfig; diff --git a/beacon_node/network/src/router/mod.rs b/beacon_node/network/src/router/mod.rs index 178a16319..8d639c5ee 100644 --- a/beacon_node/network/src/router/mod.rs +++ b/beacon_node/network/src/router/mod.rs @@ -10,11 +10,11 @@ mod processor; use crate::error; use crate::service::NetworkMessage; use beacon_chain::{BeaconChain, BeaconChainTypes}; -use eth2_libp2p::{ +use futures::prelude::*; +use lighthouse_network::{ rpc::RequestId, MessageId, NetworkGlobals, PeerId, PeerRequestId, PubsubMessage, Request, Response, }; -use futures::prelude::*; use processor::Processor; use slog::{debug, o, trace}; use std::sync::Arc; diff --git a/beacon_node/network/src/router/processor.rs b/beacon_node/network/src/router/processor.rs index 1df83173b..47d82d81e 100644 --- a/beacon_node/network/src/router/processor.rs +++ b/beacon_node/network/src/router/processor.rs @@ -4,8 +4,10 @@ use crate::beacon_processor::{ use crate::service::NetworkMessage; use crate::sync::SyncMessage; use beacon_chain::{BeaconChain, BeaconChainError, BeaconChainTypes}; -use eth2_libp2p::rpc::*; -use eth2_libp2p::{Client, MessageId, NetworkGlobals, PeerId, PeerRequestId, Request, Response}; +use lighthouse_network::rpc::*; +use lighthouse_network::{ + Client, MessageId, NetworkGlobals, PeerId, PeerRequestId, Request, Response, +}; use slog::{debug, error, o, trace, warn}; use std::cmp; use std::sync::Arc; diff --git a/beacon_node/network/src/service.rs b/beacon_node/network/src/service.rs index 7badec3d4..d4e0ebec2 100644 --- a/beacon_node/network/src/service.rs +++ b/beacon_node/network/src/service.rs @@ -7,17 +7,17 @@ use crate::{ NetworkConfig, }; use beacon_chain::{BeaconChain, BeaconChainError, BeaconChainTypes}; -use eth2_libp2p::{ +use futures::future::OptionFuture; +use futures::prelude::*; +use lighthouse_network::{ rpc::{GoodbyeReason, RPCResponseErrorCode, RequestId}, Libp2pEvent, PeerAction, PeerRequestId, PubsubMessage, ReportSource, Request, Response, Subnet, }; -use eth2_libp2p::{ +use lighthouse_network::{ types::{GossipEncoding, GossipTopic}, BehaviourEvent, MessageId, NetworkGlobals, PeerId, }; -use eth2_libp2p::{MessageAcceptance, Service as LibP2PService}; -use futures::future::OptionFuture; -use futures::prelude::*; +use lighthouse_network::{MessageAcceptance, Service as LibP2PService}; use slog::{crit, debug, error, info, o, trace, warn}; use std::{net::SocketAddr, pin::Pin, sync::Arc, time::Duration}; use store::HotColdDB; @@ -102,7 +102,7 @@ pub enum NetworkMessage { }, } -/// Service that handles communication between internal services and the `eth2_libp2p` network service. +/// Service that handles communication between internal services and the `lighthouse_network` network service. pub struct NetworkService { /// A reference to the underlying beacon chain. beacon_chain: Arc>, @@ -469,7 +469,7 @@ fn spawn_service( return; } let mut subscribed_topics: Vec = vec![]; - for topic_kind in eth2_libp2p::types::CORE_TOPICS.iter() { + for topic_kind in lighthouse_network::types::CORE_TOPICS.iter() { for fork_digest in service.required_gossip_fork_digests() { let topic = GossipTopic::new(topic_kind.clone(), GossipEncoding::default(), fork_digest); if service.libp2p.swarm.behaviour_mut().subscribe(topic.clone()) { diff --git a/beacon_node/network/src/service/tests.rs b/beacon_node/network/src/service/tests.rs index f9e861a91..33b190e48 100644 --- a/beacon_node/network/src/service/tests.rs +++ b/beacon_node/network/src/service/tests.rs @@ -4,7 +4,7 @@ mod tests { use crate::persisted_dht::load_dht; use crate::{NetworkConfig, NetworkService}; use beacon_chain::test_utils::BeaconChainHarness; - use eth2_libp2p::Enr; + use lighthouse_network::Enr; use slog::{o, Drain, Level, Logger}; use sloggers::{null::NullLoggerBuilder, Build}; use std::str::FromStr; diff --git a/beacon_node/network/src/status.rs b/beacon_node/network/src/status.rs index d4eeba57d..ade490e00 100644 --- a/beacon_node/network/src/status.rs +++ b/beacon_node/network/src/status.rs @@ -1,6 +1,6 @@ use beacon_chain::{BeaconChain, BeaconChainError, BeaconChainTypes}; -use eth2_libp2p::rpc::StatusMessage; +use lighthouse_network::rpc::StatusMessage; /// Trait to produce a `StatusMessage` representing the state of the given `beacon_chain`. /// /// NOTE: The purpose of this is simply to obtain a `StatusMessage` from the `BeaconChain` without diff --git a/beacon_node/network/src/subnet_service/attestation_subnets.rs b/beacon_node/network/src/subnet_service/attestation_subnets.rs index dcfd35897..5c87062e2 100644 --- a/beacon_node/network/src/subnet_service/attestation_subnets.rs +++ b/beacon_node/network/src/subnet_service/attestation_subnets.rs @@ -14,8 +14,8 @@ use rand::seq::SliceRandom; use slog::{debug, error, o, trace, warn}; use beacon_chain::{BeaconChain, BeaconChainTypes}; -use eth2_libp2p::{NetworkConfig, Subnet, SubnetDiscovery}; use hashset_delay::HashSetDelay; +use lighthouse_network::{NetworkConfig, Subnet, SubnetDiscovery}; use slot_clock::SlotClock; use types::{Attestation, EthSpec, Slot, SubnetId, ValidatorSubscription}; diff --git a/beacon_node/network/src/subnet_service/mod.rs b/beacon_node/network/src/subnet_service/mod.rs index 4df540d9b..6450fc72e 100644 --- a/beacon_node/network/src/subnet_service/mod.rs +++ b/beacon_node/network/src/subnet_service/mod.rs @@ -1,7 +1,7 @@ pub mod attestation_subnets; pub mod sync_subnets; -use eth2_libp2p::{Subnet, SubnetDiscovery}; +use lighthouse_network::{Subnet, SubnetDiscovery}; pub use attestation_subnets::AttestationService; pub use sync_subnets::SyncCommitteeService; diff --git a/beacon_node/network/src/subnet_service/sync_subnets.rs b/beacon_node/network/src/subnet_service/sync_subnets.rs index 4162fdd16..51fef235a 100644 --- a/beacon_node/network/src/subnet_service/sync_subnets.rs +++ b/beacon_node/network/src/subnet_service/sync_subnets.rs @@ -12,8 +12,8 @@ use slog::{debug, error, o, trace, warn}; use super::SubnetServiceMessage; use beacon_chain::{BeaconChain, BeaconChainTypes}; -use eth2_libp2p::{NetworkConfig, Subnet, SubnetDiscovery}; use hashset_delay::HashSetDelay; +use lighthouse_network::{NetworkConfig, Subnet, SubnetDiscovery}; use slot_clock::SlotClock; use types::{Epoch, EthSpec, SyncCommitteeSubscription, SyncSubnetId}; diff --git a/beacon_node/network/src/subnet_service/tests/mod.rs b/beacon_node/network/src/subnet_service/tests/mod.rs index 6ad083764..da0c1fc8c 100644 --- a/beacon_node/network/src/subnet_service/tests/mod.rs +++ b/beacon_node/network/src/subnet_service/tests/mod.rs @@ -4,10 +4,10 @@ use beacon_chain::{ eth1_chain::CachingEth1Backend, BeaconChain, }; -use eth2_libp2p::NetworkConfig; use futures::prelude::*; use genesis::{generate_deterministic_keypairs, interop_genesis_state}; use lazy_static::lazy_static; +use lighthouse_network::NetworkConfig; use slog::Logger; use sloggers::{null::NullLoggerBuilder, Build}; use slot_clock::{SlotClock, SystemTimeSlotClock}; diff --git a/beacon_node/network/src/sync/backfill_sync/mod.rs b/beacon_node/network/src/sync/backfill_sync/mod.rs index 903b57f03..a47faa735 100644 --- a/beacon_node/network/src/sync/backfill_sync/mod.rs +++ b/beacon_node/network/src/sync/backfill_sync/mod.rs @@ -14,8 +14,8 @@ use crate::sync::manager::BatchProcessResult; use crate::sync::network_context::SyncNetworkContext; use crate::sync::range_sync::{BatchConfig, BatchId, BatchInfo, BatchState}; use beacon_chain::{BeaconChain, BeaconChainTypes}; -use eth2_libp2p::types::{BackFillState, NetworkGlobals}; -use eth2_libp2p::{PeerAction, PeerId}; +use lighthouse_network::types::{BackFillState, NetworkGlobals}; +use lighthouse_network::{PeerAction, PeerId}; use rand::seq::SliceRandom; use slog::{crit, debug, error, info, warn}; use std::collections::{ diff --git a/beacon_node/network/src/sync/manager.rs b/beacon_node/network/src/sync/manager.rs index ae19db32a..f0726ca94 100644 --- a/beacon_node/network/src/sync/manager.rs +++ b/beacon_node/network/src/sync/manager.rs @@ -42,11 +42,11 @@ use crate::beacon_processor::{ProcessId, WorkEvent as BeaconWorkEvent}; use crate::service::NetworkMessage; use crate::status::ToStatusMessage; use beacon_chain::{BeaconChain, BeaconChainTypes, BlockError}; -use eth2_libp2p::rpc::{methods::MAX_REQUEST_BLOCKS, BlocksByRootRequest, GoodbyeReason}; -use eth2_libp2p::types::{NetworkGlobals, SyncState}; -use eth2_libp2p::SyncInfo; -use eth2_libp2p::{PeerAction, PeerId}; use fnv::FnvHashMap; +use lighthouse_network::rpc::{methods::MAX_REQUEST_BLOCKS, BlocksByRootRequest, GoodbyeReason}; +use lighthouse_network::types::{NetworkGlobals, SyncState}; +use lighthouse_network::SyncInfo; +use lighthouse_network::{PeerAction, PeerId}; use lru_cache::LRUCache; use slog::{crit, debug, error, info, trace, warn, Logger}; use smallvec::SmallVec; diff --git a/beacon_node/network/src/sync/network_context.rs b/beacon_node/network/src/sync/network_context.rs index 073b83a85..cedc2f036 100644 --- a/beacon_node/network/src/sync/network_context.rs +++ b/beacon_node/network/src/sync/network_context.rs @@ -7,9 +7,11 @@ use super::RequestId as SyncRequestId; use crate::service::NetworkMessage; use crate::status::ToStatusMessage; use beacon_chain::{BeaconChain, BeaconChainTypes}; -use eth2_libp2p::rpc::{BlocksByRangeRequest, BlocksByRootRequest, GoodbyeReason, RequestId}; -use eth2_libp2p::{Client, NetworkGlobals, PeerAction, PeerId, ReportSource, Request}; use fnv::FnvHashMap; +use lighthouse_network::rpc::{ + BlocksByRangeRequest, BlocksByRootRequest, GoodbyeReason, RequestId, +}; +use lighthouse_network::{Client, NetworkGlobals, PeerAction, PeerId, ReportSource, Request}; use slog::{debug, trace, warn}; use std::sync::Arc; use tokio::sync::mpsc; diff --git a/beacon_node/network/src/sync/peer_sync_info.rs b/beacon_node/network/src/sync/peer_sync_info.rs index 912c4d011..ed3f07763 100644 --- a/beacon_node/network/src/sync/peer_sync_info.rs +++ b/beacon_node/network/src/sync/peer_sync_info.rs @@ -1,6 +1,6 @@ use super::manager::SLOT_IMPORT_TOLERANCE; use beacon_chain::{BeaconChain, BeaconChainTypes}; -use eth2_libp2p::{SyncInfo, SyncStatus as PeerSyncStatus}; +use lighthouse_network::{SyncInfo, SyncStatus as PeerSyncStatus}; use std::cmp::Ordering; /// The type of peer relative to our current state. diff --git a/beacon_node/network/src/sync/range_sync/batch.rs b/beacon_node/network/src/sync/range_sync/batch.rs index 5e2abc046..70e27b5a0 100644 --- a/beacon_node/network/src/sync/range_sync/batch.rs +++ b/beacon_node/network/src/sync/range_sync/batch.rs @@ -1,6 +1,6 @@ use crate::sync::RequestId; -use eth2_libp2p::rpc::methods::BlocksByRangeRequest; -use eth2_libp2p::PeerId; +use lighthouse_network::rpc::methods::BlocksByRangeRequest; +use lighthouse_network::PeerId; use ssz::Encode; use std::collections::HashSet; use std::hash::{Hash, Hasher}; diff --git a/beacon_node/network/src/sync/range_sync/chain.rs b/beacon_node/network/src/sync/range_sync/chain.rs index 3da865503..a1acac614 100644 --- a/beacon_node/network/src/sync/range_sync/chain.rs +++ b/beacon_node/network/src/sync/range_sync/chain.rs @@ -3,8 +3,8 @@ use crate::beacon_processor::ProcessId; use crate::beacon_processor::WorkEvent as BeaconWorkEvent; use crate::sync::{network_context::SyncNetworkContext, BatchProcessResult, RequestId}; use beacon_chain::BeaconChainTypes; -use eth2_libp2p::{PeerAction, PeerId}; use fnv::FnvHashMap; +use lighthouse_network::{PeerAction, PeerId}; use rand::seq::SliceRandom; use slog::{crit, debug, o, warn}; use std::collections::{btree_map::Entry, BTreeMap, HashSet}; diff --git a/beacon_node/network/src/sync/range_sync/chain_collection.rs b/beacon_node/network/src/sync/range_sync/chain_collection.rs index 89d49121b..13d1bef3c 100644 --- a/beacon_node/network/src/sync/range_sync/chain_collection.rs +++ b/beacon_node/network/src/sync/range_sync/chain_collection.rs @@ -9,9 +9,9 @@ use crate::beacon_processor::WorkEvent as BeaconWorkEvent; use crate::metrics; use crate::sync::network_context::SyncNetworkContext; use beacon_chain::{BeaconChain, BeaconChainTypes}; -use eth2_libp2p::PeerId; -use eth2_libp2p::SyncInfo; use fnv::FnvHashMap; +use lighthouse_network::PeerId; +use lighthouse_network::SyncInfo; use slog::{crit, debug, error}; use smallvec::SmallVec; use std::collections::hash_map::Entry; diff --git a/beacon_node/network/src/sync/range_sync/range.rs b/beacon_node/network/src/sync/range_sync/range.rs index 097f6158f..0663ad266 100644 --- a/beacon_node/network/src/sync/range_sync/range.rs +++ b/beacon_node/network/src/sync/range_sync/range.rs @@ -47,8 +47,8 @@ use crate::status::ToStatusMessage; use crate::sync::network_context::SyncNetworkContext; use crate::sync::{BatchProcessResult, RequestId}; use beacon_chain::{BeaconChain, BeaconChainTypes}; -use eth2_libp2p::PeerId; -use eth2_libp2p::SyncInfo; +use lighthouse_network::PeerId; +use lighthouse_network::SyncInfo; use slog::{crit, debug, error, trace}; use std::collections::HashMap; use std::sync::Arc; diff --git a/beacon_node/network/src/sync/range_sync/sync_type.rs b/beacon_node/network/src/sync/range_sync/sync_type.rs index a73f1735b..c3a7c9345 100644 --- a/beacon_node/network/src/sync/range_sync/sync_type.rs +++ b/beacon_node/network/src/sync/range_sync/sync_type.rs @@ -2,7 +2,7 @@ //! of a remote. use beacon_chain::{BeaconChain, BeaconChainTypes}; -use eth2_libp2p::SyncInfo; +use lighthouse_network::SyncInfo; use std::sync::Arc; /// The type of Range sync that should be done relative to our current state. diff --git a/beacon_node/src/config.rs b/beacon_node/src/config.rs index f22011da0..8369ebe05 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -2,9 +2,9 @@ use clap::ArgMatches; use clap_utils::{flags::DISABLE_MALLOC_TUNING_FLAG, BAD_TESTNET_DIR_MESSAGE}; use client::{ClientConfig, ClientGenesis}; use directory::{DEFAULT_BEACON_NODE_DIR, DEFAULT_NETWORK_DIR, DEFAULT_ROOT_DIR}; -use eth2_libp2p::{multiaddr::Protocol, Enr, Multiaddr, NetworkConfig, PeerIdSerialized}; use eth2_network_config::{Eth2NetworkConfig, DEFAULT_HARDCODED_NETWORK}; use http_api::TlsConfig; +use lighthouse_network::{multiaddr::Protocol, Enr, Multiaddr, NetworkConfig, PeerIdSerialized}; use sensitive_url::SensitiveUrl; use slog::{info, warn, Logger}; use std::cmp; diff --git a/beacon_node/src/lib.rs b/beacon_node/src/lib.rs index ad0e6f6a8..bdaefb0e9 100644 --- a/beacon_node/src/lib.rs +++ b/beacon_node/src/lib.rs @@ -158,7 +158,7 @@ impl DerefMut for ProductionBeaconNode { #[derive(Clone)] struct Discv5Executor(task_executor::TaskExecutor); -impl eth2_libp2p::discv5::Executor for Discv5Executor { +impl lighthouse_network::discv5::Executor for Discv5Executor { fn spawn(&self, future: std::pin::Pin + Send>>) { self.0.spawn(future, "discv5") } diff --git a/boot_node/Cargo.toml b/boot_node/Cargo.toml index 828931353..47dbaa86b 100644 --- a/boot_node/Cargo.toml +++ b/boot_node/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] beacon_node = { path = "../beacon_node" } clap = "2.33.3" -eth2_libp2p = { path = "../beacon_node/eth2_libp2p" } +lighthouse_network = { path = "../beacon_node/lighthouse_network" } types = { path = "../consensus/types" } eth2_ssz = "0.4.0" slog = "2.5.2" diff --git a/boot_node/src/config.rs b/boot_node/src/config.rs index 1a1d4f1bb..93be6b05c 100644 --- a/boot_node/src/config.rs +++ b/boot_node/src/config.rs @@ -1,7 +1,7 @@ use beacon_node::{get_data_dir, get_eth2_network_config, set_network_config}; use clap::ArgMatches; -use eth2_libp2p::discv5::{enr::CombinedKey, Discv5Config, Enr}; -use eth2_libp2p::{ +use lighthouse_network::discv5::{enr::CombinedKey, Discv5Config, Enr}; +use lighthouse_network::{ discovery::{create_enr_builder_from_config, load_enr_from_disk, use_or_load_enr}, load_private_key, CombinedKeyExt, NetworkConfig, }; diff --git a/boot_node/src/server.rs b/boot_node/src/server.rs index 6956a1f54..6b7f0bf48 100644 --- a/boot_node/src/server.rs +++ b/boot_node/src/server.rs @@ -1,7 +1,7 @@ //! The main bootnode server execution. use super::BootNodeConfig; -use eth2_libp2p::{ +use lighthouse_network::{ discv5::{enr::NodeId, Discv5, Discv5Event}, EnrExt, Eth2Enr, }; diff --git a/common/eth2/Cargo.toml b/common/eth2/Cargo.toml index 78108eab4..b22cfc28f 100644 --- a/common/eth2/Cargo.toml +++ b/common/eth2/Cargo.toml @@ -11,7 +11,7 @@ serde = { version = "1.0.116", features = ["derive"] } serde_json = "1.0.58" types = { path = "../../consensus/types" } reqwest = { version = "0.11.0", features = ["json","stream"] } -eth2_libp2p = { path = "../../beacon_node/eth2_libp2p" } +lighthouse_network = { path = "../../beacon_node/lighthouse_network" } proto_array = { path = "../../consensus/proto_array", optional = true } eth2_serde_utils = "0.1.0" eth2_keystore = { path = "../../crypto/eth2_keystore" } diff --git a/common/eth2/src/lib.rs b/common/eth2/src/lib.rs index 1f38f9653..97bcdc1b3 100644 --- a/common/eth2/src/lib.rs +++ b/common/eth2/src/lib.rs @@ -13,9 +13,9 @@ pub mod lighthouse_vc; pub mod types; use self::types::{Error as ResponseError, *}; -use eth2_libp2p::PeerId; use futures::Stream; use futures_util::StreamExt; +use lighthouse_network::PeerId; pub use reqwest; use reqwest::{IntoUrl, Response}; pub use reqwest::{StatusCode, Url}; diff --git a/common/eth2/src/lighthouse.rs b/common/eth2/src/lighthouse.rs index 6ea008b8e..a8993a39c 100644 --- a/common/eth2/src/lighthouse.rs +++ b/common/eth2/src/lighthouse.rs @@ -12,7 +12,7 @@ use ssz::four_byte_option_impl; use ssz_derive::{Decode, Encode}; use store::{AnchorInfo, Split}; -pub use eth2_libp2p::{types::SyncState, PeerInfo}; +pub use lighthouse_network::{types::SyncState, PeerInfo}; // Define "legacy" implementations of `Option` which use four bytes for encoding the union // selector. diff --git a/common/eth2/src/types.rs b/common/eth2/src/types.rs index 1e4bfca2d..3f9950870 100644 --- a/common/eth2/src/types.rs +++ b/common/eth2/src/types.rs @@ -2,7 +2,7 @@ //! required for the HTTP API. use crate::Error as ServerError; -use eth2_libp2p::{ConnectionDirection, Enr, Multiaddr, PeerConnectionStatus}; +use lighthouse_network::{ConnectionDirection, Enr, Multiaddr, PeerConnectionStatus}; pub use reqwest::header::ACCEPT; use serde::{Deserialize, Serialize}; use std::convert::TryFrom; diff --git a/lcli/Cargo.toml b/lcli/Cargo.toml index ae90855df..245247ba4 100644 --- a/lcli/Cargo.toml +++ b/lcli/Cargo.toml @@ -26,7 +26,7 @@ genesis = { path = "../beacon_node/genesis" } deposit_contract = { path = "../common/deposit_contract" } tree_hash = "0.4.0" clap_utils = { path = "../common/clap_utils" } -eth2_libp2p = { path = "../beacon_node/eth2_libp2p" } +lighthouse_network = { path = "../beacon_node/lighthouse_network" } validator_dir = { path = "../common/validator_dir", features = ["insecure_keys"] } lighthouse_version = { path = "../common/lighthouse_version" } directory = { path = "../common/directory" } diff --git a/lcli/src/generate_bootnode_enr.rs b/lcli/src/generate_bootnode_enr.rs index 966081a4b..cb65bb438 100644 --- a/lcli/src/generate_bootnode_enr.rs +++ b/lcli/src/generate_bootnode_enr.rs @@ -1,5 +1,5 @@ use clap::ArgMatches; -use eth2_libp2p::{ +use lighthouse_network::{ discovery::{build_enr, CombinedKey, CombinedKeyExt, Keypair, ENR_FILENAME}, NetworkConfig, NETWORK_KEY_FILENAME, }; diff --git a/lighthouse/Cargo.toml b/lighthouse/Cargo.toml index 5481f6876..fbcc9d172 100644 --- a/lighthouse/Cargo.toml +++ b/lighthouse/Cargo.toml @@ -45,7 +45,7 @@ malloc_utils = { path = "../common/malloc_utils" } tempfile = "3.1.0" validator_dir = { path = "../common/validator_dir" } slashing_protection = { path = "../validator_client/slashing_protection" } -eth2_libp2p = { path = "../beacon_node/eth2_libp2p" } +lighthouse_network = { path = "../beacon_node/lighthouse_network" } [[test]] name = "lighthouse_tests" diff --git a/lighthouse/tests/beacon_node.rs b/lighthouse/tests/beacon_node.rs index a454ad63e..b95d8b942 100644 --- a/lighthouse/tests/beacon_node.rs +++ b/lighthouse/tests/beacon_node.rs @@ -1,6 +1,6 @@ use beacon_node::ClientConfig as Config; -use eth2_libp2p::PeerId; +use lighthouse_network::PeerId; use serde_json::from_reader; use std::fs::File; use std::io::Write; diff --git a/slasher/service/Cargo.toml b/slasher/service/Cargo.toml index 789cf7393..071e0da5c 100644 --- a/slasher/service/Cargo.toml +++ b/slasher/service/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] beacon_chain = { path = "../../beacon_node/beacon_chain" } directory = { path = "../../common/directory" } -eth2_libp2p = { path = "../../beacon_node/eth2_libp2p" } +lighthouse_network = { path = "../../beacon_node/lighthouse_network" } network = { path = "../../beacon_node/network" } slasher = { path = ".." } slog = "2.5.2" diff --git a/slasher/service/src/service.rs b/slasher/service/src/service.rs index 227a6344a..5cfd3f667 100644 --- a/slasher/service/src/service.rs +++ b/slasher/service/src/service.rs @@ -2,7 +2,7 @@ use beacon_chain::{ observed_operations::ObservationOutcome, BeaconChain, BeaconChainError, BeaconChainTypes, }; use directory::size_of_dir; -use eth2_libp2p::PubsubMessage; +use lighthouse_network::PubsubMessage; use network::NetworkMessage; use slasher::{ metrics::{self, SLASHER_DATABASE_SIZE, SLASHER_RUN_TIME},