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

feat(x/auth): define simplified account query service #13210

Merged
merged 28 commits into from
Sep 16, 2022

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented Sep 8, 2022

Description

Ref: #13211. This proposes a query service which exposes account details to clients in a more simpler way. It could be implemented very easily with the current x/auth module and could serve as the basis for a refactored v1 x/auth module.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@aaronc aaronc marked this pull request as ready for review September 12, 2022 13:54
@aaronc aaronc requested a review from a team as a code owner September 12, 2022 13:54
@codecov
Copy link

codecov bot commented Sep 12, 2022

Codecov Report

Merging #13210 (5193994) into main (4fe7797) will decrease coverage by 0.90%.
The diff coverage is 29.41%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #13210      +/-   ##
==========================================
- Coverage   55.87%   54.96%   -0.91%     
==========================================
  Files         646      648       +2     
  Lines       54895    55398     +503     
==========================================
- Hits        30675    30452     -223     
- Misses      21762    22491     +729     
+ Partials     2458     2455       -3     
Impacted Files Coverage Δ
baseapp/abci.go 67.01% <0.00%> (+2.59%) ⬆️
baseapp/grpcrouter.go 90.00% <ø> (ø)
baseapp/grpcrouter_helpers.go 25.00% <ø> (ø)
baseapp/grpcserver.go 1.72% <ø> (ø)
baseapp/msg_service_router.go 85.29% <ø> (+4.41%) ⬆️
baseapp/options.go 69.23% <ø> (+0.71%) ⬆️
client/broadcast.go 51.54% <ø> (ø)
client/cmd.go 57.73% <ø> (ø)
client/context.go 54.49% <ø> (-1.79%) ⬇️
client/flags/flags.go 19.35% <ø> (-0.32%) ⬇️
... and 217 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.

I'm confused where the actual gRPC handler is?

proto/cosmos/auth/v1/query.proto Outdated Show resolved Hide resolved
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
@aaronc
Copy link
Member Author

aaronc commented Sep 12, 2022

I'm confused where the actual gRPC handler is?

It needs to be implemented in x/auth

@alexanderbez
Copy link
Contributor

I know, but the PR is marked R4R. Can you either move it to draft and implement the handler?

@aaronc
Copy link
Member Author

aaronc commented Sep 12, 2022

I know, but the PR is marked R4R. Can you either move it to draft and implement the handler?

I know, but the PR is marked R4R. Can you either move it to draft and implement the handler?

Do we need to implement the handlers in the same PR? My preference is to do protos in one PR and impl in a second PR. But if you prefer we can add here

@alexanderbez
Copy link
Contributor

Yeah prefer to have query handlers added with their proto definitions

@alexanderbez
Copy link
Contributor

@aaronc why is this under package v1 when the rest aren't? Do you want to define the gRPC handler anyway?

@aaronc
Copy link
Member Author

aaronc commented Sep 12, 2022

@aaronc why is this under package v1 when the rest aren't? Do you want to define the gRPC handler anyway?

See the description at the top and the linked issue. Basically I'm proposing that in v1, auth exposes a simpler data model. If that's too much of a leap right now, we can keep in v1beta1 and just add this simple query.

@alexanderbez
Copy link
Contributor

But where do you define that handler? In the keeper?

@aaronc
Copy link
Member Author

aaronc commented Sep 12, 2022

You can just create a struct that wrap the keeper and implements the QueryServer

@alexanderbez
Copy link
Contributor

Pushed the handler change.

x/auth/keeper/keeper_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

The query LGTM, though I'm wondering if this is too premature.

I would add this query to v1beta1 for now TBH, and once we do the real auth refactor, we create v1 and think of a good API. For example, the name AccountInfo could or could not be changed to simply Account.

proto/cosmos/auth/v1/query.proto Outdated Show resolved Hide resolved
proto/cosmos/auth/v1/query.proto Outdated Show resolved Hide resolved
proto/cosmos/auth/v1/query.proto Outdated Show resolved Hide resolved
x/auth/keeper/grpc_query.go Outdated Show resolved Hide resolved
proto/cosmos/auth/v1/query.proto Outdated Show resolved Hide resolved
proto/cosmos/auth/v1/query.proto Outdated Show resolved Hide resolved
@aaronc
Copy link
Member Author

aaronc commented Sep 13, 2022

I would add this query to v1beta1 for now TBH, and once we do the real auth refactor, we create v1 and think of a good API. For example, the name AccountInfo could or could not be changed to simply Account.

Maybe v1beta2?

@amaury1093
Copy link
Contributor

Maybe v1beta2?

Sure, but why not v1beta1 actually?

@aaronc
Copy link
Member Author

aaronc commented Sep 13, 2022

Maybe v1beta2?

Sure, but why not v1beta1 actually?

That's fine

@aaronc
Copy link
Member Author

aaronc commented Sep 14, 2022

What's the error you're getting?

There's a mistake in the Makefile for proto-gen (that I made) so gogo isn't running. Need to figure out the fix...

@aaronc
Copy link
Member Author

aaronc commented Sep 14, 2022

Fixed the proto-gen issue. Thanks @kocubinski ! Also added a test. Marking R4R again.

@aaronc aaronc marked this pull request as ready for review September 14, 2022 20:20
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

LGTM, a couple of small nits

x/auth/keeper/grpc_query.go Outdated Show resolved Hide resolved
x/auth/module.go Show resolved Hide resolved
proto/cosmos/auth/v1beta1/query.proto Show resolved Hide resolved
@aaronc aaronc enabled auto-merge (squash) September 15, 2022 16:12
@alexanderbez alexanderbez enabled auto-merge (squash) September 16, 2022 08:56
@alexanderbez alexanderbez merged commit d9ef976 into main Sep 16, 2022
@alexanderbez alexanderbez deleted the aaronc/simple-auth-query-proto branch September 16, 2022 09:12
Wryhder pushed a commit to Wryhder/cosmos-sdk that referenced this pull request Oct 26, 2022
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.

4 participants