Convert produceBlockV4 to POST and round-trip Eth-Builder-Url (Gloas builder API 4/5) - #9806
Conversation
|
This pull request is part of a Mergify stack:
|
c6cb1f0 to
0ad508e
Compare
Revision history
|
0ad508e to
1541fc9
Compare
1541fc9 to
b75cd14
Compare
b75cd14 to
d763878
Compare
d763878 to
510daa9
Compare
510daa9 to
9ffd62f
Compare
d6bc23f to
f979c15
Compare
f979c15 to
f9c9f6b
Compare
f9c9f6b to
275486f
Compare
chong-he
left a comment
There was a problem hiding this comment.
Looks good, just some nits. I also notice the comment (beacon-APIs #630) is mentioned too many times, would be good to clean them up
| // Accepts the `BuilderPreferenceEntry` list as either JSON or SSZ, selected by the request's | ||
| // `Content-Type` (`application/octet-stream` => SSZ, otherwise JSON). A required |
There was a problem hiding this comment.
Nit: comment like this maybe is not necessary?
There was a problem hiding this comment.
Yeah agree, this is a fairly common pattern.
| .and_then(|content_type: Option<String>, body: Bytes| async move { | ||
| let builder_config: BuilderConfig = if content_type.as_deref() | ||
| == Some(SSZ_CONTENT_TYPE_HEADER) | ||
| { | ||
| BuilderConfig::from_ssz_bytes(&body).map_err(|e| { | ||
| warp_utils::reject::custom_bad_request(format!("invalid SSZ: {e:?}")) | ||
| })? | ||
| } else { | ||
| serde_json::from_slice(&body).map_err(|e| { | ||
| warp_utils::reject::custom_deserialize_error(format!("{e:?}")) | ||
| })? | ||
| }; |
There was a problem hiding this comment.
Both endpoints in this PR combines the request body of JSON and SSZ into one funciton, which is fine. The default is still JSON because if the header is not specified as application/octet-stream, then it goes to the else branch.
Just want to point out that I see in Lighthouse code base it is usually separate the JSON and SSZ request body into 2 functions, for example:
pub fn post_validator_proposer_preferencesaccepts the JSON request bodypub fn post_validator_proposer_preferences_sszaccepts the SSZ request body
There was a problem hiding this comment.
Good point, but this is just one parameter in the post body.
I'm fine either way, I'll leave this to mark.
b659f44 to
d1b834f
Compare
d1b834f to
0e582da
Compare
pawanjay176
left a comment
There was a problem hiding this comment.
This also looks good to me. Just one question mainly
| warp::header::optional::<String>(CONTENT_TYPE_HEADER) | ||
| .and(warp::body::bytes()) | ||
| .and_then(|content_type: Option<String>, body: Bytes| async move { | ||
| let builder_config: BuilderConfig = if content_type.as_deref() |
There was a problem hiding this comment.
Isn't the builder_config optional?
| .and_then(|content_type: Option<String>, body: Bytes| async move { | ||
| let builder_config: BuilderConfig = if content_type.as_deref() | ||
| == Some(SSZ_CONTENT_TYPE_HEADER) | ||
| { | ||
| BuilderConfig::from_ssz_bytes(&body).map_err(|e| { | ||
| warp_utils::reject::custom_bad_request(format!("invalid SSZ: {e:?}")) | ||
| })? | ||
| } else { | ||
| serde_json::from_slice(&body).map_err(|e| { | ||
| warp_utils::reject::custom_deserialize_error(format!("{e:?}")) | ||
| })? | ||
| }; |
There was a problem hiding this comment.
Good point, but this is just one parameter in the post body.
I'm fine either way, I'll leave this to mark.
| // Accepts the `BuilderPreferenceEntry` list as either JSON or SSZ, selected by the request's | ||
| // `Content-Type` (`application/octet-stream` => SSZ, otherwise JSON). A required |
There was a problem hiding this comment.
Yeah agree, this is a fairly common pattern.
0e582da to
99bddcf
Compare
99bddcf to
f227c06
Compare
…builder API 4/5) Fourth PR of the Gloas builder API stack (beacon-APIs #630): - convert `/eth/v4/validator/blocks/{slot}` to POST with an optional `BuilderConfig` body (min_bid, builder_boost_factor, direct builders) - add `POST /eth/v1/validator/builder_preferences` for forwarding signed builder preferences - set `Eth-Builder-Url` on produceBlockV4 responses when a direct-builder bid wins, accept it on `POST /eth/v2/beacon/blocks`, and forward the signed block to that builder The validator client still uses the legacy GET methods at this point; it migrates in the final PR of this stack. Change-Id: I0ad30b8f36ad9b588ea1a0398220f92c9597bb95
f227c06 to
6359b33
Compare
Fourth PR of the Gloas builder API stack (beacon-APIs #630):
/eth/v4/validator/blocks/{slot}to POST with an optionalBuilderConfigbody (min_bid, builder_boost_factor, direct builders)POST /eth/v1/validator/builder_preferencesfor forwarding signedbuilder preferences
Eth-Builder-Urlon produceBlockV4 responses when a direct-builder bidwins, accept it on
POST /eth/v2/beacon/blocks, and forward the signedblock to that builder
The validator client still uses the legacy GET methods at this point; it
migrates in the final PR of this stack.
Depends-On: #9805