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

First RESTful HTTP API #399

Merged
merged 32 commits into from
Jul 31, 2019
Merged

First RESTful HTTP API #399

merged 32 commits into from
Jul 31, 2019

Conversation

spble
Copy link
Contributor

@spble spble commented Jun 18, 2019

Background Info

As discussed in ethereum/consensus-specs#1011 and ethereum/consensus-specs#1012, and formalised in PR ethereum/consensus-specs#1069, we are changing the gRPC interface between the validator client and beacon node to be a simple HTTP REST interface.

This PR brings the first iteration of the RESTful API to Lighthouse

Proposed Changes

This PR includes a new crate called rest_api, which implements all of the API functionality.
It also introduces three new flags, which can be used to enable the API:
--api --api-address 127.0.0.1 --api-port 12345

This is the first iteration of the API, but only includes some simple endpoints to demonstrate the fundamental REST server and integration with stateful information in Lighthouse. the full API implementation is pending.

 - Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
 - Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
@spble spble added task Task to be completed work-in-progress PR is a work-in-progress val-client Relates to the validator client binary labels Jun 18, 2019
 - Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
 - Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
 - Started adding the rest_api into the beacon node's dependencies.
 - Set up configuration file for rest_api and integrated into main client config
 - Added CLI flags for REST API.
 - Adding the dependencies to rest_api crate
 - Created a skeleton BeaconNodeService, which will handle /node requests.
 - Started the rest_api server definition, with the high level request handling logic.
@paulhauner paulhauner added this to the v0.0.1 milestone Jun 25, 2019
spble added 12 commits July 12, 2019 15:37
 - Created a new crate rest_api, which will adapt the openapi generated code to Lighthouse
 - Committed automatically generated code from openapi-generator-cli (via docker). Should hopfully not have to modify this at all, and do all changes in the rest_api crate.
 - Started adding the rest_api into the beacon node's dependencies.
 - Set up configuration file for rest_api and integrated into main client config
 - Added CLI flags for REST API.
 - Adding the dependencies to rest_api crate
 - Created a skeleton BeaconNodeService, which will handle /node requests.
 - Started the rest_api server definition, with the high level request handling logic.
 - Changed CLI flags from rest-api* to api*
 - Fixed port cli flag
 - Tested, works over HTTP
 - Started writing a macro for getting the handler functions.
 - Added the BeaconChain into the type map, gives stateful access to the beacon state.
 - Created new generic error types (haven't figured out yet), to reduce code duplication.
 - Moved common stuff into lib.rs
 - did more logging when creating HTTP responses
 - Tried moving stuff into macros, but can't get macros in macros to compile.
 - Pulled out a lot of placeholder code.
@paulhauner paulhauner removed the ready-for-review The code is ready for review label Jul 26, 2019
@spble spble added the ready-for-review The code is ready for review label Jul 26, 2019
Copy link
Member

@paulhauner paulhauner left a comment

Choose a reason for hiding this comment

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

Hey man, looks good! Just a few minor comments.

Keen to get this merged!

beacon_node/rest_api/src/beacon_node.rs Outdated Show resolved Hide resolved
beacon_node/rest_api/src/beacon_node.rs Outdated Show resolved Hide resolved
beacon_node/rest_api/src/lib.rs Outdated Show resolved Hide resolved
beacon_node/rest_api/src/lib.rs Outdated Show resolved Hide resolved
beacon_node/rest_api/src/macros.rs Outdated Show resolved Hide resolved
beacon_node/rest_api/src/beacon_node.rs Outdated Show resolved Hide resolved
 - Fixed spelling mistake
 - Moved the simple macros into functions, since it doesn't make sense for them to be macros.
 - Removed redundant code & inclusions.
@paulhauner paulhauner added under-review A reviewer has only partially completed a review. waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review under-review A reviewer has only partially completed a review. labels Jul 29, 2019
@paulhauner paulhauner self-assigned this Jul 30, 2019
@spble spble added ready-for-review The code is ready for review bug Something isn't working waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. ready-for-review The code is ready for review labels Jul 30, 2019
@spble
Copy link
Contributor Author

spble commented Jul 30, 2019

Actually, there is something happening that prevents beacon_node from exiting after a state-read API call is made. It blocks until a subsequent call is made, sounds like the Tokio thing @AgeManning was talking about the other day.

@paulhauner paulhauner removed the bug Something isn't working label Jul 31, 2019
@paulhauner
Copy link
Member

My preference is to ditch the graceful shutdown for now and create an issue so we can pick it up later.

I need to do some updates to our metrics and I'd like to start doing them using this HTTP server.

@spble
Copy link
Contributor Author

spble commented Jul 31, 2019

So I have tried to resolve this shutdown issue, but without much avail. I have created issue #478 to cover this.
Apart from that, this PR should be ready to land.

@spble spble added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Jul 31, 2019
@paulhauner paulhauner merged commit 0052ea7 into master Jul 31, 2019
@paulhauner paulhauner deleted the rest-val-api branch September 2, 2019 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-review The code is ready for review task Task to be completed val-client Relates to the validator client binary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants