Skip to content

Conversation

@macladson
Copy link
Member

Proposed Changes

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 Strings 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.

Additional Info

Here are some cargo tree stats before and after these changes:

# Before
➜ cargo tree -p eth2 --all-features -e normal | wc -l
906
➜ cargo tree -p eth2 --no-default-features -e normal | wc -l
906

# After
➜ cargo tree -p eth2 --all-features -e normal | wc -l
786
➜ cargo tree -p eth2 --no-default-features -e normal | wc -l
669

@macladson macladson requested a review from jxs as a code owner December 3, 2025 12:49
@macladson macladson added work-in-progress PR is a work-in-progress code-quality dependencies Pull requests that update a dependency file labels Dec 3, 2025
@macladson
Copy link
Member Author

We could also consider feature gating all SSZ related crates/dependencies if we can. The http client would then basically be JSON-only which is probably suitable for many use cases, and might even be required for WASM support

@macladson macladson added ready-for-review The code is ready for review and removed work-in-progress PR is a work-in-progress labels Dec 7, 2025
Copy link
Member

@michaelsproul michaelsproul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Definitely a step in the right direction!

default = ["lighthouse"]
lighthouse = []
default = []
lighthouse = ["proto_array", "eth2_keystore", "eip_3076", "zeroize"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing we could do is split the "standard" VC endpoints and Lighthouse VC endpoints. At the moment both are under the same feature as lighthouse. Only the standard VC endpoints require eip_3076, for example.

}

#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Encode, Decode, TestRandom)]
#[cfg_attr(test, derive(TestRandom))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting that this attribute means we will not be able to use TestRandom on BlobsBundle in any crates that depend on eth2, because dependencies do not get compiled with cfg(test):

This is fine at the moment, but might need to be adjusted in future. And in general I think we should be wary of putting any actual code behind cfg(test). A separate cfg(feature = "testing") is the alternative.

//! This module exposes a superset of the `types` crate. It adds additional types that are only
//! required for the HTTP API.
pub use types::*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that the git blame for this line will now be your username 😉

@michaelsproul michaelsproul added ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Dec 8, 2025
@mergify
Copy link

mergify bot commented Dec 8, 2025

Merge Queue Status

✅ The pull request has been merged

This pull request spent 39 minutes 47 seconds in the queue, including 37 minutes 54 seconds running CI.
The checks were run on draft #8552.

Required conditions to merge
  • check-success=local-testnet-success
  • check-success=test-suite-success

@mergify mergify bot added the queued label Dec 8, 2025
mergify bot added a commit that referenced this pull request Dec 8, 2025
@mergify mergify bot merged commit 7bfcc03 into sigp:unstable Dec 8, 2025
36 checks passed
@mergify mergify bot removed the queued label Dec 8, 2025
@macladson macladson deleted the eth2-features branch December 8, 2025 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-quality dependencies Pull requests that update a dependency file ready-for-merge This PR is ready to merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants