-
Notifications
You must be signed in to change notification settings - Fork 612
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
Replace the pass-through querier with an extension API #5325
Comments
I think that it's a great addition to have but I think we could support both custom queries and stargate queries at the same time by having an interface similar to what accepted := wasmkeeper.AcceptedStargateQueries{
"/cosmos.auth.v1beta1.Query/Account": &authtypes.QueryAccountResponse{},
}
querierOpts := wasmkeeper.WithQueryPlugins(
&wasmkeeper.QueryPlugins{
Stargate: wasmkeeper.AcceptListStargateQuerier(accepted, app.GRPCQueryRouter(), appCodec),
}) This way, users can provide both custom query and accepted stargate queries. We can also restrict the above interface a bit more and instead of getting the stargate querier implementation as a parameter, we can make the // Query implements the wasmvmtypes.Querier interface.
func (q *DefaultQuerier) Query(request wasmvmtypes.QueryRequest, gasLimit uint64) ([]byte, error) {
sdkGas := VMGasRegister.FromWasmVMGas(gasLimit)
subCtx, _ := q.Ctx.WithGasMeter(storetypes.NewGasMeter(sdkGas)).CacheContext()
// make sure we charge the higher level context even on panic
defer func() {
q.Ctx.GasMeter().ConsumeGas(subCtx.GasMeter().GasConsumed(), "contract sub-query")
}()
if request.Stargate != nil {
return handleStargateQuery(subCtx, request.Stargate, e.acceptList, e.router) // NEW: Provide the user defined accept list and router
} else if request.Custom != nil {
return q.customQueryHandler(subCtx, request.Custom) // NEW: Pass execution to the user defined custom query handler
}
return nil, wasmvmtypes.UnsupportedRequest{Kind: "unsupported query type"}
} |
The most important change here is to internalize the |
Summary
This proposal recommends removing the pass-through querier from the
08-wasm
module in ibc-go and replacing it with an extension API for the default querier, focusing initially on Stargate queries. The change addresses concerns regarding user complexity, lack of standardization, and API inconsistency. It introduces a.AddWhitelistedQuery
method to08-wasm
's keeper, allowing for a controlled, gRPC based whitelist-based querying mechanism. This modification is aimed at aligning08-wasm
with wasmd practices, enhancing the module's usability and consistency with existing standards.Problem Definition
In wasmd, queriers are not typically exposed to the public API. However, an exception was made for the
08-wasm
querier in #5192.Upon review and consultation with @webmaster128, several concerns have been raised about this approach:
Proposal
To align with wasmd's practices, we propose the removal of the pass-through querier from
08-wasm
. Instead, we suggest implementing an extension API for the08-wasm
's default querier. Initially, we plan to support only Stargate (protobuf gRPC) queries, enabling contracts to perform any whitelisted protobuf gRPC query and receive responses accordingly.To facilitate this, we'll introduce a
.AddWhitelistedQuery
method in the08-wasm
keeper. This method will allow adding queries to a default, initially empty, whitelist of queries.Modifications
GRPCQueryRouter
needs to be passed to the08-wasm
through a newQueryRouter
interface.We then add a new
QueryRouter
field to theNewKeeper
in the08-wasm
module:Default querier be updated to use the
QueryRouter
interface for Stargate queries. (See #5310)A whitelist of queries should be added to the
08-wasm
module as a constant variable or a module parameter, pending further discussion.For Admin Use
The text was updated successfully, but these errors were encountered: