fix(baseapp): protocompat.go gogoproto.Merge does not work with custom types (#18654)
Co-authored-by: unknown unknown <unknown@unknown>
This commit is contained in:
co-authored by
unknown unknown
parent
6218b5b5cd
commit
dabf72cfdc
@@ -84,6 +84,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||||||
* (simulation) [#17911](https://github.com/cosmos/cosmos-sdk/pull/17911) Fix all problems with executing command `make test-sim-custom-genesis-fast` for simulation test.
|
* (simulation) [#17911](https://github.com/cosmos/cosmos-sdk/pull/17911) Fix all problems with executing command `make test-sim-custom-genesis-fast` for simulation test.
|
||||||
* (simulation) [#18196](https://github.com/cosmos/cosmos-sdk/pull/18196) Fix the problem of `validator set is empty after InitGenesis` in simulation test.
|
* (simulation) [#18196](https://github.com/cosmos/cosmos-sdk/pull/18196) Fix the problem of `validator set is empty after InitGenesis` in simulation test.
|
||||||
* (baseapp) [#18551](https://github.com/cosmos/cosmos-sdk/pull/18551) Fix SelectTxForProposal the calculation method of tx bytes size is inconsistent with CometBFT
|
* (baseapp) [#18551](https://github.com/cosmos/cosmos-sdk/pull/18551) Fix SelectTxForProposal the calculation method of tx bytes size is inconsistent with CometBFT
|
||||||
|
* (baseapp) [#18653](https://github.com/cosmos/cosmos-sdk/pull/18654) Fixes an issue in which gogoproto.Merge does not work with gogoproto messages with custom types.
|
||||||
|
|
||||||
### API Breaking Changes
|
### API Breaking Changes
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
gogoproto "github.com/cosmos/gogoproto/proto"
|
gogoproto "github.com/cosmos/gogoproto/proto"
|
||||||
|
"github.com/golang/protobuf/proto" // nolint: staticcheck // needed because gogoproto.Merge does not work consistently. See NOTE: comments.
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
proto2 "google.golang.org/protobuf/proto"
|
proto2 "google.golang.org/protobuf/proto"
|
||||||
"google.golang.org/protobuf/reflect/protoreflect"
|
"google.golang.org/protobuf/reflect/protoreflect"
|
||||||
@@ -125,14 +126,18 @@ func makeGogoHybridHandler(prefMethod protoreflect.MethodDescriptor, cdc codec.B
|
|||||||
}
|
}
|
||||||
resp, err := method.Handler(handler, ctx, func(msg any) error {
|
resp, err := method.Handler(handler, ctx, func(msg any) error {
|
||||||
// merge! ref: https://github.com/cosmos/cosmos-sdk/issues/18003
|
// merge! ref: https://github.com/cosmos/cosmos-sdk/issues/18003
|
||||||
gogoproto.Merge(msg.(gogoproto.Message), inReq)
|
// NOTE: using gogoproto.Merge will fail for some reason unknown to me, but
|
||||||
|
// using proto.Merge with gogo messages seems to work fine.
|
||||||
|
proto.Merge(msg.(gogoproto.Message), inReq)
|
||||||
return nil
|
return nil
|
||||||
}, nil)
|
}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// merge resp, ref: https://github.com/cosmos/cosmos-sdk/issues/18003
|
// merge resp, ref: https://github.com/cosmos/cosmos-sdk/issues/18003
|
||||||
gogoproto.Merge(outResp.(gogoproto.Message), resp.(gogoproto.Message))
|
// NOTE: using gogoproto.Merge will fail for some reason unknown to me, but
|
||||||
|
// using proto.Merge with gogo messages seems to work fine.
|
||||||
|
proto.Merge(outResp.(gogoproto.Message), resp.(gogoproto.Message))
|
||||||
return nil
|
return nil
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@@ -165,14 +170,19 @@ func makeGogoHybridHandler(prefMethod protoreflect.MethodDescriptor, cdc codec.B
|
|||||||
// we can just call the handler after making a copy of the message, for safety reasons.
|
// we can just call the handler after making a copy of the message, for safety reasons.
|
||||||
resp, err := method.Handler(handler, ctx, func(msg any) error {
|
resp, err := method.Handler(handler, ctx, func(msg any) error {
|
||||||
// ref: https://github.com/cosmos/cosmos-sdk/issues/18003
|
// ref: https://github.com/cosmos/cosmos-sdk/issues/18003
|
||||||
gogoproto.Merge(msg.(gogoproto.Message), m)
|
asGogoProto := msg.(gogoproto.Message)
|
||||||
|
// NOTE: using gogoproto.Merge will fail for some reason unknown to me, but
|
||||||
|
// using proto.Merge with gogo messages seems to work fine.
|
||||||
|
proto.Merge(asGogoProto, m)
|
||||||
return nil
|
return nil
|
||||||
}, nil)
|
}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// merge on the resp, ref: https://github.com/cosmos/cosmos-sdk/issues/18003
|
// merge on the resp, ref: https://github.com/cosmos/cosmos-sdk/issues/18003
|
||||||
gogoproto.Merge(outResp.(gogoproto.Message), resp.(gogoproto.Message))
|
// NOTE: using gogoproto.Merge will fail for some reason unknown to me, but
|
||||||
|
// using proto.Merge with gogo messages seems to work fine.
|
||||||
|
proto.Merge(outResp.(gogoproto.Message), resp.(gogoproto.Message))
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
|
|||||||
Reference in New Issue
Block a user