- Source callbacks:
SendPacket
callbackOnAcknowledgementPacket
callbackOnTimeoutPacket
callback
- Destination callbacks:
ReceivePacket
callback
Callbacks are always executed after the packet has been processed by the underlying IBC module.
If the underlying application module is doing an asynchronous acknowledgement on packet receive (for example, if the packet forward middleware is in the stack, and is being used by this packet), then the callbacks middleware will execute the
ReceivePacket
callback after the acknowledgement has been received.Source Callbacks
Source callbacks are natively supported in the following ibc modules (if they are wrapped by the callbacks middleware):transfer
icacontroller
Destination Callbacks
Destination callbacks are natively only supported in the transfer module. Note that wrapping icahost is not supported. This is because icahost should be able to execute an arbitrary transaction anyway, and can call contracts or modules directly. To have your destination callbacks processed by the callbacks middleware, you must set the memo in the application’s packet data to the following format:User Defined Gas Limit
User defined gas limit was added for the following reasons:- To prevent callbacks from blocking packet lifecycle.
- To prevent relayers from being able to DOS the callback execution by sending a packet with a low amount of gas.
There is a chain wide parameter that sets the maximum gas limit that a user can set for a callback. This is to prevent a user from setting a gas limit that is too high for relayers. If the
"gas_limit"
is not set in the packet memo, then the maximum gas limit is used.SendPacket
callback is always reverted if the callback execution fails or returns an error for any reason. This is so that the packet is not sent if the callback execution fails.