From 819bd9a41b8caabac5e7eb6079c006ad8febca7d Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Tue, 28 Apr 2026 17:11:35 +0200 Subject: [PATCH] Fix Gloas SSZ/JSON decoding for `FullBlockContents` and `PublishBlockRequest` --- .../http_api/src/build_block_contents.rs | 4 ++- common/eth2/src/types.rs | 29 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/beacon_node/http_api/src/build_block_contents.rs b/beacon_node/http_api/src/build_block_contents.rs index fb8fba0731..a6bcaa9368 100644 --- a/beacon_node/http_api/src/build_block_contents.rs +++ b/beacon_node/http_api/src/build_block_contents.rs @@ -13,7 +13,9 @@ pub fn build_block_contents( } BeaconBlockResponseWrapper::Full(block) => { - if fork_name.deneb_enabled() { + // TODO(gloas): revisit when produceBlockV4 PR is finalised + // https://github.com/ethereum/beacon-APIs/pull/580 + if fork_name.deneb_enabled() && !fork_name.gloas_enabled() { let BeaconBlockResponse { block, state: _, diff --git a/common/eth2/src/types.rs b/common/eth2/src/types.rs index 1dd4e3d95a..b35f0a5fd6 100644 --- a/common/eth2/src/types.rs +++ b/common/eth2/src/types.rs @@ -1883,7 +1883,9 @@ impl FullBlockContents { /// SSZ decode with fork variant passed in explicitly. pub fn from_ssz_bytes_for_fork(bytes: &[u8], fork_name: ForkName) -> Result { - if fork_name.deneb_enabled() { + // TODO(gloas): revisit when produceBlockV4 PR is finalised + // https://github.com/ethereum/beacon-APIs/pull/580 + if fork_name.deneb_enabled() && !fork_name.gloas_enabled() { let mut builder = ssz::SszDecoderBuilder::new(bytes); builder.register_anonymous_variable_length_item()?; @@ -2050,15 +2052,20 @@ impl<'de, E: EthSpec> ContextDeserialize<'de, ForkName> for PublishBlockRequest< let value = serde_json::Value::deserialize(deserializer).map_err(serde::de::Error::custom)?; - SignedBlockContents::::context_deserialize(&value, context) - .map(PublishBlockRequest::BlockContents) - .or_else(|_| { - Arc::>::context_deserialize(&value, context) - .map(PublishBlockRequest::Block) - }) - .map_err(|_| { - serde::de::Error::custom("could not match any variant of PublishBlockRequest") - }) + if context.gloas_enabled() { + Arc::>::context_deserialize(&value, context) + .map(PublishBlockRequest::Block) + } else { + SignedBlockContents::::context_deserialize(&value, context) + .map(PublishBlockRequest::BlockContents) + .or_else(|_| { + Arc::>::context_deserialize(&value, context) + .map(PublishBlockRequest::Block) + }) + .map_err(|_| { + serde::de::Error::custom("could not match any variant of PublishBlockRequest") + }) + } } } @@ -2496,7 +2503,7 @@ mod test { for fork_name in ForkName::list_all() { let signed_beacon_block = map_fork_name!(fork_name, SignedBeaconBlock, <_>::random_for_test(rng)); - let request = if fork_name.deneb_enabled() { + let request = if fork_name.deneb_enabled() && !fork_name.gloas_enabled() { let kzg_proofs = KzgProofs::::random_for_test(rng); let blobs = BlobsList::::random_for_test(rng); let block_contents = SignedBlockContents {