Skip to content

Add SSZ types, content negotiation, and encoding helpers#466

Open
JasonVranek wants to merge 5 commits into
mainfrom
pr/ssz-core
Open

Add SSZ types, content negotiation, and encoding helpers#466
JasonVranek wants to merge 5 commits into
mainfrom
pr/ssz-core

Conversation

@JasonVranek
Copy link
Copy Markdown
Collaborator

Summary

Introduces the types and helpers needed for SSZ support in the PBS pipeline. No behavior changes, just plumbing the follow-up PRs build on.

What's in this PR

  • EncodingType enum with FromStr/Display, including MIME parameter tolerance (RFC 7231 §3.1.1.1)
  • AcceptedEncodings with q-value-aware Accept header parsing (RFC 9110 §12.5.1)
  • Content-type and consensus-version header helpers
  • SSZ bid value extraction from SignedBuilderBid for all supported forks (Bellatrix through Fulu)
  • deserialize_body and parse_response_encoding_and_fork helpers
  • Per-fork type aliases for BuilderBid and ExecutionPayloadHeader
  • SszValueError, PbsError::GeneralRequest, PbsClientError::DecodeError/RelayError
  • New workspace deps: headers-accept, mediatype
  • Comprehensive unit tests for all new types and helpers

Review notes

Part 1 of 4: SSZ types → get_header → submit_block → validation bypassing

Attribution

This work builds on the SSZ builder flow originally implemented by @eserilev
in #252 and ported to the current codebase by @jclapis in #403.

Co-authored-by: Eitan Seri-Levi eserilev@ucsc.edu
Co-authored-by: Joe Clapis jclapis@outlook.com

Introduce EncodingType, AcceptedEncodings, and content negotiation
primitives for SSZ support in the PBS pipeline. Includes:

- EncodingType enum with FromStr/Display and MIME param tolerance
- AcceptedEncodings with q-value aware Accept header parsing
- SSZ bid value extraction from SignedBuilderBid by fork
- deserialize_body and parse_response_encoding_and_fork helpers
- Per-fork type aliases for BuilderBid and ExecutionPayloadHeader
- SszValueError, PbsError::GeneralRequest, PbsClientError variants
- Comprehensive unit tests for all new types and helpers
- New deps: headers-accept, mediatype
@JasonVranek JasonVranek requested a review from a team May 20, 2026 00:04
Comment thread crates/common/src/utils.rs Outdated
Comment thread crates/common/src/utils.rs Outdated
Comment thread crates/common/src/utils.rs Outdated
Comment thread crates/common/src/utils.rs Outdated
Comment thread crates/common/src/utils.rs Outdated
Comment thread crates/pbs/src/error.rs Outdated
Comment thread crates/common/src/pbs/error.rs Outdated
Comment thread crates/common/src/utils.rs Outdated
Comment thread crates/common/src/utils.rs Outdated
Comment thread crates/common/src/utils.rs Outdated
Comment thread crates/common/src/pbs/error.rs Outdated
Comment thread crates/common/src/pbs/types/mod.rs Outdated
Comment thread crates/common/src/pbs/types/mod.rs
Comment thread crates/common/src/utils.rs
Comment thread crates/common/src/utils.rs Outdated
Comment thread crates/common/src/utils.rs Outdated
Comment thread crates/pbs/src/error.rs Outdated
Comment thread crates/common/src/pbs/error.rs Outdated
Comment thread crates/common/src/ssz.rs

/// Test that SSZ encoding and decoding round-trips, returning the decoded
/// struct.
pub fn test_encode_decode_ssz<T: Encode + Decode>(d: &[u8]) -> T {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this used? is this an actual test and should be in mod test then?

Comment thread crates/common/src/wire.rs
#[error(
"response size exceeds max size; max: {max}, content_length: {content_length}, raw: {raw}"
)]
PayloadTooLarge { max: usize, content_length: usize, raw: String },
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do we need the raw field here? could we provide some identifier instead maybe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants