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

HTTP endpoint for GetChainHead #14262

Merged
merged 5 commits into from
Aug 5, 2024
Merged

HTTP endpoint for GetChainHead #14262

merged 5 commits into from
Aug 5, 2024

Conversation

saolyn
Copy link
Contributor

@saolyn saolyn commented Jul 25, 2024

What type of PR is this?

Other

What does this PR do? Why is it needed?

Adding the HTTP endpoint for GetChainHead.

Which issues(s) does this PR fix?

N/A

Other notes for review

@saolyn saolyn requested a review from rkapka July 25, 2024 16:10
@saolyn saolyn requested a review from a team as a code owner July 25, 2024 16:10
template: "/prysm/v1/beacon/chain_head",
name: namespace + ".GetChainHead",
middleware: []mux.MiddlewareFunc{
middleware.ContentTypeHandler([]string{api.JsonMediaType}),
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need the content type handler for get requests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, it's a copy paste error

Reason: Internal,
}
}
if err := consensusblocks.BeaconBlockIsNil(headBlock); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

It might make more sense to move this before the optimistic check

response := &structs.ChainHead{
HeadSlot: fmt.Sprintf("%d", ch.HeadSlot),
HeadEpoch: fmt.Sprintf("%d", ch.HeadEpoch),
HeadBlockRoot: fmt.Sprintf("%#x", ch.HeadBlockRoot),
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe use hexutil.Encode for consistency with other root fields

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep missed that one, ty


s.GetChainHead(writer, request)
require.Equal(t, http.StatusOK, writer.Code)
// require.StringContains(t, "could not get genesis block", writer.Body.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

comment

@saolyn saolyn added this pull request to the merge queue Aug 5, 2024
Merged via the queue into develop with commit fb26203 Aug 5, 2024
16 of 17 checks passed
@saolyn saolyn deleted the http-chain-head branch August 5, 2024 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants