Skip to content

Conversation

@mablr
Copy link
Contributor

@mablr mablr commented Nov 19, 2025

Motivation

Close #12610

Solution

  • Support "application/octet-stream" and "application/json" content types
  • Implemented must_be_ssz helper to determine if the Accept header prefers SSZ encoding.
  • Updated handle_get_blobs to return SSZ-encoded blobs when requested.
  • Enhanced tests to verify both JSON and SSZ responses for blob sidecars.
  • Added accept header assertions in tests to ensure correct content type selection.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

- Support "application/octet-stream" and "application/json" content types
- Implemented `must_be_ssz` helper to determine if the Accept header prefers SSZ encoding.
- Updated `handle_get_blobs` to return SSZ-encoded blobs when requested.
- Enhanced tests to verify both JSON and SSZ responses for blob sidecars.
- Added accept header assertions in tests to ensure correct content type selection.
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

@mattsse mattsse added this pull request to the merge queue Nov 19, 2025
Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

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

thank you, lgtm, left couple of comments


/// Helper function to determine if the Accept header indicates a preference for SSZ (octet-stream)
/// over JSON.
pub fn must_be_ssz(headers: &HeaderMap) -> bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: shouldn't be public

Copy link
Contributor Author

@mablr mablr Nov 19, 2025

Choose a reason for hiding this comment

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

This was merged too fast 😅

I may fix it as a follow-up. Btw Anvil's server module can be split/reorganized for clarity:

  • crates/anvil/src/server/mod.rs
  • crates/anvil/src/server/beacon/
  • crates/anvil/src/server/rpc/

I can wrap it all in one PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

thank you! yeah not a prio, can include in future PR

let mut json_q = 0.0;

// Parse each media type in the Accept header
for media_type in accept_str.split(',') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we worry if same media type present multiple times? (I think that's technically allowed) - probably not an issue as we'll consider the last one

Merged via the queue into foundry-rs:master with commit 3ba035f Nov 19, 2025
15 checks passed
@github-project-automation github-project-automation bot moved this to Done in Foundry Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add support for SSZ encoding in Anvil's Beacon API

3 participants