From bdb7387fa991eefc12962735b90df9d887935a6c Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Mon, 7 Aug 2023 17:53:45 +0200 Subject: [PATCH] refactor: reword upgrading.md and verify match with repo (#17262) --- CHANGELOG.md | 5 +- UPGRADING.md | 59 ++++++++++++++------ docs/architecture/adr-038-state-listening.md | 9 ++- simapp/app_config.go | 3 - simapp/app_v2.go | 3 - x/consensus/module.go | 27 --------- x/genutil/client/cli/commands.go | 6 -- 7 files changed, 49 insertions(+), 63 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f52e0bcac161..62a80c8f5b00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,7 +103,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/slashing) [#17098](https://github.com/cosmos/cosmos-sdk/pull/17098) `NewMsgUnjail` takes a string instead of `sdk.ValAddress` * (x/genutil) [#17098](https://github.com/cosmos/cosmos-sdk/pull/17098) `GenAppStateFromConfig`, AddGenesisAccountCmd and `GenTxCmd` takes an addresscodec to decode addresses * (x/distribution) [#17098](https://github.com/cosmos/cosmos-sdk/pull/17098) `NewMsgDepositValidatorRewardsPool`, `NewMsgFundCommunityPool`, `NewMsgWithdrawValidatorCommission` and `NewMsgWithdrawDelegatorReward` takes a string instead of `sdk.ValAddress` or `sdk.AccAddress` -* (client) [#17215](https://github.com/cosmos/cosmos-sdk/pull/17215) `server.StartCmd`,`server.ExportCmd`,`server.NewRollbackCmd`,`pruning.Cmd`,`genutilcli.InitCmd`,`genutilcli.GenTxCmd`,`genutilcli.CollectGenTxsCmd`,`genutilcli.AddGenesisAccountCmd`, `genutilcli.GenesisCoreCommand` do not take a home directory anymore. It is inferred from the root command. +* (client) [#17215](https://github.com/cosmos/cosmos-sdk/pull/17215) `server.StartCmd`,`server.ExportCmd`,`server.NewRollbackCmd`,`pruning.Cmd`,`genutilcli.InitCmd`,`genutilcli.GenTxCmd`,`genutilcli.CollectGenTxsCmd`,`genutilcli.AddGenesisAccountCmd`, do not take a home directory anymore. It is inferred from the root command. ### CLI Breaking Changes @@ -187,8 +187,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (crypto/keyring) [#14151](https://github.com/cosmos/cosmos-sdk/pull/14151) Move keys presentation from `crypto/keyring` to `client/keys` * (signing) [#14087](https://github.com/cosmos/cosmos-sdk/pull/14087) Add SignModeHandlerWithContext interface with a new `GetSignBytesWithContext` to get the sign bytes using `context.Context` as an argument to access state. * (server) [#14062](https://github.com/cosmos/cosmos-sdk/pull/14062) Remove rosetta from server start. -* (baseapp) [#14417](https://github.com/cosmos/cosmos-sdk/pull/14417) `SetStreamingService` accepts appOptions, AppCodec and Storekeys needed to set streamers. - * Store pacakge no longer has a dependency on baseapp. +* (baseapp) [#14417](https://github.com/cosmos/cosmos-sdk/pull/14417) The store pacakge no longer has a dependency on baseapp. * (store) [#14438](https://github.com/cosmos/cosmos-sdk/pull/14438) Pass logger from baseapp to store. * (store) [#14439](https://github.com/cosmos/cosmos-sdk/pull/14439) Remove global metric gatherer from store. * By default store has a no op metric gatherer, the application developer must set another metric gatherer or us the provided one in `store/metrics`. diff --git a/UPGRADING.md b/UPGRADING.md index d1a3ba787b36..e5bf3e291dcd 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -5,6 +5,12 @@ Note, always read the **SimApp** section for more information on application wir ## [Unreleased] +### Migration to Collections + +Most of Cosmos SDK modules have migrated to [collections](https://docs.cosmos.network/main/packages/collections). +Many functions have been removed due to this changes as the API can be smaller thanks to collections. +For modules that have migrated, verify you are checking against `collections.ErrNotFound` when applicable. + ## [v0.50.x](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.0-alpha.0) ### Migration to CometBFT (Part 2) @@ -27,7 +33,7 @@ For backward compatibility, the `**/tendermint/**` gRPC services are still suppo Additionally, the SDK is starting its abstraction from CometBFT Go types thorought the codebase: * The usage of the CometBFT logger has been replaced by the Cosmos SDK logger interface (`cosmossdk.io/log.Logger`). -* The usage of `github.com/cometbft/cometbft/libs/bytes.HexByte` have been replaced by `[]byte`. +* The usage of `github.com/cometbft/cometbft/libs/bytes.HexByte` has been replaced by `[]byte`. #### Enable Vote Extensions @@ -81,12 +87,17 @@ to `BeginBlock` or `EndBlock`. ### Config files -A new tool has been created for migrating configuration of the SDK. Use the following command to migrate your configuration: +Confix is a new SDK tool for modifying and migrating configuration of the SDK. +It is the replacement of the `config.Cmd` command from the `client/config` package. + +Use the following command to migrate your configuration: ```bash simd config migrate v0.50 ``` +If you were using ` config [key]` or ` config [key] [value]` to set and get values from the `client.toml`, replace it with ` config get client [key]` and ` config set client [key] [value]`. The extra verbosity is due to the extra functionalities added in config. + More information about [confix](https://docs.cosmos.network/main/tooling/confix) and how to add it in your application binary in the [documentation](https://docs.cosmos.network/main/tooling/confix). #### gRPC-Web @@ -97,15 +108,13 @@ Use `confix` to clean-up your `app.toml`. A nginx (or alike) reverse-proxy can b #### Database Support -ClevelDB, BoltDB and BadgerDB are not supported anymore. To migrate from a unsupported database to a supported database please use the database migration tool. - -**TODO: talk about db migration tool.** +ClevelDB, BoltDB and BadgerDB are not supported anymore. To migrate from a unsupported database to a supported database please use a database migration tool. ### Protobuf -With the deprecation of the amino JSON codec defined in [cosmos/gogoproto](https://github.com/cosmos/gogoproto) in favor of the protoreflect powered x/tx/aminojson codec, module developers are encouraged verify that their messages have the correct protobuf annotations to deterministically produce identical output from both codecs. +With the deprecation of the Amino JSON codec defined in [cosmos/gogoproto](https://github.com/cosmos/gogoproto) in favor of the protoreflect powered x/tx/aminojson codec, module developers are encouraged verify that their messages have the correct protobuf annotations to deterministically produce identical output from both codecs. -For core SDK types equivalence is asserted by generative testing of [SignableTypes](https://github.com/cosmos/cosmos-sdk/blob/76f0d101530ed78befc95506ab473c771d0d8a8c/tests/integration/rapidgen/rapidgen.go#L106) in [TestAminoJSON_Equivalence](https://github.com/cosmos/cosmos-sdk/blob/76f0d101530ed78befc95506ab473c771d0d8a8c/tests/integration/aminojson/aminojson_test.go#L90). +For core SDK types equivalence is asserted by generative testing of [SignableTypes](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-beta.0/tests/integration/rapidgen/rapidgen.go#L102) in [TestAminoJSON_Equivalence](https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-beta.0/tests/integration/tx/aminojson/aminojson_test.go#L94). **TODO: summarize proto annotation requirements.** @@ -117,7 +126,7 @@ The `gogoproto.goproto_stringer = false` annotation has been removed from most p ### SimApp In this section we describe the changes made in Cosmos SDK' SimApp. -These changes are directly applicable to your application wiring. +**These changes are directly applicable to your application wiring.** #### Module Assertions @@ -156,7 +165,9 @@ app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper( #### Logger -`depinject` / app v2 users must now supply a logger through the main `depinject.Supply` function instead of passing it to `appBuilder.Build`. +Replace all your CometBFT logger imports by `cosmossdk.io/log`. + +Additionally, `depinject` / app v2 users must now supply a logger through the main `depinject.Supply` function instead of passing it to `appBuilder.Build`. ```diff appConfig = depinject.Configs( @@ -248,6 +259,18 @@ References to `types/store.go` which contained aliases for store types have been The `store` module is extracted to have a separate go.mod file which allows it be a standalone module. All the store imports are now renamed to use `cosmossdk.io/store` instead of `github.com/cosmos/cosmos-sdk/store` across the SDK. +##### Streaming + +[ADR-38](https://docs.cosmos.network/main/architecture/adr-038-state-listening) has been implemented in the SDK. + +To continue using state streaming, replace `streaming.LoadStreamingServices` by the following in your `app.go`: + +```go +if err := app.RegisterStreamingServices(appOpts, app.kvStoreKeys()); err != nil { + panic(err) +} +``` + #### Client The return type of the interface method `TxConfig.SignModeHandler()` has been changed from `x/auth/signing.SignModeHandler` to `x/tx/signing.HandlerMap`. This change is transparent to most users as the `TxConfig` interface is typically implemented by private `x/auth/tx.config` struct (as returned by `auth.NewTxConfig`) which has been updated to return the new type. If users have implemented their own `TxConfig` interface, they will need to update their implementation to return the new type. @@ -262,7 +285,7 @@ It is now recommended to validate message directly in the message server. When t * Messages no longer need to implement the `LegacyMsg` interface and implementations of `GetSignBytes` can be deleted. Because of this change, global legacy Amino codec definitions and their registration in `init()` can safely be removed as well. -* The `AppModuleBasic` interface has been simplifed. Defining `GetTxCmd() *cobra.Command` and `GetQueryCmd() *cobra.Command` is no longer required. The module manager registers detects when module commands are defined. If AutoCLI is enabled, `EnhanceRootCommand()` will add the auto-generated commands to the root command, unless a custom module command is defined and register that one instead. +* The `AppModuleBasic` interface has been simplifed. Defining `GetTxCmd() *cobra.Command` and `GetQueryCmd() *cobra.Command` is no longer required. The module manager detects when module commands are defined. If AutoCLI is enabled, `EnhanceRootCommand()` will add the auto-generated commands to the root command, unless a custom module command is defined and register that one instead. * The following modules' `Keeper` methods now take in a `context.Context` instead of `sdk.Context`. Any module that has an interfaces for them (like "expected keepers") will need to update and re-generate mocks if needed: @@ -288,18 +311,18 @@ Capability has been moved to [IBC-GO](https://github.com/cosmos/ibc-go). IBC v8 ##### Expedited Proposals -The `gov` v1 module has been updated to support the ability to expedite governance proposals. When a proposal is expedited, the voting period will be shortened to `ExpeditedVotingPeriod` parameter. An expedited proposal must have an higher voting threshold than a classic proposal, that threshold is defined with the `ExpeditedThreshold` parameter. +The `gov` v1 module now supports expedited governance proposals. When a proposal is expedited, the voting period will be shortened to `ExpeditedVotingPeriod` parameter. An expedited proposal must have an higher voting threshold than a classic proposal, that threshold is defined with the `ExpeditedThreshold` parameter. ##### Cancelling Proposals -The `gov` module has been updated to support the ability to cancel governance proposals. When a proposal is canceled, all the deposits of the proposal are either burnt or sent to `ProposalCancelDest` address. The deposits burn rate will be determined by a new parameter called `ProposalCancelRatio` parameter. +The `gov` module now supports cancelling governance proposals. When a proposal is canceled, all the deposits of the proposal are either burnt or sent to `ProposalCancelDest` address. The deposits burn rate will be determined by a new parameter called `ProposalCancelRatio` parameter. ```text - 1. deposits * proposal_cancel_ratio will be burned or sent to `ProposalCancelDest` address , if `ProposalCancelDest` is empty then deposits will be burned. - 2. deposits * (1 - proposal_cancel_ratio) will be sent to depositors. +1. deposits * proposal_cancel_ratio will be burned or sent to `ProposalCancelDest` address , if `ProposalCancelDest` is empty then deposits will be burned. +2. deposits * (1 - proposal_cancel_ratio) will be sent to depositors. ``` -By default, the new `ProposalCancelRatio` parameter is set to 0.5 during migration and `ProposalCancelDest` is set to empty string (i.e. burnt). +By default, the new `ProposalCancelRatio` parameter is set to `0.5` during migration and `ProposalCancelDest` is set to empty string (i.e. burnt). #### `x/evidence` @@ -333,9 +356,9 @@ All the upgrade imports are now renamed to use `cosmossdk.io/x/upgrade` instead #### Rosetta -Extracted Rosetta tool from the cosmos-sdk and simapp into it's own [rosetta repo](https://github.com/cosmos/rosetta). Any user who is interested on using -the tool can connect it standalone to any node without the need to add it as part of the node binary. The rosetta tool -also allows multi chain connections. +Rosetta has moved to it's own [repo](https://github.com/cosmos/rosetta) and not imported by the Cosmos SDK SimApp by default. +Any user who is interested on using the tool can connect it standalone to any node without the need to add it as part of the node binary. +The rosetta tool also allows multi chain connections. ## [v0.47.x](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.0) diff --git a/docs/architecture/adr-038-state-listening.md b/docs/architecture/adr-038-state-listening.md index 81bfa5a712db..319d872be36e 100644 --- a/docs/architecture/adr-038-state-listening.md +++ b/docs/architecture/adr-038-state-listening.md @@ -568,9 +568,12 @@ func registerABCIListenerPlugin( exposeKeysStr := cast.ToStringSlice(appOpts.Get(keysKey)) exposedKeys := exposeStoreKeysSorted(exposeKeysStr, keys) bApp.cms.AddListeners(exposedKeys) - bApp.SetStreamingService(abciListener) - bApp.stopNodeOnABCIListenerErr = stopNodeOnErr - bApp.abciListenersAsync = async + app.SetStreamingManager( + storetypes.StreamingManager{ + ABCIListeners: []storetypes.ABCIListener{abciListener}, + StopNodeOnErr: stopNodeOnErr, + }, + ) } ``` diff --git a/simapp/app_config.go b/simapp/app_config.go index 402ece7cc7a7..351433f0fece 100644 --- a/simapp/app_config.go +++ b/simapp/app_config.go @@ -116,14 +116,12 @@ var ( slashingtypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, - genutiltypes.ModuleName, authz.ModuleName, }, EndBlockers: []string{ crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName, - genutiltypes.ModuleName, feegrant.ModuleName, group.ModuleName, }, @@ -154,7 +152,6 @@ var ( paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, - consensustypes.ModuleName, circuittypes.ModuleName, }, // When ExportGenesis is not specified, the export genesis module order diff --git a/simapp/app_v2.go b/simapp/app_v2.go index fa0b87791335..50bb5cb3687d 100644 --- a/simapp/app_v2.go +++ b/simapp/app_v2.go @@ -268,9 +268,6 @@ func NewSimApp( return app } -// Name returns the name of the App -func (app *SimApp) Name() string { return app.BaseApp.Name() } - // LegacyAmino returns SimApp's amino codec. // // NOTE: This is solely to be used for testing purposes as it may be desirable diff --git a/x/consensus/module.go b/x/consensus/module.go index ec30b7b8e86d..3a962b5b12b3 100644 --- a/x/consensus/module.go +++ b/x/consensus/module.go @@ -2,9 +2,7 @@ package consensus import ( "context" - "encoding/json" - abci "github.com/cometbft/cometbft/abci/types" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "google.golang.org/grpc" @@ -19,7 +17,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/consensus/keeper" @@ -47,18 +44,6 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { types.RegisterLegacyAminoCodec(cdc) } -// DefaultGenesis returns default genesis state as raw bytes for the consensus -// module. -func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - // nil is returned since default genesis of consensus params is handled by tendermint - return nil -} - -// ValidateGenesis performs genesis state validation -func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { - return nil -} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { @@ -107,18 +92,6 @@ func NewAppModule(cdc codec.Codec, keeper keeper.Keeper) AppModule { // Name returns the consensus module's name. func (AppModule) Name() string { return types.ModuleName } -// InitGenesis is handled by for init genesis of consensus -func (am AppModule) InitGenesis(sdk.Context, codec.JSONCodec, json.RawMessage) []abci.ValidatorUpdate { - // nil is returned since initgenesis of consensus params is handled by tendermint - return nil -} - -// ExportGenesis is handled by CometBFT export of genesis -func (am AppModule) ExportGenesis(sdk.Context, codec.JSONCodec) json.RawMessage { - // nil is returned since ExportGenesis of consensus params is handled by CometBFT and baseapp - return nil -} - // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } diff --git a/x/genutil/client/cli/commands.go b/x/genutil/client/cli/commands.go index bc737886b13d..d4fa48ef781b 100644 --- a/x/genutil/client/cli/commands.go +++ b/x/genutil/client/cli/commands.go @@ -10,12 +10,6 @@ import ( genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" ) -// GenesisCoreCommand adds core sdk's sub-commands into genesis command. -// Deprecated: use Commands instead. -func GenesisCoreCommand(txConfig client.TxConfig, moduleBasics module.BasicManager) *cobra.Command { - return Commands(txConfig, moduleBasics) -} - // Commands adds core sdk's sub-commands into genesis command. func Commands(txConfig client.TxConfig, moduleBasics module.BasicManager) *cobra.Command { return CommandsWithCustomMigrationMap(txConfig, moduleBasics, MigrationMap)