CosmWasm / wasmd

Basic cosmos-sdk app with web assembly smart contracts
Other
369 stars 406 forks source link

Emit any redacted errors as events #1122

Open nicolaslara opened 1 year ago

nicolaslara commented 1 year ago

Since https://github.com/CosmWasm/wasmd/issues/759, any errors from submessages are redacted to avoid issues with non-determinism.

This means that a parent contract only has codespace/code as information to guess what happened and notify the user, which ends up leaving the user in the dark about what actually made their message fail.

A simple solution is to keep track of any errors generated in submessages and emit them as events. This leaves the interaction between contracts unaffected while surfacing the errors to the users (and contract devs in the process of debugging).

This can easily be implemented here: https://github.com/CosmWasm/wasmd/blob/main/x/wasm/keeper/msg_dispatcher.go#L150-L152 (or inside redactError if we pass the context)

alpe commented 1 year ago

Thanks for bringing attention to this topic. 👍

alpe commented 1 year ago

Events are emitted for successful TX, only. There may be no need to redact the contract errors with https://github.com/CosmWasm/cosmwasm/issues/1707