mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Add network feature to eth2 (#8558)
This reverts some of the changes from #8524 by adding back the typed network endpoints with an optional `network` feature. Without the `network` feature, these endpoints (and associated dependencies) will not be built. This means the `enr`, `multiaddr` and `libp2p-identity` dependencies have returned but are now optional Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
@@ -8,19 +8,23 @@ edition = { workspace = true }
|
||||
default = []
|
||||
lighthouse = ["proto_array", "eth2_keystore", "eip_3076", "zeroize"]
|
||||
events = ["reqwest-eventsource", "futures", "futures-util"]
|
||||
network = ["libp2p-identity", "enr", "multiaddr"]
|
||||
|
||||
[dependencies]
|
||||
bls = { workspace = true }
|
||||
context_deserialize = { workspace = true }
|
||||
educe = { workspace = true }
|
||||
eip_3076 = { workspace = true, optional = true }
|
||||
enr = { version = "0.13.0", features = ["ed25519"], optional = true }
|
||||
eth2_keystore = { workspace = true, optional = true }
|
||||
ethereum_serde_utils = { workspace = true }
|
||||
ethereum_ssz = { workspace = true }
|
||||
ethereum_ssz_derive = { workspace = true }
|
||||
futures = { workspace = true, optional = true }
|
||||
futures-util = { version = "0.3.8", optional = true }
|
||||
libp2p-identity = { version = "0.2", features = ["peerid"], optional = true }
|
||||
mediatype = "0.19.13"
|
||||
multiaddr = { version = "0.18.2", optional = true }
|
||||
pretty_reqwest_error = { workspace = true }
|
||||
proto_array = { workspace = true, optional = true }
|
||||
reqwest = { workspace = true }
|
||||
|
||||
@@ -35,6 +35,8 @@ use educe::Educe;
|
||||
use futures::Stream;
|
||||
#[cfg(feature = "events")]
|
||||
use futures_util::StreamExt;
|
||||
#[cfg(feature = "network")]
|
||||
use libp2p_identity::PeerId;
|
||||
use reqwest::{
|
||||
Body, IntoUrl, RequestBuilder, Response,
|
||||
header::{HeaderMap, HeaderValue},
|
||||
@@ -1939,6 +1941,7 @@ impl BeaconNodeHttpClient {
|
||||
}
|
||||
|
||||
/// `GET node/identity`
|
||||
#[cfg(feature = "network")]
|
||||
pub async fn get_node_identity(&self) -> Result<GenericResponse<IdentityData>, Error> {
|
||||
let mut path = self.eth_path(V1)?;
|
||||
|
||||
@@ -1986,9 +1989,10 @@ impl BeaconNodeHttpClient {
|
||||
}
|
||||
|
||||
/// `GET node/peers/{peer_id}`
|
||||
#[cfg(feature = "network")]
|
||||
pub async fn get_node_peers_by_id(
|
||||
&self,
|
||||
peer_id: &str,
|
||||
peer_id: PeerId,
|
||||
) -> Result<GenericResponse<PeerData>, Error> {
|
||||
let mut path = self.eth_path(V1)?;
|
||||
|
||||
@@ -1996,7 +2000,7 @@ impl BeaconNodeHttpClient {
|
||||
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
|
||||
.push("node")
|
||||
.push("peers")
|
||||
.push(peer_id);
|
||||
.push(&peer_id.to_string());
|
||||
|
||||
self.get(path).await
|
||||
}
|
||||
|
||||
@@ -9,7 +9,11 @@ use crate::{
|
||||
};
|
||||
use bls::{PublicKeyBytes, SecretKey, Signature, SignatureBytes};
|
||||
use context_deserialize::ContextDeserialize;
|
||||
#[cfg(feature = "network")]
|
||||
use enr::{CombinedKey, Enr};
|
||||
use mediatype::{MediaType, MediaTypeList, names};
|
||||
#[cfg(feature = "network")]
|
||||
use multiaddr::Multiaddr;
|
||||
use reqwest::header::HeaderMap;
|
||||
use serde::{Deserialize, Deserializer, Serialize};
|
||||
use serde_utils::quoted_u64::Quoted;
|
||||
@@ -559,12 +563,13 @@ pub struct ChainHeadData {
|
||||
pub execution_optimistic: Option<bool>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "network")]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct IdentityData {
|
||||
pub peer_id: String,
|
||||
pub enr: String,
|
||||
pub p2p_addresses: Vec<String>,
|
||||
pub discovery_addresses: Vec<String>,
|
||||
pub enr: Enr<CombinedKey>,
|
||||
pub p2p_addresses: Vec<Multiaddr>,
|
||||
pub discovery_addresses: Vec<Multiaddr>,
|
||||
pub metadata: MetaData,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user