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

bug: submessages broken when using WithMessageHandler #1735

Closed
Reecepbcups opened this issue Nov 20, 2023 · 3 comments
Closed

bug: submessages broken when using WithMessageHandler #1735

Reecepbcups opened this issue Nov 20, 2023 · 3 comments

Comments

@Reecepbcups
Copy link

Reecepbcups commented Nov 20, 2023

Bug

Submessages do not work via contract since v0.43.

Juno's Uni testnet has had this with

  • 0.43 + wasmvm 1.4
  • 0.45 + wasmvm 1.5 (upgraded to today).

This did not happen on 0.42.

Codebase: Juno v18.0.0-alpha.3

Terp network has also had this issue (reported in the cosmwasm discord)

Full Error 0.43

Error: rpc error: code = Unknown desc = rpc error: code = Unknown desc = failed to execute message; message index: 0: dispatch: submessages: unknown message from the contract [CosmWasm/[email protected]/x/wasm/keeper/keeper.go:1247] With gas wanted: '100000000' and gas used: '115661' : unknown request
9:36AM ERR failure when running app err="rpc error: code = Unknown desc = rpc error: code = Unknown desc = failed to execute message; message index: 0: dispatch: submessages: unknown message from the contract [CosmWasm/[email protected]/x/wasm/keeper/keeper.go:1247] With gas wanted: '100000000' and gas used: '115661' : unknown request"

Full error 0.45

Error: rpc error: code = Unknown desc = rpc error: code = Unknown desc = failed to execute message; message index: 0: dispatch: submessages: unknown message from the contract [CosmWasm/[email protected]/x/wasm/keeper/keeper.go:1247] With gas wanted: '100000000' and gas used: '117137' : unknown request
12:06AM ERR failure when running app err="rpc error: code = Unknown desc = rpc error: code = Unknown desc = failed to execute message; message index: 0: dispatch: submessages: unknown message from the contract [CosmWasm/[email protected]/x/wasm/keeper/keeper.go:1247] With gas wanted: '100000000' and gas used: '117137' : unknown request"

Reproduce:

(credit to mr_t of Ark protocol for this)

- Compile https://github.com/CosmWasm/cw-nfts/tree/main/contracts/cw721-base  (code id 3743 on Uni testnet)

# create contract instance
junod tx wasm instantiate 3743 '{"name":"Reece #00001", "symbol":"juno-reece-test-#00001", "minter":"juno15twk6xu5rnrrlnf7c5zy92gvykcs4h5ucxzzqq"}' --from validator --label 'JUNO Ark Test #00001' --admin juno15twk6xu5rnrrlnf7c5zy92gvykcs4h5ucxzzqq --gas-prices 0.0045ujunox --gas auto --gas-adjustment 1.5 -b sync --yes --node https://uni-rpc.reece.sh:443 --chain-id uni-6 --output json

# mint token
junod tx wasm execute juno1jvx62zqj3wucmwuxa9e8uuawv9ljgzg22uhjzw7mze2x9tamcz8qhrq7xt '{"mint": {"token_id":"00000", "owner":"juno15twk6xu5rnrrlnf7c5zy92gvykcs4h5ucxzzqq" }}' --from validator --gas-prices 0.0045ujunox --gas auto --gas-adjustment 1.5 -b sync --chain-id uni-6 --node https://uni-rpc.reece.sh:443 --yes --output json

# use a sub message from any contract
junod tx wasm execute juno1jvx62zqj3wucmwuxa9e8uuawv9ljgzg22uhjzw7mze2x9tamcz8qhrq7xt '{"send_nft": { "contract": "juno16u3qcynv998c6yt9kpr32anm55prsusmvp0exlk6u45lp5rk3rhqjzmdfp", "token_id": "00000", "msg": "b2s=" }}' --from validator --gas-prices 0.0045ujunox --gas auto --gas-adjustment 1.3 -b sync --yes --output json --chain-id uni-6 --node https://uni-rpc.reece.sh:443

Reported to affect their testnet contracts by:

  • James O
  • Mr T
  • Whalelphant

Request

add a e2e with submessage execution along with the patch

@Reecepbcups Reecepbcups changed the title bug: wasmd 0.45 breaks submessages bug: v0.43+ breaks contract submessages Nov 20, 2023
@alpe
Copy link
Contributor

alpe commented Nov 21, 2023

Thank you @Reecepbcups for your bug report!

Sub-message handling is a core part of wasmd and any problems are very had to trace on test or production systems.
I have tried to replicate the issue that you reported with the last release artifact of cw721-base and also the code with id 3743 that you had referenced in your report with our vanilla wasmd but failed.
@chipshort was so kind to contribute a test contract for the receiver side so that we had a full contract-to-contract setup in e2e and system tests. #1736

When I took a brief look at the linked Juno version, I could see that not the default wasmd message handler was used but a custom setup is passed to the wasm keeper. Our BurnCoinMessageHandler handles only one specific message and fails for all the others. This setup seems to be the root cause for your problems.
The keeper options come with a lot of power and almost no docs. In your case it may have been easier to chain your burn handler setup before the default handler chain You can find an example in the MS repo.

I would close this issue tomorrow.

@Reecepbcups
Copy link
Author

Thank you so much for this! I really appreciate it 😄

I had not considered it being related to the BurnPlugin since that is only Juno specific. Looks like Terp network blindly copy pasted that into their repo which is why it affected them too.

@Reecepbcups Reecepbcups changed the title bug: v0.43+ breaks contract submessages bug: submessages broken when using WithMessageHandler Nov 21, 2023
@hard-nett
Copy link

Thank you for the the insight & examples from both of you, much more clarity on the wasmOpts 👍

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

No branches or pull requests

3 participants