CosmWasm / wasmd

Basic cosmos-sdk app with web assembly smart contracts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: show text along with codespace numbers

taitruong opened this issue · comments

afaik sei chain does this, but many Cosmos chains doesnt. Ngl, would save a lot of time for devs.
It's quite tedious figuring out all the time what these codespace errors mean:
https://github.com/CosmWasm/wasmd/blob/7ea00e2ea858ed599141e322bd68171998a3259a/x/wasm/types/errors.go

Thanks for the feature request!
Errors are a bigger topic. We have to redact them for contracts to not contain host specific and therefore consensus breaking information. It is also quite easy to break backwards compatibility if a contract builds upon an error message and then this text is changed for some reason. Other than this, errors are handled by the SDK for IO.
Can you elaborate more on your scenario so that I can understand the use case better?
I could imagine a CLI command for example that can help to translate the codespace/ code into the error message...

i think that's what Sei did (but im not 100% sure), they used the CLI to interpret the error msgs, instead of adding them directly to the chain.

i could not agree more with @alpe solution of adding it to the CLI instead of anywhere else
this way we can keep things more agnostic at chain level

CLI helps, but in case of IBC, this wont help. Like errors are passed through ACK message.

There are two related topics here and we need to address them separately:

Errors in submessage replies

Currently redacted due to consensus problems. This will change for all errors coming from CosmWasm contracts with 2.0. The change is already implemented here and will be integrated into wasmd soon.

Errors in acknowledgements

channeltypes.NewErrorAcknowledgement from ibc-go which is used here does not even contain the codespace. We only get a code X and don't know if it is sdk/X or wasm/X or any other module:

func NewErrorAcknowledgement(err error) Acknowledgement {
	// the ABCI code is included in the abcitypes.ResponseDeliverTx hash
	// constructed in Tendermint and is therefore deterministic
	_, code, _ := errorsmod.ABCIInfo(err, false) // discard non-determinstic codespace and log values

	return Acknowledgement{
		Response: &Acknowledgement_Error{
			Error: fmt.Sprintf("ABCI code: %d: %s", code, ackErrorString),
		},
	}
}

This is because codespace is not part of consesus for some reason.

I think a wasmd port of NewErrorAcknowledgement replacing the call to ack = channeltypes.NewErrorAcknowledgement(err) from ibc-go would allow us to provide much more insights into the error acknowledgement. We must be extra careful to not introduce non-determinism. But I think we can do much better than just having the error code number there.

amazing!, good to know this is being worked on.

for new comers (devs with experience in other fields) and general new devs that are starting directly in blockchain and in cosmwasm it can be a bit frustrating and challenging to figure out what broke with the current errors.

i believe this change can help improve dev UX by a lot and be more welcoming to devs without tons of experience

thank you Simon

cheers!