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(bank): Add secondary query for bank metadata #16852

Merged
merged 11 commits into from
Jul 27, 2023

Conversation

mattverse
Copy link
Contributor

@mattverse mattverse commented Jul 6, 2023

Description

Current bank metadata query takes in denom field as query path, thus does not support querying any denom with "/". (Ex tokenfactory/~") cannot be queried through current query.

This PR adds secondary query for denom meta data, where here we take in query as query string, thus also supports query as above.

The reason this query is designed as a secondary query is because last time we have made similar change to the supply query, it was API breaking thus effected(broke) lots of products or contracts having dependency on the API. This way of creating a secondary query would not break any other dependency.


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)

@mattverse mattverse requested a review from a team as a code owner July 6, 2023 07:04
@github-prbot github-prbot requested review from a team, aaronc and atheeshp and removed request for a team July 6, 2023 07:05
@julienrbrt julienrbrt changed the title !feat: Add secondary query for bank metadata (non-api breaking) feat(bank): Add secondary query for bank metadata Jul 6, 2023
CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

how come this has changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This I do not know, probably something to do with protoc or how we generate pulsar files, do you want me to revert this file for now?

Copy link
Member

Choose a reason for hiding this comment

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

Just running make proto-gen should suffice.

Copy link
Contributor Author

@mattverse mattverse Jul 6, 2023

Choose a reason for hiding this comment

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

I have used the same command for proto gen 🤔 I'm wondering if we check docker image versions for protogen and if that might be the cause for this?

Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

utACK

@@ -225,6 +225,28 @@ func (k BaseKeeper) DenomMetadata(c context.Context, req *types.QueryDenomMetada
}, nil
}

// DenomMetadataByQueryString is identical to DenomMetadata query, but receives request via query string.
func (k BaseKeeper) DenomMetadataByQueryString(c context.Context, req *types.QueryDenomMetadataByQueryStringRequest) (*types.QueryDenomMetadataByQueryStringResponse, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I missine something but isn't this the same as DenomMetadata?

Copy link
Contributor

Choose a reason for hiding this comment

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

If the issue is just the fact that we MUST provide a denom in the URL path, then I would avoid creating a duplicate query handler -- we can at least extract out the handler code into a single method.

In addition, is there no annotation or something that we can add to the existing query to allow an empty query argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can at least extract out the handler code into a single method.

@alexanderbez We need to suffice the BaseKeeper Interface, thus need to have this method with this specific request field and response field. What I can do is extract the duplicated method between DenomMetadata and DenomMetadataByQueryString` to reduce code duplication.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, the code within the query handlers are identical I believe, so that should be kept DRY 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the second look, the way it is right now seems as far as we could go for having non-duplicated code.
We use the same abstracted keeper method, namely k.GetDenomMetaData whilst the remaining part is simply handling the request and response itself

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.

ACK

rpc DenomMetadataByQueryString(QueryDenomMetadataByQueryStringRequest)
returns (QueryDenomMetadataByQueryStringResponse) {
option (cosmos.query.v1.module_query_safe) = true;
option (google.api.http).get = "/cosmos/bank/v1beta1/denoms_metadata_by_query_string";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
option (google.api.http).get = "/cosmos/bank/v1beta1/denoms_metadata_by_query_string";
option (google.api.http).get = "/cosmos/bank/v1beta1/denoms_metadata_by_query";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO, query string seems like the correct term to use, is there a reason for suggestion above?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, a few items:

  • It makes an already verbose query even more verbose without adding context
  • The fact that denom is a string is already available based on the proto schema
  • Generally, you dont wan't to annotate a query's path (e.g. /users/by_name vs /users/by_name_string), the latter doesn't give you anything as it's superfluous IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I was referring to query string as a single term here though (https://en.wikipedia.org/wiki/Query_string)

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 happy with it either way, but just wanted to make things clear :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocker for me, just my two cents :p

we can merge

@julienrbrt
Copy link
Member

If the naming is okay, can you run make proto-swagger-gen?

@julienrbrt
Copy link
Member

Gentle ping @mattverse

@mattverse
Copy link
Contributor Author

@julienrbrt Done!

@github-actions github-actions bot added the C:CLI label Jul 27, 2023
@julienrbrt julienrbrt enabled auto-merge July 27, 2023 15:08
@julienrbrt julienrbrt added the backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release label Jul 27, 2023
@julienrbrt julienrbrt added this pull request to the merge queue Jul 27, 2023
Merged via the queue into cosmos:main with commit c295832 Jul 27, 2023
mergify bot pushed a commit that referenced this pull request Jul 27, 2023
(cherry picked from commit c295832)

# Conflicts:
#	CHANGELOG.md
#	x/bank/keeper/grpc_query.go
julienrbrt added a commit that referenced this pull request Jul 27, 2023
…17168)

Co-authored-by: Matt, Park <45252226+mattverse@users.noreply.github.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
@faddat faddat mentioned this pull request Nov 8, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.50.x PR scheduled for inclusion in the v0.50's next stable release C:CLI C:x/bank C:x/gov
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants