cosmwasm
cosmwasm copied to clipboard
Add a way to inter-call(msg and query) using protobuf messages (stargate msg, stargate query)
Does this (https://github.com/line/cosmwasm/blob/25690c3b58c3e9deee077b528543d45746d1403d/packages/std/src/results/cosmos_msg.rs#L30-L36) message include ibc protobuf message?
Or, this issue aims inter-call/all cosmwasm msg wraps into protobuf format message?
My idea is to remove the other CosmosMsgs but leave only StargateMsg.
To do that, we'll need to add a way to generate a Binary. https://github.com/line/cosmwasm/blob/25690c3b58c3e9deee077b528543d45746d1403d/packages/std/src/results/cosmos_msg.rs#L35
Can you check these two repos? They may be a hint. https://github.com/cosmos/cosmos-rust https://github.com/cosmos/cosmos-rust/tree/main/cosmos-sdk-rs
The IBC
should be optional as before. I think we can do it by making cfg
for proto files(or proto generated files or ...).
And we should use a new style msg invoking.
https://github.com/line/lfb-sdk/blob/1e36431bf95bad4e09823ca39dae89b6d88a4e96/x/wasm/internal/keeper/keeper.go#L832
The current is a legacy style msg invoking, seems not to be able to handle proto msg. https://github.com/line/lfb-sdk/blob/1e36431bf95bad4e09823ca39dae89b6d88a4e96/x/wasm/internal/keeper/handler_plugin.go#L369-L373
old style: handler new style: msgServer
Could you look into it?
I will do
- [x] Fork cosmos-sdk-rust and make our version of cosmos-sdk-proto.
- [x] Test using it with integration-test
- [x] Remake contracts using proto messages
- [x] Research about CosmWasm ibc messages. (Can we use cosmos-ibc?)
- [ ] Removing other messages (Moved to other issues )
Looks good as a first step. Let's implement your plan first and plan further work(Removing cosmos-msg, legacy handler, ...).
Research Report
Almost all messages in https://github.com/line/cosmwasm/blob/main/packages/std/src/results/cosmos_msg.rs correspond to SDK's message and are handled by https://github.com/line/lfb-sdk/blob/7214594363f82d35245b7a0ea6d98397dfa3a78f/x/wasm/keeper/handler_plugin.go#L368-L411 except BankMsg::Burn
and IbcMsg::SendPacket
. Other than these two messages have proto form and can use CosmosMsg::Stargate
.
But, using CosmosMsg::Stargate
instead of other than two messages is not very simple. This is because sdk/x/wasm's encoder complements some fields of issued cosmos messages. For example, BankMsg::Send
are complemented from_address
field (https://github.com/line/lfb-sdk/blob/7214594363f82d35245b7a0ea6d98397dfa3a78f/x/wasm/keeper/handler_plugin.go#L142-L159). ForIbcMsg
, complementing is more complex (https://github.com/line/lfb-sdk/blob/7214594363f82d35245b7a0ea6d98397dfa3a78f/x/wasm/keeper/handler_plugin.go#L308-L336). Before removing these messages and replace them with CosmWasm::Stargate
we should discuss it.
How to encode and decode data
of IbcMsg::SendPacket
is on each contract, so it can use the proto message way.
BankMsg::Burn
and IBCMsg::SendPacket
are handled by https://github.com/line/lfb-sdk/blob/7214594363f82d35245b7a0ea6d98397dfa3a78f/x/wasm/keeper/handler_plugin.go#L413-L523 part. These two messages request sdk/x/wasm using a handler chain to handle msgs from contracts. If we remake the cosmwasm contract's response interface and separate these two messages and other messages into two vectors (arrays), it can be simpler. I think it should be discussed in another issue.