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

[Feature] Add serde rountrip tests for executionpayload #2004

Closed
mattsse opened this issue Feb 4, 2025 · 4 comments · Fixed by #2014
Closed

[Feature] Add serde rountrip tests for executionpayload #2004

mattsse opened this issue Feb 4, 2025 · 4 comments · Fixed by #2014
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mattsse
Copy link
Member

mattsse commented Feb 4, 2025

Component

rpc

Describe the feature you would like

for these we need some sanity serde rountrip tests:

/// An execution payload, which can be either [ExecutionPayloadV1], [ExecutionPayloadV2], or
/// [ExecutionPayloadV3].
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", serde(untagged))]
pub enum ExecutionPayload {

because I believe V3 deserde doesn't behave as expected and we likely need manual deserde impl

see also: alloy-rs/op-alloy#416 (comment)

Additional context

No response

@mattsse mattsse added enhancement New feature or request good first issue Good for newcomers labels Feb 4, 2025
@mattsse mattsse added this to Alloy Feb 4, 2025
@github-project-automation github-project-automation bot moved this to Todo in Alloy Feb 4, 2025
@siosw
Copy link
Contributor

siosw commented Feb 5, 2025

right now if we have a ExecutionPayloadV3 json, we can still do:
let payload: ExecutionPayloadV2 = serde_json::from_str(json).unwrap();

and extra fields just implicitly get ignored. but obv you can no longer roundtrip then.

is this the behavior you're referring to?

@mattsse
Copy link
Member Author

mattsse commented Feb 5, 2025

exactly

which means the untagged serde for deserialize is wrong

I guess we could solve this with deny_unknown_fields but could be problematic as well

@siosw
Copy link
Contributor

siosw commented Feb 5, 2025

afaik we can't use deny_unknown_field because we rely on flatten already and the two are incompatible

i'd like to work on this. do you think it makes sense to start with a test that asserts this faulty behavior and then work on a custom deserde impl in a follow up PR?

@mattsse
Copy link
Member Author

mattsse commented Feb 6, 2025

do you think it makes sense to start with a test that asserts this faulty behavior and then work on a custom deserde impl in a follow up PR?

yep

great, assigned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants