mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +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:
@@ -12,7 +12,7 @@ bs58 = "0.4.0"
|
||||
bytes = { workspace = true }
|
||||
directory = { workspace = true }
|
||||
either = { workspace = true }
|
||||
eth2 = { workspace = true }
|
||||
eth2 = { workspace = true, features = ["lighthouse"] }
|
||||
ethereum_serde_utils = { workspace = true }
|
||||
ethereum_ssz = { workspace = true }
|
||||
execution_layer = { workspace = true }
|
||||
|
||||
@@ -2118,9 +2118,12 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
let discovery_addresses = enr.multiaddr_p2p_udp();
|
||||
Ok(api_types::GenericResponse::from(api_types::IdentityData {
|
||||
peer_id: network_globals.local_peer_id().to_base58(),
|
||||
enr,
|
||||
p2p_addresses,
|
||||
discovery_addresses,
|
||||
enr: enr.to_base64(),
|
||||
p2p_addresses: p2p_addresses.iter().map(|a| a.to_string()).collect(),
|
||||
discovery_addresses: discovery_addresses
|
||||
.iter()
|
||||
.map(|a| a.to_string())
|
||||
.collect(),
|
||||
metadata: utils::from_meta_data::<T::EthSpec>(
|
||||
&network_globals.local_metadata,
|
||||
&chain.spec,
|
||||
|
||||
@@ -2853,9 +2853,19 @@ impl ApiTester {
|
||||
|
||||
let expected = IdentityData {
|
||||
peer_id: self.local_enr.peer_id().to_string(),
|
||||
enr: self.local_enr.clone(),
|
||||
p2p_addresses: self.local_enr.multiaddr_p2p_tcp(),
|
||||
discovery_addresses: self.local_enr.multiaddr_p2p_udp(),
|
||||
enr: self.local_enr.to_base64(),
|
||||
p2p_addresses: self
|
||||
.local_enr
|
||||
.multiaddr_p2p_tcp()
|
||||
.iter()
|
||||
.map(|a| a.to_string())
|
||||
.collect(),
|
||||
discovery_addresses: self
|
||||
.local_enr
|
||||
.multiaddr_p2p_udp()
|
||||
.iter()
|
||||
.map(|a| a.to_string())
|
||||
.collect(),
|
||||
metadata: MetaData::V2(MetaDataV2 {
|
||||
seq_number: 0,
|
||||
attnets: "0x0000000000000000".to_string(),
|
||||
@@ -2884,7 +2894,7 @@ impl ApiTester {
|
||||
pub async fn test_get_node_peers_by_id(self) -> Self {
|
||||
let result = self
|
||||
.client
|
||||
.get_node_peers_by_id(self.external_peer_id)
|
||||
.get_node_peers_by_id(&self.external_peer_id.to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.data;
|
||||
|
||||
Reference in New Issue
Block a user