-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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]: math.LegacyDec
type is not deserialized in GRPC queries
#18430
Comments
We have bunch of queries that contain |
@robert-zaremba Did you try the one related to inflation? Same thing is reported here: forbole/callisto#655 |
No, I will try. |
The same thing happens for osmosis's ArithmeticTwap query on the latest version - we're using it to measure differences between Ojo's prices & osmosis's. I'll comment here if we find anything Code example:
Results in:
|
Update: I found an old SDK issue with the same problem. It was solved by adding this replace:
Relevant issue: #8426 I tested it for my problem above and the patch works for now @robert-zaremba @wojtek-coreum, but it should really be fixed |
@adamewozniak by any chance do you know the underlying issue? If a |
Didn't find any details as to the actual fix, though to me it makes the most sense that this bug is somewhere in the SDK if it reappeared only recently with the dec package moving. I'll post here if I have some time to look into it. Also, good to see you @alexanderbez ! |
@robert-zaremba when you use |
@tac0turtle @julienrbrt can someone pls check this out. the problem occurs for any use of |
I met the same issue when using this gRPC query, any updates? |
Just to add another instance of this bug, when trying to call some liquidity queries in Osmosis:
|
We're getting an instance of this with the newest osmosis version - the replace directive I mentioned doesn't work with
Update - if anyone else has this problem, we fixed it by overriding the codec GRPC uses to serialize: import proto "github.com/cosmos/gogoproto/proto"
...
type customCodec struct {
parentCodec encoding.Codec
}
func (c customCodec) Marshal(v interface{}) ([]byte, error) {
protoMsg, ok := v.(proto.Message)
if !ok {
return nil, fmt.Errorf("failed to assert proto.Message")
}
return proto.Marshal(protoMsg)
}
func (c customCodec) Unmarshal(data []byte, v interface{}) error {
protoMsg, ok := v.(proto.Message)
if !ok {
return fmt.Errorf("failed to assert proto.Message")
}
return proto.Unmarshal(data, protoMsg)
}
func (c customCodec) Name() string {
return "gogoproto"
}
// connectGRPC dials up our grpc connection endpoint.
func (c *Client) connectGRPC() error {
config := &tls.Config{
InsecureSkipVerify: false,
}
customCodec := &customCodec{parentCodec: encoding.GetCodec("proto")}
grpcOpts := []grpc.DialOption{
grpc.WithContextDialer(dial),
grpc.WithInsecure(),
grpc.WithDefaultCallOptions(grpc.ForceCodec(customCodec)),
}
if c.tls {
grpcOpts = []grpc.DialOption{
grpc.WithTransportCredentials(credentials.NewTLS(config)),
grpc.WithContextDialer(dial),
grpc.WithKeepaliveParams(keepalive.ClientParameters{}),
grpc.WithDefaultCallOptions(grpc.ForceCodec(customCodec)),
}
}
grpcConn, err := grpc.Dial(
c.grpcEndpoint,
grpcOpts...,
)
if err != nil {
return fmt.Errorf("failed to dial Cosmos gRPC service: %w", err)
}
c.grpcConnection = grpcConn
return nil
} |
@adamewozniak I had the same experience with
Thanks for your suggested fix, it also works in my case |
Is there an existing issue for this?
What happened?
When querying for inflation using GRPC client:
$ cored query mint inflation --grpc-addr 127.0.0.1:9090 --grpc-insecure
it panics:
Call stack:
I guess all the types using
math.LegacyDec
are affected everywhere.Cosmos SDK Version
0.47.5
How to reproduce?
No response
The text was updated successfully, but these errors were encountered: