-
Notifications
You must be signed in to change notification settings - Fork 640
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
Querier Approach for Conditional Clients #5310
Comments
👍 Introducing JSON responses was a mistake we will repair in wasmd as well in the future. |
Excellent investigative work!! 🙏 I'm happy with either approach :) To add some more color to the general design narrative. As mentioned, the current state of ibc-go creates a uni-directional communication channel where 02-client sends requests to the light client modules. It's desirable to have bi-directional communication (conditional clients being an initial use case). To achieve this, we are establishing two sets of API's: API for sending requests to light client modules this is what is proposed in #5084. This is yet to be designed, but I'm imagining something similar to the existing client state interface, but a bit more standardized API for sending requests to 02-client this is what is proposed here. As noted in this issue, there's two sets of API naturally exposed by 02-client. The message server and the grpc query server. As of today, these are intended for user <> ibc-go interaction, but they are reusable for module <> ibc-go interaction. The primary difference between the two is that the grpc query server does perform state changes and generally does not track gas unless marked as module safe and modified to handle gas (as noted in this issue) This issue outlines that there are two possible flows:
The first is a read-only query to a state modifying API (state changes discarded) during contract execution. The second is a sub-messages responses execution without an optional reply back to the contract with the message execution result. The only thing I find odd is that we make a read-only query to a state modifying API, but in 99% of cases, this is a non-state modifying action. Only solo machine modifies state during VerifyMembership and VerifyNonMembership. If we reworked solo machine to somehow not modify state during membership verification then these would be read-only, but simultaneously, that's a bit like treating the ante handler (sig verifier) as a type of query. But I don't think this is a substantial enough reason not to add the grpc routes I think we will likely be asked to support both approaches and I think it's possible we end up with a VerifyMembership grpc route and a VerifyMembership msg server handler (but that doesn't mean we need to support both now). Once we add a query route or msg service handler, I expect we commit to maintaining it for quite a while to avoid breaking contracts. |
We decided to move forward with this approach adding |
I updated the |
Credit to @colin-axner for writing #5112 and @webmaster128 for the helpful discussions on the idea
Summary
This proposal introduces a querier-based mechanism in
ibc-go
to enable conditional clients, based on the requirements and workflows outlined in #5112. It specifically enables light clients to query other light clients through gRPC, offering a non-intrusive solution. A key feature of this proposal is the introduction of a non-state-modifying proof verification query within the02-client
module, which streamlines the process of implementing conditional clients, particularly within the08-wasm
module. The document details necessary modifications to both the02-client
and08-wasm
modules and includes a proof of concept branch (outdated08-wasm
). Additionally, the proposal contrasts this approach with an alternative method based on a gRPC message server, to provide a comprehensive view of potential gRPC based solutions.Problem Definition
Issue #5112 introduced the concept of conditional execution in light clients, dependent on the state of another light client. Traditional light client modules in our framework lack the capability to execute code conditionally based on the state of other modules. While we have extended the functionality in the
08-wasm
module (see #5192) by allowing chains to provide a custom querier, a more comprehensive solution is needed to facilitate conditional execution between light clients.At present, the interaction between light client modules and the core
02-client
module is unidirectional: the02-client
can only send information to light clients without receiving any queries in return. This proposal aims to enable light clients to query other light clients (or even modules if enabled) via theGRPCQueryRouter
in BaseApp.The
02-client
already includes a query gRPC service in its keeper, which enables querying light client states. A gap in the current model is the lack of queries for proof verification. To address this, we propose introducing a non-state-modifying proof verification query in the02-client
module. This enhancement will reduce the engineering complexity and dependencies involved in building conditional clients.Here is an example workflow to illustrate the proposed solution based on #5112:
07-tendermint
) on the counterparty chain (say Osmosis).QueryVerifyMembershipProofRequest
for the inclusion of the state header on Celestia's client.true
, the conditional client performs the proof verification on the inclusion of the packet commitment in the state header of the conditional client.Proposal
02-client
modificationsOur approach introduces a new query,
VerifyMembershipProof
, to the02-client
module. Note that this query is marked asmodule_query_safe
to highlight that it can be safely called from within the state machine. This requires that we ensure that the query is deterministic and has its gas usage tracked.This proposal only introduces the
VerifyMembershipProof
query because it wasn't clear if other queries would be needed. We can add more queries in the same manner if needed.In implementing this, a new gRPC query handler is added to the
02-client
module:08-wasm
modificationsQueriers have already been introduced to
08-wasm
as a part of #5325. Thus, the only change that needs to be done is to enable this query type by default in/modules/light-clients/08-wasm/types/querier.go
Other clients
Clients that don't need to depend on other light clients can continue to be implemented as they are now.
For those requiring inter-client dependencies,
02-client
's query server offers a streamlined method to interact through gRPC or by directly accessing the02-client
keeper.Pros and Cons
A proof of concept implementation of this proposal is in the
serdar/poc-querier-conditional-clients
branch. (Outdated with respect to08-wasm
modifications, but not outdated for02-client
modifications)Pros
02-client
, enhancing flexibility.VerifyMembershipProof
facilitates proof verification through gRPC by any on-chain or off-chain entity.Cons
VerifyMembership
is technically a state modifying method, but we are using it in a non-state modifying query. This is a bit of a hack.08-wasm
module might require maintenance for a whitelist of queries or its conversion into a chain parameter.VerifyNonMembershipProof
, we need to add a new query handler to the02-client
module.Pros and Cons
Pros
02-client
. ( Always enabled )Cons
ibc-go
.VerifyNonMembershipProof
, we need to add a new message handler to the02-client
module.Conclusion
Considering the advantages and limitations of both the gRPC querier and message server approaches, the querier method appears more suitable for conditional clients in the current context. It offers a non-intrusive, flexible solution compatible with existing systems. However, should there be a future need for comprehensive state-modifying inter-client communication, the message server approach remains a viable option to explore.
For Admin Use
The text was updated successfully, but these errors were encountered: