Skip to content
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

Fix SigVerifiedOp SSZ implementation #6035

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

michaelsproul
Copy link
Member

Issue Addressed

The schema v20 migration was liable to fail and brick the database due to a discrepency in the Encode and Decode implementations for SigVerifiedOp. This was identified while testing the v21 schema migration: #5897 (comment).

Proposed Changes

Rather than trying to tweak the hand-written implementation I've replaced it with a more obviously correct implementation that translates to and from SigVerifiedOp{Encode,Decode} types. IMO this is much easier to check the correctness of, because the Decode and Encode implementations are just mappings.

I've also added some roundtrip tests which pass on the new impl and fail on the old.

Additional Info

Manual testing of the migration didn't catch this because the error only occurs sometimes: when there are SigVerifiedOps in the op pool.

@michaelsproul michaelsproul added bug Something isn't working ready-for-review The code is ready for review database labels Jul 2, 2024
@@ -39,12 +39,13 @@ pub trait TransformPersist {
///
/// The inner `op` field is private, meaning instances of this type can only be constructed
/// by calling `validate`.
#[derive(Derivative, Debug, Clone)]
#[derive(Derivative, Debug, Clone, Arbitrary)]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this arbitrary implementation because my first reproduction used cargo-fuzz. It was quicker than wiring up TestRandom.

We don't usually check in cargo fuzz targets, but I figured there's no harm in leaving this in case we want to wire it up again in future.

Copy link
Member

@ethDreamer ethDreamer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is way simpler. Thanks for finding and fixing this!

@michaelsproul
Copy link
Member Author

@mergify queue

Copy link

mergify bot commented Jul 2, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at 937f8b2

@mergify mergify bot merged commit 937f8b2 into sigp:unstable Jul 2, 2024
28 checks passed
@michaelsproul michaelsproul deleted the verified-op-ssz branch July 2, 2024 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working database ready-for-review The code is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants