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 rest api endpoints for external applications #51

Merged
merged 55 commits into from
Sep 14, 2023
Merged

Conversation

TobiWo
Copy link
Owner

@TobiWo TobiWo commented Jun 22, 2023

Summary

This PR includes the following features/updates:

  • Add a localhost rest server with endpoints for fetching upcoming duties and adding/deleting new validator identifiers (indices or pubkeys)
    • Swagger spec can be reached via localhost:<port>/docs
    • Note on validator endpoints:
      • If the user only provide bad formatted indices or pubkeys the response will be a 400
      • As long as one index or pubkey is correct the endpoint will return a 201 (POST) or 200 (DELETE) with the added/deleted identifiers as response
      • Relevant for POST: Indices/Pubkeys which are already present will be overwritten and therefore returned in the response
      • Relevant for DELETE: Indices/Pubkeys which were already deleted will not cause an error and will be returned in the response
      • The rationale behind this is that the target state for the user is to delete or add certain indices/pubkeys. Therefore it doesn't matter whether the index/pubkey was already present or not
      • This behavior might be changed in the future
  • Add time_to_duty property to ValidatorDuty object which is used for:
    • rest response objects so that the user can implement it's own logic on top of it
    • log concrete time values for sync committee duties
  • Add validation of provided beacon node url
  • Fix a bug where upcoming duties did not get updated (fetching new data from beacon client) while sync-committee duty ended
  • Add better handling of bad formatted indices/pubkeys
  • Code refactoring

Note

Documentation will be updated in a separate PR since the next release will include multiple PRs

@TobiWo TobiWo force-pushed the feature/add-rest-api branch 2 times, most recently from a6f821d to 95d5a95 Compare July 6, 2023 08:01
* Refactor global constants to global variables
* Refactor method to use global variable
* Use root logger
* Add methods to update validator identifiers from rest calls
@TobiWo TobiWo force-pushed the feature/add-rest-api branch 2 times, most recently from ca5b295 to ddf7c8a Compare July 20, 2023 13:25
@TobiWo TobiWo linked an issue Jul 20, 2023 that may be closed by this pull request
@TobiWo TobiWo self-assigned this Aug 3, 2023
@TobiWo TobiWo requested a review from LuisNaldo7 August 3, 2023 11:12
* Add beacon node url parsing method
* Rename existing parsing method
@TobiWo TobiWo marked this pull request as ready for review August 3, 2023 11:28
@TobiWo TobiWo marked this pull request as draft August 3, 2023 15:25
* Add port check before starting the server
* Add check if server has started
* Add function to start correct processes
* Add clean server shutdown
* Delete unnecessary wrong character message due to code optimization
* Add new message for skipped identifiers
* Add new message for modified identifiers via rest
* Delete not allowed characters due to code optimizations
* Delete check for unsupported characters
* Delete system exits while bad pubkey is provided
* Add check for bad formatted validator index
* Add logging if identifier is skipped due to bad format
* Return empty identifier object while provided identifier could not be parsed
* Add return object for bad request
* Delete None as return value
* Add filter to filter for empty validator identifiers as returned from parsing process
* Add 400 as documented response
@TobiWo TobiWo marked this pull request as ready for review August 29, 2023 09:08
@TobiWo TobiWo merged commit 6bcd4a1 into main Sep 14, 2023
@TobiWo TobiWo deleted the feature/add-rest-api branch September 14, 2023 14:26
@TobiWo TobiWo mentioned this pull request Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants