Skip to content

Conversation

@ethanfrey
Copy link
Contributor

This is an experiment towards solving CosmWasm/wasmd#1220
To show it is possible and suggest a way forward. I do not expect this to be merged as is, and will likely need a lot of cleanup

Basically, I want to allow ibc_packet_receive to be able to return 3 types:

  • Ok - Success and return ack
  • Err - Rollback state changes and write an error string as ack
  • Abort - Completely rollback the transaction.

The last case is used in places where you have some external constaints. Eg. you only want whitelisted relayers to be able to relay on a channel. If another relayer submits the package, the whole Tx should fail, not just some error message. This is a very advanced use-case and not that common. Trying to "Rollback state changes and write an error string as ack" in an Ok response is very very difficult and we made the change to behavior of Err to empower 98% of the ibc contract devs. This is just for a very few special protocols that need a full abort.

My approach is to use another type for ibc_packet_receive. It returns AdvResult, which is like Result, but with a new ::Abort variant. There is a corresponding AdvContractError, which serializes like ContractError, but has one more variant.

The issue is that changing this is breaking to the API. My workaround is to add a new #[entry_point_adv] case, which generates the same ibc_packet_receive export, but has another handler that expects a function that returns AdvResult<> not Result<>. I demo how this can be used in ibc-reflect-send.

The other option I see if making this a CosmWasm 2.0 feature when we break APIs in a larger way. However, I would like to use this in some protocols in the next 3-6 months, and CosmWasm 2.0 seems much further off.

@webmaster128
Copy link
Member

In #1644 you find a version that is doing more or less the same. But in contrast to this PR, it uses a generic result trait to avoid the need to change entry point macros.

@webmaster128
Copy link
Member

As discussed, we use a different path documented in #1646

@webmaster128 webmaster128 deleted the extend-ibc-receive branch March 27, 2023 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants