Replies: 3 comments 4 replies
-
Yeah, this would be cool. I designed something to do this a while ago but forgot to post it. My idea was to combine a small expression language like CEL with state charts. I'll try to dig up what I started writing and post it sometime this week |
Beta Was this translation helpful? Give feedback.
-
Great use-case. Solution: Put processed Msgs in a Transient StoreAn easy solution would be to create a new Transient Store with all previous messages and responses. It would be indexed by message index, and would contain the following: type ProcessedMsg struct {
Msg Msg
Resp MsgResponse // a new Any
} Then you would need to create a new message, to include an offset prameter referencing an output from the previous message. eg: message MsgIBCTransferWithPastPreMsgOutput {
byte msg_offset = 1; // 1 = previous message, 2 = prev prev message ...
string offset_attribute = 2; // eg tokenOutAmount
... other IBC transfer attributes
} Accessing the storeCurrently, a unique transient store is assign for every module requesting it.
|
Beta Was this translation helpful? Give feedback.
-
Have a look at "Promise Pipelining" from the Xanadu project as prior art, especially for error handling: https://wiki.c2.com/?PromisePipelining |
Beta Was this translation helpful? Give feedback.
-
In the SDK, we support "multimsg txs" which allow multiple sdk.Msgs to be packed into a single atomic tx. This is very useful for many ux flows. However, the usability of this is severely limited because the inputs of all msgs needs to be known at tx creation, meaning that subsequent msgs cannot be based on the input of previous msgs. To give a concrete example, imagine a user on Osmosis wanted to do a swap of
OSMO
toATOM
and then IBC the Atoms to the Cosmos Hub.They would ideally want to construct a multimsg tx that looks something like:
sdk.Msg[{Swap 5 OSMO to _X_ ATOM, IBC _X_ ATOM to Cosmos Hub}]
However, X cannot be known at the time of creating the tx, because of slippage and how AMMs work.
So ideally, what we would want is a way of piping an output from one msg into the input of a later msg.
To do this, we could make use of the MsgResponse of the msgs. For example, in Osmosis's MsgSwapResponse, we include the
tokenOutAmount
. If there was a way that in the IBC Transfer msg, we could signal to use theMsgSwapResponse.tokenOutAmount
at runtime instead of a pre-filled number.In the specific above case, we could hack this in because both the output and input are strings, and so we could special case a string format to signal doing pipelining during
runTx
(i.e. something like"|MsgSwapResponse.tokenOutAmount"
).However, this is not fully generalizable if the types were not strings, and were instead uint64 (for example an id of some sort).
How would we make this possible? Would it require turning every field in all proto structs for Msgs into some type of new interface or type? Would love to hear if anyone has any other ideas?
Beta Was this translation helpful? Give feedback.
All reactions