Skip to content

Conversation

@jclapis
Copy link
Collaborator

@jclapis jclapis commented Nov 11, 2025

This is an update to #372 which is now obsolete, and adds robust SSZ support to get_header() and submit_block():

  • Support for multiple ACCEPT types
  • Support for dynamically converting SSZ requests when the relay only supports JSON
  • Ability to translate transparently from the type returned by the relay back to the type requested by the client (e.g. SSZ (client request) -> JSON (relay request / response) -> SSZ (client response))

@jclapis jclapis self-assigned this Nov 11, 2025
@jclapis jclapis added the core Core part of the repo (signer, modules interface) label Nov 11, 2025
@jclapis jclapis marked this pull request as ready for review November 17, 2025 15:08
let mut original_headers = req_config.headers.clone();

// Check which types this request is for
let accept_types = get_accept_types(&req_config.headers).map_err(|e| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why repeat this every time we send a get_header?


// Send the header request
let mut start_request = Instant::now();
let config = RequestContext {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if we're just cloning the full RequestContext we should just do that as it's clearer

Ok((start_request_time, Some(get_header_response)))
}

async fn send_get_header_impl(
Copy link
Collaborator

Choose a reason for hiding this comment

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

think would be cleaner if we try to decode the header here?

// Get the content type; this is only really useful for OK responses, and
// doesn't handle encoding types besides SSZ and JSON
let mut content_type: Option<EncodingType> = None;
if res.status() == StatusCode::OK &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can check if this is false and early return an error

}
};
// Regenerate the header from the response
let get_header_response =
Copy link
Collaborator

Choose a reason for hiding this comment

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

in general i think we should be "forgiving" as much as possible, eg. if the header is missing we try to parse as json


// Check which types this request is for
let accept_types = get_accept_types(&req_config.headers).map_err(|e| {
PbsError::GeneralRequest(format!("error reading accept types: {e}").to_string())
Copy link
Collaborator

Choose a reason for hiding this comment

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

similar here, i think we can assume json if there's any issue

Ok(Some(block_response))
}

async fn send_submit_block_impl(
Copy link
Collaborator

Choose a reason for hiding this comment

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

similar here, i think we should move some of the logic here and only return a parsed block. So we submit and retry if there was an issue


// This won't actually fail since the string is a const
let content_type_header =
HeaderValue::from_str(EncodingType::Ssz.content_type()).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there a way we can make a const with this?

Comment on lines 52 to 53
let accepts_ssz = accept_types.contains(&EncodingType::Ssz);
let accepts_json = accept_types.contains(&EncodingType::Json);
Copy link
Collaborator

Choose a reason for hiding this comment

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

we make this check also in the call? can we avoid the duplication eg by passing a context?

@jclapis jclapis changed the base branch from add-ssz-to-pbs to main February 9, 2026 15:04
@jclapis jclapis changed the title Add improvements to SSZ support Add SSZ Support Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core part of the repo (signer, modules interface)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants