From 7cd3d085881b78a8ca975d2d4126ab9f7cb2ca6c Mon Sep 17 00:00:00 2001 From: Daniel Wedul Date: Mon, 21 Nov 2022 14:30:28 -0700 Subject: [PATCH] Bring in changes from Cosmos-SDK v0.46.6 (#367) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs: add ApplicationQueryService release notes (#13587) * docs: add ApplicationQueryService release notes * updates Co-authored-by: Julien Robert * feat(cli): add module-account cli cmd and grpc get api (backport #13612) (#13616) * feat(cli): add module-account cli cmd and grpc get api (#13612) (cherry picked from commit ddf5cf0d8d26f8beb504cb2fcc2d4a8b0964261c) # Conflicts: # CHANGELOG.md # api/cosmos/auth/v1beta1/query.pulsar.go # api/cosmos/auth/v1beta1/query_grpc.pb.go # x/auth/client/testutil/suite.go # x/auth/types/query.pb.go * fix conflicts * updates * updates Co-authored-by: Sai Kumar <17549398+gsk967@users.noreply.github.com> Co-authored-by: Julien Robert * fix(x/auth): allow multiple = signs in `GetTxsEvent` (backport #12474) (#13598) * fix(x/auth): allow multiple = signs in `GetTxsEvent` (#12474) (cherry picked from commit 18da0e9c15e0210fdd289e3f1f0f5fefe3f6b72a) # Conflicts: # CHANGELOG.md * fix changelog * changelog * fix: flakey test Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> Co-authored-by: Julien Robert * fix: app-hash mismatch if upgrade migration commit is interrupted (backport #13530) (#13627) * feat(cli): Add iavl-disable-fastnode cmd flag with proper description (#13656) (#13659) (cherry picked from commit c833190a166e92039659f0b35f5401d796841532) Co-authored-by: William Chong <6198816+williamchong@users.noreply.github.com> * build(deps): Bump github.com/cosmos/iavl from 0.19.3 to 0.19.4 (#13680) * feat: emit cached context events (backport #13063) (#13702) * chore: prepare 0.46.4 changelog (#13716) * chore: prepare 0.46.4 changelog * wording * updates * updates * ci: notify for 0.46.x releases (#13719) * feat: notify for 0.46.x releases * updates changelog * docs: fix algolia on 0.46 (#13730) * ci: modifying docs in 0.46 should not redeploy docs (#13732) * ci: modifying docs in 0.46 should not redeploy docs * updates * fix: propagate msg events correctly in x/gov (backport #13728) (#13748) * refactor: add error log when iavl set failed (backport #13803) (#13804) * refactor: add error log when iavl set failed (#13803) * add error log when iavl set failed Ref: #12012 * Update CHANGELOG.md * play safe (cherry picked from commit 22f326128559065b33606184bddcde9ad9fbcec3) # Conflicts: # CHANGELOG.md * fix conflicts Co-authored-by: yihuang * chore: bump tendermint to `0.34.23` (#13814) * fix: propagate events in x/group through sdk.Results (backport #13808) (#13809) * docs: update algolia index (#13823) * fix: bank store migration (backport #13821) (#13829) * fix: bank store migration (#13821) (cherry picked from commit d314a12e688060aab6afa63fa8b12bcd69ecb3bd) # Conflicts: # x/bank/migrations/v3/store.go # x/bank/migrations/v3/store_test.go * updates Co-authored-by: billy rennekamp Co-authored-by: Julien Robert * feat(types): set custom GasConfig on Context for GasKVStore (backport #13826) (#13833) * feat(types): set custom GasConfig on Context for GasKVStore (#13826) (cherry picked from commit f001b467a005bb0164563f43f6a04af6403b1fcd) # Conflicts: # CHANGELOG.md # types/context.go # types/context_test.go * fix conflicts * updates Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Julien Robert * chore: prepare 0.46.5 release (#13816) * fix: Allow underscores in EventRegex (backport #13861) (#13864) * fix: Allow underscores in EventRegex (#13861) (cherry picked from commit 14c582f30ec1f6f0c661e916f4dccf46b7305701) # Conflicts: # CHANGELOG.md # tests/e2e/tx/service_test.go * updates * updates Co-authored-by: Aleksandr Bezobchuk Co-authored-by: Julien Robert * fix(group): add group members weight checks (backport #13869) (#13880) * fix(group): add group members weight checks (#13869) (cherry picked from commit 3423442ab198434adc29862414dc49990155083f) # Conflicts: # CHANGELOG.md # api/cosmos/tx/v1beta1/service.pulsar.go # types/tx/service.pb.go # x/group/keeper/keeper.go * fix conflicts * updates * updates Co-authored-by: Julien Robert * fix(group)!: Fix group min execution period (backport #13876) (#13885) * fix(group)!: Fix group min execution period (#13876) * fix: don't check MinExecutionPeriod in `Allow` * Check MinExecutionPeriod on doExecuteMsgs * Fix TestExec * Fix TestExec * test exec pruned * Fix submitproposal * Add changelog * typo * revert some changes * add minExecutionPeriod * Add docs and specs (cherry picked from commit 7661f627370f73379d9b04c02ad3828ee600dbec) # Conflicts: # CHANGELOG.md # x/group/README.md # x/group/keeper/keeper_test.go * fix docs * fix other conflicts * fix test Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com> Co-authored-by: Julien Robert * feat(bank): Add helper for v0.46 denom migration (#13891) * feat(bank): Add helper for v0.46 denom migration * CL * Clearer name * Update x/bank/migrations/v046/store.go Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com> * rename Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com> * chore: impove 0.46.5 release notes (#13898) * chore: impove 0.46.5 release notes * update changelog * refactor: State Streaming Docs + Explicit Config Support (backport #13894) (#13909) * chore: remove typo (#13914) (#13917) (cherry picked from commit 34dcca710b15c8be2a73af2cf709246a9e1966d9) Co-authored-by: Julien Robert * fix: correctly propagate msg errors in gov (backport #13918) (#13928) * fix: correctly propagate msg errors in gov (#13918) * fix: correctly propagate msg errors in gov * chore: update changelog * fix: correctly check proposal status in tests * chore: delete unused var (cherry picked from commit 5581f7f3004116b3031702959f72c7fc2d7811d8) # Conflicts: # CHANGELOG.md # x/gov/abci_test.go * fix conflicts * updates Co-authored-by: John Letey Co-authored-by: Julien Robert * feat(bank): enable 0.46.5 bank migration fix through migrator keeper (#13929) * Update changelog for version bump. * Bring in Cosmos-SDK PR 13651 that overhauls/cleans up the GetConfig function to not require manual addition of stuff in order for it to be read. * Fix the pruning command to use the existing viper instance (that has everything loaded into it) instead of creating a new one. Co-authored-by: Robert Zaremba Co-authored-by: Julien Robert Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Sai Kumar <17549398+gsk967@users.noreply.github.com> Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com> Co-authored-by: William Chong <6198816+williamchong@users.noreply.github.com> Co-authored-by: yihuang Co-authored-by: billy rennekamp Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com> Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com> Co-authored-by: John Letey --- CHANGELOG.md | 18 +++++- RELEASE_NOTES.md | 27 ++++++++ client/pruning/main.go | 3 +- server/config/config.go | 115 ++++++++++++----------------------- server/config/config_test.go | 35 +++++++++-- server/config/toml.go | 13 ++++ simapp/app.go | 7 ++- store/streaming/README.md | 73 ++++++++++++++-------- x/bank/keeper/migrations.go | 6 ++ x/gov/abci.go | 4 +- x/gov/abci_test.go | 16 ++--- x/gov/common_test.go | 2 - x/group/internal/math/dec.go | 4 -- 13 files changed, 195 insertions(+), 128 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10e844697525..103b5f90b25b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements -* Bring in Cosmos-SDK [v0.46.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.5) changes [#365](https://github.com/provenance-io/cosmos-sdk/pull/365). +* Bring in Cosmos-SDK [v0.46.6](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.6) changes [#367](https://github.com/provenance-io/cosmos-sdk/pull/367). --- @@ -182,6 +182,18 @@ It also contains the Provenance Blockchain customizations that were part of [v0. # Cosmos-SDK releases +## [v0.46.6](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.6) - 2022-11-18 + +### Improvements + +* (config) [#13894](https://github.com/cosmos/cosmos-sdk/pull/13894) Support state streaming configuration in `app.toml` template and default configuration. + +## Bug Fixes + +* (x/gov) [#13918](https://github.com/cosmos/cosmos-sdk/pull/13918) Fix propagation of message errors when executing a proposal. + +--- + ## [v0.46.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.5) - 2022-11-17 ### Features @@ -210,6 +222,8 @@ It also contains the Provenance Blockchain customizations that were part of [v0. * (store) [#13803](https://github.com/cosmos/cosmos-sdk/pull/13803) Add an error log if IAVL set operation failed. * [#13861](https://github.com/cosmos/cosmos-sdk/pull/13861) Allow `_` characters in tx event queries, i.e. `GetTxsEvent`. +--- + ## [v0.46.4](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.4) - 2022-11-01 ### Features @@ -233,6 +247,8 @@ It also contains the Provenance Blockchain customizations that were part of [v0. * (context) [#13063](https://github.com/cosmos/cosmos-sdk/pull/13063) Update `Context#CacheContext` to automatically emit all events on the parent context's `EventManager`. +--- + ## [v0.46.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.3) - 2022-10-20 ATTENTION: diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 1781e9a91e37..b3e3136ea0c2 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -12,6 +12,33 @@ --- +## [v0.46.6](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.6) - 2022-11-18 + +This release introduces small bug fixes and improvements. + +Please read the release notes of [v0.46.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.5) if you are upgrading from `<=0.46.4`. + +Please see the [CHANGELOG](https://github.com/cosmos/cosmos-sdk/blob/release/v0.46.x/CHANGELOG.md) for an exhaustive list of changes. + +Full Commit History: https://github.com/cosmos/cosmos-sdk/compare/v0.46.5...v0.46.6 + +**NOTE**: The changes mentioned in `v0.46.3` are **still** required: + +```go +# Chains must add the following to their go.mod for the application: +replace github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 +``` + +### Improvements + +* (config) [#13894](https://github.com/cosmos/cosmos-sdk/pull/13894) Support state streaming configuration in `app.toml` template and default configuration. + +## Bug Fixes + +* (x/gov) [#13918](https://github.com/cosmos/cosmos-sdk/pull/13918) Fix propagation of message errors when executing a proposal. + +--- + ## [v0.46.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.5) - 2022-11-17 This release introduces a number of serious bug fixes and improvements. Notably, an upgrade to Tendermint [v0.34.23](https://github.com/tendermint/tendermint/releases/tag/v0.34.23). diff --git a/client/pruning/main.go b/client/pruning/main.go index fb62dd21a050..8a4be876819b 100644 --- a/client/pruning/main.go +++ b/client/pruning/main.go @@ -6,7 +6,6 @@ import ( "path/filepath" "github.com/spf13/cobra" - "github.com/spf13/viper" "github.com/cosmos/cosmos-sdk/client/flags" pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" @@ -40,7 +39,7 @@ func PruningCmd(appCreator servertypes.AppCreator) *cobra.Command { `, Example: "prune --home './' --app-db-backend 'goleveldb' --pruning 'custom' --pruning-keep-recent 100", RunE: func(cmd *cobra.Command, _ []string) error { - vp := viper.New() + vp := server.GetServerContextFromCmd(cmd).Viper // Bind flags to the Context's Viper so we can get pruning options. if err := vp.BindPFlags(cmd.Flags()); err != nil { diff --git a/server/config/config.go b/server/config/config.go index 969771d86000..950ff5026c4f 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -33,6 +33,9 @@ const ( // DefaultGRPCMaxSendMsgSize defines the default gRPC max message size in // bytes the server can send. DefaultGRPCMaxSendMsgSize = math.MaxInt32 + + // FileStreamer defines the store streaming type for file streaming. + FileStreamer = "file" ) // BaseConfig defines the server's basic configuration @@ -196,6 +199,28 @@ type StateSyncConfig struct { SnapshotKeepRecent uint32 `mapstructure:"snapshot-keep-recent"` } +type ( + // StoreConfig defines application configuration for state streaming and other + // storage related operations. + StoreConfig struct { + Streamers []string `mapstructure:"streamers"` + } + + // StreamersConfig defines concrete state streaming configuration options. These + // fields are required to be set when state streaming is enabled via a non-empty + // list defined by 'StoreConfig.Streamers'. + StreamersConfig struct { + File FileStreamerConfig `mapstructure:"file"` + } + + // FileStreamerConfig defines the file streaming configuration options. + FileStreamerConfig struct { + Keys []string `mapstructure:"keys"` + WriteDir string `mapstructure:"write_dir"` + Prefix string `mapstructure:"prefix"` + } +) + // Config defines the server's top level configuration type Config struct { BaseConfig `mapstructure:",squash"` @@ -207,6 +232,8 @@ type Config struct { Rosetta RosettaConfig `mapstructure:"rosetta"` GRPCWeb GRPCWebConfig `mapstructure:"grpc-web"` StateSync StateSyncConfig `mapstructure:"state-sync"` + Store StoreConfig `mapstructure:"store"` + Streamers StreamersConfig `mapstructure:"streamers"` } // SetMinGasPrices sets the validator's minimum gas prices. @@ -288,88 +315,24 @@ func DefaultConfig() *Config { SnapshotInterval: 0, SnapshotKeepRecent: 2, }, + Store: StoreConfig{ + Streamers: []string{}, + }, + Streamers: StreamersConfig{ + File: FileStreamerConfig{ + Keys: []string{"*"}, + }, + }, } } // GetConfig returns a fully parsed Config object. func GetConfig(v *viper.Viper) (Config, error) { - globalLabelsRaw, ok := v.Get("telemetry.global-labels").([]interface{}) - if !ok { - return Config{}, fmt.Errorf("failed to parse global-labels config") + conf := DefaultConfig() + if err := v.Unmarshal(conf); err != nil { + return Config{}, fmt.Errorf("error extracting app config: %w", err) } - - globalLabels := make([][]string, 0, len(globalLabelsRaw)) - for idx, glr := range globalLabelsRaw { - labelsRaw, ok := glr.([]interface{}) - if !ok { - return Config{}, fmt.Errorf("failed to parse global label number %d from config", idx) - } - if len(labelsRaw) == 2 { - globalLabels = append(globalLabels, []string{labelsRaw[0].(string), labelsRaw[1].(string)}) - } - } - - return Config{ - BaseConfig: BaseConfig{ - MinGasPrices: v.GetString("minimum-gas-prices"), - InterBlockCache: v.GetBool("inter-block-cache"), - Pruning: v.GetString("pruning"), - PruningKeepRecent: v.GetString("pruning-keep-recent"), - PruningInterval: v.GetString("pruning-interval"), - HaltHeight: v.GetUint64("halt-height"), - HaltTime: v.GetUint64("halt-time"), - IndexEvents: v.GetStringSlice("index-events"), - MinRetainBlocks: v.GetUint64("min-retain-blocks"), - IAVLCacheSize: v.GetUint64("iavl-cache-size"), - IAVLDisableFastNode: v.GetBool("iavl-disable-fastnode"), - AppDBBackend: v.GetString("app-db-backend"), - }, - Telemetry: telemetry.Config{ - ServiceName: v.GetString("telemetry.service-name"), - Enabled: v.GetBool("telemetry.enabled"), - EnableHostname: v.GetBool("telemetry.enable-hostname"), - EnableHostnameLabel: v.GetBool("telemetry.enable-hostname-label"), - EnableServiceLabel: v.GetBool("telemetry.enable-service-label"), - PrometheusRetentionTime: v.GetInt64("telemetry.prometheus-retention-time"), - GlobalLabels: globalLabels, - }, - API: APIConfig{ - Enable: v.GetBool("api.enable"), - Swagger: v.GetBool("api.swagger"), - Address: v.GetString("api.address"), - MaxOpenConnections: v.GetUint("api.max-open-connections"), - RPCReadTimeout: v.GetUint("api.rpc-read-timeout"), - RPCWriteTimeout: v.GetUint("api.rpc-write-timeout"), - RPCMaxBodyBytes: v.GetUint("api.rpc-max-body-bytes"), - EnableUnsafeCORS: v.GetBool("api.enabled-unsafe-cors"), - }, - Rosetta: RosettaConfig{ - Enable: v.GetBool("rosetta.enable"), - Address: v.GetString("rosetta.address"), - Blockchain: v.GetString("rosetta.blockchain"), - Network: v.GetString("rosetta.network"), - Retries: v.GetInt("rosetta.retries"), - Offline: v.GetBool("rosetta.offline"), - EnableFeeSuggestion: v.GetBool("rosetta.enable-fee-suggestion"), - GasToSuggest: v.GetInt("rosetta.gas-to-suggest"), - DenomToSuggest: v.GetString("rosetta.denom-to-suggest"), - }, - GRPC: GRPCConfig{ - Enable: v.GetBool("grpc.enable"), - Address: v.GetString("grpc.address"), - MaxRecvMsgSize: v.GetInt("grpc.max-recv-msg-size"), - MaxSendMsgSize: v.GetInt("grpc.max-send-msg-size"), - }, - GRPCWeb: GRPCWebConfig{ - Enable: v.GetBool("grpc-web.enable"), - Address: v.GetString("grpc-web.address"), - EnableUnsafeCORS: v.GetBool("grpc-web.enable-unsafe-cors"), - }, - StateSync: StateSyncConfig{ - SnapshotInterval: v.GetUint64("state-sync.snapshot-interval"), - SnapshotKeepRecent: v.GetUint32("state-sync.snapshot-keep-recent"), - }, - }, nil + return *conf, nil } // ValidateBasic returns an error if min-gas-prices field is empty in BaseConfig. Otherwise, it returns nil. diff --git a/server/config/config_test.go b/server/config/config_test.go index 442e56026ec4..042b1ebd1612 100644 --- a/server/config/config_test.go +++ b/server/config/config_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/spf13/viper" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" @@ -32,28 +31,54 @@ func TestIndexEventsMarshalling(t *testing.T) { err := configTemplate.Execute(&buffer, cfg) require.NoError(t, err, "executing template") actual := buffer.String() - assert.Contains(t, actual, expectedIn, "config file contents") + require.Contains(t, actual, expectedIn, "config file contents") +} + +func TestParseStoreStreaming(t *testing.T) { + expectedContents := `[store] +streamers = ["file", ] + +[streamers] +[streamers.file] +keys = ["*", ] +write_dir = "/foo/bar" +prefix = ""` + + cfg := DefaultConfig() + cfg.Store.Streamers = []string{FileStreamer} + cfg.Streamers.File.Keys = []string{"*"} + cfg.Streamers.File.WriteDir = "/foo/bar" + + var buffer bytes.Buffer + require.NoError(t, configTemplate.Execute(&buffer, cfg), "executing template") + require.Contains(t, buffer.String(), expectedContents, "config file contents") } func TestIndexEventsWriteRead(t *testing.T) { expected := []string{"key3", "key4"} + // Create config with two IndexEvents entries, and write it to a file. confFile := filepath.Join(t.TempDir(), "app.toml") conf := DefaultConfig() conf.IndexEvents = expected + WriteConfigFile(confFile, conf) - // Read that file into viper. + // read the file into Viper vpr := viper.New() vpr.SetConfigFile(confFile) + err := vpr.ReadInConfig() require.NoError(t, err, "reading config file into viper") + // Check that the raw viper value is correct. actualRaw := vpr.GetStringSlice("index-events") require.Equal(t, expected, actualRaw, "viper's index events") + // Check that it is parsed into the config correctly. cfg, perr := ParseConfig(vpr) require.NoError(t, perr, "parsing config") + actual := cfg.IndexEvents require.Equal(t, expected, actual, "config value") } @@ -62,7 +87,7 @@ func TestGlobalLabelsEventsMarshalling(t *testing.T) { expectedIn := `global-labels = [ ["labelname1", "labelvalue1"], ["labelname2", "labelvalue2"], -]` + "\n" +]` cfg := DefaultConfig() cfg.Telemetry.GlobalLabels = [][]string{{"labelname1", "labelvalue1"}, {"labelname2", "labelvalue2"}} var buffer bytes.Buffer @@ -70,7 +95,7 @@ func TestGlobalLabelsEventsMarshalling(t *testing.T) { err := configTemplate.Execute(&buffer, cfg) require.NoError(t, err, "executing template") actual := buffer.String() - assert.Contains(t, actual, expectedIn, "config file contents") + require.Contains(t, actual, expectedIn, "config file contents") } func TestGlobalLabelsWriteRead(t *testing.T) { diff --git a/server/config/toml.go b/server/config/toml.go index 275914f8f5b2..e69f3845222b 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -235,6 +235,19 @@ snapshot-interval = {{ .StateSync.SnapshotInterval }} # snapshot-keep-recent specifies the number of recent snapshots to keep and serve (0 to keep all). snapshot-keep-recent = {{ .StateSync.SnapshotKeepRecent }} + +############################################################################### +### Store / State Streaming ### +############################################################################### + +[store] +streamers = [{{ range .Store.Streamers }}{{ printf "%q, " . }}{{end}}] + +[streamers] +[streamers.file] +keys = [{{ range .Streamers.File.Keys }}{{ printf "%q, " . }}{{end}}] +write_dir = "{{ .Streamers.File.WriteDir }}" +prefix = "{{ .Streamers.File.Prefix }}" ` var configTemplate *template.Template diff --git a/simapp/app.go b/simapp/app.go index c2df8be04d07..5261b552827c 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -2,6 +2,7 @@ package simapp import ( "encoding/json" + "fmt" "io" "net/http" "os" @@ -228,10 +229,10 @@ func NewSimApp( // not include this key. memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, "testingkey") - // configure state listening capabilities using AppOptions - // we are doing nothing with the returned streamingServices and waitGroup in this case + // load state streaming if enabled if _, _, err := streaming.LoadStreamingServices(bApp, appOpts, appCodec, keys); err != nil { - tmos.Exit(err.Error()) + fmt.Printf("failed to load state streaming: %s", err) + os.Exit(1) } app := &SimApp{ diff --git a/store/streaming/README.md b/store/streaming/README.md index 3118ceed9834..9eb962ac862c 100644 --- a/store/streaming/README.md +++ b/store/streaming/README.md @@ -1,29 +1,38 @@ # State Streaming Service -This package contains the constructors for the `StreamingService`s used to write state changes out from individual KVStores to a -file or stream, as described in [ADR-038](https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-038-state-listening.md) and defined in [types/streaming.go](https://github.com/cosmos/cosmos-sdk/blob/main/baseapp/streaming.go). +This package contains the constructors for the `StreamingService`s used to write +state changes out from individual KVStores to a file or stream, as described in +[ADR-038](https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-038-state-listening.md) +and defined in [types/streaming.go](https://github.com/cosmos/cosmos-sdk/blob/main/baseapp/streaming.go). The child directories contain the implementations for specific output destinations. -Currently, a `StreamingService` implementation that writes state changes out to files is supported, in the future support for additional -output destinations can be added. +Currently, a `StreamingService` implementation that writes state changes out to +files is supported, in the future support for additional output destinations can +be added. -The `StreamingService` is configured from within an App using the `AppOptions` loaded from the app.toml file: +The `StreamingService` is configured from within an App using the `AppOptions` +loaded from the `app.toml` file: ```toml +# ... + [store] - streamers = [ # if len(streamers) > 0 we are streaming - "file", # name of the streaming service, used by constructor - ] +# streaming is enabled if one or more streamers are defined +streamers = [ + # name of the streaming service, used by constructor + "file" +] [streamers] - [streamers.file] - keys = ["list", "of", "store", "keys", "we", "want", "to", "expose", "for", "this", "streaming", "service"] - write_dir = "path to the write directory" - prefix = "optional prefix to prepend to the generated file names" +[streamers.file] + keys = ["list", "of", "store", "keys", "we", "want", "to", "expose", "for", "this", "streaming", "service"] + write_dir = "path to the write directory" + prefix = "optional prefix to prepend to the generated file names" ``` -`store.streamers` contains a list of the names of the `StreamingService` implementations to employ which are used by `ServiceTypeFromString` -to return the `ServiceConstructor` for that particular implementation: +The `store.streamers` field contains a list of the names of the `StreamingService` +implementations to employ which are used by `ServiceTypeFromString` to return +the `ServiceConstructor` for that particular implementation: ```go listeners := cast.ToStringSlice(appOpts.Get("store.streamers")) @@ -35,18 +44,27 @@ for _, listenerName := range listeners { } ``` -`streamers` contains a mapping of the specific `StreamingService` implementation name to the configuration parameters for that specific service. -`streamers.x.keys` contains the list of `StoreKey` names for the KVStores to expose using this service and is required by every type of `StreamingService`. -In order to expose *all* KVStores, we can include `*` in this list. An empty list is equivalent to turning the service off. +The `streamers` field contains a mapping of the specific `StreamingService` +implementation name to the configuration parameters for that specific service. + +The `streamers.x.keys` field contains the list of `StoreKey` names for the +KVStores to expose using this service and is required by every type of +`StreamingService`. In order to expose *ALL* KVStores, we can include `*` in +this list. An empty list is equivalent to turning the service off. Additional configuration parameters are optional and specific to the implementation. -In the case of the file streaming service, `streamers.file.write_dir` contains the path to the -directory to write the files to, and `streamers.file.prefix` contains an optional prefix to prepend to the output files to prevent potential collisions -with other App `StreamingService` output files. +In the case of the file streaming service, the `streamers.file.write_dir` field +contains the path to the directory to write the files to, and `streamers.file.prefix` +contains an optional prefix to prepend to the output files to prevent potential +collisions with other App `StreamingService` output files. -The `ServiceConstructor` accepts `AppOptions`, the store keys collected using `streamers.x.keys`, a `BinaryMarshaller` and -returns a `StreamingService` implementation. The `AppOptions` are passed in to provide access to any implementation specific configuration options, -e.g. in the case of the file streaming service the `streamers.file.write_dir` and `streamers.file.prefix`. +The `ServiceConstructor` accepts `AppOptions`, the store keys collected using +`streamers.x.keys`, a `BinaryMarshaller` and returns a `StreamingService +implementation. + +The `AppOptions` are passed in to provide access to any implementation specific +configuration options, e.g. in the case of the file streaming service the +`streamers.file.write_dir` and `streamers.file.prefix`. ```go streamingService, err := constructor(appOpts, exposeStoreKeys, appCodec) @@ -55,9 +73,12 @@ if err != nil { } ``` -The returned `StreamingService` is loaded into the BaseApp using the BaseApp's `SetStreamingService` method. -The `Stream` method is called on the service to begin the streaming process. Depending on the implementation this process -may be synchronous or asynchronous with the message processing of the state machine. +The returned `StreamingService` is loaded into the BaseApp using the BaseApp's +`SetStreamingService` method. + +The `Stream` method is called on the service to begin the streaming process. +Depending on the implementation this process may be synchronous or asynchronous +with the message processing of the state machine. ```go bApp.SetStreamingService(streamingService) diff --git a/x/bank/keeper/migrations.go b/x/bank/keeper/migrations.go index 88ea12c7392a..100e02e9901d 100644 --- a/x/bank/keeper/migrations.go +++ b/x/bank/keeper/migrations.go @@ -34,3 +34,9 @@ func (m Migrator) Migrate3to4(ctx sdk.Context) error { m.keeper.SetParams(ctx, banktypes.NewParams(oldParams.DefaultSendEnabled)) return nil } + +// Migrate3_V046_4_To_V046_5 fixes migrations from version 2 to for chains based on SDK 0.46.0 - v0.46.4 ONLY. +// See v046.Migrate_V046_4_To_V046_5 for more details. +func (m Migrator) Migrate3_V046_4_To_V046_5(ctx sdk.Context) error { + return v046.Migrate_V046_4_To_V046_5(ctx.KVStore(m.keeper.storeKey)) +} diff --git a/x/gov/abci.go b/x/gov/abci.go index 21aca44ed08a..ae553149d9c1 100644 --- a/x/gov/abci.go +++ b/x/gov/abci.go @@ -71,7 +71,9 @@ func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) { if err == nil { for idx, msg = range messages { handler := keeper.Router().Handler(msg) - res, err := handler(cacheCtx, msg) + + var res *sdk.Result + res, err = handler(cacheCtx, msg) if err != nil { break } diff --git a/x/gov/abci_test.go b/x/gov/abci_test.go index f0e002f12395..ad789edeec89 100644 --- a/x/gov/abci_test.go +++ b/x/gov/abci_test.go @@ -10,6 +10,8 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov/keeper" "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -340,10 +342,8 @@ func TestEndBlockerProposalHandlerFailed(t *testing.T) { createValidators(t, stakingMsgSvr, ctx, []sdk.ValAddress{valAddr}, []int64{10}) staking.EndBlocker(ctx, app.StakingKeeper) - // Create a proposal where the handler will pass for the test proposal - // because the value of contextKeyBadProposal is true. - ctx = ctx.WithValue(contextKeyBadProposal, true) - proposal, err := app.GovKeeper.SubmitProposal(ctx, []sdk.Msg{mkTestLegacyContent(t)}, "") + msg := banktypes.NewMsgSend(authtypes.NewModuleAddress(types.ModuleName), addrs[0], sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000)))) + proposal, err := app.GovKeeper.SubmitProposal(ctx, []sdk.Msg{msg}, "") require.NoError(t, err) proposalCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 10))) @@ -361,12 +361,12 @@ func TestEndBlockerProposalHandlerFailed(t *testing.T) { newHeader.Time = ctx.BlockHeader().Time.Add(*app.GovKeeper.GetDepositParams(ctx).MaxDepositPeriod).Add(*app.GovKeeper.GetVotingParams(ctx).VotingPeriod) ctx = ctx.WithBlockHeader(newHeader) - // Set the contextKeyBadProposal value to false so that the handler will fail - // during the processing of the proposal in the EndBlocker. - ctx = ctx.WithValue(contextKeyBadProposal, false) - // validate that the proposal fails/has been rejected gov.EndBlocker(ctx, app.GovKeeper) + + proposal, ok := app.GovKeeper.GetProposal(ctx, proposal.Id) + require.True(t, ok) + require.Equal(t, v1.StatusFailed, proposal.Status) } func createValidators(t *testing.T, stakingMsgSvr stakingtypes.MsgServer, ctx sdk.Context, addrs []sdk.ValAddress, powerAmt []int64) { diff --git a/x/gov/common_test.go b/x/gov/common_test.go index d4d9bd382d4c..ad3d0e3cb94d 100644 --- a/x/gov/common_test.go +++ b/x/gov/common_test.go @@ -78,8 +78,6 @@ func SortByteArrays(src [][]byte) [][]byte { return sorted } -const contextKeyBadProposal = "contextKeyBadProposal" - var pubkeys = []cryptotypes.PubKey{ ed25519.GenPrivKey().PubKey(), ed25519.GenPrivKey().PubKey(), diff --git a/x/group/internal/math/dec.go b/x/group/internal/math/dec.go index 3755304ccacd..b9e6e55d95f8 100644 --- a/x/group/internal/math/dec.go +++ b/x/group/internal/math/dec.go @@ -46,10 +46,6 @@ func (x Dec) IsPositive() bool { return !x.dec.Negative && !x.dec.IsZero() } -func (x Dec) IsFinite() bool { - return x.dec.Form != apd.Finite -} - // NewDecFromString returns a new Dec from a string // It only support finite numbers, not NaN, +Inf, -Inf func NewDecFromString(s string) (Dec, error) {