refactor: use libssz instead of ethereum_ssz#242
Conversation
🤖 Kimi Code ReviewReview SummaryThis PR migrates ethlambda from the legacy ✅ Correctness & Consensus Safety
|
🤖 Codex Code Review
Overall, the SSZ migration itself looks mostly consistent (hash root and encode/decode replacements are generally coherent), but Point 1 is a significant correctness gap in consensus test coverage. Automated review by OpenAI Codex · custom prompt |
🤖 Claude Code ReviewNow I have enough context. Let me write up the review. PR #242 Review: refactor: use libssz instead of ethereum_sszThis is a large mechanical migration from Bug:
|
| rec_aggregation = { git = "https://github.com/leanEthereum/leanMultisig.git", rev = "e4474138487eeb1ed7c2e1013674fe80ac9f3165" } | ||
| # ethereum_ssz is needed for Devnet2XmssAggregateSignature from lean-multisig, | ||
| # which implements the old ethereum_ssz Encode/Decode traits | ||
| ethereum_ssz = { package = "ethereum_ssz", version = "0.10.0" } |
There was a problem hiding this comment.
lean-multisig is still using ethereum_ssz::Encode/Decode traits. So we are depending on both libraries
pablodeymo
left a comment
There was a problem hiding this comment.
Nice work on the migration, clean and well-structured. CI is green and all tests pass. A few observations:
H256(x.hash_tree_root()) wrapping pattern
There are ~25 call sites wrapping hash_tree_root() in H256(...). I checked libssz and confirmed there's no ethereum_types feature flag — HashTreeRoot returns [u8; 32] by design, which makes sense for a generic no_std library.
Since H256 is now a local type, we can add a convenience trait on our side to reduce the boilerplate. Something like:
// In ethlambda_types::primitives
use ssz_merkle::HashTreeRoot;
pub trait HashTreeRootExt: HashTreeRoot {
fn tree_hash_root(&self) -> H256 {
H256(self.hash_tree_root())
}
}
impl<T: HashTreeRoot> HashTreeRootExt for T {}This would turn H256(block.hash_tree_root()) back into block.tree_hash_root() everywhere. Not a blocker for this PR — could be a quick follow-up.
ethereum_ssz residual in crypto crate
The comment in crates/common/crypto/Cargo.toml explains this well — lean-multisig still uses the old ethereum_ssz traits. Just flagging it for tracking so it gets cleaned up when lean-multisig migrates.
ValidatorPubkeyBytes manual impls
The ~40 lines of manual SszEncode/SszDecode/HashTreeRoot for the 52-byte pubkey newtype are correct but boilerplate. Could libssz support arbitrary [u8; N] via const generics? Would eliminate the need for manual impls on uncommon byte array sizes. Low priority.
Bitlist set() no longer returns Result
The old set(i, true).unwrap() pattern is now just set(i, true). Cleaner, but what happens on out-of-bounds? Silent no-op or panic? Worth documenting the contract.
Overall this is a solid migration. The const generics over typenum are a clear readability win, and removing 6 external deps is great for the dependency tree.
No description provided.