-
-
Notifications
You must be signed in to change notification settings - Fork 325
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
Update API response object #4994
Conversation
Performance Report✔️ no performance regression detected Full benchmark results
|
This API is very strange, there must be another way such that routes do not have to expose the status code publishBlock(block: allForks.SignedBeaconBlock): Promise<HttpStatusCode>; |
eccb215
to
923137f
Compare
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.
the approach generally looks good to me.
looking for more discussion about the ErrorAsResponse feature
|
||
/** | ||
* REST HTTP client for lightclient routes | ||
*/ | ||
export function getClient(_config: IChainForkConfig, httpClient: IHttpClient): Api { | ||
export function getClient<ErrorAsResponse extends boolean = false>( |
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.
Can you document the behavior of ErrorAsResponse somewhere?
Seems that depending on the option passed, you can make errors either throw or return.
Do we need both behaviors? Might be simpler to pick a convention (ie always return) and stick with it.
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.
@wemeetagain My preference is to use always return
case. But to avoid backward compatibility, I made it optional for now. If we all agree to one approach we can stick to it.
…nto nh/4993-node-health
@@ -11,8 +11,10 @@ Typescript REST client for the [Ethereum Consensus API spec](https://github.com/ | |||
|
|||
## Usage | |||
|
|||
We use more typesafe approach for the API client, where all the errors are returned not thrown. This approach is more easy to document and better to handle all possible error cases. |
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.
Maybe also reference the similarity to the Response
type.
// For `getState()` generate request serializer | ||
const fetchOptsSerializers = getFetchOptsSerializers<Api, ReqTypes>(routesData, reqSerializers); | ||
|
||
return { | ||
...client, | ||
|
||
// TODO: Debug the type issue |
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.
Can you also think about how we would be able to incorporate this? ethereum/beacon-APIs#250
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.
We already have support for SZZ encoding for few endpoints, similarly we can support for others when required.
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 beacon-apis PR is about systematically supporting SSZ for all endpoints, not just supporting one-by-one.
Edit: I'm not suggesting to tackle this in this PR, just more an FYI of possible improvement that will be desired.
* Hypertext Transfer Protocol (HTTP) response status codes. | ||
* @see {@link https://www.rfc-editor.org/rfc/rfc7231#section-6} | ||
*/ | ||
export enum HttpStatusCode { |
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.
Who is using all these protocols? What's the point of declaring this?
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.
To create types for the API which is completely matching the specification.
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.
I mean just declare the codes actually used, not every single code out there
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.
Please note this will introduce a breaking change where we don't want to just have to bump the version of the monorepo to 2.0.0 for this.
Do we need to change the monorepo to 2.0 for this? We should consider:
|
@dapplion @wemeetagain I think we consider from a product mindset. This is not a breaking change for the Lodestar users. Where as it concerns for |
Motivation
Make the
/eth/v1/node/health
compliance with the spec.Description
Read/Write the http status code for the node health.
Closes #4993
Steps to test or reproduce
Run all tests.