Skip to content

POST version of GetValidators and GetValidatorBalances#13199

Merged
prylabs-bulldozer[bot] merged 7 commits intodevelopfrom
state-validators-post
Nov 22, 2023
Merged

POST version of GetValidators and GetValidatorBalances#13199
prylabs-bulldozer[bot] merged 7 commits intodevelopfrom
state-validators-post

Conversation

@rkapka
Copy link
Copy Markdown
Contributor

@rkapka rkapka commented Nov 17, 2023

What type of PR is this?

Feature

What does this PR do? Why is it needed?

Implements ethereum/beacon-APIs#367. I also simplified testing to use less validators.

Which issues(s) does this PR fix?

Fixes #13187

@rkapka rkapka requested a review from a team as a code owner November 17, 2023 18:39
@rkapka rkapka changed the title POST versions of GetValidators and GetValidatorBalances POST version of GetValidators and GetValidatorBalances Nov 17, 2023
if r.Method == http.MethodGet {
rawIds = r.URL.Query()["id"]
} else {
err = json.NewDecoder(r.Body).Decode(&rawIds)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I saw the spec and this list should be a unique list of IDs, i don't think decodeIds is checking for uniqueness.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't see it anywhere in the spec. It is a useful thing to add, but I would prefer to have it in another PR.

nalepae
nalepae previously approved these changes Nov 22, 2023
Copy link
Copy Markdown
Contributor

@nalepae nalepae left a comment

Choose a reason for hiding this comment

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

3 minors comments


statuses := r.URL.Query()["status"]
var statuses []string
if r.Method == http.MethodGet {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe grouping rawIds and statuses to reduce the number of r.Method == http.MethodGet?
(Not sure what is the most idiomatic in that case.)

Like:

	var rawIds []string
	var statuses []string

	if r.Method == http.MethodGet {
		rawIds = r.URL.Query()["id"]
		statuses = r.URL.Query()["status"]
	} else {
		rawIds = req.Ids
		statuses = req.Statuses
	}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

if r.Method == http.MethodPost {
err = json.NewDecoder(r.Body).Decode(&req)
switch {
case err == io.EOF:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Those errors case seem not to be tested.
(Not sure about the testing policy in that case.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

} else {
err = json.NewDecoder(r.Body).Decode(&rawIds)
switch {
case err == io.EOF:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Those errors case seem not to be tested.
(Not sure about the testing policy in that case.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@prylabs-bulldozer prylabs-bulldozer bot merged commit 4b3c511 into develop Nov 22, 2023
@prylabs-bulldozer prylabs-bulldozer bot deleted the state-validators-post branch November 22, 2023 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BEACON API: add POST validators endpoints for validators and validator_balances endpoints

3 participants