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

fix: set Eth-Consensus-Version header in publish block requests #6593

Merged
merged 3 commits into from
Mar 27, 2024
Merged
Changes from 2 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
8 changes: 8 additions & 0 deletions packages/api/src/beacon/routes/beacon/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,12 @@ export function getReqSerializers(config: ChainForkConfig): ReqSerializers<Api,
fromJson: (data) => getSignedBlindedBeaconBlockType(data as allForks.SignedBlindedBeaconBlock).fromJson(data),
};

function extractSlot(signedBlockOrContents: allForks.SignedBeaconBlockOrContents): Slot {
return isSignedBlockContents(signedBlockOrContents)
jeluard marked this conversation as resolved.
Show resolved Hide resolved
? signedBlockOrContents.signedBlock.message.slot
: signedBlockOrContents.message.slot;
}

return {
getBlock: getBlockReq,
getBlockV2: getBlockReq,
Expand All @@ -335,6 +341,7 @@ export function getReqSerializers(config: ChainForkConfig): ReqSerializers<Api,
writeReq: (item, {broadcastValidation} = {}) => ({
body: AllForksSignedBlockOrContents.toJson(item),
query: {broadcast_validation: broadcastValidation},
headers: {"Eth-Consensus-Version": config.getForkName(extractSlot(item))},
Copy link
Member

Choose a reason for hiding this comment

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

nit: I would probably just inline the logic here, avoids jumping in multiple functions if you wanna review the code but doesn't matter much for this change

}),
parseReq: ({body, query}) => [
AllForksSignedBlockOrContents.fromJson(body),
Expand All @@ -350,6 +357,7 @@ export function getReqSerializers(config: ChainForkConfig): ReqSerializers<Api,
writeReq: (item, {broadcastValidation}) => ({
body: AllForksSignedBlindedBlock.toJson(item),
query: {broadcast_validation: broadcastValidation},
headers: {"Eth-Consensus-Version": config.getForkName(extractSlot(item))},
}),
parseReq: ({body, query}) => [
AllForksSignedBlindedBlock.fromJson(body),
Expand Down
Loading