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
IBC Callbacks #2025
base: main
Are you sure you want to change the base?
IBC Callbacks #2025
Conversation
2aed858
to
3b18e9e
Compare
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.
Cool stuff! Very incomplete but some first thoughts. Thanks for the nice documentation, very helpful.
83c2b6a
to
ee37d1e
Compare
1f0f92c
to
6aa17e2
Compare
15eab52
to
5a7f6b6
Compare
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! (from my point of view with more limited understanding)
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 job, clean and straight forward
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] | ||
pub struct IbcDestinationChainCallbackMsg { | ||
pub packet: IbcPacket, | ||
pub ack: IbcAcknowledgement, |
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.
On the destination chain, how do we know if there is an ack or not?
- What about notifications for timeouts (e.g. someone tried to send you funds but failed)?
- What about cases where a packet is received but no acknowledgement is written because the protocol never writes 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.
In general we don't know that, but I just learned that my understanding of how this works was slightly off. Here's how it actually works:
If the ack is async (using WriteAcknowledgement), then the callback is called both for successful and unsuccessful acknowledgements.
If the ack is not async (by returning from OnRecvPacket), then the callback is only called if it was successful.
I originally thought only successful acks cause a callback, so we need to change the interface here to convey whether it was successful or not.
- Regarding timeout: The destination chain does not get to know about timeouts because (AFAIK) the IBC protocol has no mechanism for that. It would require the protocol built on top to support it (by sending another packet).
- Regarding no ack: If no ack is written, no callback is received.
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.
The destination chain doesn't know about timeouts at all (even core ibc), so it is not possible to do a callback anyway.
If OnRecvPacket
returns an unsuccessful ack, core ibc reverts the cached context, so there is no reason to make a callback since it'd be reverted anyway. The intuition is that an unsuccessful ack means that the packet couldn't be received. The knowledge that a sender has attempted and failed to make a transfer is only useful to the sender (not the destination).
However, things get more complicated with async acknowledgements. (Note that no application in ibc-go currently supports async acknowledgements.) This is because async acknowledgements are initiated by an application module, not core ibc (unlike RecvPacket). This means that the decision to revert state on unsuccessful acknowledgement is up to the application module, and thus, we perform the callback in this case.
5a7f6b6
to
ff8b0f5
Compare
7b98eb6
to
2ea0c1f
Compare
97ea02f
to
35d1592
Compare
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.
Thank you for this amazing work. Left some of my thoughts. Always feel free to ping me.
Co-authored-by: srdtrk <59252793+srdtrk@users.noreply.github.com>
fb845d9
to
381be55
Compare
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.
🥳🥳🥳
packages/vm/src/calls.rs
Outdated
/// Max length (in bytes) of the result data from a ibc_source_chain_callback call. | ||
pub const RESULT_IBC_SOURCE_CHAIN_CALLBACK: usize = 64 * MI; | ||
/// Max length (in bytes) of the result data from a ibc_destination_chain_callback call. | ||
pub const RESULT_IBC_DESTINATION_CHAIN_CALLBACK: usize = 64 * MI; |
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.
Independent of this PR: those are generous limits given that the Wasm contract has a memory size limit of 32 MiB. See in wasmd
// contractMemoryLimit is the memory limit of each contract execution (in MiB)
// constant value so all nodes run with the same limit.
const contractMemoryLimit = 32
Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com>
closes #1938
Implements the following:
ibc-callbacks
contract: a new contract that keeps track of the callbacks that were called and provides a query to get the data that was passed to the callbacks. This is used in wasmd for an e2e test.ibc_source_chain_callback
andibc_destination_chain_callback
, as well as the corresponding message typesIbcCallbackRequest
type (and types it contains): Allows constructing the json format for thememo
field with strong typing