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

Add syncing_status query parameter to health API #5702

Closed
nflaig opened this issue Jun 24, 2023 · 9 comments · Fixed by #5790
Closed

Add syncing_status query parameter to health API #5702

nflaig opened this issue Jun 24, 2023 · 9 comments · Fixed by #5790
Labels
good first issue Issues that are suitable for first-time contributors. help wanted The author indicates that additional help is wanted. meta-feature-request Issues to track feature requests.

Comments

@nflaig
Copy link
Member

nflaig commented Jun 24, 2023

Problem description

Latest beacon API spec requires syncing_status query parameter

Solution description

Add syncing_status query parameter to health API

Additional context

No response

@nflaig nflaig added the meta-feature-request Issues to track feature requests. label Jun 24, 2023
@nflaig nflaig added good first issue Issues that are suitable for first-time contributors. help wanted The author indicates that additional help is wanted. labels Jun 26, 2023
@allwin199
Copy link

I would like to work on this if it is still open.

@allwin199
Copy link

allwin199 commented Jul 15, 2023

Can you give more info about this issue?

@nflaig
Copy link
Member Author

nflaig commented Jul 15, 2023

You can find more information in the spec PR ethereum/beacon-APIs#251 and this issue ethereum/beacon-APIs#147.

This requires to update the api definition here

getHealth: {url: "/eth/v1/node/health", method: "GET"},

and further changes on beacon node side

async getHealth(_req, res) {

handler: async (req, res) => {

Best to check other routes that use query parameters and see how it is implemented there.

You can find more about the reasoning how the API routes are defined here

// Reasoning of the API definitions
// ================================
//

The validator client won't use this feature, so no changes required there.

@allwin199
Copy link

Thanks for the explanation! Will work on it.

@allwin199
Copy link

I tried fixing this issue, but I am unable to fix it.

If someone fixes this issue, I will learn from it.

Thanks for the opportunity.

@nflaig
Copy link
Member Author

nflaig commented Jul 16, 2023

I tried fixing this issue, but I am unable to fix it.

All good, thanks for giving it a try.

It would be great if you could provide some feedback

  • what were the obstacles you faced when trying to solve this?
  • and is there anything we could do to make it easier to contribute?

@allwin199
Copy link

To fix the issue, I changed below lines

export type ReqTypes = {
   getHealth: {query: {syncing_status?: boolean}};
}
export function getReqSerializers = {
  getHealth: {
      writeReq: (syncing_status) => ({query: syncing_status || {}}),
      parseReq: ({query}) => [query],
      schema: {query: {syncing_status: Schema.Boolean}},
    },
}

Is the flow correct? I have also added type boolean in Schema.ts

If the flow is correct,
In the getReqSerializers(), I don't understand this parseReq part.
This is where I am stuck.

@nflaig
Copy link
Member Author

nflaig commented Jul 23, 2023

Is the flow correct? I have also added type boolean in Schema.ts

First you need to update the types, this makes it easier to update all the other parts. syncing_status is an optional integer value not a boolean so the schema needs to be Schema.Uint.

In the getReqSerializers(), I don't understand this parseReq part.

That just parses the incoming request to the right format expected in the code.

getHealth: {
writeReq: (options) => ({query: {syncing_status: options?.syncingStatus}}),
parseReq: ({query}) => [{syncingStatus: query.syncing_status}],
schema: {query: {syncing_status: Schema.Uint}},
},

I found an issue with the current implementation, it always returned 200 even if node is syncing, this made the task also not that great for someone new to codebase.

I opened a PR #5790 to implement the new query parameter and fix the issue. @worksofallwin Feel free to give this a review and ask questions if something is unclear.

@allwin199
Copy link

@nflaig Thanks for the reply. I will go through and I will post If I don't understand anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues that are suitable for first-time contributors. help wanted The author indicates that additional help is wanted. meta-feature-request Issues to track feature requests.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants