-
Notifications
You must be signed in to change notification settings - Fork 410
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
MessageHandlerChain DispatchMsg may be a problem #931
Comments
A message is one type? How can it be both? We loop through this function once for |
Then wasmvmtypes.CosmosMsg struct is fllow
When msg.BankMsg and msg.IBCMsg is not nil, and dispatch this msg, if In this case I think |
I write a unit test to prove this case. I simluate msg which have
|
@BananaLF The underlying JSON type comes from Rust contracts (until today) that use an enum there. This only allows exactly one of those fields to be set. We should add some validation logic in Go that exactly one field is set, if we haven't already. It is supposed to be an enum/union type, not some random set of items. If we fix that validation step, then the rest of your issue goes away, right? |
@ethanfrey Right ! |
Thanks for reporting this with a test to run! Very much appreciated! ❤️ I think there are only some wrong expectations related to the So why is your test failing? The Even in the case where we have multiple message fields in the To be completely on the safe side for a great dev UX, we can ensure that |
Yes, you are right, this can go into validation logic in wasmvm and in the next release. Not critical, but a nice to have. I created CosmWasm/wasmvm#349 and will close this issue. You an track progress there. |
Edit (ethanfrey): To solve we just need to add validation logic than only one variant of CosmosMsg is set. Read comments below.
The MessageHandlerChain.DispatchMsg may be problem.
wasmd/x/wasm/keeper/handler_plugin.go
Lines 128 to 141 in 2886092
This Line ignore err.unknownMsg when handler deal with unknownMsg which is correct in other handler. (like IBCRawPacketHandler deal with BankMsg ).
wasmd/x/wasm/keeper/handler_plugin.go
Line 134 in 2886092
But I think This Line can not ignore ,because handler may be deal with unknownMsg which EncodeBankMsg is error, other Encode**Msg is the same.
Like fllow:
wasmd/x/wasm/keeper/handler_plugin_encoders.go
Line 109 in 2886092
wasmd/x/wasm/keeper/handler_plugin_encoders.go
Line 128 in 2886092
case:
for _, h := range m.handlers
So I think MessageHandlerChain DispatchMsg is a problem.
Could your please answer my question?
The text was updated successfully, but these errors were encountered: