refactor(core): replace SignedData trait with a closed enum - #700
Merged
Merged
Conversation
Closes #639. Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
emlautarom1
approved these changes
Sep 11, 2026
emlautarom1
left a comment
Collaborator
There was a problem hiding this comment.
LGTM. The code is pretty much the same but relies on match instead of downcasting which could have caused problems in the future. We also skip some Boxes and we can drop the dyn-* dependencies.
Comment on lines
+96
to
+98
| // --------------------------------------------------------------- | ||
| // SSZ-capable types — encode as SSZ binary (matching Go `marshal`) | ||
| // --------------------------------------------------------------- |
Collaborator
There was a problem hiding this comment.
Now that we use a closed enum we could remove all of these comments, the match is already exhaustive.
Collaborator
Author
There was a problem hiding this comment.
Done — dropped the section banners and the per-arm restatements in serialize_signed_data; only the note explaining why SyncContributionAndProof has no wire encoding is left, since that one is not derivable from the match.
Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ata-enum # Conflicts: # crates/core/Cargo.toml
The module docs for `eth2signeddata` linked `[`SignedData`]`, which rustdoc could not resolve, failing the docs job under `RUSTDOCFLAGS=-D warnings`. Qualify the link with its defining path. Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
…ata-enum Resolved conflicts between the SignedData enum refactor and main's eth2api client rewrite: - core/types.rs: dropped the trait-era imports (dyn_clone, dyn_eq, HashRoot, SignedDataError) and signeddata::AttesterDuty; kept main's pluto_eth2api::v1 for the reworked DutyDefinition variants. - core/fetcher: dropped both `downcast` (removed here) and `attestation_payload` (moved into eth2api on main); test imports keep the signeddata selection/message types alongside main's types::SlotNumber. - core/sigagg: new_verifier takes main's unwrapped EthBeaconNodeApiClient and the enum-typed `&SignedData` closure argument. - core/bcast: proposal submission goes through main's publish_block_v2 against the enum-matched block; the now-unused std::any::Any / StdError import is gone. Also ported main's new sync-contribution fetcher test off `Box<dyn SignedData>` onto the enum. Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #639.
SignedDatais now a closed enum incrates/core/src/signeddata.rs(mirroringUnsignedDutyData) instead of an object-safe trait:signature/set_signature/message_rootare exhaustive matches, and everyBox<dyn SignedData>/&dyn SignedDatabecomes a plain value or reference (SignedDataSetis nowHashMap<PubKey, SignedData>,ParSignedDataderivesClone/PartialEq).This deletes the
Anysupertrait, thedyn-clone/dyn-eqdependencies (no other crate used them), theset_signature/set_signature_boxedduplication, the 12-armdowncast_refchain inparsigex_codec's encode side, and the ad-hoc downcasts in sigagg, bcast, fetcher, tracker/inclusion and validatorapi — each is now a pattern match on the expected variant.Eth2SignedDatais a borrowed sub-enum built bySignedData::as_eth2_signed_data(Go'sdata.(core.Eth2SignedData)assertion); as the compiler-checked match forced a decision,SyncContributionAndProofis now included, matching charon (core/signeddata.gogives itDomainName/Epoch), where the previous hand-written ladder silently returnedNone. Test mocks are consolidated into one#[cfg(test)]MockSignedDatavariant. The parsigex decode probing (#640) andSomeMsg::as_anyare left for the follow-ups.Co-Authored-By: Bohdan Ohorodnii 35969035+varex83@users.noreply.github.com