Skip to content

Commit

Permalink
fix: fix the publish blinded block api parsing for optional header ve…
Browse files Browse the repository at this point in the history
…rison (#6966)
  • Loading branch information
g11tech authored and philknows committed Jul 19, 2024
1 parent 01fde12 commit fb6bef8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/api/src/beacon/routes/beacon/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,16 @@ export function getDefinitions(config: ChainForkConfig): RouteDefinitions<Endpoi
};
},
parseReqJson: ({body, headers}) => {
const fork = toForkName(fromHeaders(headers, MetaHeader.Version));
let fork: ForkName;
// As per spec, version header is optional for JSON requests
const versionHeader = fromHeaders(headers, MetaHeader.Version, false);
if (versionHeader !== undefined) {
fork = toForkName(versionHeader);
} else {
// Determine fork from slot in JSON payload
fork = config.getForkName((body as SignedBlindedBeaconBlock).message.slot);
}

return {
signedBlindedBlock: getExecutionForkTypes(fork).SignedBlindedBeaconBlock.fromJson(body),
};
Expand Down

0 comments on commit fb6bef8

Please sign in to comment.