fix(baseapp): protocompat.go gogoproto.Merge does not work with custom types (backport #18654) (#18661)
Co-authored-by: testinginprod <98415576+testinginprod@users.noreply.github.com> Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
co-authored by
testinginprod
Julien Robert
parent
4459865ea7
commit
455b0be998
@@ -59,6 +59,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
* (client/tx) [#18472](https://github.com/cosmos/cosmos-sdk/pull/18472) Utilizes the correct Pubkey when simulating a transaction.
|
||||
* (baseapp) [#18486](https://github.com/cosmos/cosmos-sdk/pull/18486) Fixed FinalizeBlock calls not being passed to ABCIListeners.
|
||||
* (baseapp) [#18627](https://github.com/cosmos/cosmos-sdk/pull/18627) Post handlers are run on non successful transaction executions too.
|
||||
* (baseapp) [#18654](https://github.com/cosmos/cosmos-sdk/pull/18654) Fixes an issue in which `gogoproto.Merge` does not work with gogoproto messages with custom types.
|
||||
|
||||
## [v0.50.1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.1) - 2023-11-07
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"reflect"
|
||||
|
||||
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"
|
||||
proto2 "google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
@@ -122,14 +123,18 @@ func makeGogoHybridHandler(prefMethod protoreflect.MethodDescriptor, cdc codec.B
|
||||
}
|
||||
resp, err := method.Handler(handler, ctx, func(msg any) error {
|
||||
// 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
|
||||
}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 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
|
||||
}, nil
|
||||
}
|
||||
@@ -162,14 +167,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.
|
||||
resp, err := method.Handler(handler, ctx, func(msg any) error {
|
||||
// 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
|
||||
}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 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
|
||||
default:
|
||||
panic("unreachable")
|
||||
|
||||
Reference in New Issue
Block a user