Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the difference in codespace of error between execute and query intended behavior? #926

Closed
da1suk8 opened this issue Aug 8, 2022 · 3 comments · Fixed by #1125
Closed
Assignees

Comments

@da1suk8
Copy link

da1suk8 commented Aug 8, 2022

I would like to check something about the behavior of codespace when an error occurs in contract.

The following contract with errors was created, and the behavior of execute and query was investigated.
https://github.com/da1suk8/cosmwasm_cosmwasm/blob/error_behavior/contracts/queue/src/contract.rs

Please could you check below 2 points.

  1. When an error occurs, in execute, the codespace is wasm, and in query, the codespace is std. Is this intentional behavior?
  2. When an error occurs in query, usage is displayed, is this correct behavior?

please see below for log

$wasmd q wasm contract-state smart wasm1nc5tatafv6eyq7llkr2gv50ff9e22mnf70qgjlv737ktmt4eswrqr5j2ht '{"count":{}}'
Error: rpc error: code = InvalidArgument desc = Error calling the VM: Error executing Wasm: Wasmer runtime error: RuntimeError: Aborted: panicked at 'explicit panic', src/contract.rs:110:9: query wasm contract failed: invalid request
Usage:
wasmd query wasm contract-state smart [bech32_address] [query] [flags]
 
Flags:
--ascii ascii encoded query argument
--b64 base64 encoded query argument
--height int Use a specific height to query state at (this can error if the node is pruning state)
-h, --help help for smart
--hex hex encoded query argument
--node string <host>:<port> to Tendermint RPC interface for this chain (default "tcp://localhost:26657")
-o, --output string Output format (text|json) (default "text")
 
Global Flags:
--chain-id string The network chain ID
--home string directory for config and data (default "/Users/jp30571/.wasmd")
--log_format string The logging format (json|plain) (default "plain")
--log_level string The logging level (trace|debug|info|warn|error|fatal|panic) (default "info")
--trace print out full stack trace on errors
@da1suk8 da1suk8 changed the title Is the difference in codespace between execute and query intended behavior? Is the difference in codespace of error between execute and query intended behavior? Aug 8, 2022
@alpe alpe moved this to 🆕 New in wasmd backlog Sep 23, 2022
@alpe
Copy link
Contributor

alpe commented Sep 28, 2022

Thanks for bringing this up!

  1. the codespace reflects where the error was created. When a contract execution fails, then it is within the wasm module and it should be wasm. Same for smart queries. There are cases like out of gas, where this is not true and the std lib takes over
  2. For contracts the errors are redacted . For clients like the CLI, the server returns a redacted error or when setup with --trace flag, the full stacktrace.

Do you have some concrete examples for queries that return the std namespace?

@alpe alpe moved this from 🆕 New to ❓ Needs more info in wasmd backlog Sep 30, 2022
@pinosu pinosu self-assigned this Dec 13, 2022
@pinosu
Copy link
Contributor

pinosu commented Dec 16, 2022

this issue was fixed in #1068 . There is another problem in the smart query, when there is an error in the contract side e.g. wrong message is passed, then it panics and the following stack trace is printed.
Example:

wasmd q wasm contract-state smart wasm1wudavzm6w94ettwl4l4ty2hgaxlk03c9cxda84kqh9prnakn3rmq6ph297 '{"abc": ""}'
Error: rpc error: code = InvalidArgument desc = 
github.com/cosmos/cosmos-sdk/baseapp.gRPCErrorToSDKError
        github.com/cosmos/cosmos-sdk@v0.45.11/baseapp/abci.go:596
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).handleQueryGRPC
        github.com/cosmos/cosmos-sdk@v0.45.11/baseapp/abci.go:585
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).Query
        github.com/cosmos/cosmos-sdk@v0.45.11/baseapp/abci.go:427
github.com/tendermint/tendermint/abci/client.(*localClient).QuerySync
        github.com/tendermint/tendermint@v0.34.23/abci/client/local_client.go:256
github.com/tendermint/tendermint/proxy.(*appConnQuery).QuerySync
        github.com/tendermint/tendermint@v0.34.23/proxy/app_conn.go:159
github.com/tendermint/tendermint/rpc/core.ABCIQuery
        github.com/tendermint/tendermint@v0.34.23/rpc/core/abci.go:20
reflect.Value.call
        reflect/value.go:556
reflect.Value.Call
        reflect/value.go:339
github.com/tendermint/tendermint/rpc/jsonrpc/server.makeJSONRPCHandler.func1
        github.com/tendermint/tendermint@v0.34.23/rpc/jsonrpc/server/http_json_handler.go:108
github.com/tendermint/tendermint/rpc/jsonrpc/server.handleInvalidJSONRPCPaths.func1
        github.com/tendermint/tendermint@v0.34.23/rpc/jsonrpc/server/http_json_handler.go:140
net/http.HandlerFunc.ServeHTTP
        net/http/server.go:2084
net/http.(*ServeMux).ServeHTTP
        net/http/server.go:2462
github.com/tendermint/tendermint/rpc/jsonrpc/server.maxBytesHandler.ServeHTTP
        github.com/tendermint/tendermint@v0.34.23/rpc/jsonrpc/server/http_server.go:256
github.com/tendermint/tendermint/rpc/jsonrpc/server.RecoverAndLogHandler.func1
        github.com/tendermint/tendermint@v0.34.23/rpc/jsonrpc/server/http_server.go:229
net/http.HandlerFunc.ServeHTTP
        net/http/server.go:2084
net/http.serverHandler.ServeHTTP
        net/http/server.go:2916
net/http.(*conn).serve
        net/http/server.go:1966
Error parsing into type hackatom::msg::QueryMsg: unknown variant `abc`, expected one of `verifier`, `other_balance`, `recurse`: query wasm contract failed: invalid request

@github-project-automation github-project-automation bot moved this from ❓ Needs more info to ✅ Done in wasmd backlog Jan 10, 2023
@da1suk8
Copy link
Author

da1suk8 commented Jan 13, 2023

Sorry for the late response, thank you for your support and check.

@alpe alpe removed this from wasmd backlog Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants