Comments (14)
I think this may be an overflow when converting from our Decimal
to rust-decimal
' s Decimal
. There's a panic there that we're not currently handling / avoiding.
Thanks for the report. We will fix this asap.
from cw-tokens.
ah, 18 decimals... this causes all kinds of math overflows.
Why do you use that (besides habit from Ethereum)?
I mean, 6 or 9 decimals seems to suffice for almost any project.
The smallest measurement I have seen in use in Ethereum is GigaWei (for gas prices), which effectively is 9 decimal places.
Bitcoin works on 8, and still seems to be fine with that, even with $60.000/BTC (and 16 satoshi to $0.01)
from cw-tokens.
We can still avoid panic when converting, basically by checking / limiting the range of allowed values / decimal places.
from cw-tokens.
I am also having trouble executing a message on cosmwasm contract, and I am getting the same exact method in the OP:
Error: rpc error: code = InvalidArgument desc = Error calling the VM: Error executing Wasm: Wasmer runtime error: RuntimeError: unreachable: query wasm contract failed: invalid request
I am estimating the gas for a MsgExecute on a custom contract.
I've battle tested the contract locally and am at 90% test coverage, this only happens after the contract is deployed.
Is there any way to get a better error message or some stacktrace?
from cw-tokens.
Interesting. It would be good if you provide the data you're using / a path for reproducing this.
Perhaps it can be encoded as a unit test, or in any case, an integration test.
from cw-tokens.
Thanks for your reply.
I got error when I set the "INIT" as follows.
In addition, I haven't tried all the different cases, but...
When decimals, reserve_decimals, scale = 6, there is no error even if the curve_type is square_root.
~/dev/cw-plus tags/v0.10.0
❯ INIT='{"name": "bonding_curves_token","symbol": "BCT", "decimals": 18, "reserve_denom": "ucosm", "reserve_decimals": 18, "curve_type": {"square_root":{"slope":"1", "scale":18}}}'
~/dev/cw-plus tags/v0.10.0
❯ wasmd tx wasm instantiate $CODE_ID "$INIT" --home ~/.wasmd --keyring-backend test --keyring-dir ~/.wasmd_keys --from alice --label "bonding curves token" --chain-id localnet --gas-prices 1.2ucosm --gas auto --gas-adjustment 1.3 -y
gas estimate: 191782
{"height":"49","txhash":"432AE3896C06F9D8631B45F9BF5E74701126357353EF25BAFEDE9802C9A0316F","data":"0A3C0A0B696E7374616E7469617465122D0A2B7761736D3179796361303878716467766A7A3070736735367A3637656A6839786D73366C34396E74777730","raw_log":"[{\"events\":[{\"type\":\"instantiate\",\"attributes\":[{\"key\":\"_contract_address\",\"value\":\"wasm1yyca08xqdgvjz0psg56z67ejh9xms6l49ntww0\"},{\"key\":\"code_id\",\"value\":\"1\"}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"instantiate\"},{\"key\":\"module\",\"value\":\"wasm\"},{\"key\":\"sender\",\"value\":\"wasm10zyagjxmqjh2jn3sstpe7e2jkh430g6w6yqn7w\"}]}]}]","logs":[{"events":[{"type":"instantiate","attributes":[{"key":"_contract_address","value":"wasm1yyca08xqdgvjz0psg56z67ejh9xms6l49ntww0"},{"key":"code_id","value":"1"}]},{"type":"message","attributes":[{"key":"action","value":"instantiate"},{"key":"module","value":"wasm"},{"key":"sender","value":"wasm10zyagjxmqjh2jn3sstpe7e2jkh430g6w6yqn7w"}]}]}],"gas_wanted":"191782","gas_used":"160641"}
~/dev/cw-plus tags/v0.10.0
❯ CONTRACT=$(wasmd query wasm list-contract-by-code $CODE_ID $NODE --output json | jq -r '.contracts[-1]')
~/dev/cw-plus tags/v0.10.0
❯ wasmd query wasm contract-state smart $CONTRACT "$CURVEINFO" $NODE --output json
{"data":{"reserve":"0","supply":"0","spot_price":"0","reserve_denom":"ucosm"}}
~/dev/cw-plus tags/v0.10.0
❯ wasmd tx wasm execute $CONTRACT "$BUY" --home ~/.wasmd --keyring-backend test --keyring-dir ~/.wasmd_keys --from alice --amount 10ucosm --chain-id localnet --gas-prices 1.2ucosm --gas auto --gas-adjustment 1.3 -y
gas estimate: 176326
{"height":"52","txhash":"35D63C13AB8CC91381E6BAA600ED5C9AABA377C5C711FCC358759F667CBB6103","data":"0A090A0765786563757465","raw_log":"[{\"events\":[{\"type\":\"execute\",\"attributes\":[{\"key\":\"_contract_address\",\"value\":\"wasm1yyca08xqdgvjz0psg56z67ejh9xms6l49ntww0\"}]},{\"type\":\"message\",\"attributes\":[{\"key\":\"action\",\"value\":\"execute\"},{\"key\":\"module\",\"value\":\"wasm\"},{\"key\":\"sender\",\"value\":\"wasm10zyagjxmqjh2jn3sstpe7e2jkh430g6w6yqn7w\"}]},{\"type\":\"transfer\",\"attributes\":[{\"key\":\"recipient\",\"value\":\"wasm1yyca08xqdgvjz0psg56z67ejh9xms6l49ntww0\"},{\"key\":\"sender\",\"value\":\"wasm10zyagjxmqjh2jn3sstpe7e2jkh430g6w6yqn7w\"},{\"key\":\"amount\",\"value\":\"10ucosm\"}]},{\"type\":\"wasm\",\"attributes\":[{\"key\":\"_contract_address\",\"value\":\"wasm1yyca08xqdgvjz0psg56z67ejh9xms6l49ntww0\"},{\"key\":\"action\",\"value\":\"buy\"},{\"key\":\"from\",\"value\":\"wasm10zyagjxmqjh2jn3sstpe7e2jkh430g6w6yqn7w\"},{\"key\":\"reserve\",\"value\":\"10\"},{\"key\":\"supply\",\"value\":\"6082000000000000000\"}]}]}]","logs":[{"events":[{"type":"execute","attributes":[{"key":"_contract_address","value":"wasm1yyca08xqdgvjz0psg56z67ejh9xms6l49ntww0"}]},{"type":"message","attributes":[{"key":"action","value":"execute"},{"key":"module","value":"wasm"},{"key":"sender","value":"wasm10zyagjxmqjh2jn3sstpe7e2jkh430g6w6yqn7w"}]},{"type":"transfer","attributes":[{"key":"recipient","value":"wasm1yyca08xqdgvjz0psg56z67ejh9xms6l49ntww0"},{"key":"sender","value":"wasm10zyagjxmqjh2jn3sstpe7e2jkh430g6w6yqn7w"},{"key":"amount","value":"10ucosm"}]},{"type":"wasm","attributes":[{"key":"_contract_address","value":"wasm1yyca08xqdgvjz0psg56z67ejh9xms6l49ntww0"},{"key":"action","value":"buy"},{"key":"from","value":"wasm10zyagjxmqjh2jn3sstpe7e2jkh430g6w6yqn7w"},{"key":"reserve","value":"10"},{"key":"supply","value":"6082000000000000000"}]}]}],"gas_wanted":"176326","gas_used":"148751"}
~/dev/cw-plus tags/v0.10.0
❯ wasmd query wasm contract-state smart $CONTRACT "$CURVEINFO" $NODE --output json
Error: rpc error: code = InvalidArgument desc = Error calling the VM: Error executing Wasm: Wasmer runtime error: RuntimeError: unreachable: query wasm contract failed: invalid request
from cw-tokens.
I don't have to plan to use 18 decimals.
I think a check or limit to avoid panic is sufficient.
from cw-tokens.
I fully agree... a readable error message to the user is always better than a panic.
Removing the error condition (precision limit) can be discussed if there is a clear need. We would need to eg use u256 internally for all calculations, which may be a good idea? But checks/limits are 💯 need
from cw-tokens.
btw, cw20-bonding was written like 1 year ago and just updated to match versions.
It could probably use some care and cleanup in general.
If you are planning to deploy something on this to production, it would be good to revisit it and feel free to raise issues (and PRs 😄 ) on any points that seem a bit questionable.
I think I have an outstanding issue to allow cw20 as the input tokens, not just native
from cw-tokens.
Hello, i'm having the same issue. i'm working with U256...
here is some debug logs:
github.com/CosmWasm/wasmd/x/wasm/keeper.Keeper.execute
github.com/CosmWasm/[email protected]/x/wasm/keeper/keeper.go:355
github.com/CosmWasm/wasmd/x/wasm/keeper.PermissionedKeeper.Execute
github.com/CosmWasm/[email protected]/x/wasm/keeper/contract_keeper.go:50
github.com/CosmWasm/wasmd/x/wasm/keeper.msgServer.ExecuteContract
github.com/CosmWasm/[email protected]/x/wasm/keeper/msg_server.go:93
github.com/CosmWasm/wasmd/x/wasm/types._Msg_ExecuteContract_Handler.func1
github.com/CosmWasm/[email protected]/x/wasm/types/tx.pb.go:784
github.com/cosmos/cosmos-sdk/baseapp.(*MsgServiceRouter).RegisterService.func2.1
github.com/cosmos/[email protected]/baseapp/msg_service_router.go:113
github.com/CosmWasm/wasmd/x/wasm/types._Msg_ExecuteContract_Handler
github.com/CosmWasm/[email protected]/x/wasm/types/tx.pb.go:786
github.com/cosmos/cosmos-sdk/baseapp.(*MsgServiceRouter).RegisterService.func2
github.com/cosmos/[email protected]/baseapp/msg_service_router.go:117
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runMsgs
github.com/cosmos/[email protected]/baseapp/baseapp.go:720
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx
github.com/cosmos/[email protected]/baseapp/baseapp.go:677
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).DeliverTx
github.com/cosmos/[email protected]/baseapp/abci.go:276
github.com/tendermint/tendermint/abci/client.(*localClient).DeliverTxAsync
github.com/tendermint/[email protected]/abci/client/local_client.go:93
github.com/tendermint/tendermint/proxy.(*appConnConsensus).DeliverTxAsync
github.com/tendermint/[email protected]/proxy/app_conn.go:85
github.com/tendermint/tendermint/state.execBlockOnProxyApp
github.com/tendermint/[email protected]/state/execution.go:320
github.com/tendermint/tendermint/state.(*BlockExecutor).ApplyBlock
github.com/tendermint/[email protected]/state/execution.go:140
github.com/tendermint/tendermint/consensus.(*State).finalizeCommit
github.com/tendermint/[email protected]/consensus/state.go:1638
github.com/tendermint/tendermint/consensus.(*State).tryFinalizeCommit
github.com/tendermint/[email protected]/consensus/state.go:1547
github.com/tendermint/tendermint/consensus.(*State).enterCommit.func1
github.com/tendermint/[email protected]/consensus/state.go:1482
github.com/tendermint/tendermint/consensus.(*State).enterCommit
github.com/tendermint/[email protected]/consensus/state.go:1520
github.com/tendermint/tendermint/consensus.(*State).addVote
github.com/tendermint/[email protected]/consensus/state.go:2135
github.com/tendermint/tendermint/consensus.(*State).tryAddVote
github.com/tendermint/[email protected]/consensus/state.go:1933
github.com/tendermint/tendermint/consensus.(*State).handleMsg
github.com/tendermint/[email protected]/consensus/state.go:839
github.com/tendermint/tendermint/consensus.(*State).receiveRoutine
github.com/tendermint/[email protected]/consensus/state.go:783
failed to execute message; message index: 0:
Error calling the VM: Error executing Wasm: Wasmer runtime error: RuntimeError: unreachable: execute wasm contract failed" module=state
from cw-tokens.
I am getting this error,
Error: rpc error: code = InvalidArgument desc = unable to resolve type URL /cosmwasm.wasm.v1beta1.MsgStoreCode: tx parse error: invalid request
for this setup command from cosmwasm document
RES=$(wasmd tx wasm store target/wasm32-unknown-unknown/release/cw_nameservice.wasm --from fred $TXFLAG -y)
can anyone help me out in resolving?
from cw-tokens.
Hi,
I am also getting the same error when trying to upload data to a contract from a .csv file
CREATE='{"create_graph_from_file":{"filepath": "../AllEdges_Test.csv"}}
wasmd tx wasm execute $CONTRACT "$CREATE" --from admin $TXFLAG -y
I get the following error:
Error: rpc error: code = InvalidArgument desc = failed to execute message; message index: 0: Error
calling the VM:
Error executing Wasm: Wasmer runtime error:
RuntimeError: unreachable: execute wasm contract failed: invalid request
from cw-tokens.
If you use a cosmwasm 1.0.0 (no more rc) VM, ie. wasmd 0.27 or something that imports it, there is help.
Add features = ["abort"]
to cosmwasm-std in your Cargo.toml and rebuild the wasm file.
Then it will give you a better error message
See "But there's more..." in this article https://medium.com/cosmwasm/cosmwasm-1-0-0-finalized-fadc148f9e18
from cw-tokens.
I am upgrading to wasmd 0.27 and cw 1.0.0 to try and see.
I managed to add abort adding this to Cargo.toml
[features]
abort = []
from cw-tokens.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cw-tokens.