-
Notifications
You must be signed in to change notification settings - Fork 619
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(08-wasm): querier plugins implemented #5345
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work @srdtrk! This looks good to me, pending @DimitrisJim suggestions on error redactions. I left a couple of nits on godocs etc
LGTM!!
@@ -107,3 +113,88 @@ func (suite *TypesTestSuite) TestCustomQuery() { | |||
}) | |||
} | |||
} | |||
|
|||
func (suite *TypesTestSuite) TestStargateQuery() { | |||
typeURL := "/ibc.lightclients.wasm.v1.Query/Checksums" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wonder if we should add any more test queries for something basic, query from x/bank or x/staking for example, this is probably fine tho!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add more if others also want this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing, @srdtrk! Thanks for raising the issue and then opening the PR so quickly. Left a bunch of comments for now, but it looks good in my opinion. I will take a second look later today/tomorrow.
// SetQueryPlugins sets the current query plugins | ||
func SetQueryPlugins(plugins *QueryPlugins) { | ||
queryPlugins = plugins | ||
} | ||
|
||
// GetQueryPlugins returns the current query plugins | ||
func GetQueryPlugins() *QueryPlugins { | ||
return queryPlugins | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to make these package internal? Should users use only WithQueryPlugins
or do we expect them also to be able to use these 2 functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible it would be nice. There's the option of moving queryPlugins
to internal/ibcwasm
that I think @DimitrisJim suggested but unsure if that comes with some import cycle shenanigans.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the keeper needs access to these functions and the user needs to be exposed to QueryPlugins
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my main Q was w.r.t DefaultQuerier
. As far as I understood, people will never override it, it just wraps things they override (namely, the queryPlugins) hence it could ideally be private (though still in types
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the keeper needs access to these functions
The keeper can access these functions when it is internal? The 08-wasm keeper right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After reviewing some more, I'd have a preference to move GetQueryPlugins
/SetQueryPlugins
to the internal package so that WithQueryPlugins
is the only option to override the query plugins (ensuring no accidental nil values)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough @colin-axner. Do you think it'd be ok to keep queryHandler
in types (after it is made private)? So that I don't need to move gas_registry to internal too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I am definitely in favour of keeping all implementation code in types. Make it private when possible. For Get/Set of QueryPlugins, I would add QueryPlugins as an expected interface, so you don't need to move over the implementation logic. Hopefully we remove all this global stuff before too long
If it is too much work, I'm fine as is. Mostly interested in limiting accidental misuse of query plugins by creating one api for setting/updating them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully we remove all this global stuff before too long
Agree! But from the looks of things we should be able to switch over quite nicely from the internal/ibcwasm
stuff to the vm
and such existing as fields on the Keeper
. Looks like it will be clean enough to do it when the time comes :)
And fwiw I think working with the internal
dir for the global types makes a big difference for the time being!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved getters and setters to internal now. And made queryHandler
private
|
||
isAccepted := slices.Contains(accepted, request.Path) | ||
if !isAccepted { | ||
return nil, wasmvmtypes.UnsupportedRequest{Kind: fmt.Sprintf("'%s' path is not allowed from the contract", request.Path)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use wasmvm errors or our own?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wasmvm in my opinion. Similar to what wasmd does. This also helps with the redactErr
function that I just added.
clientState.Status(suite.chainA.GetContext(), clientStore, suite.chainA.App.AppCodec()) | ||
|
||
// reset query plugins after each test | ||
types.SetQueryPlugins(types.NewDefaultQueryPlugins()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not do this after the call to SetupWasmWithMockVM
as you do in the TestCustomQuery
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the end of test might be more reliable now. I should maybe change the other one too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, going to review the test files next
// SetQueryPlugins sets the current query plugins | ||
func SetQueryPlugins(plugins *QueryPlugins) { | ||
queryPlugins = plugins | ||
} | ||
|
||
// GetQueryPlugins returns the current query plugins | ||
func GetQueryPlugins() *QueryPlugins { | ||
return queryPlugins | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the keeper needs access to these functions
The keeper can access these functions when it is internal? The 08-wasm keeper right?
// SetQueryPlugins sets the current query plugins | ||
func SetQueryPlugins(plugins *QueryPlugins) { | ||
queryPlugins = plugins | ||
} | ||
|
||
// GetQueryPlugins returns the current query plugins | ||
func GetQueryPlugins() *QueryPlugins { | ||
return queryPlugins | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it just wraps things they override (namely, the queryPlugins) hence it could ideally be private (though still in types).
Yea, I think it could be nice to make queryHandler
and newQueryHandler
private as it should only be invoked by types/vm.go? But it is a nice to have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick implementation @srdtrk! The feature looks good to me 🙂
@srdtrk Can you please, pretty please update the docs as well (in this PR or in a follow-up)? 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Left just one more nit. Let's update the docs in a separate PR, so that the backport of this PR is clean to the release branches.
@crodriguezvega, let's add the docs in another PR as this feature should not be blocked on documentation issues and nits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all aboard! ⛵ lgtm!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
* imp: moved gas to internal * fix: fixed compiler complaints * feat: added 'QueryRouter' interface * imp: passing the queryRouter to keeper * Revert "fix: fixed compiler complaints" This reverts commit 208e314. * Revert "imp: moved gas to internal" This reverts commit b45b605. * fix(test): fixed keeper_test.go * imp: initial querier template * imp: moved querier to types * fix: compiler complaints * imp: removed querier from keeper * feat: including default querier * imp: added options * feat: querier implemented fully * docs: improved godocs * imp: improved the querier * style: improved styling of querier * fix: fixed options * fix: fixed options not being passed with config * style: renamed variables * imp: added review items * imp: review items * imp: set and get query plugins made private * docs: added more godocs * fix: default plugin not set * imp: review items * docs: added a godoc --------- Co-authored-by: Carlos Rodriguez <carlos@interchain.io> (cherry picked from commit e2bcb77) # Conflicts: # modules/light-clients/08-wasm/internal/ibcwasm/wasm.go # modules/light-clients/08-wasm/keeper/keeper.go # modules/light-clients/08-wasm/keeper/keeper_test.go # modules/light-clients/08-wasm/keeper/migrations.go # modules/light-clients/08-wasm/testing/simapp/app.go # modules/light-clients/08-wasm/types/querier_test.go
* imp: moved gas to internal * fix: fixed compiler complaints * feat: added 'QueryRouter' interface * imp: passing the queryRouter to keeper * Revert "fix: fixed compiler complaints" This reverts commit 208e314. * Revert "imp: moved gas to internal" This reverts commit b45b605. * fix(test): fixed keeper_test.go * imp: initial querier template * imp: moved querier to types * fix: compiler complaints * imp: removed querier from keeper * feat: including default querier * imp: added options * feat: querier implemented fully * docs: improved godocs * imp: improved the querier * style: improved styling of querier * fix: fixed options * fix: fixed options not being passed with config * style: renamed variables * imp: added review items * imp: review items * imp: set and get query plugins made private * docs: added more godocs * fix: default plugin not set * imp: review items * docs: added a godoc --------- Co-authored-by: Carlos Rodriguez <carlos@interchain.io> (cherry picked from commit e2bcb77)
* imp: moved gas to internal * fix: fixed compiler complaints * feat: added 'QueryRouter' interface * imp: passing the queryRouter to keeper * Revert "fix: fixed compiler complaints" This reverts commit 208e314. * Revert "imp: moved gas to internal" This reverts commit b45b605. * fix(test): fixed keeper_test.go * imp: initial querier template * imp: moved querier to types * fix: compiler complaints * imp: removed querier from keeper * feat: including default querier * imp: added options * feat: querier implemented fully * docs: improved godocs * imp: improved the querier * style: improved styling of querier * fix: fixed options * fix: fixed options not being passed with config * style: renamed variables * imp: added review items * imp: review items * imp: set and get query plugins made private * docs: added more godocs * fix: default plugin not set * imp: review items * docs: added a godoc --------- Co-authored-by: Carlos Rodriguez <carlos@interchain.io> (cherry picked from commit e2bcb77) Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com>
* feat(08-wasm): querier plugins implemented (#5345) * imp: moved gas to internal * fix: fixed compiler complaints * feat: added 'QueryRouter' interface * imp: passing the queryRouter to keeper * Revert "fix: fixed compiler complaints" This reverts commit 208e314. * Revert "imp: moved gas to internal" This reverts commit b45b605. * fix(test): fixed keeper_test.go * imp: initial querier template * imp: moved querier to types * fix: compiler complaints * imp: removed querier from keeper * feat: including default querier * imp: added options * feat: querier implemented fully * docs: improved godocs * imp: improved the querier * style: improved styling of querier * fix: fixed options * fix: fixed options not being passed with config * style: renamed variables * imp: added review items * imp: review items * imp: set and get query plugins made private * docs: added more godocs * fix: default plugin not set * imp: review items * docs: added a godoc --------- Co-authored-by: Carlos Rodriguez <carlos@interchain.io> (cherry picked from commit e2bcb77) # Conflicts: # modules/light-clients/08-wasm/internal/ibcwasm/wasm.go # modules/light-clients/08-wasm/keeper/keeper.go # modules/light-clients/08-wasm/keeper/keeper_test.go # modules/light-clients/08-wasm/keeper/migrations.go # modules/light-clients/08-wasm/testing/simapp/app.go # modules/light-clients/08-wasm/types/querier_test.go * fix conflicts. * lint issues --------- Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com> Co-authored-by: DimitrisJim <d.f.hilliard@gmail.com>
Description
closes: #5325
Commit Message / Changelog Entry
see the guidelines for commit messages. (view raw markdown for examples)
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.
docs/
) or specification (x/<module>/spec/
).godoc
comments.Files changed
in the Github PR explorer.Codecov Report
in the comment section below once CI passes.