chore: remove builder_index from produce_block_v4 (#9267)

Part of #8828 for the stateful path and helps align gloas `produceBlockV4` with beacon-APIs [PR](https://github.com/ethereum/beacon-APIs/pull/580)


  - Plumb `include_payload` query through the handler. Ignored for now since stateless mode isn't wired up yet
- Add `execution_payload_included` metadata field + `Eth-Execution-Payload-Included` header per spec. Both `false` until stateless lands
- Drop the `{builder_index}` segment from the envelope GET URL since no longer included in spec


Co-Authored-By: shane-moore <skm1790@gmail.com>

Co-Authored-By: Eitan Seri-Levi <eserilev@ucsc.edu>
This commit is contained in:
Shane K Moore
2026-05-11 08:27:41 -07:00
committed by GitHub
parent 1b921a64e6
commit 2208e17937
7 changed files with 76 additions and 36 deletions

View File

@@ -2,8 +2,9 @@ use crate::{
build_block_contents,
version::{
ResponseIncludesVersion, add_consensus_block_value_header, add_consensus_version_header,
add_execution_payload_blinded_header, add_execution_payload_value_header,
add_ssz_content_type_header, beacon_response, inconsistent_fork_rejection,
add_execution_payload_blinded_header, add_execution_payload_included_header,
add_execution_payload_value_header, add_ssz_content_type_header, beacon_response,
inconsistent_fork_rejection,
},
};
use beacon_chain::graffiti_calculator::GraffitiSettings;
@@ -83,7 +84,16 @@ pub async fn produce_block_v4<T: BeaconChainTypes>(
warp_utils::reject::custom_bad_request(format!("failed to fetch a block: {:?}", e))
})?;
build_response_v4::<T>(block, consensus_block_value, accept_header, &chain.spec)
// TODO(gloas): wire up for stateless mode (#8828).
let execution_payload_included = false;
build_response_v4::<T>(
block,
consensus_block_value,
execution_payload_included,
accept_header,
&chain.spec,
)
}
#[instrument(
@@ -133,6 +143,7 @@ pub async fn produce_block_v3<T: BeaconChainTypes>(
pub fn build_response_v4<T: BeaconChainTypes>(
block: BeaconBlock<T::EthSpec, FullPayload<T::EthSpec>>,
consensus_block_value: u64,
execution_payload_included: bool,
accept_header: Option<api_types::Accept>,
spec: &ChainSpec,
) -> Result<Response<Body>, warp::Rejection> {
@@ -146,6 +157,7 @@ pub fn build_response_v4<T: BeaconChainTypes>(
let metadata = ProduceBlockV4Metadata {
consensus_version: fork_name,
consensus_block_value: consensus_block_value_wei,
execution_payload_included,
};
match accept_header {
@@ -155,6 +167,7 @@ pub fn build_response_v4<T: BeaconChainTypes>(
.map(|res: Response<Body>| add_ssz_content_type_header(res))
.map(|res: Response<Body>| add_consensus_version_header(res, fork_name))
.map(|res| add_consensus_block_value_header(res, consensus_block_value_wei))
.map(|res| add_execution_payload_included_header(res, execution_payload_included))
.map_err(|e| -> warp::Rejection {
warp_utils::reject::custom_server_error(format!("failed to create response: {}", e))
}),
@@ -165,7 +178,8 @@ pub fn build_response_v4<T: BeaconChainTypes>(
})
.into_response())
.map(|res| add_consensus_version_header(res, fork_name))
.map(|res| add_consensus_block_value_header(res, consensus_block_value_wei)),
.map(|res| add_consensus_block_value_header(res, consensus_block_value_wei))
.map(|res| add_execution_payload_included_header(res, execution_payload_included)),
}
}

View File

@@ -12,7 +12,7 @@ use types::Slot;
use warp::http::Response;
use warp::{Filter, Rejection};
// GET validator/execution_payload_envelope/{slot}/{builder_index}
// GET validator/execution_payload_envelope/{slot}
pub fn get_validator_execution_payload_envelope<T: BeaconChainTypes>(
eth_v1: EthV1Filter,
chain_filter: ChainFilter<T>,
@@ -27,11 +27,6 @@ pub fn get_validator_execution_payload_envelope<T: BeaconChainTypes>(
"Invalid slot".to_string(),
))
}))
.and(warp::path::param::<u64>().or_else(|_| async {
Err(warp_utils::reject::custom_bad_request(
"Invalid builder_index".to_string(),
))
}))
.and(warp::path::end())
.and(warp::header::optional::<Accept>("accept"))
.and(not_while_syncing_filter)
@@ -39,10 +34,6 @@ pub fn get_validator_execution_payload_envelope<T: BeaconChainTypes>(
.and(chain_filter)
.then(
|slot: Slot,
// TODO(gloas) we're only doing local building
// we'll need to implement builder index logic
// eventually.
_builder_index: u64,
accept_header: Option<Accept>,
not_synced_filter: Result<(), Rejection>,
task_spawner: TaskSpawner<T::EthSpec>,

View File

@@ -5,7 +5,8 @@ use eth2::beacon_response::{
};
use eth2::{
CONSENSUS_BLOCK_VALUE_HEADER, CONSENSUS_VERSION_HEADER, CONTENT_TYPE_HEADER,
EXECUTION_PAYLOAD_BLINDED_HEADER, EXECUTION_PAYLOAD_VALUE_HEADER, SSZ_CONTENT_TYPE_HEADER,
EXECUTION_PAYLOAD_BLINDED_HEADER, EXECUTION_PAYLOAD_INCLUDED_HEADER,
EXECUTION_PAYLOAD_VALUE_HEADER, SSZ_CONTENT_TYPE_HEADER,
};
use serde::Serialize;
use types::{ForkName, InconsistentFork, Uint256};
@@ -88,6 +89,19 @@ pub fn add_execution_payload_blinded_header<T: Reply>(
.into_response()
}
/// Add the `Eth-Execution-Payload-Included` header to a response.
pub fn add_execution_payload_included_header<T: Reply>(
reply: T,
execution_payload_included: bool,
) -> Response {
reply::with_header(
reply,
EXECUTION_PAYLOAD_INCLUDED_HEADER,
execution_payload_included.to_string(),
)
.into_response()
}
/// Add the `Eth-Execution-Payload-Value` header to a response.
pub fn add_execution_payload_value_header<T: Reply>(
reply: T,