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

refactor: use unexported types for core query servers #6794

Merged
merged 16 commits into from
Jul 11, 2024

Conversation

damiannolan
Copy link
Member

Description

Refactors the query servers in core to use unexported/private queryServer structs.
Removes the core/types QueryServer top level interface.

closes: #6775


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

@@ -150,7 +148,6 @@ func NewTestChainWithValSet(tb testing.TB, coord *Coordinator, chainID string, v
ChainID: chainID,
App: app,
ProposedHeader: header,
QueryServer: app.GetIBCKeeper(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason why you didn't want to keep this with keeper.NewQueryServer(app.GetIBCKeeper().ChannelKeeper)?

Copy link
Member Author

Choose a reason for hiding this comment

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

This query server is the interface that was previously defined in core/types which I removed in this PR.
It was the union of all core query servers.

type QueryServer interface {
	clienttypes.QueryServer
	connectiontypes.QueryServer
	channeltypes.QueryServer
}

I'm not sure this provides a tonne of value and each submodule query server can be created on demand since the sub keepers are public on the ibc core keeper.

If folks feel strongly about keeping this type for testing purposes then I would suggest moving this to the testing pkg, which would still require creating a struct to passthrough to each submodule query server. Similar to what was removed in core/keeper/grpc_query.go in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good to me. I don't feel strongly about it tbh, was mostly curious about the thinking, but it makes sense! 👍

Copy link
Contributor

@colin-axner colin-axner Jul 11, 2024

Choose a reason for hiding this comment

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

IIRC the query server was added to the testing chain struct for testing grpcs. Given that the individual query server is created as necessary in the grpc tests, I agree it makes sense to remove. It also didn't contain all the queries available on the chain (non core ibc queries) so it might have led to confusion

Copy link
Contributor

@gjermundgaraba gjermundgaraba left a comment

Choose a reason for hiding this comment

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

Great to get this done! LGTM! 🚀

Copy link
Contributor

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

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

lgtm, I guess we should also add a note to changelog for this?

should we open follow up issues for apps?

res, err := suite.chainA.QueryServer.ClientState(ctx, req)

queryServer := keeper.NewQueryServer(suite.chainA.GetSimApp().IBCKeeper.ClientKeeper)
res, err := queryServer.ClientState(ctx, req)
Copy link
Contributor

Choose a reason for hiding this comment

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

these could also be defined on a ClientQuerierTestSuite to further separate. Probably could also init the querier in the setup to avoid needing to call new in each test. Nice for follow up if people agree.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that's a nice idea 👍🏻

@damiannolan damiannolan added the priority PRs that need prompt reviews label Jul 10, 2024
@damiannolan damiannolan requested a review from srdtrk as a code owner July 10, 2024 14:09
Copy link
Contributor

@chatton chatton left a comment

Choose a reason for hiding this comment

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

LGTM! Nice bit of cleanup

@damiannolan damiannolan added this pull request to the merge queue Jul 11, 2024
Copy link

sonarcloud bot commented Jul 11, 2024

Merged via the queue into main with commit 99f21bf Jul 11, 2024
71 of 72 checks passed
@damiannolan damiannolan deleted the damian/refactor-query-servers branch July 11, 2024 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority PRs that need prompt reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use unexported types for core query servers
6 participants