Skip to content

Commit

Permalink
Bring in changes from Cosmos-SDK v0.46.6 (#367)
Browse files Browse the repository at this point in the history
* docs: add ApplicationQueryService release notes (cosmos#13587)

* docs: add ApplicationQueryService release notes

* updates

Co-authored-by: Julien Robert <[email protected]>

* feat(cli): add module-account cli cmd and grpc get api (backport cosmos#13612) (cosmos#13616)

* feat(cli): add module-account cli cmd and grpc get api (cosmos#13612)

(cherry picked from commit ddf5cf0)

* fix conflicts

* updates

* updates

Co-authored-by: Sai Kumar <[email protected]>
Co-authored-by: Julien Robert <[email protected]>

* fix(x/auth): allow multiple = signs in `GetTxsEvent` (backport cosmos#12474) (cosmos#13598)

* fix(x/auth): allow multiple = signs in `GetTxsEvent` (cosmos#12474)

(cherry picked from commit 18da0e9)

* fix changelog

* changelog

* fix: flakey test

Co-authored-by: Tyler <[email protected]>
Co-authored-by: Julien Robert <[email protected]>

* fix: app-hash mismatch if upgrade migration commit is interrupted (backport cosmos#13530) (cosmos#13627)

* feat(cli): Add iavl-disable-fastnode cmd flag with proper description (cosmos#13656) (cosmos#13659)

(cherry picked from commit c833190)

Co-authored-by: William Chong <[email protected]>

* build(deps): Bump github.com/cosmos/iavl from 0.19.3 to 0.19.4 (cosmos#13680)

* feat: emit cached context events (backport cosmos#13063) (cosmos#13702)

* chore: prepare 0.46.4 changelog (cosmos#13716)

* chore: prepare 0.46.4 changelog

* wording

* updates

* updates

* ci: notify for 0.46.x releases (cosmos#13719)

* feat: notify for 0.46.x releases

* updates changelog

* docs: fix algolia on 0.46 (cosmos#13730)

* ci: modifying docs in 0.46 should not redeploy docs (cosmos#13732)

* ci: modifying docs in 0.46 should not redeploy docs

* updates

* fix: propagate msg events correctly in x/gov (backport cosmos#13728) (cosmos#13748)

* refactor: add error log when iavl set failed (backport cosmos#13803) (cosmos#13804)

* refactor: add error log when iavl set failed (cosmos#13803)

* add error log when iavl set failed

Ref: cosmos#12012

* Update CHANGELOG.md

* play safe

(cherry picked from commit 22f3261)

* fix conflicts

Co-authored-by: yihuang <[email protected]>

* chore: bump tendermint to `0.34.23` (cosmos#13814)

* fix: propagate events in x/group through sdk.Results (backport cosmos#13808) (cosmos#13809)

* docs: update algolia index (cosmos#13823)

* fix: bank store migration (backport cosmos#13821) (cosmos#13829)

* fix: bank store migration (cosmos#13821)

(cherry picked from commit d314a12)

* updates

Co-authored-by: billy rennekamp <[email protected]>
Co-authored-by: Julien Robert <[email protected]>

* feat(types): set custom GasConfig on Context for GasKVStore (backport cosmos#13826) (cosmos#13833)

* feat(types): set custom GasConfig on Context for GasKVStore (cosmos#13826)

(cherry picked from commit f001b46)

* fix conflicts

* updates

Co-authored-by: Federico Kunze Küllmer <[email protected]>
Co-authored-by: Julien Robert <[email protected]>

* chore: prepare 0.46.5 release (cosmos#13816)

* fix: Allow underscores in EventRegex (backport cosmos#13861) (cosmos#13864)

* fix: Allow underscores in EventRegex (cosmos#13861)

(cherry picked from commit 14c582f)

* updates

* updates

Co-authored-by: Aleksandr Bezobchuk <[email protected]>
Co-authored-by: Julien Robert <[email protected]>

* fix(group): add group members weight checks (backport cosmos#13869) (cosmos#13880)

* fix(group): add group members weight checks (cosmos#13869)

(cherry picked from commit 3423442)

* fix conflicts

* updates

* updates

Co-authored-by: Julien Robert <[email protected]>

* fix(group)!: Fix group min execution period (backport cosmos#13876) (cosmos#13885)

* fix(group)!: Fix group min execution period (cosmos#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 7661f62)

* fix docs

* fix other conflicts

* fix test

Co-authored-by: Amaury <[email protected]>
Co-authored-by: Julien Robert <[email protected]>

* feat(bank): Add helper for v0.46 denom migration (cosmos#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 <[email protected]>

* rename

Co-authored-by: Likhita Polavarapu <[email protected]>

* chore: impove 0.46.5 release notes (cosmos#13898)

* chore: impove 0.46.5 release notes

* update changelog

* refactor: State Streaming Docs + Explicit Config Support (backport cosmos#13894) (cosmos#13909)

* chore: remove typo (cosmos#13914) (cosmos#13917)

(cherry picked from commit 34dcca7)

Co-authored-by: Julien Robert <[email protected]>

* fix: correctly propagate msg errors in gov (backport cosmos#13918) (cosmos#13928)

* fix: correctly propagate msg errors in gov (cosmos#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 5581f7f)

* fix conflicts

* updates

Co-authored-by: John Letey <[email protected]>
Co-authored-by: Julien Robert <[email protected]>

* feat(bank): enable 0.46.5 bank migration fix through migrator keeper (cosmos#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 <[email protected]>
Co-authored-by: Julien Robert <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Sai Kumar <[email protected]>
Co-authored-by: Tyler <[email protected]>
Co-authored-by: William Chong <[email protected]>
Co-authored-by: yihuang <[email protected]>
Co-authored-by: billy rennekamp <[email protected]>
Co-authored-by: Federico Kunze Küllmer <[email protected]>
Co-authored-by: Aleksandr Bezobchuk <[email protected]>
Co-authored-by: Amaury <[email protected]>
Co-authored-by: Likhita Polavarapu <[email protected]>
Co-authored-by: John Letey <[email protected]>
  • Loading branch information
14 people committed Nov 28, 2022
1 parent 8bebdb6 commit c2622cd
Show file tree
Hide file tree
Showing 12 changed files with 168 additions and 128 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,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).

---

Expand Down Expand Up @@ -186,6 +186,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
Expand Down Expand Up @@ -214,6 +226,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
Expand All @@ -237,6 +251,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:
Expand Down
3 changes: 1 addition & 2 deletions client/pruning/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
115 changes: 39 additions & 76 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"`
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
35 changes: 30 additions & 5 deletions server/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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")
}
Expand All @@ -62,15 +87,15 @@ 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

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) {
Expand Down
13 changes: 13 additions & 0 deletions server/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package simapp

import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
Expand Down Expand Up @@ -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{
Expand Down
Loading

0 comments on commit c2622cd

Please sign in to comment.