Skip to content

Commit

Permalink
Merge branch 'main' into hieu/prune-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
hieuvubk authored Jul 23, 2024
2 parents 7d6bdaa + 2c236af commit 145dcc2
Show file tree
Hide file tree
Showing 270 changed files with 1,797 additions and 1,280 deletions.
3 changes: 2 additions & 1 deletion .github/.codespellignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ pullrequest
keypair
pastTime
hasTables
Nam
Nam
EyT
10 changes: 10 additions & 0 deletions .github/pr_labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@
- x/upgrade/**/*
"C:x/epochs":
- x/epochs/**/*
"C:server/v2":
- server/v2/**/*
"C:server/v2 stf":
- server/v2/stf/**/*
"C:server/v2 appmanager":
- server/v2/appmanager/**/*
"C:server/v2 cometbft":
- server/v2/cometbft/**/*
"C:server/v2 api":
- server/v2/api/**/*
"Type: ADR":
- docs/architecture/**/*
"Type: Build":
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/misspell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
continue-on-error: true
run: |
sudo apt-get install codespell -y
codespell -w --skip="*.pulsar.go,*.pb.go,*.pb.gw.go,*.cosmos_orm.go,*.json,*.git,*.js,crypto/keys,fuzz,*.h,proto/tendermint,*.bin" --ignore-words=.github/.codespellignore
codespell -w --skip="*.pulsar.go,*.pb.go,*.pb.gw.go,*.cosmos_orm.go,*.json,*.git,*.js,crypto/keys,fuzz,*.h,proto/tendermint,*.bin,go.sum,go.mod" --ignore-words=.github/.codespellignore
- uses: peter-evans/create-pull-request@v6
if: github.event_name != 'pull_request'
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1.34.0
- uses: bufbuild/buf-setup-action@v1.35.0
- uses: bufbuild/buf-lint-action@v1
with:
input: "proto"
Expand All @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1.34.0
- uses: bufbuild/buf-setup-action@v1.35.0
- uses: bufbuild/buf-breaking-action@v1
with:
input: "proto"
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* [#19851](https://github.com/cosmos/cosmos-sdk/pull/19851) Fix some places in which we call Remove inside a Walk (x/staking and x/gov).
* [#20939](https://github.com/cosmos/cosmos-sdk/pull/20939) Fix collection reverse iterator to include `pagination.key` in the result.
* (client/grpc) [#20969](https://github.com/cosmos/cosmos-sdk/pull/20969) Fix `node.NewQueryServer` method not setting `cfg`.
* (testutil/integration) [#21006](https://github.com/cosmos/cosmos-sdk/pull/21006) Fix `NewIntegrationApp` method not writing default genesis to state

### API Breaking Changes

Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ include scripts/build/testing.mk
include scripts/build/documentation.mk
include scripts/build/build.mk

.DEFAULT_GOAL := help

###############################################################################
### Tools & Dependencies ###
###############################################################################
Expand Down
4 changes: 3 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ There is no longer a need for the Cosmos SDK to host these protos for itself and
That package containing proto v2 generated code, but the SDK now uses [buf generated go SDK instead](https://buf.build/docs/bsr/generated-sdks/go).
If you were depending on `cosmossdk.io/api/tendermint`, please use the buf generated go SDK instead, or ask CometBFT host the generated proto v2 code.

The `codectypes.Any` has moved to `github.com/cosmos/gogoproto/types/any`. Module developers can 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 directly mapping the`Any` type to its new location. This change is optional as `codectypes.Any` is aliased to `gogoproto.Any` in the SDK.
The `codectypes.Any` has moved to `github.com/cosmos/gogoproto/types/any`. Module developers need to 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 directly mapping the`Any` type to its new location. This change is optional, but recommended, as `codectypes.Any` is aliased to `gogoproto.Any` in the SDK.

Also, any usages of the interfaces `AnyUnpacker` and `UnpackInterfacesMessage` must be replaced with the interfaces of the same name in the `github.com/cosmos/gogoproto/types/any` package.

### Modules

Expand Down
2 changes: 1 addition & 1 deletion api/cosmos/base/node/v1beta1/query.pulsar.go

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

4 changes: 2 additions & 2 deletions api/cosmos/nft/v1beta1/query_grpc.pb.go

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

2 changes: 1 addition & 1 deletion client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29831,7 +29831,7 @@ paths:
/cosmos/nft/v1beta1/balance:
get:
summary: >-
BalancebyQueryString queries the number of NFTs of a given class owned
BalanceByQueryString queries the number of NFTs of a given class owned
by the owner, same as balanceOf in ERC721
operationId: BalanceByQueryString
responses:
Expand Down
7 changes: 4 additions & 3 deletions client/grpc/cmtservice/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

abci "github.com/cometbft/cometbft/api/cometbft/abci/v1"
gogogrpc "github.com/cosmos/gogoproto/grpc"
gogoprotoany "github.com/cosmos/gogoproto/types/any"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand All @@ -20,8 +21,8 @@ import (
)

var (
_ ServiceServer = queryServer{}
_ codectypes.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{}
_ ServiceServer = queryServer{}
_ gogoprotoany.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{}
)

type (
Expand Down Expand Up @@ -112,7 +113,7 @@ func (s queryServer) GetLatestValidatorSet(ctx context.Context, req *GetLatestVa
return ValidatorsOutput(ctx, s.clientCtx, nil, page, limit)
}

func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker gogoprotoany.AnyUnpacker) error {
var pubKey cryptotypes.PubKey
for _, val := range m.Validators {
err := unpacker.UnpackAny(val.PubKey, &pubKey)
Expand Down
2 changes: 1 addition & 1 deletion client/grpc/node/query.pb.go

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

23 changes: 23 additions & 0 deletions client/keys/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import (

"github.com/cosmos/cosmos-sdk/codec"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
codectestutil "github.com/cosmos/cosmos-sdk/codec/testutil"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
)

func generatePubKeys(n int) []types.PubKey {
Expand Down Expand Up @@ -100,3 +102,24 @@ func TestProtoMarshalJSON(t *testing.T) {
require.Equal(ko.Address, expectedOutput)
require.Equal(ko.PubKey, string(bz))
}

func TestNestedMultisigOutput(t *testing.T) {
cdc := moduletestutil.MakeTestEncodingConfig(codectestutil.CodecOptions{}).Codec

sk := secp256k1.PrivKey{Key: []byte{154, 49, 3, 117, 55, 232, 249, 20, 205, 216, 102, 7, 136, 72, 177, 2, 131, 202, 234, 81, 31, 208, 46, 244, 179, 192, 167, 163, 142, 117, 246, 13}}
tmpKey := sk.PubKey()
multisigPk := kmultisig.NewLegacyAminoPubKey(1, []types.PubKey{tmpKey})
multisigPk2 := kmultisig.NewLegacyAminoPubKey(1, []types.PubKey{tmpKey, multisigPk})

kb, err := keyring.New(t.Name(), keyring.BackendTest, t.TempDir(), nil, cdc)
require.NoError(t, err)

_, err = kb.SaveMultisig("multisig", multisigPk2)
require.NoError(t, err)

k, err := kb.Key("multisig")
require.NoError(t, err)

_, err = MkAccKeyOutput(k, addresscodec.NewBech32Codec("cosmos"))
require.NoError(t, err)
}
3 changes: 1 addition & 2 deletions client/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.2
require (
cosmossdk.io/api v0.7.5
cosmossdk.io/core v0.12.1-0.20231114100755-569e3ff6a0d7
cosmossdk.io/depinject v1.0.0-alpha.4
cosmossdk.io/depinject v1.0.0
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91
cosmossdk.io/x/gov v0.0.0-20231113122742-912390d5fc4a
cosmossdk.io/x/tx v0.13.3
Expand Down Expand Up @@ -183,7 +183,6 @@ replace (
cosmossdk.io/api => ./../../api
cosmossdk.io/core => ./../../core
cosmossdk.io/core/testing => ../../core/testing
cosmossdk.io/depinject => ./../../depinject
cosmossdk.io/log => ./../../log
cosmossdk.io/store => ./../../store
cosmossdk.io/x/accounts => ./../../x/accounts
Expand Down
2 changes: 2 additions & 0 deletions client/v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
cosmossdk.io/depinject v1.0.0 h1:dQaTu6+O6askNXO06+jyeUAnF2/ssKwrrszP9t5q050=
cosmossdk.io/depinject v1.0.0/go.mod h1:zxK/h3HgHoA/eJVtiSsoaRaRA2D5U4cJ5thIG4ssbB8=
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U=
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
Expand Down
3 changes: 2 additions & 1 deletion codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package codec

import (
"github.com/cosmos/gogoproto/proto"
gogoprotoany "github.com/cosmos/gogoproto/types/any"
"google.golang.org/grpc/encoding"
"google.golang.org/protobuf/reflect/protoreflect"

Expand Down Expand Up @@ -76,7 +77,7 @@ type (
// is not registered in codec, or is not compatible with the serialized data
UnmarshalInterface(bz []byte, ptr interface{}) error

types.AnyUnpacker
gogoprotoany.AnyUnpacker
}

JSONCodec interface {
Expand Down
44 changes: 4 additions & 40 deletions codec/types/interface_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,18 @@ import (

"github.com/cosmos/gogoproto/jsonpb"
"github.com/cosmos/gogoproto/proto"
gogoprotoany "github.com/cosmos/gogoproto/types/any"
"google.golang.org/protobuf/reflect/protodesc"
"google.golang.org/protobuf/reflect/protoreflect"

"cosmossdk.io/core/registry"
"cosmossdk.io/x/tx/signing"
)

// AnyUnpacker is an interface which allows safely unpacking types packed
// in Any's against a whitelist of registered types
type AnyUnpacker interface {
// UnpackAny unpacks the value in any to the interface pointer passed in as
// iface. Note that the type in any must have been registered in the
// underlying whitelist registry as a concrete type for that interface
// Ex:
// var msg sdk.Msg
// err := cdc.UnpackAny(any, &msg)
// ...
UnpackAny(any *Any, iface interface{}) error
}

// UnpackInterfacesMessage is meant to extend protobuf types (which implement
// proto.Message) to support a post-deserialization phase which unpacks
// types packed within Any's using the whitelist provided by AnyUnpacker
type UnpackInterfacesMessage interface {
// UnpackInterfaces is implemented in order to unpack values packed within
// Any's using the AnyUnpacker. It should generally be implemented as
// follows:
// func (s *MyStruct) UnpackInterfaces(unpacker AnyUnpacker) error {
// var x AnyInterface
// // where X is an Any field on MyStruct
// err := unpacker.UnpackAny(s.X, &x)
// if err != nil {
// return nil
// }
// // where Y is a field on MyStruct that implements UnpackInterfacesMessage itself
// err = s.Y.UnpackInterfaces(unpacker)
// if err != nil {
// return nil
// }
// return nil
// }
UnpackInterfaces(unpacker AnyUnpacker) error
}

// UnpackInterfaces is a convenience function that calls UnpackInterfaces
// on x if x implements UnpackInterfacesMessage
func UnpackInterfaces(x interface{}, unpacker AnyUnpacker) error {
if msg, ok := x.(UnpackInterfacesMessage); ok {
func UnpackInterfaces(x interface{}, unpacker gogoprotoany.AnyUnpacker) error {
if msg, ok := x.(gogoprotoany.UnpackInterfacesMessage); ok {
return msg.UnpackInterfaces(unpacker)
}
return nil
Expand All @@ -65,7 +29,7 @@ var protoMessageType = reflect.TypeOf((*proto.Message)(nil)).Elem()
// InterfaceRegistry provides a mechanism for registering interfaces and
// implementations that can be safely unpacked from Any
type InterfaceRegistry interface {
AnyUnpacker
gogoprotoany.AnyUnpacker
jsonpb.AnyResolver
registry.InterfaceRegistrar

Expand Down
12 changes: 4 additions & 8 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,15 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#18861](https://github.com/cosmos/cosmos-sdk/pull/18861) Moved `coin.ParseCoin` to `client/v2/internal`.
* [#18866](https://github.com/cosmos/cosmos-sdk/pull/18866) All items related to depinject have been moved to `cosmossdk.io/depinject` (`Provide`, `Invoke`, `Register`)
* [#19041](https://github.com/cosmos/cosmos-sdk/pull/19041) `HasEventListeners` was removed from appmodule due to the fact that it was not used anywhere in the SDK nor implemented

## [v0.12.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.12.0)

:::note
This release contains breaking changes and should not be used with 0.50.x or earlier versions of the Cosmos SDK.
:::

* [#17689](https://github.com/cosmos/cosmos-sdk/pull/17689) Move Comet service to return structs instead of interfaces.
* `BlockInfo` was renamed to `Info` and `BlockInfoService` was renamed to `CometInfoService`
* [#17693](https://github.com/cosmos/cosmos-sdk/pull/17693) Remove `appmodule.UpgradeModule` interface in favor of preblock

## [v0.11.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.0)
## [v0.11.1](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.1)

* [#21022](https://github.com/cosmos/cosmos-sdk/pull/21022) Upgrade depinject to v1.0.0.

## [v0.11.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.11.0)

* [#17468](https://github.com/cosmos/cosmos-sdk/pull/17468) Add `appmodule.HasPreBlocker` interface.

Expand Down
19 changes: 11 additions & 8 deletions core/appmodule/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,20 @@ import (
"cosmossdk.io/core/appmodule/v2"
)

// HasGenesisBasics is the legacy interface for stateless genesis methods.
type HasGenesisBasics interface {
DefaultGenesis() json.RawMessage
ValidateGenesis(json.RawMessage) error
}

// HasGenesis defines a custom genesis handling API implementation.
type HasGenesis = appmodule.HasGenesis

// HasABCIGenesis defines a custom genesis handling API implementation for ABCI.
// (stateful genesis methods which returns validator updates)
// Most modules should not implement this interface.
type HasABCIGenesis = appmodule.HasABCIGenesis

// HasGenesisAuto is the extension interface that modules should implement to handle
// genesis data and state initialization.
// WARNING: This interface is experimental and may change at any time.
Expand All @@ -30,14 +41,6 @@ type HasGenesisAuto interface {
ExportGenesis(context.Context, GenesisTarget) error
}

// HasGenesisBasics is the legacy interface for stateless genesis methods.
type HasGenesisBasics interface {
HasName

DefaultGenesis() json.RawMessage
ValidateGenesis(json.RawMessage) error
}

// GenesisSource is a source for genesis data in JSON format. It may abstract over a
// single JSON object or separate files for each field in a JSON object that can
// be streamed over. Modules should open a separate io.ReadCloser for each field that
Expand Down
5 changes: 0 additions & 5 deletions core/appmodule/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ type HasPrecommit interface {
Precommit(context.Context) error
}

// HasName is an extension interface that must return the appmodule.AppModule's Name.
type HasName interface {
Name() string
}

// HasAminoCodec is an extension interface that module must implement to support JSON encoding and decoding of its types
// through amino. This is used in genesis & the CLI client.
type HasAminoCodec interface {
Expand Down
Loading

0 comments on commit 145dcc2

Please sign in to comment.