diff --git a/packages/api/src/beacon/server/validator.ts b/packages/api/src/beacon/server/validator.ts index 6bf446e05a16..5d6c22557060 100644 --- a/packages/api/src/beacon/server/validator.ts +++ b/packages/api/src/beacon/server/validator.ts @@ -4,6 +4,28 @@ import {ServerRoutes, getGenericJsonServer} from "../../utils/server/index.js"; import {ServerApi} from "../../interfaces.js"; export function getRoutes(config: ChainForkConfig, api: ServerApi): ServerRoutes { - // All routes return JSON, use a server auto-generator - return getGenericJsonServer, ReqTypes>({routesData, getReturnTypes, getReqSerializers}, config, api); + const reqSerializers = getReqSerializers(); + const returnTypes = getReturnTypes(); + + // Most of routes return JSON, use a server auto-generator + const serverRoutes = getGenericJsonServer, ReqTypes>( + {routesData, getReturnTypes, getReqSerializers}, + config, + api + ); + return { + ...serverRoutes, + produceBlockV3: { + ...serverRoutes.produceBlockV3, + handler: async (req, res) => { + const response = await api.produceBlockV3(...reqSerializers.produceBlockV3.parseReq(req)); + void res.header("Eth-Consensus-Version", response.version); + void res.header("Eth-Execution-Payload-Blinded", response.executionPayloadBlinded); + void res.header("Eth-Execution-Payload-Value", response.executionPayloadValue); + void res.header("Eth-Consensus-Block-Value", response.consensusBlockValue); + + return returnTypes.produceBlockV3.toJson(response); + }, + }, + }; }