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: REST Client Unsafe/Safe Endpoints #3640

Closed
wants to merge 22 commits into from

Conversation

alexanderbez
Copy link
Contributor

@alexanderbez alexanderbez commented Feb 13, 2019

  • Remove client/keys/codec.go in favor already valid codec in codec/codec.go
  • Move common functionality and types from client/keys/* to client/keys/common
  • Update all appropriate REST handlers to handle unsafe routes

closes: #3560

/cc @cosmos/cosmos-ui


  • 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 #

  • 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)

@alexanderbez alexanderbez added WIP T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine). labels Feb 13, 2019
@codecov
Copy link

codecov bot commented Feb 13, 2019

Codecov Report

Merging #3640 into develop will increase coverage by 0.03%.
The diff coverage is 29.5%.

@@             Coverage Diff             @@
##           develop    #3640      +/-   ##
===========================================
+ Coverage    60.79%   60.82%   +0.03%     
===========================================
  Files          189      187       -2     
  Lines        14170    14092      -78     
===========================================
- Hits          8615     8572      -43     
+ Misses        5011     4980      -31     
+ Partials       544      540       -4

@faboweb
Copy link
Contributor

faboweb commented Feb 14, 2019

What are the implications for this? What would change exactly? Can you give me an example of what we would need to change if this is done?

@alexanderbez
Copy link
Contributor Author

alexanderbez commented Feb 14, 2019

@faboweb no routes will changes. Simply any routes that actually sign txs and all of the /keys/* will need to have the rest server started with --allow-unsafe.

@alexanderbez alexanderbez mentioned this pull request Feb 14, 2019
4 tasks
@@ -77,6 +77,11 @@ type voteReq struct {

func postProposalHandlerFn(cdc *codec.Codec, cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if !cliCtx.AllowUnsafe {
Copy link
Contributor Author

@alexanderbez alexanderbez Feb 14, 2019

Choose a reason for hiding this comment

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

I initially went with a ClientRouter wrapper struct that contained a mux router and an unsafe bool, but found the route registration ugly as there was a if/else switch in every module's registration handler

The following solution leaves it up to the actual handler and relies on the context. Also, not super clean, but I feel like it is more DRY compared to the previous solution.

@alexanderbez
Copy link
Contributor Author

In order to wrap this up, we need to pass a CLIContext to the keys REST handlers. This causes import cycles. I would like to fix this as part of this PR, but I also don't want to step on the toes of #3580. So I say this is blocked until that is merged and then I can wrap this up.

/cc @jackzampolin @alessio

@faboweb
Copy link
Contributor

faboweb commented Feb 14, 2019

I get it now. Nice change.

@alexanderbez
Copy link
Contributor Author

alexanderbez commented Feb 14, 2019

@faboweb thanks! I believe this will leave Voyager largely, if not entirely, unaffected as from what @fedekunze tells me, Voyager performs the generate only => sign offline => broadcast flow, which is the ideal flow 👌

@alexanderbez alexanderbez changed the title WIP: REST Client Unsafe/Safe Endpoints R4R: REST Client Unsafe/Safe Endpoints Feb 15, 2019
Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

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

🍷

@alexanderbez
Copy link
Contributor Author

Ok, so with advent of #3641, this should still be merged but only exist for keybase routes.

@alexanderbez alexanderbez added the S:blocked Status: Blocked label Feb 18, 2019
@alexanderbez
Copy link
Contributor Author

closing in favor of #3674

@alexanderbez alexanderbez deleted the bez/3560-safe-unsafe-rpc-endpoints branch February 18, 2019 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S:blocked Status: Blocked T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Separate safe and unsafe RPC endpoints
3 participants