-
Notifications
You must be signed in to change notification settings - Fork 943
Reduce eth2 dependency space
#8524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
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 |
michaelsproul
left a comment
There was a problem hiding this 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"] |
There was a problem hiding this comment.
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))] |
There was a problem hiding this comment.
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::*; |
There was a problem hiding this comment.
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 😉
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. Required conditions to merge
|
Proposed Changes
Remove certain dependencies from
eth2, and feature-gate others which are only used by certain endpoints.eitherenrlibp2p-identitymultiaddrprotoarrayeth2_keystoreeip_3076zeroizereqwest-eventsourcefuturesfutures-utilrandtest_random_deriveThis is done by adding an
eventsfeature which enables the events endpoint and its associated dependencies.The
lighthousefeature also enables its associated dependencies making them optional.The networking-adjacent dependencies were removed by just having certain fields use a
Stringinstead of an explicit network type. This means the user should handle conversion at the call site instead. This is a bit spicy, but I believePeerId,EnrandMultiaddrare easily converted to and fromStrings so I think it's fine and reduces our dependency space by a lot. The alternative is to feature gate these types behind anetworkfeature instead.Additional Info
Here are some
cargo treestats before and after these changes: