Finschia / cosmwasm

Fast and reusable WebAssembly smart contract runtime(and library) for finschia-sdk.
Apache License 2.0
27 stars 14 forks source link

Summarize what is happened when callee function is panicked #211

Closed loloicci closed 2 years ago

loloicci commented 2 years ago

Now there is no information in this repository on what is happened when a callee function panics.

This issue's aims are

The following are other issues' scope

da1suk8 commented 2 years ago

When wasmer executes a callee function and the callee function panics, the following error message is returned.

The callee function is executed by wasmer. function.rs#L623

When the callee function is called in instantiate

{.....,"codespace":"wasm","code":4,"data":"","raw_log":"failed to execute message; message index: 0: Error calling the VM: Error executing Wasm: Wasmer runtime error: RuntimeError: func_info:{module_name:CalleeContract, name:stub_pong, signature:[I32] -\u003e [I32]}, error:User error during call into backend: contract: not found: instantiate wasm contract failed","logs":[],.....}

When the callee function is called in execute

{..... ,"codespace":"wasm","code":5,"data":"","raw_log":"failed to execute message; message index: 0: Error calling the VM: Error executing Wasm: Wasmer runtime error: RuntimeError: func_info:{module_name:CalleeContract, name:stub_pong, signature:[I32] -\u003e [I32]}, error:Unknown error during call into backend: Some(\"Error executing Wasm: Wasmer runtime error: RuntimeError: unreachable\\n at \u003cunnamed\u003e (\u003cmodule\u003e[226]:0x1df00)\"): execute wasm contract failed","logs":[], .....}

When the callee function is called in migrate

{..... ,"codespace":"wasm","code":4,"data":"","raw_log":"failed to execute message; message index: 0: Error calling the VM: Error executing Wasm: Wasmer runtime error: RuntimeError: func_info:{module_name:CalleeContract, name:stub_pong, signature:[I32] -\u003e [I32]}, error:User error during call into backend: contract: not found: instantiate wasm contract failed","logs":[], .....}

When the callee function is called in query

{"codespace":"sdk","code":18,"message":"Error calling the VM: Error executing Wasm: Wasmer runtime error: RuntimeError: func_info:{module_name:CalleeContract, name:stub_pong, signature:[I32] -> [I32]}, error:User error during call into backend: contract: not found: query wasm contract failed: invalid request"}

Errors are returned here.

pong function, which is a function of callee, is implemented as follows.

#[callable_point]
fn pong(x: u64) -> u64 {
    if x > 10 {
        panic!();
    }
    x + 1
}

Found Task

loloicci commented 2 years ago

Nice work!