Replies: 4 comments 7 replies
-
This is how |
Beta Was this translation helpful? Give feedback.
-
We could probably have system error codes defined as negatives. That way, the simulator will know if a program created an error that is reserved and return a specific error for that. |
Beta Was this translation helpful? Give feedback.
-
What do you mean here? And Maybe we should come up with a list of potential error cases so that we have a better defined problem space. |
Beta Was this translation helpful? Give feedback.
-
Thanks @richardpringle , so it becomes clear that we need to frame this feature more clearly. I will take popular projects and explain why these may need faillible external calls.
It's becoming quite clear that some of these errors are fatal, and that we may probably not want them in the user space. Programs don't need to deal with potential bugs in the hypersdk or if they are doing really unsafe stuff, with the wasmlanche-sdk we want to give them the maximum freedom without footguns. If there is something that cannot be done, then we should implement it. It probably doesn't make sense to be able to catch the "out of gas" error, since if we meter every instruction later, then there is nothing else that the program can do once it runs out of fuel. I'm not sure that a fuel check before a call would be very helpful, it would even be quite redundant and probably require a host call that crosses the WASM boundary, which costs fuel. I think that we are left with the last case being either an inexistent function if the program is calling untrusted code, or that the execution panicked. There is a last question left: Should program authors be encouraged to panic vs returning an error ? My guess is that they should not. Catching a panic is helpful, but doing pattern matching on a panic is cumbersome. For instance, if an |
Beta Was this translation helpful? Give feedback.
-
Returning a faillible type from external program calls has been a concern since some time because two of these issues have been raised: #666 and #595 and because of the recent updates, we are probably more than ever ready for this to be implemented.
Currently, external calls will panic in the runtime and this is probably not a great way of doing since we cannot handle errors at all in the execution as they will halt the whole execution.
If we look at the implementation of program-to-program calls, they return a single 32 bits value which is the pointer to the return data. We currently cannot use multi values to return an error code as the 2nd value of the tuple, as they are not implemented in the official target.
This discussion is still at the research state, so I will add possible paths that we can explore further.
wasm-bindgen
does something similar so we might want to do that:Beta Was this translation helpful? Give feedback.
All reactions