-
-
Notifications
You must be signed in to change notification settings - Fork 312
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: properly consider Eth-Consensus-Version header #6582
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## unstable #6582 +/- ##
============================================
+ Coverage 61.49% 61.50% +0.01%
============================================
Files 556 556
Lines 58895 58917 +22
Branches 1856 1857 +1
============================================
+ Hits 36216 36236 +20
- Misses 22638 22640 +2
Partials 41 41 |
Performance Report✔️ no performance regression detected 🚀🚀 Significant benchmark improvement detected
Full benchmark results
|
publishBlockV2: { | ||
body: unknown; | ||
query: {broadcast_validation?: string}; | ||
headers: {"eth-consensus-version"?: ForkName}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can't be sure this is a valid ForkName here, as I think we shouldn't be modifying the server side in this PR it doesn't matter much but it is safer to handle this as string as header value needs to be validated first
headers: {"eth-consensus-version"?: ForkName}; | |
headers: {"eth-consensus-version"?: string}; |
@@ -187,7 +187,7 @@ export type Api = { | |||
|
|||
publishBlockV2( | |||
blockOrContents: allForks.SignedBeaconBlockOrContents, | |||
opts?: {broadcastValidation?: BroadcastValidation} | |||
opts?: {broadcastValidation?: BroadcastValidation; version?: ForkName} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
relying on consumer to provide this is not correct, this is mandatory and should be handled internally by the API client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR does not address the actual problem noted in #6580 that we are not setting the header when sending the request.
As noted in #6580 (comment) I don't think it is worth it to change the behavior on the server at all, current approach works and it compatible with all clients. Would prefer to keep this PR minimal to avoid regressions and cause less conflicts on refactor branch.
Header is still missing
{
host: '127.0.0.1:9596',
connection: 'keep-alive',
'content-type': 'application/json',
accept: '*/*',
'accept-language': '*',
'sec-fetch-mode': 'cors',
'user-agent': 'node',
'accept-encoding': 'gzip, deflate',
'content-length': '1022'
}
body: createAllForksSignedBlockOrContents(version).toJson(item), | ||
query: {broadcast_validation: broadcastValidation}, | ||
}; | ||
const headers = version !== undefined ? {"eth-consensus-version": version} : {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version header must be set as per spec, see how this is handled in the refactored api client
lodestar/packages/api/src/beacon/routes/beacon/block.ts
Lines 357 to 370 in c3afb0b
writeReqJson: ({signedBlockOrContents, broadcastValidation}) => { | |
const slot = isSignedBlockContents(signedBlockOrContents) | |
? signedBlockOrContents.signedBlock.message.slot | |
: signedBlockOrContents.message.slot; | |
return { | |
body: | |
config.getForkSeq(slot) < ForkSeq.deneb | |
? config | |
.getForkTypes(slot) | |
.SignedBeaconBlock.toJson(signedBlockOrContents as allForks.SignedBeaconBlock) | |
: SignedBlockContentsType.toJson(signedBlockOrContents as SignedBlockContents), | |
headers: { | |
"Eth-Consensus-Version": config.getForkName(slot), | |
}, |
Superseded by #6593 |
Motivation
Follow the beacon-APIs specs.
Description
Get the consensus version of submitted block from the
Eth-Consensus-Version
header value. Falls back to current behavior (extract from the submitted block payload) if not submitted.Test by executing the following command, with
block.json
containing the appropriate block data:Fixes #6580