@@ -23,34 +23,33 @@ include e.g.
2323
2424## Error handling
2525
26- In wasmvm those two error types are merged into one and handled as one thing in
27- the caller (wasmd):
28-
29- - [ Instantiate] ( https://github.com/CosmWasm/wasmvm/blob/v1.2.0/lib.go#L144-L151 )
30- - [ Execute] ( https://github.com/CosmWasm/wasmvm/blob/v1.2.0/lib.go#L192-L199 )
31- - [ Migtate] ( https://github.com/CosmWasm/wasmvm/blob/v1.2.0/lib.go#L275-L282 )
32- - [ Sudo] ( https://github.com/CosmWasm/wasmvm/blob/v1.2.0/lib.go#L318-L325 )
33- - [ Reply] ( https://github.com/CosmWasm/wasmvm/blob/v1.2.0/lib.go#L363-L370 )
34- - [ IBCChannelOpen] ( https://github.com/CosmWasm/wasmvm/blob/v1.2.0/lib.go#L406-L413 )
35- - [ IBCChannelConnect] ( https://github.com/CosmWasm/wasmvm/blob/v1.2.0/lib.go#L449-L456 )
36- - [ IBCChannelClose] ( https://github.com/CosmWasm/wasmvm/blob/v1.2.0/lib.go#L492-L499 )
37- - [ IBCPacketAck] ( https://github.com/CosmWasm/wasmvm/blob/v1.2.0/lib.go#L576-L583 )
38- - [ IBCPacketTimeout] ( https://github.com/CosmWasm/wasmvm/blob/v1.2.0/lib.go#L620-L627 )
39-
40- However, there is one exception:
41-
42- - [ IBCPacketReceive] ( https://github.com/CosmWasm/wasmvm/blob/v1.2.0/lib.go#L535-L539 )
43-
26+ Before version 2.0 those two error types were merged into one in wasmvm and
27+ handled as one thing in the caller (wasmd). See for example
28+ [ Instantiate] ( https://github.com/CosmWasm/wasmvm/blob/v1.2.0/lib.go#L144-L151 ) .
29+ However, there was one exception to this:
30+ [ IBCPacketReceive] ( https://github.com/CosmWasm/wasmvm/blob/v1.2.0/lib.go#L535-L539 ) .
4431Instead of returning only the contents of the ` Ok ` case, the whole
4532` IBCReceiveResult ` is returned. This allows the caller to handle the two layers
4633of errors differently.
4734
4835As pointed out by our auditors from Oak Security, this
49- [ is inconsistent] ( https://github.com/CosmWasm/wasmvm/issues/398 ) . Historically
36+ [ was inconsistent] ( https://github.com/CosmWasm/wasmvm/issues/398 ) . Historically
5037merging the two error types was the desired behaviour. When ` IBCPacketReceive `
5138came in, we needed the differentiation to be available in wasmd, which is why
52- the API is different than the others. Ideally we always return the contract
53- Result and let wasmd handle it.
39+ the API was different than the others.
40+
41+ In wasmvm >= 2.0 (wasmd >= 0.51), we
42+ [ always return the contract result] ( https://github.com/CosmWasm/wasmvm/blob/v2.0.0-rc.2/lib.go#L132 )
43+ and let wasmd handle it. Apart from making everything more consistent, this also
44+ allows wasmd to handle contract errors differently from VM errors.
45+
46+ Most errors returned by sub-messages are
47+ [ redacted] ( https://github.com/CosmWasm/wasmd/blob/v0.51.0-rc.1/x/wasm/keeper/msg_dispatcher.go#L205 )
48+ by wasmd before passing them back into the contract. The reason for this is the
49+ possible non-determinism of error messages. However, as contract errors come
50+ from the contract, they have to be deterministic. With the new separation, wasmd
51+ now passes the full contract error message back into the calling contract,
52+ massively improving the debugging experience.
5453
5554## Handing ibc_packet_receive errors
5655
0 commit comments