Migrate from `ethereum-types` to `alloy-primitives`
Issue Addressed
partially #6022
Proposed Changes
Migrate LH from ethereum-types to alloy-primitives
Additional Info
Some of the dependencies are referencing branches from my repo. I've opened PR's that need to be merged into those repos so we can revert back to referencing the sigp repos.
I've attempted to patch in some dependencies, but quickly faced some cyclic dep issues that I was unable to resolve
I tried investigating the circular dependency issue that crops up when using [patch].
I think it is down to how Cargo handles optional dependencies, and possibly the ethereum_ssz?/arbitrary dependency here:
https://github.com/alloy-rs/core/blob/6540523385ea10c9adce31beae7106cfa7da770f/crates/primitives/Cargo.toml#L96-L105
I made a minimal test case here, and it is very broken, even without the ? syntax:
https://github.com/michaelsproul/circular-test
I think our two options are:
- Tolerate the existence of two
ethereum_sszcrates in the build tree untilalloy-primitivesis updated to not depend onethereum_sszat all. If we bump theethereum_sszversion to0.6on the alloy branch, and depend on that version in Lighthouse, then theethereum_sszdep ofalloy-primitiveswill not get patched. - Raise a PR to
alloy-primitivesto remove theethereum_sszdep, and make this part of thepatchsection. This probably needs to be the long-term solution, so maybe we should start working on this even if we take option (1) for now.
Related Cargo issue:
- https://github.com/rust-lang/cargo/issues/6743
Thanks for taking a look at this @michaelsproul
For option (2), removing the ethereum_ssz dep, I think this means we'll need to impl ssz Encode & Decode directly in the alloy_primitives crate. Does that sound correct?
I think we should move the SSZ impls that are currently in alloy-primitives into ethereum_ssz itself.
E.g. implementing Decode/Encode for H256 should be in ethereum_ssz
I went ahead and made some progress on option (2)
- PR to
alloyhttps://github.com/alloy-rs/core/pull/701 - PR to
ethereum_sszhttps://github.com/sigp/ethereum_ssz/pull/26
I've also patched in the relevant deps into Lighthouse. No more circular dependency issues!
I've released preliminary versions of all our crates which we can use in this PR. I think we could merge it to unstable and then come back for the coordinated release to remove ethereum_ssz 0.5.4 later.
sounds good, will resolve the conflicts and get those dependencies pointed to the right versions
Updated to point to the correct dependencies and resolved all conflicts. Since we're not patching any deps in anymore, we're actually ok to use the existing alloy-primitives crate.
I've just released new versions of all the packages depending on alloy-primitives 0.8, so we should be able to cut out the duplicate version of ethereum_ssz now!
Can you bump every dep by +0.1.0?
we cant bump alloy-primitives to 0.8 until this gets merged: https://github.com/alloy-rs/alloy/pull/1167
alloy-consensus still depends on alloy-primitives 0.7.7 and theres some diff between alloy_primitives::TxKind on 0.7 vs 0.8 that causes issues
maybe theres a way to work around this issue? not 100% sure. We can either wait for the new alloy release or figure out a workaround
EDIT: in
11d8a26 I've commented out the problematic code and added a TODO to reintroduce it once alloy cuts a new release
fyi new alloy-rs/alloy crate release coming later today, tmrw at the latest
alloy cut a release so were no longer blocked by that
this should be ready for another review!
@mergify queue
queue
✅ The pull request has been merged automatically
The pull request has been merged automatically at 99e53b88c3bd2e3af5aefe2e86bb0804556d8d8c