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

feat: add response headers to produceBlockV3 #6228

Merged
merged 4 commits into from
Dec 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions packages/api/src/beacon/server/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ import {ServerRoutes, getGenericJsonServer} from "../../utils/server/index.js";
import {ServerApi} from "../../interfaces.js";

export function getRoutes(config: ChainForkConfig, api: ServerApi<Api>): ServerRoutes<Api, ReqTypes> {
// All routes return JSON, use a server auto-generator
return getGenericJsonServer<ServerApi<Api>, 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<ServerApi<Api>, 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);
Copy link
Member

Choose a reason for hiding this comment

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

Do we want set other headers here as well? My guess is that most should get those from the json body anyways though

Copy link
Contributor Author

@ensi321 ensi321 Dec 22, 2023

Choose a reason for hiding this comment

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

Do we want set other headers here as well? My guess is that most should get those from the json body anyways though

I was trying to ask sproul if he needs the other headers but it doesn't seem like he needs them.

I guess it's easy enough to add the other headers. It doesn't hurt to add them now so might as well

Copy link
Member

Choose a reason for hiding this comment

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

One optimization could be that you just look at the block value header and not even parse the body, might be what vouch is doing if it requests blocks from multiple bns

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);
},
},
};
}
Loading