Skip to content

Commit 581aab8

Browse files
committed
Cleanup deps and add feature gates
1 parent 41ba135 commit 581aab8

File tree

14 files changed

+62
-47
lines changed

14 files changed

+62
-47
lines changed

Cargo.lock

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

beacon_node/beacon_chain/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ alloy-primitives = { workspace = true }
1919
bitvec = { workspace = true }
2020
bls = { workspace = true }
2121
educe = { workspace = true }
22-
eth2 = { workspace = true }
22+
eth2 = { workspace = true, features = ["lighthouse"] }
2323
eth2_network_config = { workspace = true }
2424
ethereum_hashing = { workspace = true }
2525
ethereum_serde_utils = { workspace = true }

beacon_node/execution_layer/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ alloy-rpc-types-eth = { workspace = true }
1212
arc-swap = "1.6.0"
1313
builder_client = { path = "../builder_client" }
1414
bytes = { workspace = true }
15-
eth2 = { workspace = true }
15+
eth2 = { workspace = true, features = ["events"] }
1616
ethereum_serde_utils = { workspace = true }
1717
ethereum_ssz = { workspace = true }
1818
fixed_bytes = { workspace = true }

beacon_node/http_api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bs58 = "0.4.0"
1212
bytes = { workspace = true }
1313
directory = { workspace = true }
1414
either = { workspace = true }
15-
eth2 = { workspace = true }
15+
eth2 = { workspace = true, features = ["lighthouse"] }
1616
ethereum_serde_utils = { workspace = true }
1717
ethereum_ssz = { workspace = true }
1818
execution_layer = { workspace = true }

beacon_node/http_api/src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3093,9 +3093,12 @@ pub fn serve<T: BeaconChainTypes>(
30933093
let discovery_addresses = enr.multiaddr_p2p_udp();
30943094
Ok(api_types::GenericResponse::from(api_types::IdentityData {
30953095
peer_id: network_globals.local_peer_id().to_base58(),
3096-
enr,
3097-
p2p_addresses,
3098-
discovery_addresses,
3096+
enr: enr.to_base64(),
3097+
p2p_addresses: p2p_addresses.iter().map(|a| a.to_string()).collect(),
3098+
discovery_addresses: discovery_addresses
3099+
.iter()
3100+
.map(|a| a.to_string())
3101+
.collect(),
30993102
metadata: from_meta_data::<T::EthSpec>(
31003103
&network_globals.local_metadata,
31013104
&chain.spec,

beacon_node/http_api/tests/tests.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,9 +2853,19 @@ impl ApiTester {
28532853

28542854
let expected = IdentityData {
28552855
peer_id: self.local_enr.peer_id().to_string(),
2856-
enr: self.local_enr.clone(),
2857-
p2p_addresses: self.local_enr.multiaddr_p2p_tcp(),
2858-
discovery_addresses: self.local_enr.multiaddr_p2p_udp(),
2856+
enr: self.local_enr.to_base64(),
2857+
p2p_addresses: self
2858+
.local_enr
2859+
.multiaddr_p2p_tcp()
2860+
.iter()
2861+
.map(|a| a.to_string())
2862+
.collect(),
2863+
discovery_addresses: self
2864+
.local_enr
2865+
.multiaddr_p2p_udp()
2866+
.iter()
2867+
.map(|a| a.to_string())
2868+
.collect(),
28592869
metadata: MetaData::V2(MetaDataV2 {
28602870
seq_number: 0,
28612871
attnets: "0x0000000000000000".to_string(),
@@ -2884,7 +2894,7 @@ impl ApiTester {
28842894
pub async fn test_get_node_peers_by_id(self) -> Self {
28852895
let result = self
28862896
.client
2887-
.get_node_peers_by_id(self.external_peer_id)
2897+
.get_node_peers_by_id(&self.external_peer_id.to_string())
28882898
.await
28892899
.unwrap()
28902900
.data;

beacon_node/lighthouse_network/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ directory = { workspace = true }
1717
dirs = { workspace = true }
1818
discv5 = { workspace = true }
1919
either = { workspace = true }
20-
eth2 = { workspace = true }
20+
eth2 = { workspace = true, features = ["lighthouse"] }
2121
ethereum_ssz = { workspace = true }
2222
ethereum_ssz_derive = { workspace = true }
2323
fnv = { workspace = true }

common/eth2/Cargo.toml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,32 @@ authors = ["Paul Hauner <[email protected]>"]
55
edition = { workspace = true }
66

77
[features]
8-
default = ["lighthouse"]
9-
lighthouse = []
8+
default = []
9+
lighthouse = ["proto_array", "eth2_keystore", "eip_3076", "zeroize"]
10+
events = ["reqwest-eventsource", "futures", "futures-util"]
1011

1112
[dependencies]
1213
educe = { workspace = true }
13-
eip_3076 = { workspace = true }
14-
either = { workspace = true }
15-
enr = { version = "0.13.0", features = ["ed25519"] }
16-
eth2_keystore = { workspace = true }
14+
eip_3076 = { workspace = true, optional = true }
15+
eth2_keystore = { workspace = true, optional = true }
1716
ethereum_serde_utils = { workspace = true }
1817
ethereum_ssz = { workspace = true }
1918
ethereum_ssz_derive = { workspace = true }
20-
futures = { workspace = true }
21-
futures-util = "0.3.8"
22-
libp2p-identity = { version = "0.2", features = ["peerid"] }
19+
futures = { workspace = true, optional = true }
20+
futures-util = { version = "0.3.8", optional = true }
2321
mediatype = "0.19.13"
24-
multiaddr = "0.18.2"
2522
pretty_reqwest_error = { workspace = true }
26-
proto_array = { workspace = true }
27-
rand = { workspace = true }
23+
proto_array = { workspace = true, optional = true }
2824
reqwest = { workspace = true }
29-
reqwest-eventsource = "0.6.0"
25+
reqwest-eventsource = { version = "0.6.0", optional = true }
3026
sensitive_url = { workspace = true }
3127
serde = { workspace = true }
3228
serde_json = { workspace = true }
3329
ssz_types = { workspace = true }
34-
test_random_derive = { path = "../../common/test_random_derive" }
3530
types = { workspace = true }
36-
zeroize = { workspace = true }
31+
zeroize = { workspace = true, optional = true }
3732

3833
[dev-dependencies]
34+
rand = { workspace = true }
35+
test_random_derive = { path = "../../common/test_random_derive" }
3936
tokio = { workspace = true }

common/eth2/src/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::{fmt, path::PathBuf};
1414
pub enum Error {
1515
/// The `reqwest` client raised an error.
1616
HttpClient(PrettyReqwestError),
17+
#[cfg(feature = "events")]
1718
/// The `reqwest_eventsource` client raised an error.
1819
SseClient(Box<reqwest_eventsource::Error>),
1920
/// The server returned an error message where the body was able to be parsed.
@@ -91,6 +92,7 @@ impl Error {
9192
pub fn status(&self) -> Option<StatusCode> {
9293
match self {
9394
Error::HttpClient(error) => error.inner().status(),
95+
#[cfg(feature = "events")]
9496
Error::SseClient(error) => {
9597
if let reqwest_eventsource::Error::InvalidStatusCode(status, _) = error.as_ref() {
9698
Some(*status)

common/eth2/src/lib.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,24 @@ pub mod mixin;
1616
pub mod types;
1717

1818
pub use self::error::{Error, ok_or_error, success_or_error};
19+
pub use reqwest;
20+
pub use reqwest::{StatusCode, Url};
21+
pub use sensitive_url::SensitiveUrl;
22+
1923
use self::mixin::{RequestAccept, ResponseOptional};
2024
use self::types::*;
2125
use ::types::beacon_response::ExecutionOptimisticFinalizedBeaconResponse;
2226
use educe::Educe;
27+
#[cfg(feature = "events")]
2328
use futures::Stream;
29+
#[cfg(feature = "events")]
2430
use futures_util::StreamExt;
25-
use libp2p_identity::PeerId;
26-
pub use reqwest;
2731
use reqwest::{
2832
Body, IntoUrl, RequestBuilder, Response,
2933
header::{HeaderMap, HeaderValue},
3034
};
31-
pub use reqwest::{StatusCode, Url};
35+
#[cfg(feature = "events")]
3236
use reqwest_eventsource::{Event, EventSource};
33-
pub use sensitive_url::SensitiveUrl;
3437
use serde::{Serialize, de::DeserializeOwned};
3538
use ssz::Encode;
3639
use std::fmt;
@@ -1973,15 +1976,15 @@ impl BeaconNodeHttpClient {
19731976
/// `GET node/peers/{peer_id}`
19741977
pub async fn get_node_peers_by_id(
19751978
&self,
1976-
peer_id: PeerId,
1979+
peer_id: &str,
19771980
) -> Result<GenericResponse<PeerData>, Error> {
19781981
let mut path = self.eth_path(V1)?;
19791982

19801983
path.path_segments_mut()
19811984
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
19821985
.push("node")
19831986
.push("peers")
1984-
.push(&peer_id.to_string());
1987+
.push(peer_id);
19851988

19861989
self.get(path).await
19871990
}
@@ -2756,6 +2759,7 @@ impl BeaconNodeHttpClient {
27562759
}
27572760

27582761
/// `GET events?topics`
2762+
#[cfg(feature = "events")]
27592763
pub async fn get_events<E: EthSpec>(
27602764
&self,
27612765
topic: &[EventTopic],

0 commit comments

Comments
 (0)