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 Client Generalization (+ associated module refactor) #4451

Merged
merged 28 commits into from
Jun 5, 2019

Conversation

rigelrozanski
Copy link
Contributor

@rigelrozanski rigelrozanski commented May 30, 2019

Replaces #4296

Updates to Gaia: cosmos/gaia#31

closes #1124
closes #2955
closes #4299

followup to module genesis generalization

To accomplish the client generalization which is in theory pretty simple there is a bunch of restructuring required due to lots of early design choices which are now leading to lots of circular dependencies.

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

x/gov/module.go Outdated Show resolved Hide resolved
@rigelrozanski rigelrozanski mentioned this pull request May 30, 2019
5 tasks
@rigelrozanski rigelrozanski changed the title WIP Client Generalization WIP Client Generalization (+ associated module refactor) May 31, 2019
@rigelrozanski rigelrozanski changed the title WIP Client Generalization (+ associated module refactor) R4R Client Generalization (+ associated module refactor) May 31, 2019
crypto/ledger_mock.go Show resolved Hide resolved
crypto/ledger_mock.go Show resolved Hide resolved
crypto/ledger_secp256k1.go Outdated Show resolved Hide resolved
simapp/app.go Show resolved Hide resolved
types/config.go Outdated Show resolved Hide resolved
x/gov/client/cli/tx.go Show resolved Hide resolved
x/slashing/keeper.go Show resolved Hide resolved
x/slashing/types/keys.go Outdated Show resolved Hide resolved
x/slashing/types/keys.go Outdated Show resolved Hide resolved
x/staking/types/codec.go Outdated Show resolved Hide resolved
crypto/ledger_mock.go Show resolved Hide resolved
crypto/ledger_test.go Outdated Show resolved Hide resolved
simapp/app.go Show resolved Hide resolved
x/auth/module.go Outdated Show resolved Hide resolved
x/auth/module.go Outdated Show resolved Hide resolved
x/distribution/client/cli/tx.go Show resolved Hide resolved
x/distribution/client/cli/tx.go Show resolved Hide resolved
x/gov/types/codec.go Show resolved Hide resolved
x/staking/types/expected_keepers.go Outdated Show resolved Hide resolved
x/staking/client/rest/utils.go Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jun 3, 2019

Codecov Report

Merging #4451 into master will decrease coverage by 1.45%.
The diff coverage is 31.49%.

@@            Coverage Diff             @@
##           master    #4451      +/-   ##
==========================================
- Coverage   54.69%   53.23%   -1.46%     
==========================================
  Files         253      259       +6     
  Lines       16150    16173      +23     
==========================================
- Hits         8833     8610     -223     
- Misses       6668     6917     +249     
+ Partials      649      646       -3

Copy link
Member

@jackzampolin jackzampolin left a comment

Choose a reason for hiding this comment

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

On the first read through here it looks really good and a substantial improvement @rigelrozanski !!!

My only concern was that it looks like we are moving the codec to be on a per module basis and using init in each module to handle the codec? This seems like a codesmell and def not something we should be doing afaik.

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

Second pass. Minor comments but otherwise LGTM

x/auth/keeper.go Outdated Show resolved Hide resolved
x/auth/keeper.go Outdated Show resolved Hide resolved
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec, kb keys.Keybase) {
r.HandleFunc("/bank/accounts/{address}/transfers", SendRequestHandlerFn(cdc, kb, cliCtx)).Methods("POST")
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec) {
r.HandleFunc("/bank/accounts/{address}/transfers", SendRequestHandlerFn(cdc, cliCtx)).Methods("POST")
Copy link
Collaborator

Choose a reason for hiding this comment

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

where does the send command live rn ?

x/bank/client/rest/sendtx.go Show resolved Hide resolved
x/bank/invariants.go Outdated Show resolved Hide resolved
x/gov/keeper.go Outdated Show resolved Hide resolved
x/staking/keeper/querier.go Show resolved Hide resolved
alexanderbez and others added 2 commits June 4, 2019 09:38
Co-Authored-By: Federico Kunze <[email protected]>
Co-Authored-By: Federico Kunze <[email protected]>
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Performed a first initial passthrough. Left some general feedback. Overall, looks like a step in the right direction. Still not clear on why some codec are public and others aren't. Also, I think queriers should be consistently defined in terms of their location (ie. x/{module}/querier).

crypto/ledger_mock.go Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
DefaultGenesis() json.RawMessage
ValidateGenesis(json.RawMessage) error

// client functionality
RegisterRESTRoutes(context.CLIContext, *mux.Router, *codec.Codec)
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of scope of this PR, but we can and should stop passing a CLIContext AND a *coded.Codec. The context should already have the codec set. I'll make an issue of this and address it once this PR is merged.

REF: #4479

x/auth/client/txbuilder/stdsignmsg.go Outdated Show resolved Hide resolved
@@ -427,7 +427,7 @@ func TestTrackUndelegationDelVestingAcc(t *testing.T) {
now := tmtime.Now()
endTime := now.Add(24 * time.Hour)

_, _, addr := keyPubAddr()
_, _, addr := KeyTestPubAddr()
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be exposed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we don't want duplicate code it does need to be exposed... ideally this will move out into a common testing-helpers root level package at some point!

x/auth/types/querier.go Show resolved Hide resolved
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec, kb keys.Keybase) {
r.HandleFunc("/bank/accounts/{address}/transfers", SendRequestHandlerFn(cdc, kb, cliCtx)).Methods("POST")
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec) {
r.HandleFunc("/bank/accounts/{address}/transfers", SendRequestHandlerFn(cdc, cliCtx)).Methods("POST")
Copy link
Contributor

Choose a reason for hiding this comment

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

Que? The send command lives in bank @jackzampolin. I think you mean the /bank/balances/{address} endpoint needs to move from auth to bank ;-)


// Register routes
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec) {
RegisterRPCRoutes(cliCtx, r)
Copy link
Contributor

Choose a reason for hiding this comment

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

Once we remove the need for a codec as an argument, this should really only be RegisterRoutes 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure that will be possible given that client doesn't define it's own "client" level cdc

x/distribution/client/proposal_handler.go Outdated Show resolved Hide resolved
)

// function to create the rest handler
type RESTHandlerFn func(context.CLIContext, *codec.Codec) rest.ProposalRESTHandler
Copy link
Contributor

Choose a reason for hiding this comment

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

Errr shall we not just define this ProposalRESTHandler type in the rest package? Has nothing to do specifically with gov, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm confused ProposalRESTHandler is already defined in "github.com/cosmos/cosmos-sdk/x/gov/client/rest" - if you were referring to the RESTHandlerFn this should stay where it is, it's only used for defining the ProposalHandler (which belongs outside of rest because its used for both the cli and rest)

@alexanderbez alexanderbez added T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine). ready-for-review labels Jun 4, 2019
@rigelrozanski rigelrozanski mentioned this pull request Jun 5, 2019
8 tasks
Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

👍 👍

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

testedACK

@alexanderbez alexanderbez merged commit 5f9c3fd into master Jun 5, 2019
@alexanderbez alexanderbez deleted the rigel/client-generalization2 branch June 5, 2019 23:26
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine).
Projects
None yet
6 participants