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

Add Query for tracking ICA msg execution #2300

Closed
3 tasks
okwme opened this issue Sep 16, 2022 · 8 comments
Closed
3 tasks

Add Query for tracking ICA msg execution #2300

okwme opened this issue Sep 16, 2022 · 8 comments
Assignees
Milestone

Comments

@okwme
Copy link

okwme commented Sep 16, 2022

Summary

Add a query to host and controller chains to make it easy to see the results of a message executed with interchain accounts. These messages aren't executed in the way normal messages are where the user is given a tx hash to query. There is a tx hash but it's difficult to know what it will be since it is submitted by some relayer.

Problem Definition

Pasting the relevant parts of a conversation in the IBC internal slack channel about querying the results of interchain account msg execution under Problem Definition.

it looks like the only query the host module of ica has is for the params. I guess when a message is submitted via ICA it's the relayer's tx that contains information about the execution of the ICA msg right? Is there a convenient method for the user/module that initiated the ICA msg (controller side) to query the host about the results of the Msg? I know there is some Ack logic in the controller demo but it has to be custom created to handle each msg type and isn't necessary unless there is some action that takes place depending on the results of the execution.

basically what i'm looking for is how to check the results of the ICA msg on the host chain. Would the flow be something like:

  • controller chain generates outgoing IBC packet (this has some kind of UID?)
  • query the host chain for a transaction that contains the incoming IBC packet by UID(?)
  • once you know the tx hash on the host chain you can query the tx for events about the execution of the actual Msg?

...

as a user who initiated the transaction would i do the following:

  • submit my IBC transaction on controller chain
  • look in my successful tx for EventTypeSendPacket which contains all the unique info of my outgoing packet. However I don't see any universal unique ID here that I might be able to query on the host chain.

Now I know that there's the possibility for the packet to be submitted to the host chain but I don't know who will do it so I don't know what the tx hash of that tx will be. Is there any generic query on the host chain to ask for the tx that contained my message?

is it possible to query the host chain for transactions that contain EventTypeRecvPacket messages where all the attributes from EventTypeSendPacket are the same?

...

You can query all txs on the host by running something like this:

icad q txs --events 'recv_packet.packet_src_port=icacontroller-cosmos1m9l358xunhhwds0568za49mzhvuxx9uxre5tud' -o json | jq

where the event attribute of interest is the channel source port. Piping the JSON output through jq is a little more readable, but you do get quiet a hefty response, as the relayer sends a multi msg tx including the MsgUpdateClient as well as the MsgRecvPacket.

...

I wonder if it's worth considering a new query on the host chain that is designed for this specifically? maybe like the tx command but for messages that have been executed by an ICA? Adding new queries doesn't break state so it could be a patch release down the line and not block any major or minor releases in the mean time.

just thinking it would make debugging ICA account interactions easier for users and eventually wallets / applications.

...

In the v6.0.0 release (with the ICA improvements) the MsgSendTxResponse will include the sequence number, so maybe we can use that on the query on the host to get information about the message execution. Although then any custom authentication modules (like mauth) would need to implement also a response message that includes the sequence (i.e. adding it here).

Proposal

On the controller chain make it easy to retrieve a set of unique identifiers for a message sent over ICA using a new query (or the result returned from the originally executed message)

On the host chain create a query that accepts the set of unique identifiers for a message sent over ICA to return results similar to a tx query for that specific set of messages.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged/assigned
@crodriguezvega crodriguezvega added 27-interchain-accounts needs discussion Issues that need discussion before they can be worked on labels Sep 19, 2022
@crodriguezvega crodriguezvega added this to the v6.0.0 milestone Sep 26, 2022
@crodriguezvega
Copy link
Contributor

crodriguezvega commented Sep 26, 2022

@okwme Thanks for opening the issue and raising awareness for this problem.

After discussing with the rest of the team we have decided the following:

  • We will use this issue to implement a CLI query on the controller chain that will check if the acknowledgment for a packet was successful or not. This will be part of the v6 release, but we think that we can back port this CLI to previous version (v3, v4, v5).
  • For pre-v6 ibc-go, the custom authentication modules should implement the OnAcknowledgment callback and check whether the ack contains an error or not. You can do that with a simple switch like it is done here for transfer. Then on each case of the switch statement you can log or emit an event.

@crodriguezvega crodriguezvega removed the needs discussion Issues that need discussion before they can be worked on label Oct 4, 2022
@okwme
Copy link
Author

okwme commented Oct 5, 2022

It's nice to be able to see from the controller side whether the tx was successful in the Ack but it does not achieve the goals stated in the issue above unless all of the events are also carried through the Ack. As a user I want to know whether my tx was successful and what the events that followed were and this is only possible by querying the host side.

@AdityaSripal mentioned that a new packet ID system was being implemented, being able to query the host for the packet ID and receiving the events would satisfy the flow I'm describing I believe.

@colin-axner
Copy link
Contributor

Hey @okwme, what is your use case? Is this only going to be used for testing purposes?

@okwme
Copy link
Author

okwme commented Oct 5, 2022

As someone who is facillitating a governance enabled interchain account transaction I need to populate the gov module with correct subsequent transactions to be voted on. One flow in mind is adding liquidity to an osmosis pool or swapping tokens on an osmosis pool. It should be possible to query the account for LP tokens or resulting tokens but if the account already has a balance it is much safer to check the event logs to ensure the correct amount.

Since ICA can be used with any variety of host chain modules I would expect there to be a generalized way to query resulting events.

Beyond being the party resposible for checking gov ICA messages and setting up subsequent ones there is, as you said, a need just for debugging that this would enable.

@crodriguezvega crodriguezvega added the needs discussion Issues that need discussion before they can be worked on label Oct 6, 2022
@colin-axner
Copy link
Contributor

Thanks for the followup @okwme. We will add a cli to the host chain which takes in the channel-id and sequence on the host chain side and returns the events associated with the ica tx execution


For the implementer, see how sdk queries events via cli

@colin-axner colin-axner removed the needs discussion Issues that need discussion before they can be worked on label Oct 10, 2022
@damiannolan
Copy link
Member

Events aren't included in the ack sent to the controller due to the nondeterminism.

being able to query the host for the packet ID and receiving the events would satisfy the flow I'm describing I believe.

We implemented a query on the host for packet events in: #782

@crodriguezvega
Copy link
Contributor

We implemented a query on the host for packet events in: #782

So good that you remembered about this, @damiannolan! :) So then we can close this issue?

@damiannolan
Copy link
Member

Closing as packet events query implemented in #782 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

4 participants