Extend ibc receive with advanced variant #1640
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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::Abortvariant. There is a correspondingAdvContractError, which serializes likeContractError, 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 sameibc_packet_receiveexport, but has another handler that expects a function that returnsAdvResult<>notResult<>. I demo how this can be used inibc-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.