Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SSZ request body for POST /beacon/blocks endpoints (v1 & v2) #4457

Closed
jimmygchen opened this issue Jul 3, 2023 · 4 comments
Closed
Labels

Comments

@jimmygchen
Copy link
Member

Description

The /eth/v1/beacon/blocks and /eth/v2/beacon/blocks beacon api endpoint supports both ssz and json bodies (spec here). However, Lighthouse only supports json. This can cause missed blocks when a non-lighthouse VC hits that api with a ssz payload. Moreover, we return a 500 error when we should be returning 415 (The supplied content-type is not supported).

There is a separate issue for blinded blocks endpoints in #4262

Version

stable

Steps to resolve

Add SSZ request body support, use the supplied Eth-Consensus-Version HTTP request header to decode the SSZ bytes.

@eserilev
Copy link
Collaborator

eserilev commented Jul 3, 2023

would adding ssz request body support for these endpoints look something like:

defining post routes where the Content-Type header matches application/octet-stream

in beacon_node/http_api/src/lib.rs starting around line 3879

let routes = warp::get()
.and( ... )
.boxed()
.uor(
    warp::post().and(
       warp::header::exact("Content-Type", "application/octet-stream").and(
           post_beacon_blocks
               .uor(post_beacon_blocks_v2_ssz)
               .uor(post_beacon_blocks_v1_ssz),
                ),
            ),
      )
.uor(...)

then parsing the request body as ssz and executing the post beacon block logic in the relevant 'route handler' i.e. in post_beacon_blocks_v2_ssz and post_beacon_blocks_v1_ssz

@jimmygchen
Copy link
Member Author

Hi @eserilev

I don't think we have any endpoint that supports SSZ request body yet, so I'm not exactly sure how it would look like, will probably need to look into the docs.

I think you got the idea though - we do need to define a separate route(s) for this. In your above example, I think the existing post_beacon_blocks json endpoint should probably be placed outside the application/octet-stream header matcher, otherwise it won't route the json requests to that handler. (I could be wrong though)

@eserilev
Copy link
Collaborator

eserilev commented Jul 7, 2023

great, I think i have a general understanding of this feature. I'd be happy to work on it

bors bot pushed a commit that referenced this issue Jul 31, 2023
#4479)

## Issue Addressed

[#4457](#4457)

## Proposed Changes

add ssz support in request body for  /beacon/blocks endpoints (v1 & v2)


## Additional Info
bors bot pushed a commit that referenced this issue Jul 31, 2023
#4479)

## Issue Addressed

[#4457](#4457)

## Proposed Changes

add ssz support in request body for  /beacon/blocks endpoints (v1 & v2)


## Additional Info
bors bot pushed a commit that referenced this issue Jul 31, 2023
#4479)

## Issue Addressed

[#4457](#4457)

## Proposed Changes

add ssz support in request body for  /beacon/blocks endpoints (v1 & v2)


## Additional Info
@jimmygchen
Copy link
Member Author

Completed in #4479 🎉 Thanks @eserilev

Woodpile37 pushed a commit to Woodpile37/lighthouse that referenced this issue Jan 6, 2024
sigp#4479)

[sigp#4457](sigp#4457)

add ssz support in request body for  /beacon/blocks endpoints (v1 & v2)
Woodpile37 pushed a commit to Woodpile37/lighthouse that referenced this issue Jan 6, 2024
sigp#4479)

[sigp#4457](sigp#4457)

add ssz support in request body for  /beacon/blocks endpoints (v1 & v2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants