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 all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i

### Improvements

* (types) [#19869](https://github.com/cosmos/cosmos-sdk/pull/19869) Removed `Any` type from `codec/types` and replaced it with an alias for `cosmos/gogoproto/types/any`.
* (server) [#19854](https://github.com/cosmos/cosmos-sdk/pull/19854) Add customizability to start command.
* Add `StartCmdOptions` in `server.AddCommands` instead of `servertypes.ModuleInitFlags`. To set custom flags set them in the `StartCmdOptions` struct on the `AddFlags` field.
* Add `StartCommandHandler` to `StartCmdOptions` to allow custom start command handlers. Users now have total control over how the app starts.
Expand Down
3 changes: 3 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,9 @@ With the deprecation of the Amino JSON codec defined in [cosmos/gogoproto](https

For core SDK types equivalence is asserted by generative testing of [SignableTypes](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-beta.0/tests/integration/rapidgen/rapidgen.go#L102) in [TestAminoJSON_Equivalence](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-beta.0/tests/integration/tx/aminojson/aminojson_test.go#L94).

Due to the `Any` type moving to the `github.com/cosmos/gogoproto/types/any` repository, module developers must update the `buf.gen.gogo.yaml` configuration files by adjusting the corresponding `opt` option to `Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any` for correct mapping to the new `Any` type location.
Copy link
Member

@julienrbrt julienrbrt Mar 28, 2024

Choose a reason for hiding this comment

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

This is at the wrong place, should be https://github.com/cosmos/cosmos-sdk/blob/main/UPGRADING.md#protobuf. And they don't have to, we should clarify it is optional but recommended (one less sdk import)


Comment on lines +443 to +444
Copy link
Contributor

Choose a reason for hiding this comment

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

Due to the Any type moving to the github.com/cosmos/gogoproto/types/any repository, module developers must update the buf.gen.gogo.yaml configuration files by adjusting the corresponding opt option to Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any for correct mapping to the new Any type location.

- Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types
+ Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
Due to the `Any` type moving to the `github.com/cosmos/gogoproto/types/any` repository, module developers must update the `buf.gen.gogo.yaml` configuration files by adjusting the corresponding `opt` option to `Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any` for correct mapping to the new `Any` type location.
Due to the `Any` type moving to the `github.com/cosmos/gogoproto/types/any` repository, module developers must update the `buf.gen.gogo.yaml` configuration files by adjusting the corresponding `opt` option to `Mgoogle/protobuf/any.proto=github.com/cosmos/gogoproto/types/any` for correct mapping to the new `Any` type location.


**TODO: summarize proto annotation requirements.**

#### Stringer
Expand Down
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