Skip to content

Commit

Permalink
chore: sync with v0.46.12
Browse files Browse the repository at this point in the history
  • Loading branch information
johnletey committed Apr 11, 2023
2 parents c5e9bb4 + 5cd0b23 commit 445555e
Show file tree
Hide file tree
Showing 24 changed files with 893 additions and 135 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

## [v0.46.12](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.12) - 2022-04-04

### Features

* (x/groups) [#14879](https://github.com/cosmos/cosmos-sdk/pull/14879) Add `Query/Groups` query to get all the groups.

### Improvements

* (simapp) [#15305](https://github.com/cosmos/cosmos-sdk/pull/15305) Add `AppStateFnWithExtendedCb` with callback function to extend rawState and `AppStateRandomizedFnWithState` with extra genesisState argument which is the genesis state of the app.
* (x/distribution) [#15462](https://github.com/cosmos/cosmos-sdk/pull/15462) Add delegator address to the event for withdrawing delegation rewards
* [#14019](https://github.com/cosmos/cosmos-sdk/issues/14019) Remove the interface casting to allow other implementations of a `CommitMultiStore`.

### Bug Fixes

* (x/auth/vesting) [#15383](https://github.com/cosmos/cosmos-sdk/pull/15383) Add extra checks when creating a periodic vesting account.
* (x/gov) [#13051](https://github.com/cosmos/cosmos-sdk/pull/13051) In SubmitPropsal, when a legacy msg fails it's handler call, wrap the error as ErrInvalidProposalContent (instead of ErrNoProposalHandlerExists).

## [v0.46.11](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.11) - 2022-03-03

### Improvements
Expand Down
23 changes: 5 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf:1.0.0-rc8
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)
DOCS_DOMAIN=docs.cosmos.network
# RocksDB is a native dependency, so we don't assume the library is installed.
# Instead, it must be explicitly enabled and we warn when it is not.
ENABLE_ROCKSDB ?= false

export GO111MODULE = on

Expand Down Expand Up @@ -63,33 +60,23 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=sim \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TMVERSION)

ifeq ($(ENABLE_ROCKSDB),true)
BUILD_TAGS += rocksdb_build
test_tags += rocksdb_build
else
$(warning RocksDB support is disabled; to build and test with RocksDB support, set ENABLE_ROCKSDB=true)
endif
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TMVERSION)

# DB backend selection
ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS)))
build_tags += gcc
endif
ifeq (badgerdb,$(findstring badgerdb,$(COSMOS_BUILD_OPTIONS)))
BUILD_TAGS += badgerdb
build_tags += badgerdb
endif
# handle rocksdb
ifeq (rocksdb,$(findstring rocksdb,$(COSMOS_BUILD_OPTIONS)))
ifneq ($(ENABLE_ROCKSDB),true)
$(error Cannot use RocksDB backend unless ENABLE_ROCKSDB=true)
endif
CGO_ENABLED=1
BUILD_TAGS += rocksdb
build_tags += rocksdb
endif
# handle boltdb
ifeq (boltdb,$(findstring boltdb,$(COSMOS_BUILD_OPTIONS)))
BUILD_TAGS += boltdb
build_tags += boltdb
endif

ifeq (,$(findstring nostrip,$(COSMOS_BUILD_OPTIONS)))
Expand Down Expand Up @@ -406,6 +393,7 @@ proto-gen:
@echo "Generating Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
sh ./scripts/protocgen.sh; fi
@go mod tidy

# This generates the SDK's custom wrapper for google.protobuf.Any. It should only be run manually when needed
proto-gen-any:
Expand All @@ -423,7 +411,6 @@ proto-format:
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then docker start -a $(containerProtoFmt); else docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \
find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; ; fi


proto-lint:
@$(DOCKER_BUF) lint --error-format=json

Expand Down
14 changes: 5 additions & 9 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# Cosmos SDK v0.46.11 Release Notes
# Cosmos SDK v0.46.12 Release Notes

This release includes the migration to [CometBFT v0.34.27](https://github.com/cometbft/cometbft/blob/v0.34.27/CHANGELOG.md#v03427).
This migration should be not be breaking for chains.
From `v0.46.11`+, the following replace is *mandatory* in the `go.mod` of your application:
This release introduces a number of improvements and bug fixes, notably a new query for the `x/group` module, for querying all groups on a chain.

Note, from `v0.46.11`+, the following replace is *mandatory* in the `go.mod` of your application:

```go
// use cometbft
replace github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.27
```

Additionally, the SDK sets its minimum version to Go 1.19. This is not because the SDK uses new Go 1.19 functionalities, but to signal that we recommend chains to upgrade to Go 1.19 — Go 1.18 is not supported by the Go Team anymore.
Note, that SDK recommends chains to use the same Go version across all of their network.
We recommend, as well, chains to perform a **coordinated upgrade** when migrating from Go 1.18 to Go 1.19.

Please see the [CHANGELOG](https://github.com/cosmos/cosmos-sdk/blob/release/v0.46.x/CHANGELOG.md) for an exhaustive list of changes.

**Full Commit History**: https://github.com/cosmos/cosmos-sdk/compare/v0.46.10...v0.46.11
**Full Commit History**: https://github.com/cosmos/cosmos-sdk/compare/v0.46.11...v0.46.12
10 changes: 5 additions & 5 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package baseapp

import (
"errors"
"fmt"
"strings"

Expand All @@ -14,7 +15,6 @@ import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/snapshots"
"github.com/cosmos/cosmos-sdk/store"
"github.com/cosmos/cosmos-sdk/store/rootmulti"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down Expand Up @@ -352,11 +352,11 @@ func (app *BaseApp) Init() error {
app.setCheckState(tmproto.Header{})
app.Seal()

rms, ok := app.cms.(*rootmulti.Store)
if !ok {
return fmt.Errorf("invalid commit multi-store; expected %T, got: %T", &rootmulti.Store{}, app.cms)
if app.cms == nil {
return errors.New("commit multi-store must not be nil")
}
return rms.GetPruning().Validate()

return app.cms.GetPruning().Validate()
}

func (app *BaseApp) setMinGasPrices(gasPrices sdk.DecCoins) {
Expand Down
2 changes: 1 addition & 1 deletion docs/CosmWasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ parent:
>CosmWasm is written as a module that can plug into the Cosmos SDK. This means that anyone currently building a blockchain using the Cosmos SDK can quickly and easily add CosmWasm smart contracting support to their chain, without adjusting existing logic.
Read more about writing smart contracts with CosmWasm at their [documentation site](https://docs.cosmwasm.com/docs/1.0/), or visit [the repository](https://github.com/CosmWasm/cosmwasm).
Read more about writing smart contracts with CosmWasm at their [documentation site](https://book.cosmwasm.com/), or visit [the repository](https://github.com/CosmWasm/cosmwasm).
27 changes: 27 additions & 0 deletions proto/cosmos/group/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ service Query {
rpc TallyResult(QueryTallyResultRequest) returns (QueryTallyResultResponse) {
option (google.api.http).get = "/cosmos/group/v1/proposals/{proposal_id}/tally";
};

// Groups queries all groups in state.
//
// Since: cosmos-sdk 0.47.1
rpc Groups(QueryGroupsRequest) returns (QueryGroupsResponse) {
option (google.api.http).get = "/cosmos/group/v1/groups";
};
}

// QueryGroupInfoRequest is the Query/GroupInfo request type.
Expand Down Expand Up @@ -311,3 +318,23 @@ message QueryTallyResultResponse {
// tally defines the requested tally.
TallyResult tally = 1 [(gogoproto.nullable) = false];
}

// QueryGroupsRequest is the Query/Groups request type.
//
// Since: cosmos-sdk 0.47.1
message QueryGroupsRequest {

// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// QueryGroupsResponse is the Query/Groups response type.
//
// Since: cosmos-sdk 0.47.1
message QueryGroupsResponse {
// `groups` is all the groups present in state.
repeated GroupInfo groups = 1;

// pagination defines the pagination in the response.
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}
2 changes: 1 addition & 1 deletion proto/cosmos/tx/v1beta1/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ message GetTxsEventRequest {
// pagination defines a pagination for the request.
// Deprecated post v0.46.x: use page and limit instead.
cosmos.base.query.v1beta1.PageRequest pagination = 2 [deprecated = true];
;

OrderBy order_by = 3;
// page is the page number to query, starts at 1. If not provided, will default to first page.
uint64 page = 4;
Expand Down
2 changes: 2 additions & 0 deletions proto/cosmos/vesting/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ message MsgCreateVestingAccount {
repeated cosmos.base.v1beta1.Coin amount = 3
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];

// end of vesting as unix time (in seconds).
int64 end_time = 4;
bool delayed = 5;
}
Expand Down Expand Up @@ -75,6 +76,7 @@ message MsgCreatePeriodicVestingAccount {

string from_address = 1;
string to_address = 2;
// start of vesting as unix time (in seconds).
int64 start_time = 3;
repeated Period vesting_periods = 4 [(gogoproto.nullable) = false];
}
Expand Down
3 changes: 3 additions & 0 deletions proto/cosmos/vesting/v1beta1/vesting.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ message BaseVestingAccount {
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
repeated cosmos.base.v1beta1.Coin delegated_vesting = 4
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
// Vesting end time, as unix timestamp (in seconds).
int64 end_time = 5;
}

Expand All @@ -30,6 +31,7 @@ message ContinuousVestingAccount {
option (gogoproto.goproto_stringer) = false;

BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true];
// Vesting start time, as unix timestamp (in seconds).
int64 start_time = 2;
}

Expand All @@ -47,6 +49,7 @@ message DelayedVestingAccount {
message Period {
option (gogoproto.goproto_stringer) = false;

// Period duration in seconds.
int64 length = 1;
repeated cosmos.base.v1beta1.Coin amount = 2
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
Expand Down
2 changes: 0 additions & 2 deletions scripts/protocgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,3 @@ cd ..
# move proto files to the right places
cp -r github.com/cosmos/cosmos-sdk/* ./
rm -rf github.com

go mod tidy -compat=1.19
38 changes: 35 additions & 3 deletions simapp/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ import (
// It panics if the user provides files for both of them.
// If a file is not given for the genesis or the sim params, it creates a randomized one.
func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simtypes.AppStateFn {
genesisState := NewDefaultGenesisState(cdc)
return AppStateFnWithExtendedCb(cdc, simManager, genesisState, nil)
}

// AppStateFnWithExtendedCb returns the initial application state using a genesis or the simulation parameters.
// It panics if the user provides files for both of them.
// If a file is not given for the genesis or the sim params, it creates a randomized one.
// genesisState is the genesis state of the app.
// cb is the callback function to extend rawState.
func AppStateFnWithExtendedCb(
cdc codec.JSONCodec,
simManager *module.SimulationManager,
genesisState map[string]json.RawMessage,
cb func(rawState map[string]json.RawMessage),
) simtypes.AppStateFn {
return func(r *rand.Rand, accs []simtypes.Account, config simtypes.Config,
) (appState json.RawMessage, simAccs []simtypes.Account, chainID string, genesisTimestamp time.Time) {
if FlagGenesisTimeValue == 0 {
Expand Down Expand Up @@ -64,11 +79,11 @@ func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simty
if err != nil {
panic(err)
}
appState, simAccs = AppStateRandomizedFn(simManager, r, cdc, accs, genesisTimestamp, appParams)
appState, simAccs = AppStateRandomizedFnWithState(simManager, r, cdc, accs, genesisTimestamp, appParams, genesisState)

default:
appParams := make(simtypes.AppParams)
appState, simAccs = AppStateRandomizedFn(simManager, r, cdc, accs, genesisTimestamp, appParams)
appState, simAccs = AppStateRandomizedFnWithState(simManager, r, cdc, accs, genesisTimestamp, appParams, genesisState)
}

rawState := make(map[string]json.RawMessage)
Expand Down Expand Up @@ -127,6 +142,11 @@ func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simty
rawState[stakingtypes.ModuleName] = cdc.MustMarshalJSON(stakingState)
rawState[banktypes.ModuleName] = cdc.MustMarshalJSON(bankState)

// extend state from callback function
if cb != nil {
cb(rawState)
}

// replace appstate
appState, err = json.Marshal(rawState)
if err != nil {
Expand All @@ -142,8 +162,20 @@ func AppStateRandomizedFn(
simManager *module.SimulationManager, r *rand.Rand, cdc codec.JSONCodec,
accs []simtypes.Account, genesisTimestamp time.Time, appParams simtypes.AppParams,
) (json.RawMessage, []simtypes.Account) {
numAccs := int64(len(accs))
genesisState := NewDefaultGenesisState(cdc)
return AppStateRandomizedFnWithState(simManager, r, cdc, accs, genesisTimestamp, appParams, genesisState)
}

// AppStateRandomizedFnWithState creates calls each module's GenesisState generator function
// and creates the simulation params
// genesisState is the genesis state of the app.
// This function will not exist in v0.47, but be replaced by AppStateRandomizedFn with an extra genesisState argument.
func AppStateRandomizedFnWithState(
simManager *module.SimulationManager, r *rand.Rand, cdc codec.JSONCodec,
accs []simtypes.Account, genesisTimestamp time.Time, appParams simtypes.AppParams,
genesisState map[string]json.RawMessage,
) (json.RawMessage, []simtypes.Account) {
numAccs := int64(len(accs))

// generate a random amount of initial stake coins and a random initial
// number of bonded accounts
Expand Down
5 changes: 5 additions & 0 deletions types/simulation/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ type AppStateFn func(r *rand.Rand, accs []Account, config Config) (
appState json.RawMessage, accounts []Account, chainId string, genesisTimestamp time.Time,
)

// AppStateFnWithExtendedCb returns the app state json bytes and the genesis accounts
type AppStateFnWithExtendedCb func(r *rand.Rand, accs []Account, config Config) (
appState json.RawMessage, accounts []Account, chainId string, genesisTimestamp time.Time,
)

// RandomAccountFn returns a slice of n random simulation accounts
type RandomAccountFn func(r *rand.Rand, n int) []Account

Expand Down
14 changes: 7 additions & 7 deletions x/auth/vesting/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ func (s msgServer) CreateVestingAccount(goCtx context.Context, msg *types.MsgCre
}
}()

err = bk.SendCoins(ctx, from, to, msg.Amount)
if err != nil {
if err = bk.SendCoins(ctx, from, to, msg.Amount); err != nil {
return nil, err
}

Expand Down Expand Up @@ -140,8 +139,7 @@ func (s msgServer) CreatePermanentLockedAccount(goCtx context.Context, msg *type
}
}()

err = bk.SendCoins(ctx, from, to, msg.Amount)
if err != nil {
if err = bk.SendCoins(ctx, from, to, msg.Amount); err != nil {
return nil, err
}

Expand Down Expand Up @@ -175,11 +173,14 @@ func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context, msg *type
}

var totalCoins sdk.Coins

for _, period := range msg.VestingPeriods {
totalCoins = totalCoins.Add(period.Amount...)
}

if err := bk.IsSendEnabledCoins(ctx, totalCoins...); err != nil {
return nil, err
}

baseAccount := authtypes.NewBaseAccountWithAddress(to)
baseAccount = ak.NewAccount(ctx, baseAccount).(*authtypes.BaseAccount)
vestingAccount := types.NewPeriodicVestingAccount(baseAccount, totalCoins.Sort(), msg.StartTime, msg.VestingPeriods)
Expand All @@ -200,8 +201,7 @@ func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context, msg *type
}
}()

err = bk.SendCoins(ctx, from, to, totalCoins)
if err != nil {
if err = bk.SendCoins(ctx, from, to, totalCoins); err != nil {
return nil, err
}

Expand Down
10 changes: 6 additions & 4 deletions x/auth/vesting/types/tx.pb.go

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

Loading

0 comments on commit 445555e

Please sign in to comment.