Skip to content

Conversation

@jclapis
Copy link
Collaborator

@jclapis jclapis commented Nov 11, 2025

This adds a bunch of improvements to the SSZ PR (#372), including:

  • Support for multiple ACCEPT types
  • Ability to translate from JSON (from the relay) to SSZ (to the client), for support like LH requires
  • Fixes from the comments / suggestions in the original PR

Still a draft until submit_block() is done.

@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?

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.

4 participants