Skip to content

Fix deserialization of Electra JSON responses from builders #7277

Closed
@michaelsproul

Description

@michaelsproul

I think our implementation of ForkVersionDeserialize is wrong:

impl<E: EthSpec> ForkVersionDeserialize for FullPayloadContents<E> {
fn deserialize_by_fork<'de, D: Deserializer<'de>>(
value: Value,
fork_name: ForkName,
) -> Result<Self, D::Error> {
if fork_name.deneb_enabled() {
serde_json::from_value(value)
.map(Self::PayloadAndBlobs)
.map_err(serde::de::Error::custom)
} else if fork_name.bellatrix_enabled() {
serde_json::from_value(value)
.map(Self::Payload)
.map_err(serde::de::Error::custom)
} else {
Err(serde::de::Error::custom(format!(
"FullPayloadContents deserialization for {fork_name} not implemented"
)))
}
}
}

We are relying on serde_json::from_value(value) to produce a ExecutionPayloadAndBlobs<E> without any fork hinting, so it is liable to deserialize the wrong variant (e.g. Deneb instead of Electra).

I think we should remove the Deserialize impl for ExecutionPayloadAndBlobs<E>, implement ForkVersionDeserialize instead, and use that fork-aware deserialization here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbuilder APIelectraRequired for the Electra/Prague forkv7.0.0New release c. Q1 2025

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions