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

R4R: Redelegation endpoint and Querier #2336

Closed
wants to merge 19 commits into from

Conversation

fedekunze
Copy link
Collaborator

@fedekunze fedekunze commented Sep 13, 2018

Closes #2182

  • Add GET redelegation endpoint
  • Add redelegation querier
  • refactor query.go to avoid duplicated code

  • 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 entries in PENDING.md with issue #

  • Reviewed 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 Sep 14, 2018

Codecov Report

❗ No coverage uploaded for pull request base (develop@6c9e71b). Click here to learn what that means.
The diff coverage is 42.85%.

@@            Coverage Diff             @@
##             develop    #2336   +/-   ##
==========================================
  Coverage           ?   61.66%           
==========================================
  Files              ?      122           
  Lines              ?     7500           
  Branches           ?        0           
==========================================
  Hits               ?     4625           
  Misses             ?     2553           
  Partials           ?      322

@cwgoes
Copy link
Contributor

cwgoes commented Oct 2, 2018

@fedekunze What's the status of this PR?

@fedekunze
Copy link
Collaborator Author

@cwgoes is done but I can't test it because of #2339

@fedekunze fedekunze changed the title WIP: Add missing redelegation endpoint R4R: Add missing redelegation endpoint Oct 2, 2018
@fedekunze fedekunze changed the title R4R: Add missing redelegation endpoint R4R: Redelegation endpoint and Querier Oct 2, 2018
Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

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

utACK, let's add the testcase once the upstream issue is fixed, thanks @fedekunze

@cwgoes cwgoes force-pushed the fedekunze/2182-redelegation-endpoint branch from c4cc30f to 8bd3210 Compare October 3, 2018 17:07
@fedekunze fedekunze changed the title R4R: Redelegation endpoint and Querier WIP: Redelegation endpoint and Querier Oct 3, 2018
@fedekunze fedekunze added the wip label Oct 3, 2018
@fedekunze fedekunze removed the wip label Oct 9, 2018
@fedekunze
Copy link
Collaborator Author

note: lint is failing on develop

@faboweb
Copy link
Contributor

faboweb commented Oct 10, 2018

Do we really need /stake/delegators/%s/redelegations/validator_from/%s/validator_to/%s? In which usecase would you use this query?

@fedekunze
Copy link
Collaborator Author

@faboweb the query is to query individual redelegations, same as the existing endpoints to query individual delegations and unbonding delegations

@cwgoes
Copy link
Contributor

cwgoes commented Oct 11, 2018

Merge develop, it will fix the linter. Not sure about test_cover.

@faboweb
Copy link
Contributor

faboweb commented Oct 11, 2018

the query is to query individual redelegations

yes, but why? in which case do I query for all redelegations between one validator and another validator? maybe for analytics. but there I will probably download bigger data sets and do not use a single query for each request.
I would like to avoid to spam the API with endpoints that will never be used. This makes the API less readable and there is always code attached to those endpoints, wich we should avoid.

@fedekunze
Copy link
Collaborator Author

@faboweb the query redelegation endpoint was initially specified on the Gaia-lite refactor (#2113), I'd suggest to move the discussion there if you want to propose any change

@fedekunze
Copy link
Collaborator Author

@alexanderbez You said that maybe the error had to do with the queue ? Cuz if I run the unit tests locally they pass

@jackzampolin
Copy link
Member

Lets try to get this in for 0.25? cc @cwgoes

@cwgoes
Copy link
Contributor

cwgoes commented Oct 11, 2018

Lets try to get this in for 0.25? cc @cwgoes

Needs test_cover fixed then a review.

@jackzampolin
Copy link
Member

Is this affected by the non-determinism?

@fedekunze
Copy link
Collaborator Author

I should be affected

@faboweb faboweb mentioned this pull request Oct 12, 2018
51 tasks
@cwgoes
Copy link
Contributor

cwgoes commented Oct 12, 2018

@fedekunze I think this test failure is unrelated to the CI nondeterminism, something about redelegation querying.

@fedekunze
Copy link
Collaborator Author

@cwgoes I'm getting the same error on other branch as well without the redelegation query:

REQUEST GET http://localhost:41766/auth/accounts/cosmos1vylug6qgf4n984fh5qrj5r9xqe8vagg3yaftgf
--- FAIL: TestBonding (4.06s)
	Error Trace:	lcd_test.go:577
	Error:      	Not equal: 
	            	expected: 40
	            	actual  : 100
	Test:       	TestBonding

@alexanderbez
Copy link
Contributor

Yes, I believe the non-determinism is due to the new bonding/unbonding queue logic or at least correlated.

@cwgoes
Copy link
Contributor

cwgoes commented Oct 13, 2018

@cwgoes I'm getting the same error on other branch as well without the redelegation query:

Hmm, I see another error, e.g. https://circleci.com/gh/cosmos/cosmos-sdk/36899#tests/containers/2 -

ok  	github.com/cosmos/cosmos-sdk/x/stake	5.546s	coverage: 82.4% of statements
--- FAIL: TestQueryRedelegation (0.13s)
	Error Trace:	queryable_test.go:334
	Error:      	Should be true
	Test:       	TestQueryRedelegation
FAIL
coverage: 70.8% of statements
FAIL	github.com/cosmos/cosmos-sdk/x/stake/querier	0.773s

@jackzampolin
Copy link
Member

Failing test @fedekunze

--- FAIL: TestQueryRedelegation (0.10s)
	Error Trace:	queryable_test.go:334
	Error:      	Should be true
	Test:       	TestQueryRedelegation
FAIL
coverage: 70.8% of statements
FAIL	github.com/cosmos/cosmos-sdk/x/stake/querier	0.665s
Exited with code 1


w.Header().Set("Content-Type", "application/json")
bech32ValidatorSrc := vars["validatorSrcAddr"]
bech32ValidatorDst := vars["validatorDstAddr"]

delegatorAddr, err := sdk.AccAddressFromBech32(bech32delegator)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we add

if err != nil {
    utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
    return
}

after each line? otherwise, err might end up overwritten by the subsequent calls

bech32delegator := vars["delegatorAddr"]
bech32validator := vars["validatorAddr"]

delegatorAddr, err := sdk.AccAddressFromBech32(bech32delegator)
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

return
}

w.Header().Set("Content-Type", "application/json")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be set per an API handler, not on individual endpoint level, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah agree, the standarize error responses PR (#2444) refactors all this by using utils.PostProcessResponse(w, cdc, res, cliCtx.Indent) which contains it

@fedekunze
Copy link
Collaborator Author

splitting and closing for #2537

@fedekunze fedekunze closed this Oct 19, 2018
@fedekunze fedekunze deleted the fedekunze/2182-redelegation-endpoint branch October 19, 2018 20:46
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.

6 participants