Skip to content

Update ibc handling to accommodate ibc v3 #697

@ethanfrey

Description

@ethanfrey

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. success
  2. application failure and NO rollback
  3. application error and rollback app state
  4. tx error and rollback ibc state as well

(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:

  1. contract returned error
  2. vm returned error

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions