-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[codec] Calling proto.MessageName on sdk.Msgs after decoding a TX returns an empty string #8728
Comments
I meant using the tx decoder. I will update the description. |
|
I see, but it is implemented as proto.Message, in rosetta we use the proto messages utilities to facilitate construction and parsing of sdk messages in transactions, which needs to be treated in a generalized way. Plus, since sdk.Msg implements proto.Message, I think it's expected for it to behave as such. WDYT? |
Ah yeah, we did add proto.Message implementation, as a hack for legacy Msg compatibility, it will be removed once we remove legacy support. IMO, now we should panic on In Rosetta, I think the method you are looking for is
|
You mean on ServiceMsg?
No, I need the msg type so I can resolve it via interface registry, and then fill its fields. |
Yes, panic here (these 3 implementation methods are just hacky...).
I believe this is a XY problem. If you have a PR/branch, I'm happy to take a look and help, but I'm pretty sure calling |
With the current design, |
But calling Route() on an sdk.Msg returns the module key, or am I missing something?
BTW, maybe there's some confusion on the use case, but here is how in rosetta thanks to interface registry and the message name, we can allow users to build any kind of transaction (multiple messages, multiple signers, etc) in a generalized way. https://github.com/cosmos/cosmos-sdk/blob/frojdi/rosetta-balance-tracking/server/rosetta/convert/converter.go#L89
I would think about this, like building transactions with the tx builder by simply settings messages is convenient, and having it being wrapped in a service msg I think adds unnecessary complexity. Also in this case encoding sdk.Msgs and having decoded back sdk.ServiceMsg is inconsistent and should at some point be addressed.
I hope this does not mean we want to get rid of the proto implementations on messages, I think with the implementation of protov2 is gonna open up a lot of possibilities and cool tooling (ex: a generalized query and msg command builder) |
iirc we wanted that, but our Any packing of Msgs requires them to be proto.Messages. Panicking in the ServiceMsg proto.Message stubs is the next best thing i can think of. |
|
So, for example, when using the tx builder we should set msgs by wrapping them with ServiceMsg? And if I wanted to go back, let's say I'm given the route then I want to get the request (sdk.Msg) to use for that route, how should I go about that? With rosetta ATM we map requests using messages name, and use the interface registry to build messages, which seems a lot more easier than doing all the wrapping. |
More or less. We should probably add a
For a new ADR 031 only module, you should be able to use the interface registry to get the request type for a service method. Say for the method We can chat about this on the Friday call if you'd like. |
Thank you. I was not aware that the registry also mapped gRPC methods to request messages. Perhaps the only thing it'd be worth to talk about is how to cleanup some APIs to reflect the 031 spec? IMHO, some of them are a little confusing. Maybe we could open an issue and start listing them |
I think that's a great idea 👍 , we need an issue about txBuilder UX with ADR-031. Right now it's really not ideal. IMO it belongs to a bigger story, could you make sure to link relevant issues (#8138, #8270, #7541)? |
I think #8138 suffices for now. Let's just add more context there. |
Should we close this issue then if we have a clear action item tracked elsewhere? Or is there still something specific that we need to tackle from this? |
The only doubt I still have is understanding the cases in which tx encoding and decoding produces a tx in which msgs are wrapped as service msgs or not, just to avoid having to cast it in order to access functionalities such as Route() (which in unwrapped messages return the module key and not the gRPC methods) |
closing as service msgs are no longer in the sdk #9139 |
Summary of Bug
As per title, calling
proto.MessageName
on ansdk.Msg
contained in a decoded transaction (decoded via thesdk.TxDecoder
) returns an empty string.This happens because
sdk.Msg
s are wrapped intosdk.ServiceMsg
which does not fully and correctly implement theproto.Message
interface.We could make
sdk.ServiceMsg
return thesdk.Msg
implementation (which service msg wraps). But this could bring some recursivity issues assdk.ServiceMsg
implementssdk.MsgRequest
too, so I could wrap ansdk.ServiceMsg
as thesdk.MsgRequest
.Probably a better solution would be to get rid of
sdk.ServiceMsg
, and use plainsdk.Msg
s.From what I've seen,
sdk.ServiceMsg
is used only to provide a route for a givensdk.Msg
, most likely we could map routes using the msg (proto) name itself, instead of the method.If I'm missing some context, please feel free to correct me.
Version
Steps to Reproduce
For Admin Use
The text was updated successfully, but these errors were encountered: