Conversation
emlautarom1
left a comment
There was a problem hiding this comment.
It's extremely hard to validate the PR given its length, so I'll share my general concerns here before merging:
- Some golden tests or fixtures have no clear sources. From where are we getting these?
- We don't have any integration tests with a real Beacon client and adding them is non trivial.
- There are seveal data types that look to be duplicated or even triplicated.
- We're adding yet annother SSZ library into the mix, so now we have 3 versions:
crates/cluster/ssz,tree_hashandssz. - There are some additional unused dependencies.
I don't want to block on this since it has very little business logic (it's mostly moving data around) but still I would like to evaluate:
- Using a beacon types library like https://docs.rs/alloy-rpc-types-beacon/1.7.3/alloy_rpc_types_beacon/index.html
- If you take a look closely, some types are not fully generated by oas3-gen (it ends up using
serde::Valueinstead). We can also take a look at another generator like https://openapi-generator.tech/docs/generators/rust
WDYT @varex83 ?
Cargo.toml
Outdated
| ssz = { package = "ethereum_ssz", version = "0.10.1" } | ||
| ssz_derive = { package = "ethereum_ssz_derive", version = "0.10.1" } |
There was a problem hiding this comment.
We already have tree_hash to deal with ssz. Why do we need to include a second library for the same features? Also, including this dependencies forces us to add typenum too.
There was a problem hiding this comment.
Removed ssz and typenum. Self-implement a lightweight BitList and BitVector
| use serde::{Deserialize, Serialize, de::Error as DeError}; | ||
| use tree_hash::{Hash256, PackedEncoding, TreeHash, TreeHashType, merkle_root, mix_in_length}; | ||
|
|
||
| fn tree_hash_bytes<T: TreeHash>(values: &[T]) -> Vec<u8> { |
There was a problem hiding this comment.
This looks to be the same as pluto_cluster::ssz_hasher::Hasher::put_bytes
| /// Consensus data version. | ||
| #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Serialize, Deserialize)] | ||
| #[serde(rename_all = "lowercase")] | ||
| pub enum DataVersion { |
There was a problem hiding this comment.
This is the same as pluto_eth2util::types::DataVersion except for the custom Serialize/Deserialize. Same thing for BuilderVersion.
I see that the difference is on the JSON serialization. What exactly is expected by the Beacon API? From what I could tell it uses the enum lowercase names as strings.
There was a problem hiding this comment.
The different between pluto_eth2util::types::DataVersion and eth2api::spec::version is:
pluto_eth2util::types::DataVersionuses number as serializationeth2api::spec::versionuses string
crates/eth2util/src/types.rs
Outdated
| pub signature: phase0::BLSSignature, | ||
| } | ||
|
|
||
| impl Serialize for SignedEpoch { |
There was a problem hiding this comment.
I think we can replace some of these custom instances with serde annotations.
e056798 to
ba8d6b7
Compare
| /// values. | ||
| pub struct Hex0x; | ||
|
|
||
| impl<T> SerializeAs<T> for Hex0x |
There was a problem hiding this comment.
I think we have something similar in the cluster
This reverts commit ba8d6b7.
varex83
left a comment
There was a problem hiding this comment.
As @emlautarom1 said its very hard to review this PR, and we already talked in the slack regarding it.
I would suggest using the approach with autogenerating the types together with some ssz derives (most likely I feel we will need to make our own, but not sure)
This reverts commit bbd45d0.
|
@varex83 @emlautarom1 I removed the For code generation, the structs are implemented based on the specs here: So far, I haven't found an efficient way to generate them automatically. As discussed, one possible approach is to reuse the structs from Alloy. The challenge is that we would still need to reimplement The golden test data comes from Charon. For some additional test fixtures, I used a Go library to generate the structs and corresponding hashes, and then used those outputs as test cases for the Rust implementation. |
|
@claude can you review the PR? |
|
Claude finished @varex83's task in 2m 45s —— View job PR Review
SummaryThis PR ports the Go Findings[High]
Evidence: Recommendation: Replace with a panic-free contract — return a no-op [Medium] Inconsistent error variant in
Evidence: Recommendation: Use [Medium] Redundant
Evidence: Recommendation: Remove the redundant [Medium] Three partially-overlapping There are now three version enums in the workspace:
The conversion methods ( The PR description explains the rationale (numeric vs. string serialization formats), which is valid. However, consider whether this can be collapsed into one type with two [Medium] Golden test vector sources are undocumented in the file
Recommendation: Add a short header comment in both files with the provenance: e.g., [Low] In both Evidence: [Low] Missing test coverage for Deneb (unblinded) in the golden roundtrip tests Looking at Evidence: Parity Matrix
Note on TestsTests are present and cover the main happy-path and error cases well. The golden-vector approach is effective for detecting tree-hash divergence. Gaps noted above (Deneb unblinded/Fulu unblinded roundtrip, and vector provenance) are the main issues. Open Questions / Assumptions
|
Should fix: #250
1. New
core::signeddatamodulecrates/core/src/signeddata.rs(large new module).SignedDataError)2. Expanded ETH2 API spec/model coverage
crates/eth2api/src/spec/crates/eth2api/src/versioned.rs3.
eth2utiltype/version bridgecrates/eth2util/src/types.rsSignedEpochtype + serde/tree-hash behavior4. Tests and golden vectors
crates/core/testdata/signed_data_golden.jsontest-case) for parity and serde/root checks