-
Notifications
You must be signed in to change notification settings - Fork 409
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
Update ibc handling to accommodate ibc v3 #697
Comments
Personally, I would like to take advantage of the new interface. Here are the conditions we want to ensure keep working:
Here are some open cases to cover.
Why do I say this? Look at the hoops we must do for a very simple handler:
And this is a simple case. If we actually changed state of the main contract in |
I have looked at the code in wasmvm again and we actually handle 1+3. There is currently no way for a contract to revert state AND confirm the ACK. A contract failure |
I think we have different meanings for 3. We currently handle 1, 2, and 4. 1 and 2 inside the contract (look the same to wasmd) and 4 is just returning a go error. 3 is not possible now, but is made possible by the new Acknowledgement interface |
To accomplish this, we would need to define some standard way to encode unchecked errors. A contract can return errors and make use of that, or they be careful not to return errors ever, fall into case 2 and use anything they want. ics20 and the new ics27 and using the same Acknowledgement type here. Let's just do this |
When I think about the possible scenarios then I have the following in mind:
I would consider the first 3 application (contract) level scenarios. The contract is in full control and needs to modify state only. No Go errors returned. |
You mean We currently handle (1) and (2) with If we implement the requested changes to wasmvm, we should have all info needed to distinguish between 3 and 4. |
PR to update wasmvm is made |
Both protocols have a very limited scope use cases. For dynamic IBC we target a much greater audience and therefore can not make any assumption on the transported data nor what is considered success or failure on the application level.
Thanks for for the example. I have overseen that When I try to map the This would allow all 4 cases. There is a little smell with
I had updated this post later. |
1 and 2 are both Resp.OK They are both implemented now like that |
Current:
proposed:
|
Let me be blunt. Most go ibc code is coming from the core ibc interchain team. They wrote Ibc-Go v2. Everyone else writing such protocols (Desmos) will most likely follow their idioms. These are now using the Acknowledgement type. Existing CosmWasm code (protocols) will have to use the same format when we want to intercommunicate (cw20-ics20). New CosmWasm-only protocols can pick any encoding they want, so why not the standard. By allowing (2) We allow someone to take extra care not to return errors and in return get full control over their encoding. (This is possible). By using a standard for (3) we make it much easier to interoperate with this standard. I agree to your point that we should not limit the potential (and thus not wrap the success case in (1)). And I appreciate pushing me to make this work as it does now, so we know full customisation is possible. But I do not understand the resistance to making the normal case much easier. I have written these contracts, (3) would be a huge simplification for coding. In fact, I could make 2 versions of cw20-ics20 using both approaches and add ts-relayer tests for them, to ensure they work with the "standard" or with full control of error encoding. |
Sorry, I modified my comment not aware that you answered already.
As I wrote later standardization is a good thing. But I have more the view of a network protocol with data + rollback in wasmd than application payload + error. I definitively agree that the contract developer should not have to care about these details. |
We cannot handle any rollback over multiple submessages in cosmwasm stdlib. This can only be handled in x/wasm level. |
I think we have addressed this already as part of the v0.45 upgrade. We have much nicer rollback semantics now. @alpe can I close this? |
With the current ibc implementation, we take great care a contract never errors on ibc_recv_packet. It must also take care to roll back any state internally on error (using submessage to self if needed). Any error it returns would revert the entire transaction, rather than signal a failure in the acknowledgement.
In ibcv2, we have 4 cases to cover:
(1 and 2 we handled by the current version, only difference is the interpretation of bytes in the ack data)
In https://github.com/CosmWasm/wasmvm/blob/main/lib.go#L540-L547 we unmarshall the response from the contract and consider a
Result::Err
from the contract the same as a VM error and convert both to a Go error. (VM error is "out of gas", "panic", "no ibc entry point" or other hard abort)One step suggested by @alpe would be returning the complete
IBCReceiveResult
rather than unmarshalling it in wasmvm. That will provide more info to the caller. However, how do we handle these two cases:Until wasmd 0.21 (on cosmos-sdk 0.42) both are handled the same and abort the transaction, which means the ibc packet is never recorded as received, so no ack can be returned to the sender. Can we do something better now?
The text was updated successfully, but these errors were encountered: