From dda81a2275d7a9553a74068e5edd22d942ad9124 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 6 Jun 2023 16:29:25 +0200 Subject: [PATCH 01/14] refactor: avoid breaking change due to #16415 included in v0.50 (#16430) --- baseapp/circuit.go | 6 ++---- baseapp/msg_service_router.go | 8 +++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/baseapp/circuit.go b/baseapp/circuit.go index 022ee6632c2e..3db0bc1bdcda 100644 --- a/baseapp/circuit.go +++ b/baseapp/circuit.go @@ -1,10 +1,8 @@ package baseapp -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) +import "context" // CircuitBreaker is an interface that defines the methods for a circuit breaker. type CircuitBreaker interface { - IsAllowed(ctx sdk.Context, typeURL string) bool + IsAllowed(ctx context.Context, typeURL string) (bool, error) } diff --git a/baseapp/msg_service_router.go b/baseapp/msg_service_router.go index ff448086b8bd..ec68ffd4c419 100644 --- a/baseapp/msg_service_router.go +++ b/baseapp/msg_service_router.go @@ -124,7 +124,13 @@ func (msr *MsgServiceRouter) RegisterService(sd *grpc.ServiceDesc, handler inter if msr.circuitBreaker != nil { msgURL := sdk.MsgTypeURL(req) - if !msr.circuitBreaker.IsAllowed(ctx, msgURL) { + + isAllowed, err := msr.circuitBreaker.IsAllowed(ctx, msgURL) + if err != nil { + return nil, err + } + + if !isAllowed { return nil, fmt.Errorf("circuit breaker disables execution of this message: %s", msgURL) } } From 48becdf19a342e7478aa5839e6c10c985cbfc63b Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 6 Jun 2023 18:22:35 +0200 Subject: [PATCH 02/14] docs: improve upgrading.md and changelog (backport #16429) (#16431) Co-authored-by: Julien Robert --- UPGRADING.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index f4311b7eb620..db7994f36fbb 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -178,6 +178,19 @@ The `params` module will be removed in `v0.48`, as mentioned [in v0.46 release]( When performing a chain migration, the params table must be initizalied manually. This was done in the modules keepers in previous versions. Have a look at `simapp.RegisterUpgradeHandlers()` for an example. +#### `x/crisis` + +With the migrations of all modules away from `x/params`, the crisis module now has a store. +The store must be created during a chain upgrade to v0.47.x. + +```go +storetypes.StoreUpgrades{ + Added: []string{ + crisistypes.ModuleName, + }, +} +``` + #### `x/gov` ##### Minimum Proposal Deposit At Time of Submission @@ -190,7 +203,7 @@ By default, the new `MinInitialDepositRatio` parameter is set to zero during mig feature is disabled. If chains wish to utilize the minimum proposal deposits at time of submission, the migration logic needs to be modified to set the new parameter to the desired value. -##### New Proposal.Proposer field +##### New `Proposal.Proposer` field The `Proposal` proto has been updated with proposer field. For proposal state migraton developers can call `v4.AddProposerAddressToProposal` in their upgrade handler to update all existing proposal and make them compatible and **this migration is optional**. @@ -246,7 +259,17 @@ func (app SimApp) RegisterUpgradeHandlers() { } ``` -The old params module is required to still be imported in your app.go in order to handle this migration. +The `x/params` module should still be imported in your app.go in order to handle this migration. + +Because the `x/consensus` module is a new module, its store must be added while upgrading to v0.47.x: + +```go +storetypes.StoreUpgrades{ + Added: []string{ + consensustypes.ModuleName, + }, +} +``` ##### `app.go` changes From 3bbc0aaed7d3270d5aaecd86d950aca33a5cecfb Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 7 Jun 2023 23:41:30 +0000 Subject: [PATCH 03/14] fix: StateSync Restore by excluding memory store (backport #16449) (#16452) Co-authored-by: Chill Validation <92176880+chillyvee@users.noreply.github.com> Co-authored-by: Julien Robert --- CHANGELOG.md | 1 + store/rootmulti/store.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d3757441062..bab7f0ec79d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes * (server) [#16395](https://github.com/cosmos/cosmos-sdk/pull/16395) Do not override some Comet config is purposely set differently in `InterceptConfigsPreRunHandler`. +* (store) [#16449](https://github.com/cosmos/cosmos-sdk/pull/16449) Fix StateSync Restore by excluding memory store. * (cli) [#16312](https://github.com/cosmos/cosmos-sdk/pull/16312) Allow any addresses in `client.ValidatePromptAddress`. * (x/group) [#16017](https://github.com/cosmos/cosmos-sdk/pull/16017) Correctly apply account number in group v2 migration. diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index ae9e5cff7ec0..79865502a33c 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -996,7 +996,8 @@ func (rs *Store) buildCommitInfo(version int64) *types.CommitInfo { storeInfos := []types.StoreInfo{} for _, key := range keys { store := rs.stores[key] - if store.GetStoreType() == types.StoreTypeTransient { + storeType := store.GetStoreType() + if storeType == types.StoreTypeTransient || storeType == types.StoreTypeMemory { continue } storeInfos = append(storeInfos, types.StoreInfo{ From cfc757dc5043fb2758c47c146d2912fd010c1a45 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 8 Jun 2023 11:23:26 +0200 Subject: [PATCH 04/14] chore: prepare v0.47.3 (2/2) (#16444) --- CHANGELOG.md | 3 +- RELEASE_NOTES.md | 1 + UPGRADING.md | 121 ----------------------------------------------- 3 files changed, 3 insertions(+), 122 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bab7f0ec79d9..151bb2345f08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,7 +37,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] -## [v0.47.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.3) - 2023-06-05 +## [v0.47.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.3) - 2023-06-08 ### Features @@ -62,6 +62,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* Fix [barberry](https://forum.cosmos.network/t/cosmos-sdk-security-advisory-barberry/10825) security vulnerability. * (server) [#16395](https://github.com/cosmos/cosmos-sdk/pull/16395) Do not override some Comet config is purposely set differently in `InterceptConfigsPreRunHandler`. * (store) [#16449](https://github.com/cosmos/cosmos-sdk/pull/16449) Fix StateSync Restore by excluding memory store. * (cli) [#16312](https://github.com/cosmos/cosmos-sdk/pull/16312) Allow any addresses in `client.ValidatePromptAddress`. diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 4b596e98070c..598981682552 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -7,6 +7,7 @@ Missed the v0.47.0 announcement? Read it [here](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.0). For this third patch release of the `v0.47.x` line, some of the notable changes include: +* The [barberry](https://forum.cosmos.network/t/cosmos-sdk-security-advisory-barberry/10825) security vulnerability is resolved. All chains using Cosmos SDK `<= v0.47.2` are advised to upgrade to `v0.47.3` **immediately**. A chain is safe as soon as **33%+1** of the voting power has upgraded. Coordinate with your validators to upgrade as soon as possible. * A command to be able to bootstrap comet from a local snapshot with [` comet bootstrap-state`](https://docs.cosmos.network/v0.47/run-node/run-node#local-state-sync). * Commands to manage snapshots: Add `snapshot.Cmd(appCreator)` to your chain root command for using them. * The default logger is now `cosmossdk.io/log`, which supports coloring 🟥🟩🟪🟦 and filtering again. diff --git a/UPGRADING.md b/UPGRADING.md index db7994f36fbb..2401b6543432 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -293,124 +293,3 @@ This means chain developers need to validate the `classID` and `nftID` of an NFT Ledger support has been generalized to enable use of different apps and keytypes that use `secp256k1`. The Ledger interface remains the same, but it can now be provided through the Keyring `Options`, allowing higher-level chains to connect to different Ledger apps or use custom implementations. In addition, higher-level chains can provide custom key implementations around the Ledger public key, to enable greater flexibility with address generation and signing. This is not a breaking change, as all values will default to use the standard Cosmos app implementation unless specified otherwise. - -## [v0.46.x](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.0) - -### Go API Changes - -The `replace google.golang.org/grpc` directive can be removed from the `go.mod`, it is no more required to block the version. - -A few packages that were deprecated in the previous version are now removed. - -For instance, the REST API, deprecated in v0.45, is now removed. If you have not migrated yet, please follow the [instructions](https://docs.cosmos.network/v0.45/migrations/rest.html). - -To improve clarity of the API, some renaming and improvements has been done: - -| Package | Previous | Current | -| --------- | ---------------------------------- | ------------------------------------ | -| `simapp` | `encodingConfig.Marshaler` | `encodingConfig.Codec` | -| `simapp` | `FundAccount`, `FundModuleAccount` | Functions moved to `x/bank/testutil` | -| `types` | `AccAddressFromHex` | `AccAddressFromHexUnsafe` | -| `x/auth` | `MempoolFeeDecorator` | Use `DeductFeeDecorator` instead | -| `x/bank` | `AddressFromBalancesStore` | `AddressAndDenomFromBalancesStore` | -| `x/gov` | `keeper.DeleteDeposits` | `keeper.DeleteAndBurnDeposits` | -| `x/gov` | `keeper.RefundDeposits` | `keeper.RefundAndDeleteDeposits` | -| `x/{mod}` | package `legacy` | package `migrations` | - -For the exhaustive list of API renaming, please refer to the [CHANGELOG](https://github.com/cosmos/cosmos-sdk/blob/main/CHANGELOG.md). - -#### new packages - -Additionally, new packages have been introduced in order to further split the codebase. Aliases are available for a new API breaking migration, but it is encouraged to migrate to this new packages: - -* `errors` should replace `types/errors` when registering errors or wrapping SDK errors. -* `math` contains the `Int` or `Uint` types that are used in the SDK. -* `x/nft` an NFT base module. -* `x/group` a group module allowing to create DAOs, multisig and policies. Greatly composes with `x/authz`. - -#### `x/authz` - -* `authz.NewMsgGrant` `expiration` is now a pointer. When `nil` is used, then no expiration will be set (grant won't expire). -* `authz.NewGrant` takes a new argument: block time, to correctly validate expire time. - -### Keyring - -The keyring has been refactored in v0.46. - -* The `Unsafe*` interfaces have been removed from the keyring package. Please use interface casting if you wish to access those unsafe functions. -* The keys' implementation has been refactored to be serialized as proto. -* `keyring.NewInMemory` and `keyring.New` takes now a `codec.Codec`. -* Take `keyring.Record` instead of `Info` as first argument in: - * `MkConsKeyOutput` - * `MkValKeyOutput` - * `MkAccKeyOutput` -* Rename: - * `SavePubKey` to `SaveOfflineKey` and remove the `algo` argument. - * `NewMultiInfo`, `NewLedgerInfo` to `NewLegacyMultiInfo`, `newLegacyLedgerInfo` respectively. - * `NewOfflineInfo` to `newLegacyOfflineInfo` and move it to `migration_test.go`. - -### PostHandler - -A `postHandler` is like an `antehandler`, but is run _after_ the `runMsgs` execution. It is in the same store branch that `runMsgs`, meaning that both `runMsgs` and `postHandler`. This allows to run a custom logic after the execution of the messages. - -### IAVL - -v0.19.0 IAVL introduces a new "fast" index. This index represents the latest state of the -IAVL laid out in a format that preserves data locality by key. As a result, it allows for faster queries and iterations -since data can now be read in lexicographical order that is frequent for Cosmos-SDK chains. - -The first time the chain is started after the upgrade, the aforementioned index is created. The creation process -might take time and depends on the size of the latest state of the chain. For example, Osmosis takes around 15 minutes to rebuild the index. - -While the index is being created, node operators can observe the following in the logs: -"Upgrading IAVL storage for faster queries + execution on the live state. This may take a while". The store -key is appended to the message. The message is printed for every module that has a non-transient store. -As a result, it gives a good indication of the progress of the upgrade. - -There is also downgrade and re-upgrade protection. If a node operator chooses to downgrade to IAVL pre-fast index, and then upgrade again, the index is rebuilt from scratch. This implementation detail should not be relevant in most cases. It was added as a safeguard against operator -mistakes. - -### Modules - -#### `x/params` - -* The `x/params` module has been depreacted in favour of each module housing and providing way to modify their parameters. Each module that has parameters that are changable during runtime have an authority, the authority can be a module or user account. The Cosmos SDK team recommends migrating modules away from using the param module. An example of how this could look like can be found [here](https://github.com/cosmos/cosmos-sdk/pull/12363). -* The Param module will be maintained until April 18, 2023. At this point the module will reach end of life and be removed from the Cosmos SDK. - -#### `x/gov` - -The `gov` module has been greatly improved. The previous API has been moved to `v1beta1` while the new implementation is called `v1`. - -In order to submit a proposal with `submit-proposal` you now need to pass a `proposal.json` file. -You can still use the old way by using `submit-legacy-proposal`. This is not recommended. -More information can be found in the gov module [client documentation](https://docs.cosmos.network/v0.46/modules/gov/07_client.html). - -#### `x/staking` - -The `staking module` added a new message type to cancel unbonding delegations. Users that have unbonded by accident or wish to cancel a undelegation can now specify the amount and valdiator they would like to cancel the unbond from - -### Protobuf - -The `third_party/proto` folder that existed in [previous version](https://github.com/cosmos/cosmos-sdk/tree/v0.45.3/third_party/proto) now does not contains directly the [proto files](https://github.com/cosmos/cosmos-sdk/tree/release/v0.46.x/third_party/proto). - -Instead, the SDK uses [`buf`](https://buf.build). Clients should have their own [`buf.yaml`](https://docs.buf.build/configuration/v1/buf-yaml) with `buf.build/cosmos/cosmos-sdk` as dependency, in order to avoid having to copy paste these files. - -The protos can as well be downloaded using `buf export buf.build/cosmos/cosmos-sdk:8cb30a2c4de74dc9bd8d260b1e75e176 --output `. - -Cosmos message protobufs should be extended with `cosmos.msg.v1.signer`: - -```protobuf -message MsgSetWithdrawAddress { - option (cosmos.msg.v1.signer) = "delegator_address"; ++ - - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - string withdraw_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; -} -``` - - - -When clients interract with a node they are required to set a codec in in the grpc.Dial. More information can be found in this [doc](https://docs.cosmos.network/v0.46/run-node/interact-node.html#programmatically-via-go). From 666c345ad23ddda9523cc5cd1b71187d91c26f34 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Thu, 8 Jun 2023 18:04:36 +0200 Subject: [PATCH 05/14] fix: patch barberry (#16465) --- x/auth/vesting/types/msgs.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/x/auth/vesting/types/msgs.go b/x/auth/vesting/types/msgs.go index fbce860cede4..f2194af5690b 100644 --- a/x/auth/vesting/types/msgs.go +++ b/x/auth/vesting/types/msgs.go @@ -182,6 +182,14 @@ func (msg MsgCreatePeriodicVestingAccount) ValidateBasic() error { } for i, period := range msg.VestingPeriods { + if !period.Amount.IsValid() { + return sdkerrors.ErrInvalidCoins.Wrap(period.Amount.String()) + } + + if !period.Amount.IsAllPositive() { + return sdkerrors.ErrInvalidCoins.Wrap(period.Amount.String()) + } + if period.Length < 1 { return fmt.Errorf("invalid period length of %d in period %d, length must be greater than 0", period.Length, i) } From fb08b3cacbb0c6ac97d59ac03932b982a274ce1d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Jun 2023 23:05:12 +0000 Subject: [PATCH 06/14] build(deps): Bump github.com/cometbft/cometbft from 0.37.1 to 0.37.2 (#16565) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Julien Robert --- CHANGELOG.md | 4 ++++ RELEASE_NOTES.md | 12 ++++-------- go.mod | 2 +- go.sum | 4 ++-- simapp/go.mod | 2 +- simapp/go.sum | 4 ++-- tests/go.mod | 2 +- tests/go.sum | 4 ++-- tools/cosmovisor/go.mod | 2 +- tools/cosmovisor/go.sum | 4 ++-- tools/rosetta/go.mod | 2 +- tools/rosetta/go.sum | 4 ++-- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 151bb2345f08..8090d058e60f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Improvements + +* (deps) [#16565](https://github.com/cosmos/cosmos-sdk/pull/16565) Bump CometBFT to [v0.37.2](https://github.com/cometbft/cometbft/blob/v0.37.2/CHANGELOG.md). + ## [v0.47.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.3) - 2023-06-08 ### Features diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 598981682552..88e0bd7399ff 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,18 +1,14 @@ -# Cosmos SDK v0.47.3 Release Notes +# Cosmos SDK v0.47.4 Release Notes 💬 [**Release Discussion**](https://github.com/orgs/cosmos/discussions/categories/announcements) ## 🚀 Highlights Missed the v0.47.0 announcement? Read it [here](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.0). -For this third patch release of the `v0.47.x` line, some of the notable changes include: +For this fourth patch release of the `v0.47.x` line, some of the notable changes include: -* The [barberry](https://forum.cosmos.network/t/cosmos-sdk-security-advisory-barberry/10825) security vulnerability is resolved. All chains using Cosmos SDK `<= v0.47.2` are advised to upgrade to `v0.47.3` **immediately**. A chain is safe as soon as **33%+1** of the voting power has upgraded. Coordinate with your validators to upgrade as soon as possible. -* A command to be able to bootstrap comet from a local snapshot with [` comet bootstrap-state`](https://docs.cosmos.network/v0.47/run-node/run-node#local-state-sync). -* Commands to manage snapshots: Add `snapshot.Cmd(appCreator)` to your chain root command for using them. -* The default logger is now `cosmossdk.io/log`, which supports coloring 🟥🟩🟪🟦 and filtering again. -* A bug fix in `x/group` migration. Chains migrating from v0.46.x to v0.47.x must use at least v0.47.**3**. +* -Check out the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.47.3/CHANGELOG.md) for an exhaustive list of changes or [compare changes](https://github.com/cosmos/cosmos-sdk/compare/release/v0.47.2...v0.47.3) from last release. +Check out the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.47.4/CHANGELOG.md) for an exhaustive list of changes or [compare changes](https://github.com/cosmos/cosmos-sdk/compare/release/v0.47.3...v0.47.4) from last release. Refer to the [upgrading guide](https://github.com/cosmos/cosmos-sdk/blob/release/v0.47.x/UPGRADING.md) when migrating from `v0.46.x` to `v0.47.0`. diff --git a/go.mod b/go.mod index 1914ca20b333..405d3ad9159a 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/btcsuite/btcd/btcec/v2 v2.3.2 github.com/chzyer/readline v1.5.1 github.com/cockroachdb/apd/v2 v2.0.2 - github.com/cometbft/cometbft v0.37.1 + github.com/cometbft/cometbft v0.37.2 github.com/cometbft/cometbft-db v0.7.0 github.com/confio/ics23/go v0.9.0 github.com/cosmos/btcutil v1.0.5 diff --git a/go.sum b/go.sum index ff5d5848d830..5d1f42f9caa9 100644 --- a/go.sum +++ b/go.sum @@ -309,8 +309,8 @@ github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:z github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA= github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c= -github.com/cometbft/cometbft v0.37.1 h1:KLxkQTK2hICXYq21U2hn1W5hOVYUdQgDQ1uB+90xPIg= -github.com/cometbft/cometbft v0.37.1/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= +github.com/cometbft/cometbft v0.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc= +github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo= github.com/cometbft/cometbft-db v0.7.0/go.mod h1:yiKJIm2WKrt6x8Cyxtq9YTEcIMPcEe4XPxhgX59Fzf0= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= diff --git a/simapp/go.mod b/simapp/go.mod index 7a2315dd6823..f5c13d2cb08c 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -8,7 +8,7 @@ require ( cosmossdk.io/depinject v1.0.0-alpha.3 cosmossdk.io/math v1.0.1 cosmossdk.io/tools/rosetta v0.2.1 - github.com/cometbft/cometbft v0.37.1 + github.com/cometbft/cometbft v0.37.2 github.com/cometbft/cometbft-db v0.7.0 github.com/cosmos/cosmos-sdk v0.47.2 github.com/golang/mock v1.6.0 diff --git a/simapp/go.sum b/simapp/go.sum index 896f6661b07e..23a58718a61e 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -308,8 +308,8 @@ github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:z github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA= github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c= -github.com/cometbft/cometbft v0.37.1 h1:KLxkQTK2hICXYq21U2hn1W5hOVYUdQgDQ1uB+90xPIg= -github.com/cometbft/cometbft v0.37.1/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= +github.com/cometbft/cometbft v0.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc= +github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo= github.com/cometbft/cometbft-db v0.7.0/go.mod h1:yiKJIm2WKrt6x8Cyxtq9YTEcIMPcEe4XPxhgX59Fzf0= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= diff --git a/tests/go.mod b/tests/go.mod index dfc4f7a77766..e87f81a0b21f 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/depinject v1.0.0-alpha.3 cosmossdk.io/math v1.0.1 cosmossdk.io/simapp v0.0.0-00010101000000-000000000000 - github.com/cometbft/cometbft v0.37.1 + github.com/cometbft/cometbft v0.37.2 github.com/cometbft/cometbft-db v0.7.0 github.com/cosmos/cosmos-sdk v0.47.2 github.com/cosmos/gogoproto v1.4.10 diff --git a/tests/go.sum b/tests/go.sum index 23b319b8815a..afc5bab86afa 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -308,8 +308,8 @@ github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:z github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA= github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c= -github.com/cometbft/cometbft v0.37.1 h1:KLxkQTK2hICXYq21U2hn1W5hOVYUdQgDQ1uB+90xPIg= -github.com/cometbft/cometbft v0.37.1/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= +github.com/cometbft/cometbft v0.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc= +github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo= github.com/cometbft/cometbft-db v0.7.0/go.mod h1:yiKJIm2WKrt6x8Cyxtq9YTEcIMPcEe4XPxhgX59Fzf0= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= diff --git a/tools/cosmovisor/go.mod b/tools/cosmovisor/go.mod index cb0102a8df44..980c35e36a10 100644 --- a/tools/cosmovisor/go.mod +++ b/tools/cosmovisor/go.mod @@ -34,7 +34,7 @@ require ( github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/cometbft/cometbft v0.37.0 // indirect + github.com/cometbft/cometbft v0.37.2 // indirect github.com/cometbft/cometbft-db v0.7.0 // indirect github.com/confio/ics23/go v0.9.0 // indirect github.com/cosmos/btcutil v1.0.5 // indirect diff --git a/tools/cosmovisor/go.sum b/tools/cosmovisor/go.sum index 3fae47182027..cad7181ea01b 100644 --- a/tools/cosmovisor/go.sum +++ b/tools/cosmovisor/go.sum @@ -267,8 +267,8 @@ github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd/v3 v3.1.0 h1:MK3Ow7LH0W8zkd5GMKA1PvS9qG3bWFI95WaVNfyZJ/w= github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA= -github.com/cometbft/cometbft v0.37.0 h1:M005vBaSaugvYYmNZwJOopynQSjwLoDTwflnQ/I/eYk= -github.com/cometbft/cometbft v0.37.0/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= +github.com/cometbft/cometbft v0.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc= +github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo= github.com/cometbft/cometbft-db v0.7.0/go.mod h1:yiKJIm2WKrt6x8Cyxtq9YTEcIMPcEe4XPxhgX59Fzf0= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= diff --git a/tools/rosetta/go.mod b/tools/rosetta/go.mod index 95dec28e33d1..5bcb850aabd9 100644 --- a/tools/rosetta/go.mod +++ b/tools/rosetta/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/math v1.0.1 github.com/btcsuite/btcd/btcec/v2 v2.3.2 github.com/coinbase/rosetta-sdk-go/types v1.0.0 - github.com/cometbft/cometbft v0.37.1 + github.com/cometbft/cometbft v0.37.2 github.com/cosmos/cosmos-sdk v0.47.0-rc3 github.com/cosmos/rosetta-sdk-go v0.10.0 github.com/spf13/cobra v1.6.1 diff --git a/tools/rosetta/go.sum b/tools/rosetta/go.sum index 7deba08476d0..e3bc36122698 100644 --- a/tools/rosetta/go.sum +++ b/tools/rosetta/go.sum @@ -102,8 +102,8 @@ github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnht github.com/cockroachdb/apd/v3 v3.1.0 h1:MK3Ow7LH0W8zkd5GMKA1PvS9qG3bWFI95WaVNfyZJ/w= github.com/coinbase/rosetta-sdk-go/types v1.0.0 h1:jpVIwLcPoOeCR6o1tU+Xv7r5bMONNbHU7MuEHboiFuA= github.com/coinbase/rosetta-sdk-go/types v1.0.0/go.mod h1:eq7W2TMRH22GTW0N0beDnN931DW0/WOI1R2sdHNHG4c= -github.com/cometbft/cometbft v0.37.1 h1:KLxkQTK2hICXYq21U2hn1W5hOVYUdQgDQ1uB+90xPIg= -github.com/cometbft/cometbft v0.37.1/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= +github.com/cometbft/cometbft v0.37.2 h1:XB0yyHGT0lwmJlFmM4+rsRnczPlHoAKFX6K8Zgc2/Jc= +github.com/cometbft/cometbft v0.37.2/go.mod h1:Y2MMMN//O5K4YKd8ze4r9jmk4Y7h0ajqILXbH5JQFVs= github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo= github.com/cometbft/cometbft-db v0.7.0/go.mod h1:yiKJIm2WKrt6x8Cyxtq9YTEcIMPcEe4XPxhgX59Fzf0= github.com/confio/ics23/go v0.9.0 h1:cWs+wdbS2KRPZezoaaj+qBleXgUk5WOQFMP3CQFGTr4= From de4e55dc930fdbb57b5ac74f9a2fb8fe9c84120e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 15 Jun 2023 12:56:59 +0200 Subject: [PATCH 07/14] fix(x/auth): ensure nil .BaseAccounts are reported in ModuleAccount.Validate (backport #16554) (#16569) Co-authored-by: Emmanuel T Odeke Co-authored-by: Julien Robert --- CHANGELOG.md | 4 ++++ x/auth/types/account.go | 4 ++++ x/auth/types/account_test.go | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8090d058e60f..abde89f98759 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (deps) [#16565](https://github.com/cosmos/cosmos-sdk/pull/16565) Bump CometBFT to [v0.37.2](https://github.com/cometbft/cometbft/blob/v0.37.2/CHANGELOG.md). +### Bug Fixes + +* (x/auth) [#16554](https://github.com/cosmos/cosmos-sdk/pull/16554) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking. + ## [v0.47.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.3) - 2023-06-08 ### Features diff --git a/x/auth/types/account.go b/x/auth/types/account.go index 313b563b98ac..fbdef4e89257 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -236,6 +236,10 @@ func (ma ModuleAccount) Validate() error { return errors.New("module account name cannot be blank") } + if ma.BaseAccount == nil { + return errors.New("uninitialized ModuleAccount: BaseAccount is nil") + } + if ma.Address != sdk.AccAddress(crypto.AddressHash([]byte(ma.Name))).String() { return fmt.Errorf("address %s cannot be derived from the module name '%s'", ma.Address, ma.Name) } diff --git a/x/auth/types/account_test.go b/x/auth/types/account_test.go index d465ed852568..74ab5784b199 100644 --- a/x/auth/types/account_test.go +++ b/x/auth/types/account_test.go @@ -228,3 +228,8 @@ func TestNewModuleAddressOrBech32Address(t *testing.T) { require.Equal(t, input, types.NewModuleAddressOrBech32Address(input).String()) require.Equal(t, "cosmos1jv65s3grqf6v6jl3dp4t6c9t9rk99cd88lyufl", types.NewModuleAddressOrBech32Address("distribution").String()) } + +func TestModuleAccountValidateNilBaseAccount(t *testing.T) { + ma := &types.ModuleAccount{Name: "foo"} + _ = ma.Validate() +} From 40c4daf28043b1dda720955b9c2215828bfe9fca Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 19 Jun 2023 09:44:39 +0200 Subject: [PATCH 08/14] fix: snapshotter's failure is not propogated (backport #16588) (#16603) Co-authored-by: yihuang --- CHANGELOG.md | 1 + snapshots/chunk.go | 8 +++++--- snapshots/helpers_test.go | 32 ++++++++++++++++++++++++++++++++ snapshots/manager_test.go | 12 ++++++++++++ 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abde89f98759..355a696a2bb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes * (x/auth) [#16554](https://github.com/cosmos/cosmos-sdk/pull/16554) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking. +* [#16588](https://github.com/cosmos/cosmos-sdk/pull/16588) Propogate the Snapshotter's failure to the caller, (it will create a empty snapshot silently before). ## [v0.47.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.3) - 2023-06-08 diff --git a/snapshots/chunk.go b/snapshots/chunk.go index 74503f058027..af05303b4536 100644 --- a/snapshots/chunk.go +++ b/snapshots/chunk.go @@ -58,11 +58,13 @@ func (w *ChunkWriter) Close() error { // CloseWithError closes the writer and sends an error to the reader. func (w *ChunkWriter) CloseWithError(err error) { if !w.closed { + if w.pipe == nil { + // create a dummy pipe just to propagate the error to the reader, it always returns nil + _ = w.chunk() + } w.closed = true close(w.ch) - if w.pipe != nil { - _ = w.pipe.CloseWithError(err) // CloseWithError always returns nil - } + _ = w.pipe.CloseWithError(err) // CloseWithError always returns nil } } diff --git a/snapshots/helpers_test.go b/snapshots/helpers_test.go index 66d8cb7b4330..2167fdf78f2b 100644 --- a/snapshots/helpers_test.go +++ b/snapshots/helpers_test.go @@ -171,6 +171,38 @@ func (m *mockSnapshotter) SetSnapshotInterval(snapshotInterval uint64) { m.snapshotInterval = snapshotInterval } +type mockErrorSnapshotter struct{} + +var _ snapshottypes.Snapshotter = (*mockErrorSnapshotter)(nil) + +func (m *mockErrorSnapshotter) Snapshot(height uint64, protoWriter protoio.Writer) error { + return errors.New("mock snapshot error") +} + +func (m *mockErrorSnapshotter) Restore( + height uint64, format uint32, protoReader protoio.Reader, +) (snapshottypes.SnapshotItem, error) { + return snapshottypes.SnapshotItem{}, errors.New("mock restore error") +} + +func (m *mockErrorSnapshotter) SnapshotFormat() uint32 { + return snapshottypes.CurrentFormat +} + +func (m *mockErrorSnapshotter) SupportedFormats() []uint32 { + return []uint32{snapshottypes.CurrentFormat} +} + +func (m *mockErrorSnapshotter) PruneSnapshotHeight(height int64) { +} + +func (m *mockErrorSnapshotter) GetSnapshotInterval() uint64 { + return 0 +} + +func (m *mockErrorSnapshotter) SetSnapshotInterval(snapshotInterval uint64) { +} + // setupBusyManager creates a manager with an empty store that is busy creating a snapshot at height 1. // The snapshot will complete when the returned closer is called. func setupBusyManager(t *testing.T) *snapshots.Manager { diff --git a/snapshots/manager_test.go b/snapshots/manager_test.go index 9b60691508a1..2e101fbc825e 100644 --- a/snapshots/manager_test.go +++ b/snapshots/manager_test.go @@ -4,12 +4,14 @@ import ( "errors" "testing" + db "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/libs/log" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/snapshots" "github.com/cosmos/cosmos-sdk/snapshots/types" + "github.com/cosmos/cosmos-sdk/testutil" ) var opts = types.NewSnapshotOptions(1500, 2) @@ -243,3 +245,13 @@ func TestManager_Restore(t *testing.T) { }) require.NoError(t, err) } + +func TestManager_TakeError(t *testing.T) { + snapshotter := &mockErrorSnapshotter{} + store, err := snapshots.NewStore(db.NewMemDB(), testutil.GetTempDir(t)) + require.NoError(t, err) + manager := snapshots.NewManager(store, opts, snapshotter, nil, log.NewNopLogger()) + + _, err = manager.Create(1) + require.Error(t, err) +} From 48c3134afb56cc03f1c143eafa5737ae0b18ef84 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 23 Jun 2023 22:13:38 +0000 Subject: [PATCH 09/14] docs: correct comment typo in address.go (backport #16671) (#16675) Co-authored-by: ww4tson <133960002+ww4tson@users.noreply.github.com> --- types/address.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/address.go b/types/address.go index c8818587f8e3..47928da90b7e 100644 --- a/types/address.go +++ b/types/address.go @@ -370,7 +370,7 @@ func (va ValAddress) Equals(va2 Address) bool { return bytes.Equal(va.Bytes(), va2.Bytes()) } -// Returns boolean for whether an AccAddress is empty +// Returns boolean for whether an ValAddress is empty func (va ValAddress) Empty() bool { return len(va) == 0 } From 5802a6b2cdce08e0565cf4adc625cae4d378b051 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 26 Jun 2023 21:03:12 +0000 Subject: [PATCH 10/14] feat: add configurator config options (backport #16672) (#16704) Co-authored-by: Julien Robert --- CHANGELOG.md | 1 + testutil/configurator/configurator.go | 265 ++++++++++++++++---------- 2 files changed, 163 insertions(+), 103 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 355a696a2bb5..6e37750943bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* (testutil) [#16704](https://github.com/cosmos/cosmos-sdk/pull/16704) Make app config configurator for testing for configurable. * (deps) [#16565](https://github.com/cosmos/cosmos-sdk/pull/16565) Bump CometBFT to [v0.37.2](https://github.com/cometbft/cometbft/blob/v0.37.2/CHANGELOG.md). ### Bug Fixes diff --git a/testutil/configurator/configurator.go b/testutil/configurator/configurator.go index 90b04e7c16a3..fff796610bc7 100644 --- a/testutil/configurator/configurator.go +++ b/testutil/configurator/configurator.go @@ -4,13 +4,17 @@ import ( runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" + authzmodulev1 "cosmossdk.io/api/cosmos/authz/module/v1" bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" consensusmodulev1 "cosmossdk.io/api/cosmos/consensus/module/v1" distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1" + evidencemodulev1 "cosmossdk.io/api/cosmos/evidence/module/v1" feegrantmodulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1" genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" govmodulev1 "cosmossdk.io/api/cosmos/gov/module/v1" + groupmodulev1 "cosmossdk.io/api/cosmos/group/module/v1" mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1" + nftmodulev1 "cosmossdk.io/api/cosmos/nft/module/v1" paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" slashingmodulev1 "cosmossdk.io/api/cosmos/slashing/module/v1" stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" @@ -20,82 +24,103 @@ import ( "cosmossdk.io/depinject" ) -var beginBlockOrder = []string{ - "upgrade", - "capability", - "mint", - "distribution", - "slashing", - "evidence", - "staking", - "auth", - "bank", - "gov", - "crisis", - "genutil", - "authz", - "feegrant", - "nft", - "group", - "params", - "consensus", - "vesting", +// Config should never need to be instantiated manually and is solely used for ModuleOption. +type Config struct { + ModuleConfigs map[string]*appv1alpha1.ModuleConfig + BeginBlockersOrder []string + EndBlockersOrder []string + InitGenesisOrder []string + setInitGenesis bool } -var endBlockersOrder = []string{ - "crisis", - "gov", - "staking", - "capability", - "auth", - "bank", - "distribution", - "slashing", - "mint", - "genutil", - "evidence", - "authz", - "feegrant", - "nft", - "group", - "params", - "consensus", - "upgrade", - "vesting", +var defaultConfig = &Config{ + ModuleConfigs: make(map[string]*appv1alpha1.ModuleConfig), + BeginBlockersOrder: []string{ + "upgrade", + "mint", + "distribution", + "slashing", + "evidence", + "staking", + "auth", + "bank", + "gov", + "crisis", + "genutil", + "authz", + "feegrant", + "nft", + "group", + "params", + "consensus", + "vesting", + }, + EndBlockersOrder: []string{ + "crisis", + "gov", + "staking", + "auth", + "bank", + "distribution", + "slashing", + "mint", + "genutil", + "evidence", + "authz", + "feegrant", + "nft", + "group", + "params", + "consensus", + "upgrade", + "vesting", + }, + InitGenesisOrder: []string{ + "auth", + "bank", + "distribution", + "staking", + "slashing", + "gov", + "mint", + "crisis", + "genutil", + "evidence", + "authz", + "feegrant", + "nft", + "group", + "params", + "consensus", + "upgrade", + "vesting", + }, + setInitGenesis: true, } -var initGenesisOrder = []string{ - "capability", - "auth", - "bank", - "distribution", - "staking", - "slashing", - "gov", - "mint", - "crisis", - "genutil", - "evidence", - "authz", - "feegrant", - "nft", - "group", - "params", - "consensus", - "upgrade", - "vesting", +type ModuleOption func(config *Config) + +func WithCustomBeginBlockersOrder(beginBlockOrder ...string) ModuleOption { + return func(config *Config) { + config.BeginBlockersOrder = beginBlockOrder + } } -type appConfig struct { - moduleConfigs map[string]*appv1alpha1.ModuleConfig - setInitGenesis bool +func WithCustomEndBlockersOrder(endBlockersOrder ...string) ModuleOption { + return func(config *Config) { + config.EndBlockersOrder = endBlockersOrder + } } -type ModuleOption func(config *appConfig) +func WithCustomInitGenesisOrder(initGenesisOrder ...string) ModuleOption { + return func(config *Config) { + config.InitGenesisOrder = initGenesisOrder + } +} func BankModule() ModuleOption { - return func(config *appConfig) { - config.moduleConfigs["bank"] = &appv1alpha1.ModuleConfig{ + return func(config *Config) { + config.ModuleConfigs["bank"] = &appv1alpha1.ModuleConfig{ Name: "bank", Config: appconfig.WrapAny(&bankmodulev1.Module{}), } @@ -103,8 +128,8 @@ func BankModule() ModuleOption { } func AuthModule() ModuleOption { - return func(config *appConfig) { - config.moduleConfigs["auth"] = &appv1alpha1.ModuleConfig{ + return func(config *Config) { + config.ModuleConfigs["auth"] = &appv1alpha1.ModuleConfig{ Name: "auth", Config: appconfig.WrapAny(&authmodulev1.Module{ Bech32Prefix: "cosmos", @@ -115,6 +140,7 @@ func AuthModule() ModuleOption { {Account: "bonded_tokens_pool", Permissions: []string{"burner", "staking"}}, {Account: "not_bonded_tokens_pool", Permissions: []string{"burner", "staking"}}, {Account: "gov", Permissions: []string{"burner"}}, + {Account: "nft"}, }, }), } @@ -122,8 +148,8 @@ func AuthModule() ModuleOption { } func ParamsModule() ModuleOption { - return func(config *appConfig) { - config.moduleConfigs["params"] = &appv1alpha1.ModuleConfig{ + return func(config *Config) { + config.ModuleConfigs["params"] = &appv1alpha1.ModuleConfig{ Name: "params", Config: appconfig.WrapAny(¶msmodulev1.Module{}), } @@ -131,8 +157,8 @@ func ParamsModule() ModuleOption { } func TxModule() ModuleOption { - return func(config *appConfig) { - config.moduleConfigs["tx"] = &appv1alpha1.ModuleConfig{ + return func(config *Config) { + config.ModuleConfigs["tx"] = &appv1alpha1.ModuleConfig{ Name: "tx", Config: appconfig.WrapAny(&txconfigv1.Config{}), } @@ -140,8 +166,8 @@ func TxModule() ModuleOption { } func StakingModule() ModuleOption { - return func(config *appConfig) { - config.moduleConfigs["staking"] = &appv1alpha1.ModuleConfig{ + return func(config *Config) { + config.ModuleConfigs["staking"] = &appv1alpha1.ModuleConfig{ Name: "staking", Config: appconfig.WrapAny(&stakingmodulev1.Module{}), } @@ -149,8 +175,8 @@ func StakingModule() ModuleOption { } func SlashingModule() ModuleOption { - return func(config *appConfig) { - config.moduleConfigs["slashing"] = &appv1alpha1.ModuleConfig{ + return func(config *Config) { + config.ModuleConfigs["slashing"] = &appv1alpha1.ModuleConfig{ Name: "slashing", Config: appconfig.WrapAny(&slashingmodulev1.Module{}), } @@ -158,8 +184,8 @@ func SlashingModule() ModuleOption { } func GenutilModule() ModuleOption { - return func(config *appConfig) { - config.moduleConfigs["genutil"] = &appv1alpha1.ModuleConfig{ + return func(config *Config) { + config.ModuleConfigs["genutil"] = &appv1alpha1.ModuleConfig{ Name: "genutil", Config: appconfig.WrapAny(&genutilmodulev1.Module{}), } @@ -167,8 +193,8 @@ func GenutilModule() ModuleOption { } func DistributionModule() ModuleOption { - return func(config *appConfig) { - config.moduleConfigs["distribution"] = &appv1alpha1.ModuleConfig{ + return func(config *Config) { + config.ModuleConfigs["distribution"] = &appv1alpha1.ModuleConfig{ Name: "distribution", Config: appconfig.WrapAny(&distrmodulev1.Module{}), } @@ -176,8 +202,8 @@ func DistributionModule() ModuleOption { } func FeegrantModule() ModuleOption { - return func(config *appConfig) { - config.moduleConfigs["feegrant"] = &appv1alpha1.ModuleConfig{ + return func(config *Config) { + config.ModuleConfigs["feegrant"] = &appv1alpha1.ModuleConfig{ Name: "feegrant", Config: appconfig.WrapAny(&feegrantmodulev1.Module{}), } @@ -185,8 +211,8 @@ func FeegrantModule() ModuleOption { } func VestingModule() ModuleOption { - return func(config *appConfig) { - config.moduleConfigs["vesting"] = &appv1alpha1.ModuleConfig{ + return func(config *Config) { + config.ModuleConfigs["vesting"] = &appv1alpha1.ModuleConfig{ Name: "vesting", Config: appconfig.WrapAny(&vestingmodulev1.Module{}), } @@ -194,8 +220,8 @@ func VestingModule() ModuleOption { } func GovModule() ModuleOption { - return func(config *appConfig) { - config.moduleConfigs["gov"] = &appv1alpha1.ModuleConfig{ + return func(config *Config) { + config.ModuleConfigs["gov"] = &appv1alpha1.ModuleConfig{ Name: "gov", Config: appconfig.WrapAny(&govmodulev1.Module{}), } @@ -203,8 +229,8 @@ func GovModule() ModuleOption { } func ConsensusModule() ModuleOption { - return func(config *appConfig) { - config.moduleConfigs["consensus"] = &appv1alpha1.ModuleConfig{ + return func(config *Config) { + config.ModuleConfigs["consensus"] = &appv1alpha1.ModuleConfig{ Name: "consensus", Config: appconfig.WrapAny(&consensusmodulev1.Module{}), } @@ -212,8 +238,8 @@ func ConsensusModule() ModuleOption { } func MintModule() ModuleOption { - return func(config *appConfig) { - config.moduleConfigs["mint"] = &appv1alpha1.ModuleConfig{ + return func(config *Config) { + config.ModuleConfigs["mint"] = &appv1alpha1.ModuleConfig{ Name: "mint", Config: appconfig.WrapAny(&mintmodulev1.Module{}), GolangBindings: []*appv1alpha1.GolangBinding{ @@ -226,17 +252,50 @@ func MintModule() ModuleOption { } } +func EvidenceModule() ModuleOption { + return func(config *Config) { + config.ModuleConfigs["evidence"] = &appv1alpha1.ModuleConfig{ + Name: "evidence", + Config: appconfig.WrapAny(&evidencemodulev1.Module{}), + } + } +} + +func AuthzModule() ModuleOption { + return func(config *Config) { + config.ModuleConfigs["authz"] = &appv1alpha1.ModuleConfig{ + Name: "authz", + Config: appconfig.WrapAny(&authzmodulev1.Module{}), + } + } +} + +func GroupModule() ModuleOption { + return func(config *Config) { + config.ModuleConfigs["group"] = &appv1alpha1.ModuleConfig{ + Name: "group", + Config: appconfig.WrapAny(&groupmodulev1.Module{}), + } + } +} + +func NFTModule() ModuleOption { + return func(config *Config) { + config.ModuleConfigs["nft"] = &appv1alpha1.ModuleConfig{ + Name: "nft", + Config: appconfig.WrapAny(&nftmodulev1.Module{}), + } + } +} + func OmitInitGenesis() ModuleOption { - return func(config *appConfig) { + return func(config *Config) { config.setInitGenesis = false } } func NewAppConfig(opts ...ModuleOption) depinject.Config { - cfg := &appConfig{ - moduleConfigs: make(map[string]*appv1alpha1.ModuleConfig), - setInitGenesis: true, - } + cfg := defaultConfig for _, opt := range opts { opt(cfg) } @@ -246,25 +305,25 @@ func NewAppConfig(opts ...ModuleOption) depinject.Config { initGenesis := make([]string, 0) overrides := make([]*runtimev1alpha1.StoreKeyConfig, 0) - for _, s := range beginBlockOrder { - if _, ok := cfg.moduleConfigs[s]; ok { + for _, s := range cfg.BeginBlockersOrder { + if _, ok := cfg.ModuleConfigs[s]; ok { beginBlockers = append(beginBlockers, s) } } - for _, s := range endBlockersOrder { - if _, ok := cfg.moduleConfigs[s]; ok { + for _, s := range cfg.EndBlockersOrder { + if _, ok := cfg.ModuleConfigs[s]; ok { endBlockers = append(endBlockers, s) } } - for _, s := range initGenesisOrder { - if _, ok := cfg.moduleConfigs[s]; ok { + for _, s := range cfg.InitGenesisOrder { + if _, ok := cfg.ModuleConfigs[s]; ok { initGenesis = append(initGenesis, s) } } - if _, ok := cfg.moduleConfigs["auth"]; ok { + if _, ok := cfg.ModuleConfigs["auth"]; ok { overrides = append(overrides, &runtimev1alpha1.StoreKeyConfig{ModuleName: "auth", KvStoreKey: "acc"}) } @@ -283,7 +342,7 @@ func NewAppConfig(opts ...ModuleOption) depinject.Config { Config: appconfig.WrapAny(runtimeConfig), }} - for _, m := range cfg.moduleConfigs { + for _, m := range cfg.ModuleConfigs { modules = append(modules, m) } From d681010feed3855aa1bc436573281e7e888ab23f Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 28 Jun 2023 09:30:44 +0000 Subject: [PATCH 11/14] feat: add custom max gas for block for sim config (backport #16656) (#16730) Co-authored-by: mmsqe Co-authored-by: Facundo Medica --- CHANGELOG.md | 4 ++++ types/simulation/config.go | 3 ++- x/simulation/params.go | 4 ++-- x/simulation/simulate.go | 6 +++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e37750943bd..65e98c2e3d03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Features + +* (sims) [#16656](https://github.com/cosmos/cosmos-sdk/pull/16656) Add custom max gas for block for sim config with unlimited as default. + ### Improvements * (testutil) [#16704](https://github.com/cosmos/cosmos-sdk/pull/16704) Make app config configurator for testing for configurable. diff --git a/types/simulation/config.go b/types/simulation/config.go index 7f520004d478..4ed9530a92bc 100644 --- a/types/simulation/config.go +++ b/types/simulation/config.go @@ -22,5 +22,6 @@ type Config struct { OnOperation bool // run slow invariants every operation AllInvariants bool // print all failed invariants if a broken invariant is found - DBBackend string // custom db backend type + DBBackend string // custom db backend type + BlockMaxGas int64 // custom max gas for block } diff --git a/x/simulation/params.go b/x/simulation/params.go index d98373eb92b8..10c5cd7e4ca0 100644 --- a/x/simulation/params.go +++ b/x/simulation/params.go @@ -176,7 +176,7 @@ func (w WeightedProposalContent) ContentSimulatorFn() simulation.ContentSimulato // Consensus Params // randomConsensusParams returns random simulation consensus parameters, it extracts the Evidence from the Staking genesis state. -func randomConsensusParams(r *rand.Rand, appState json.RawMessage, cdc codec.JSONCodec) *tmproto.ConsensusParams { +func randomConsensusParams(r *rand.Rand, appState json.RawMessage, cdc codec.JSONCodec, maxGas int64) *tmproto.ConsensusParams { var genesisState map[string]json.RawMessage err := json.Unmarshal(appState, &genesisState) if err != nil { @@ -187,7 +187,7 @@ func randomConsensusParams(r *rand.Rand, appState json.RawMessage, cdc codec.JSO consensusParams := &tmproto.ConsensusParams{ Block: &tmproto.BlockParams{ MaxBytes: int64(simulation.RandIntBetween(r, 20000000, 30000000)), - MaxGas: -1, + MaxGas: maxGas, }, Validator: &tmproto.ValidatorParams{ PubKeyTypes: []string{types.ABCIPubKeyTypeEd25519}, diff --git a/x/simulation/simulate.go b/x/simulation/simulate.go index aca40c94f4b8..6affec9249ac 100644 --- a/x/simulation/simulate.go +++ b/x/simulation/simulate.go @@ -31,8 +31,12 @@ func initChain( config simulation.Config, cdc codec.JSONCodec, ) (mockValidators, time.Time, []simulation.Account, string) { + blockMaxGas := int64(-1) + if config.BlockMaxGas > 0 { + blockMaxGas = config.BlockMaxGas + } appState, accounts, chainID, genesisTimestamp := appStateFn(r, accounts, config) - consensusParams := randomConsensusParams(r, appState, cdc) + consensusParams := randomConsensusParams(r, appState, cdc, blockMaxGas) req := abci.RequestInitChain{ AppStateBytes: appState, ChainId: chainID, From 398214f28dfaccea772f282fe91aeb00f22db61d Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 30 Jun 2023 20:32:34 +0200 Subject: [PATCH 12/14] fix(x/slashing): Emit slashing event with the correct reason in SlashWithInfractionReason (backport #16784) (#16793) --- CHANGELOG.md | 1 + x/slashing/keeper/keeper.go | 11 ++++++++++- x/slashing/types/events.go | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65e98c2e3d03..16615f3a8734 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/auth) [#16554](https://github.com/cosmos/cosmos-sdk/pull/16554) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking. * [#16588](https://github.com/cosmos/cosmos-sdk/pull/16588) Propogate the Snapshotter's failure to the caller, (it will create a empty snapshot silently before). +* (x/slashing) [#16784](https://github.com/cosmos/cosmos-sdk/pull/16784) Emit event with the correct reason in SlashWithInfractionReason. ## [v0.47.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.3) - 2023-06-08 diff --git a/x/slashing/keeper/keeper.go b/x/slashing/keeper/keeper.go index 92c9b4d79561..5535dd2436c9 100644 --- a/x/slashing/keeper/keeper.go +++ b/x/slashing/keeper/keeper.go @@ -79,12 +79,21 @@ func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, fraction sdk.De // module to make the necessary validator changes. It specifies an intraction reason. func (k Keeper) SlashWithInfractionReason(ctx sdk.Context, consAddr sdk.ConsAddress, fraction sdk.Dec, power, distributionHeight int64, infraction stakingtypes.Infraction) { coinsBurned := k.sk.SlashWithInfractionReason(ctx, consAddr, distributionHeight, power, fraction, infraction) + + reasonAttr := sdk.NewAttribute(types.AttributeKeyReason, types.AttributeValueUnspecified) + switch infraction { + case stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN: + reasonAttr = sdk.NewAttribute(types.AttributeKeyReason, types.AttributeValueDoubleSign) + case stakingtypes.Infraction_INFRACTION_DOWNTIME: + reasonAttr = sdk.NewAttribute(types.AttributeKeyReason, types.AttributeValueMissingSignature) + } + ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeSlash, sdk.NewAttribute(types.AttributeKeyAddress, consAddr.String()), sdk.NewAttribute(types.AttributeKeyPower, fmt.Sprintf("%d", power)), - sdk.NewAttribute(types.AttributeKeyReason, types.AttributeValueDoubleSign), + reasonAttr, sdk.NewAttribute(types.AttributeKeyBurnedCoins, coinsBurned.String()), ), ) diff --git a/x/slashing/types/events.go b/x/slashing/types/events.go index 600e59932ec2..af115fee539f 100644 --- a/x/slashing/types/events.go +++ b/x/slashing/types/events.go @@ -13,6 +13,7 @@ const ( AttributeKeyMissedBlocks = "missed_blocks" AttributeKeyBurnedCoins = "burned_coins" + AttributeValueUnspecified = "unspecified" AttributeValueDoubleSign = "double_sign" AttributeValueMissingSignature = "missing_signature" ) From 1ee99c0fe762ab06639528f0562a8af112bf8e9f Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 4 Jul 2023 19:47:17 +0000 Subject: [PATCH 13/14] fix: properly use `--trace` flag (backport #16827) (#16831) Co-authored-by: Julien Robert --- CHANGELOG.md | 1 + go.mod | 8 ++++---- go.sum | 16 ++++++++-------- server/util.go | 8 +++----- simapp/go.mod | 6 +++--- simapp/go.sum | 14 +++++++------- tests/go.mod | 8 ++++---- tests/go.sum | 16 ++++++++-------- 8 files changed, 38 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16615f3a8734..7face7e81009 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (server) [#16827](https://github.com/cosmos/cosmos-sdk/pull/16827) Properly use `--trace` flag (before it was setting the trace level instead of displaying the stacktraces). * (x/auth) [#16554](https://github.com/cosmos/cosmos-sdk/pull/16554) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking. * [#16588](https://github.com/cosmos/cosmos-sdk/pull/16588) Propogate the Snapshotter's failure to the caller, (it will create a empty snapshot silently before). * (x/slashing) [#16784](https://github.com/cosmos/cosmos-sdk/pull/16784) Emit event with the correct reason in SlashWithInfractionReason. diff --git a/go.mod b/go.mod index 405d3ad9159a..b910dd85f282 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( cosmossdk.io/core v0.5.1 cosmossdk.io/depinject v1.0.0-alpha.3 cosmossdk.io/errors v1.0.0-beta.7 - cosmossdk.io/log v1.1.0 + cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca cosmossdk.io/math v1.0.1 cosmossdk.io/tools/rosetta v0.2.1 github.com/99designs/keyring v1.2.1 @@ -42,7 +42,7 @@ require ( github.com/jhump/protoreflect v1.15.1 github.com/magiconair/properties v1.8.6 github.com/manifoldco/promptui v0.9.0 - github.com/mattn/go-isatty v0.0.18 + github.com/mattn/go-isatty v0.0.19 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.14.0 github.com/prometheus/common v0.42.0 @@ -60,7 +60,7 @@ require ( google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 google.golang.org/grpc v1.55.0 google.golang.org/protobuf v1.30.0 - gotest.tools/v3 v3.4.0 + gotest.tools/v3 v3.5.0 pgregory.net/rapid v0.5.5 sigs.k8s.io/yaml v1.3.0 ) @@ -156,7 +156,7 @@ require ( go.opencensus.io v0.24.0 // indirect golang.org/x/net v0.9.0 // indirect golang.org/x/oauth2 v0.6.0 // indirect - golang.org/x/sys v0.7.0 // indirect + golang.org/x/sys v0.8.0 // indirect golang.org/x/term v0.7.0 // indirect golang.org/x/text v0.9.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect diff --git a/go.sum b/go.sum index 5d1f42f9caa9..083415350b4c 100644 --- a/go.sum +++ b/go.sum @@ -196,8 +196,8 @@ cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= -cosmossdk.io/log v1.1.0 h1:v0ogPHYeTzPcBTcPR1A3j1hkei4pZama8kz8LKlCMv0= -cosmossdk.io/log v1.1.0/go.mod h1:6zjroETlcDs+mm62gd8Ig7mZ+N+fVOZS91V17H+M4N4= +cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca h1:msenprh2BLLRwNT7zN56TbBHOGk/7ARQckXHxXyvjoQ= +cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca/go.mod h1:PkIAKXZvaxrTRc++z53XMRvFk8AcGGWYHcMIPzVYX9c= cosmossdk.io/math v1.0.1 h1:Qx3ifyOPaMLNH/89WeZFH268yCvU4xEcnPLu3sJqPPg= cosmossdk.io/math v1.0.1/go.mod h1:Ygz4wBHrgc7g0N+8+MrnTfS9LLn9aaTGa9hKopuym5k= cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw= @@ -724,8 +724,8 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= -github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -1259,8 +1259,8 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1622,8 +1622,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o= -gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g= +gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= +gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/server/util.go b/server/util.go index 0d88fb19095f..58323b0d2108 100644 --- a/server/util.go +++ b/server/util.go @@ -24,7 +24,6 @@ import ( dbm "github.com/cometbft/cometbft-db" tmcmd "github.com/cometbft/cometbft/cmd/cometbft/commands" tmcfg "github.com/cometbft/cometbft/config" - tmcli "github.com/cometbft/cometbft/libs/cli" tmlog "github.com/cometbft/cometbft/libs/log" tmtypes "github.com/cometbft/cometbft/types" @@ -174,15 +173,14 @@ func InterceptConfigsPreRunHandler(cmd *cobra.Command, customAppConfigTemplate s } opts = append(opts, log.FilterOption(filterFunc)) - case serverCtx.Viper.GetBool(tmcli.TraceFlag): - // Check if the CometBFT flag for trace logging is set if it is then setup a tracing logger in this app as well. - // Note it overrides log level passed in `log_levels`. - opts = append(opts, log.LevelOption(zerolog.TraceLevel)) default: opts = append(opts, log.LevelOption(logLvl)) } } + // Check if the CometBFT flag for trace logging is set and enable stack traces if so. + opts = append(opts, log.TraceOption(serverCtx.Viper.GetBool("trace"))) // cmtcli.TraceFlag + logger := log.NewLogger(tmlog.NewSyncWriter(os.Stdout), opts...).With(log.ModuleKey, "server") serverCtx.Logger = serverlog.CometLoggerWrapper{Logger: logger} diff --git a/simapp/go.mod b/simapp/go.mod index f5c13d2cb08c..088b1775fa0a 100644 --- a/simapp/go.mod +++ b/simapp/go.mod @@ -27,7 +27,7 @@ require ( cloud.google.com/go/iam v0.12.0 // indirect cloud.google.com/go/storage v1.29.0 // indirect cosmossdk.io/errors v1.0.0-beta.7 // indirect - cosmossdk.io/log v1.1.0 // indirect + cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect @@ -108,7 +108,7 @@ require ( github.com/magiconair/properties v1.8.6 // indirect github.com/manifoldco/promptui v0.9.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect github.com/minio/highwayhash v1.0.2 // indirect @@ -146,7 +146,7 @@ require ( golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect golang.org/x/net v0.9.0 // indirect golang.org/x/oauth2 v0.6.0 // indirect - golang.org/x/sys v0.7.0 // indirect + golang.org/x/sys v0.8.0 // indirect golang.org/x/term v0.7.0 // indirect golang.org/x/text v0.9.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect diff --git a/simapp/go.sum b/simapp/go.sum index 23a58718a61e..ae2027812aa6 100644 --- a/simapp/go.sum +++ b/simapp/go.sum @@ -196,8 +196,8 @@ cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= -cosmossdk.io/log v1.1.0 h1:v0ogPHYeTzPcBTcPR1A3j1hkei4pZama8kz8LKlCMv0= -cosmossdk.io/log v1.1.0/go.mod h1:6zjroETlcDs+mm62gd8Ig7mZ+N+fVOZS91V17H+M4N4= +cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca h1:msenprh2BLLRwNT7zN56TbBHOGk/7ARQckXHxXyvjoQ= +cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca/go.mod h1:PkIAKXZvaxrTRc++z53XMRvFk8AcGGWYHcMIPzVYX9c= cosmossdk.io/math v1.0.1 h1:Qx3ifyOPaMLNH/89WeZFH268yCvU4xEcnPLu3sJqPPg= cosmossdk.io/math v1.0.1/go.mod h1:Ygz4wBHrgc7g0N+8+MrnTfS9LLn9aaTGa9hKopuym5k= cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw= @@ -719,8 +719,8 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= -github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -1251,8 +1251,8 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1615,7 +1615,7 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= -gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o= +gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/tests/go.mod b/tests/go.mod index e87f81a0b21f..9cff46fb9758 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -16,7 +16,7 @@ require ( github.com/spf13/cobra v1.6.1 github.com/stretchr/testify v1.8.2 google.golang.org/protobuf v1.30.0 - gotest.tools/v3 v3.4.0 + gotest.tools/v3 v3.5.0 pgregory.net/rapid v0.5.5 ) @@ -28,7 +28,7 @@ require ( cloud.google.com/go/storage v1.29.0 // indirect cosmossdk.io/core v0.5.1 // indirect cosmossdk.io/errors v1.0.0-beta.7 // indirect - cosmossdk.io/log v1.1.0 // indirect + cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca // indirect cosmossdk.io/tools/rosetta v0.2.1 // indirect filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect @@ -108,7 +108,7 @@ require ( github.com/magiconair/properties v1.8.6 // indirect github.com/manifoldco/promptui v0.9.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect github.com/minio/highwayhash v1.0.2 // indirect @@ -149,7 +149,7 @@ require ( golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect golang.org/x/net v0.9.0 // indirect golang.org/x/oauth2 v0.6.0 // indirect - golang.org/x/sys v0.7.0 // indirect + golang.org/x/sys v0.8.0 // indirect golang.org/x/term v0.7.0 // indirect golang.org/x/text v0.9.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect diff --git a/tests/go.sum b/tests/go.sum index afc5bab86afa..1b18ed7a16ab 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -196,8 +196,8 @@ cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= -cosmossdk.io/log v1.1.0 h1:v0ogPHYeTzPcBTcPR1A3j1hkei4pZama8kz8LKlCMv0= -cosmossdk.io/log v1.1.0/go.mod h1:6zjroETlcDs+mm62gd8Ig7mZ+N+fVOZS91V17H+M4N4= +cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca h1:msenprh2BLLRwNT7zN56TbBHOGk/7ARQckXHxXyvjoQ= +cosmossdk.io/log v1.1.1-0.20230704160919-88f2c830b0ca/go.mod h1:PkIAKXZvaxrTRc++z53XMRvFk8AcGGWYHcMIPzVYX9c= cosmossdk.io/math v1.0.1 h1:Qx3ifyOPaMLNH/89WeZFH268yCvU4xEcnPLu3sJqPPg= cosmossdk.io/math v1.0.1/go.mod h1:Ygz4wBHrgc7g0N+8+MrnTfS9LLn9aaTGa9hKopuym5k= cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw= @@ -722,8 +722,8 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= -github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -1259,8 +1259,8 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1623,8 +1623,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o= -gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g= +gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= +gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= From 54db4204e7f609808de47b79d3e67e530e66cb9b Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 7 Jul 2023 14:27:21 +0200 Subject: [PATCH 14/14] fix(cli): improve `prune` command ux (backport #16856) (#16875) Co-authored-by: Julien Robert --- CHANGELOG.md | 1 + client/pruning/main.go | 72 ++++++++++++++++++++++++----------------- simapp/simd/cmd/root.go | 2 +- 3 files changed, 45 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7face7e81009..b6f6d7004d45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* (cli) [#16856](https://github.com/cosmos/cosmos-sdk/pull/16856) Improve `simd prune` UX by using the app default home directory and set pruning method as first variable argument (defaults to default). `pruning.PruningCmd` rest unchanged for API compability, use `pruning.Cmd` instead. * (testutil) [#16704](https://github.com/cosmos/cosmos-sdk/pull/16704) Make app config configurator for testing for configurable. * (deps) [#16565](https://github.com/cosmos/cosmos-sdk/pull/16565) Bump CometBFT to [v0.37.2](https://github.com/cometbft/cometbft/blob/v0.37.2/CHANGELOG.md). diff --git a/client/pruning/main.go b/client/pruning/main.go index 96b3cd42bd30..247cd2c360c9 100644 --- a/client/pruning/main.go +++ b/client/pruning/main.go @@ -21,41 +21,60 @@ const FlagAppDBBackend = "app-db-backend" // PruningCmd prunes the sdk root multi store history versions based on the pruning options // specified by command flags. +// Deprecated: Use Cmd instead. func PruningCmd(appCreator servertypes.AppCreator) *cobra.Command { + cmd := Cmd(appCreator, "") + cmd.Flags().String(server.FlagPruning, pruningtypes.PruningOptionDefault, "Pruning strategy (default|nothing|everything|custom)") + + return cmd +} + +// Cmd prunes the sdk root multi store history versions based on the pruning options +// specified by command flags. +func Cmd(appCreator servertypes.AppCreator, defaultNodeHome string) *cobra.Command { cmd := &cobra.Command{ - Use: "prune", + Use: "prune [pruning-method]", Short: "Prune app history states by keeping the recent heights and deleting old heights", Long: `Prune app history states by keeping the recent heights and deleting old heights. - The pruning option is provided via the '--pruning' flag or alternatively with '--pruning-keep-recent' - - For '--pruning' the options are as follows: - - default: the last 362880 states are kept - nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node) - everything: 2 latest states will be kept - custom: allow pruning options to be manually specified through 'pruning-keep-recent'. - besides pruning options, database home directory and database backend type should also be specified via flags - '--home' and '--app-db-backend'. - valid app-db-backend type includes 'goleveldb', 'cleveldb', 'rocksdb', 'boltdb', and 'badgerdb'. - `, - Example: "prune --home './' --app-db-backend 'goleveldb' --pruning 'custom' --pruning-keep-recent 100", - RunE: func(cmd *cobra.Command, _ []string) error { - vp := viper.New() +The pruning option is provided via the 'pruning' argument or alternatively with '--pruning-keep-recent' - // Bind flags to the Context's Viper so we can get pruning options. +- default: the last 362880 states are kept +- nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node) +- everything: 2 latest states will be kept +- custom: allow pruning options to be manually specified through 'pruning-keep-recent' + +Note: When the --app-db-backend flag is not specified, the default backend type is 'goleveldb'. +Supported app-db-backend types include 'goleveldb', 'rocksdb', 'pebbledb'.`, + Example: "prune custom --pruning-keep-recent 100 --app-db-backend 'goleveldb'", + Args: cobra.RangeArgs(0, 1), + RunE: func(cmd *cobra.Command, args []string) error { + // bind flags to the Context's Viper so we can get pruning options. + vp := viper.New() if err := vp.BindPFlags(cmd.Flags()); err != nil { return err } + + // use the first argument if present to set the pruning method + if len(args) > 0 { + vp.Set(server.FlagPruning, args[0]) + } else if vp.GetString(server.FlagPruning) == "" { // this differs from orignal https://github.com/cosmos/cosmos-sdk/pull/16856 for compatibility + vp.Set(server.FlagPruning, pruningtypes.PruningOptionDefault) + } pruningOptions, err := server.GetPruningOptionsFromFlags(vp) if err != nil { return err } - fmt.Printf("get pruning options from command flags, strategy: %v, keep-recent: %v\n", + + cmd.Printf("get pruning options from command flags, strategy: %v, keep-recent: %v\n", pruningOptions.Strategy, pruningOptions.KeepRecent, ) home := vp.GetString(flags.FlagHome) + if home == "" { + home = defaultNodeHome + } + db, err := openDB(home, server.GetAppDBBackend(vp)) if err != nil { return err @@ -82,27 +101,22 @@ func PruningCmd(appCreator servertypes.AppCreator) *cobra.Command { } } if len(pruningHeights) == 0 { - fmt.Printf("no heights to prune\n") + cmd.Println("no heights to prune") return nil } - fmt.Printf( - "pruning heights start from %v, end at %v\n", - pruningHeights[0], - pruningHeights[len(pruningHeights)-1], - ) + cmd.Printf("pruning heights start from %v, end at %v\n", pruningHeights[0], pruningHeights[len(pruningHeights)-1]) - err = rootMultiStore.PruneStores(false, pruningHeights) - if err != nil { + if err = rootMultiStore.PruneStores(false, pruningHeights); err != nil { return err } - fmt.Printf("successfully pruned the application root multi stores\n") + + cmd.Println("successfully pruned the application root multi stores") return nil }, } - cmd.Flags().String(flags.FlagHome, "", "The database home directory") + cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory") cmd.Flags().String(FlagAppDBBackend, "", "The type of database for application and snapshots databases") - cmd.Flags().String(server.FlagPruning, pruningtypes.PruningOptionDefault, "Pruning strategy (default|nothing|everything|custom)") cmd.Flags().Uint64(server.FlagPruningKeepRecent, 0, "Number of recent heights to keep on disk (ignored if pruning is not 'custom')") cmd.Flags().Uint64(server.FlagPruningInterval, 10, `Height interval at which pruned heights are removed from disk (ignored if pruning is not 'custom'), diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index 849409eb1416..6bb213832cd0 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -170,7 +170,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { NewTestnetCmd(simapp.ModuleBasics, banktypes.GenesisBalancesIterator{}), debug.Cmd(), config.Cmd(), - pruning.PruningCmd(newApp), + pruning.Cmd(newApp, simapp.DefaultNodeHome), snapshot.Cmd(newApp), )