Skip to content
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

refactor: bump gogoproto #19869

Merged
merged 28 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
80f97e4
Bump gogoproto
raynaudoe Mar 20, 2024
a8c379e
Bump go mod
raynaudoe Mar 26, 2024
9999947
Fix gogo proto files generation for testdata
raynaudoe Mar 26, 2024
82bd067
Remove unnecessary files
raynaudoe Mar 26, 2024
8345a60
Update testdata proto files
raynaudoe Mar 26, 2024
23636f5
Fix codec/types tests
raynaudoe Mar 26, 2024
56d4c20
Alias gogoproto.Any
raynaudoe Mar 26, 2024
df6c467
Use new any type
raynaudoe Mar 26, 2024
0a83276
Merge branch 'main' into eze/bump_gogoproto
raynaudoe Mar 26, 2024
86a2409
Mod tidy
raynaudoe Mar 26, 2024
d63056d
Update buf.gen.gogo with new route
raynaudoe Mar 26, 2024
7a45841
Use NewAnyWithCacheWithValue (renamed func)
raynaudoe Mar 27, 2024
4e5d836
Go mod all modules
raynaudoe Mar 27, 2024
b4cb1a4
Use alias func for gogoproto.NewAnyWithValueWithCache
raynaudoe Mar 27, 2024
90444c1
Add alias for UnsafePackAny
raynaudoe Mar 27, 2024
b15b800
Sort imports
raynaudoe Mar 27, 2024
d4fc465
Sort imports
raynaudoe Mar 27, 2024
74c42f9
Fix baseapp test
raynaudoe Mar 27, 2024
a79d9fe
make lint-fix
raynaudoe Mar 27, 2024
c411a09
Fix yaml test
raynaudoe Mar 27, 2024
f61180c
Fix lint
raynaudoe Mar 27, 2024
7dfcdcb
Fix test
raynaudoe Mar 28, 2024
3eb9bc3
Fix lint
raynaudoe Mar 28, 2024
50271e5
Merge branch 'main' into eze/bump_gogoproto
raynaudoe Mar 28, 2024
3e3106b
Add aliased types from gogoproto
raynaudoe Mar 28, 2024
bca3e7c
Update changelog
raynaudoe Mar 28, 2024
8e6571b
Use alias function
raynaudoe Mar 28, 2024
cccdb50
Update upgrading.md
raynaudoe Mar 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion baseapp/grpcrouter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func testQueryDataRacesSameHandler(t *testing.T, makeClientConn func(*baseapp.GR
qr := baseapp.NewGRPCQueryRouter()
interfaceRegistry := testdata.NewTestInterfaceRegistry()
qr.SetInterfaceRegistry(interfaceRegistry)
testdata.RegisterQueryServer(qr, testdata.QueryImpl{})
testdata_pulsar.RegisterQueryServer(qr, testdata_pulsar.QueryImpl{})

// The goal is to invoke the router concurrently and check for any data races.
// 0. Run with: go test -race
Expand Down
2 changes: 1 addition & 1 deletion baseapp/testutil/buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ version: v1
plugins:
- name: gocosmos
out: ../..
opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types
opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wanted to double check this is optional correct? chains dont have to do this as part of their upgrade?

Copy link
Contributor Author

@raynaudoe raynaudoe Mar 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is optional bc all public types are aliased, but could be a good idea to use the gogoproto path to not 'depend' on sdk types. But if is ok to use one or the other, I can clarify in the UPGRADING.md that this is indeed optional

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing, thank you!!

40 changes: 20 additions & 20 deletions client/grpc/cmtservice/query.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions codec/any_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,57 @@ package codec_test
import (
"testing"

"github.com/cosmos/gogoproto/types/any/test"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/codec"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
"github.com/cosmos/cosmos-sdk/types/module/testutil"
)

func NewTestInterfaceRegistry() codectypes.InterfaceRegistry {
registry := codectypes.NewInterfaceRegistry()
registry.RegisterInterface("Animal", (*testdata.Animal)(nil))
registry.RegisterInterface("Animal", (*test.Animal)(nil))
registry.RegisterImplementations(
(*testdata.Animal)(nil),
&testdata.Dog{},
&testdata.Cat{},
(*test.Animal)(nil),
&test.Dog{},
&test.Cat{},
)
return registry
}

func TestMarshalAny(t *testing.T) {
catRegistry := codectypes.NewInterfaceRegistry()
catRegistry.RegisterImplementations((*testdata.Animal)(nil), &testdata.Cat{})
catRegistry.RegisterImplementations((*test.Animal)(nil), &test.Cat{})

registry := codectypes.NewInterfaceRegistry()

cdc := codec.NewProtoCodec(registry)

kitty := &testdata.Cat{Moniker: "Kitty"}
kitty := &test.Cat{Moniker: "Kitty"}
emptyBz, err := cdc.MarshalInterface(kitty)
require.ErrorContains(t, err, "does not have a registered interface")

catBz, err := codec.NewProtoCodec(catRegistry).MarshalInterface(kitty)
require.NoError(t, err)
require.NotEmpty(t, catBz)

var animal testdata.Animal
var animal test.Animal

// deserializing cat bytes should error in an empty registry
err = cdc.UnmarshalInterface(catBz, &animal)
require.ErrorContains(t, err, "no registered implementations of type testdata.Animal")
require.ErrorContains(t, err, "no registered implementations of type test.Animal")

// deserializing an empty byte array will return nil, but no error
err = cdc.UnmarshalInterface(emptyBz, &animal)
require.Nil(t, animal)
require.NoError(t, err)

// wrong type registration should fail
registry.RegisterImplementations((*testdata.Animal)(nil), &testdata.Dog{})
registry.RegisterImplementations((*test.Animal)(nil), &test.Dog{})
err = cdc.UnmarshalInterface(catBz, &animal)
require.Error(t, err)

Expand Down
Loading
Loading