mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 21:38:31 +00:00
Reduce eth2 dependency space (#8524)
Remove certain dependencies from `eth2`, and feature-gate others which are only used by certain endpoints. | Removed | Optional | Dev only | | -------- | -------- | -------- | | `either` `enr` `libp2p-identity` `multiaddr` | `protoarray` `eth2_keystore` `eip_3076` `zeroize` `reqwest-eventsource` `futures` `futures-util` | `rand` `test_random_derive` | This is done by adding an `events` feature which enables the events endpoint and its associated dependencies. The `lighthouse` feature also enables its associated dependencies making them optional. The networking-adjacent dependencies were removed by just having certain fields use a `String` instead of an explicit network type. This means the user should handle conversion at the call site instead. This is a bit spicy, but I believe `PeerId`, `Enr` and `Multiaddr` are easily converted to and from `String`s so I think it's fine and reduces our dependency space by a lot. The alternative is to feature gate these types behind a `network` feature instead. Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
@@ -22,20 +22,23 @@ pub use beacon_response::{
|
||||
};
|
||||
|
||||
pub use self::error::{Error, ok_or_error, success_or_error};
|
||||
pub use reqwest;
|
||||
pub use reqwest::{StatusCode, Url};
|
||||
pub use sensitive_url::SensitiveUrl;
|
||||
|
||||
use self::mixin::{RequestAccept, ResponseOptional};
|
||||
use self::types::*;
|
||||
use educe::Educe;
|
||||
#[cfg(feature = "events")]
|
||||
use futures::Stream;
|
||||
#[cfg(feature = "events")]
|
||||
use futures_util::StreamExt;
|
||||
use libp2p_identity::PeerId;
|
||||
pub use reqwest;
|
||||
use reqwest::{
|
||||
Body, IntoUrl, RequestBuilder, Response,
|
||||
header::{HeaderMap, HeaderValue},
|
||||
};
|
||||
pub use reqwest::{StatusCode, Url};
|
||||
#[cfg(feature = "events")]
|
||||
use reqwest_eventsource::{Event, EventSource};
|
||||
pub use sensitive_url::SensitiveUrl;
|
||||
use serde::{Serialize, de::DeserializeOwned};
|
||||
use ssz::Encode;
|
||||
use std::fmt;
|
||||
@@ -1978,7 +1981,7 @@ impl BeaconNodeHttpClient {
|
||||
/// `GET node/peers/{peer_id}`
|
||||
pub async fn get_node_peers_by_id(
|
||||
&self,
|
||||
peer_id: PeerId,
|
||||
peer_id: &str,
|
||||
) -> Result<GenericResponse<PeerData>, Error> {
|
||||
let mut path = self.eth_path(V1)?;
|
||||
|
||||
@@ -1986,7 +1989,7 @@ impl BeaconNodeHttpClient {
|
||||
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
|
||||
.push("node")
|
||||
.push("peers")
|
||||
.push(&peer_id.to_string());
|
||||
.push(peer_id);
|
||||
|
||||
self.get(path).await
|
||||
}
|
||||
@@ -2761,6 +2764,7 @@ impl BeaconNodeHttpClient {
|
||||
}
|
||||
|
||||
/// `GET events?topics`
|
||||
#[cfg(feature = "events")]
|
||||
pub async fn get_events<E: EthSpec>(
|
||||
&self,
|
||||
topic: &[EventTopic],
|
||||
|
||||
Reference in New Issue
Block a user