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

Fix Signing Infos Endpoint #4292

Merged
merged 9 commits into from
May 9, 2019
Merged

Conversation

alexanderbez
Copy link
Contributor

@alexanderbez alexanderbez commented May 7, 2019

  • Fix pagination in /slashing/signing_infos
  • Use querier instead of RPC call (which always limited it to the 100 max validators)
  • Use querier for /slashing/validators/{validatorPubKey}/signing_info

closes: #4194


  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added a relevant changelog entry: clog add [section] [stanza] [message]

  • rereviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@codecov
Copy link

codecov bot commented May 7, 2019

Codecov Report

Merging #4292 into master will increase coverage by 0.24%.
The diff coverage is 21.73%.

@@            Coverage Diff             @@
##           master    #4292      +/-   ##
==========================================
+ Coverage    59.1%   59.35%   +0.24%     
==========================================
  Files         217      214       -3     
  Lines       14595    14526      -69     
==========================================
- Hits         8627     8622       -5     
+ Misses       5330     5266      -64     
  Partials      638      638

@alexanderbez alexanderbez marked this pull request as ready for review May 7, 2019 19:37
@alexanderbez alexanderbez requested review from sabau and fedekunze May 7, 2019 19:37
Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com>
@alexanderbez alexanderbez requested a review from alessio May 8, 2019 01:07
Copy link
Contributor

@alessio alessio left a comment

Choose a reason for hiding this comment

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

ACK


signingInfo, found := k.getValidatorSigningInfo(ctx, params.ConsAddress)
if !found {
return nil, ErrNoSigningInfoFound(DefaultCodespace, params.ConsAddress)
Copy link
Collaborator

Choose a reason for hiding this comment

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

so there's a good practice in returning OK 200 even if the response is empty, because the request was processed successfully. See https://stackoverflow.com/a/13367198

Copy link
Contributor Author

@alexanderbez alexanderbez May 9, 2019

Choose a reason for hiding this comment

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

Hmmm, ok so for collections, this makes sense. But this is a single resource you're looking for, not a collection. If I go with this approach and just return a 200 OK with an empty ValidatorSigningInfo{} object, you'll get the following as a response:

{
    "address": "",
    "index_offset": "0",
    "jailed_until": "0001-01-01T00:00:00Z",
    "missed_blocks_counter": "0",
    "start_height": "0",
    "tombstoned": false
}

This isn't what I'd want to see as an API consumer. Or am I wrong? I suppose I can add omitempty to all the JSON tags so you'll get {} as a response. Is that better?

@@ -42,3 +45,7 @@ func ErrMissingSelfDelegation(codespace sdk.CodespaceType) sdk.Error {
func ErrSelfDelegationTooLowToUnjail(codespace sdk.CodespaceType) sdk.Error {
return sdk.NewError(codespace, CodeValidatorNotJailed, "validator's self delegation less than MinSelfDelegation, cannot be unjailed")
}

func ErrNoSigningInfoFound(codespace sdk.CodespaceType, consAddr sdk.ConsAddress) sdk.Error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto, no need for this error if the request is successful

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Responded; see above.

@alexanderbez alexanderbez requested a review from fedekunze May 9, 2019 12:53
Copy link
Contributor

@rigelrozanski rigelrozanski left a comment

Choose a reason for hiding this comment

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

looks good - only one restructure per comment

types/staking.go Show resolved Hide resolved
x/slashing/client/rest/query.go Outdated Show resolved Hide resolved
@alexanderbez alexanderbez merged commit 925070a into master May 9, 2019
@alexanderbez alexanderbez deleted the bez/4194-fix-signing-infos-endpoint branch May 9, 2019 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LCD /slashing/signing-infos endpoint not returning all validators
4 participants