Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring in changes from Cosmos-SDK v0.46.6 #367

Merged
merged 32 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7f88c60
docs: add ApplicationQueryService release notes (#13587)
robert-zaremba Oct 21, 2022
f538e09
feat(cli): add module-account cli cmd and grpc get api (backport #136…
mergify[bot] Oct 24, 2022
afdf06a
fix(x/auth): allow multiple = signs in `GetTxsEvent` (backport #12474…
mergify[bot] Oct 24, 2022
ec09eae
fix: app-hash mismatch if upgrade migration commit is interrupted (ba…
mergify[bot] Oct 25, 2022
a653798
feat(cli): Add iavl-disable-fastnode cmd flag with proper description…
mergify[bot] Oct 26, 2022
4eed46e
build(deps): Bump github.com/cosmos/iavl from 0.19.3 to 0.19.4 (#13680)
julienrbrt Oct 28, 2022
9d7028d
feat: emit cached context events (backport #13063) (#13702)
mergify[bot] Oct 31, 2022
eb1e3eb
chore: prepare 0.46.4 changelog (#13716)
julienrbrt Nov 1, 2022
68ee142
ci: notify for 0.46.x releases (#13719)
julienrbrt Nov 1, 2022
c7a9435
docs: fix algolia on 0.46 (#13730)
julienrbrt Nov 2, 2022
ba49bff
ci: modifying docs in 0.46 should not redeploy docs (#13732)
julienrbrt Nov 2, 2022
e4ae994
fix: propagate msg events correctly in x/gov (backport #13728) (#13748)
mergify[bot] Nov 3, 2022
2899dcf
refactor: add error log when iavl set failed (backport #13803) (#13804)
mergify[bot] Nov 9, 2022
0d1ed1a
chore: bump tendermint to `0.34.23` (#13814)
julienrbrt Nov 9, 2022
2bd2cf1
fix: propagate events in x/group through sdk.Results (backport #13808…
mergify[bot] Nov 9, 2022
3a809e2
docs: update algolia index (#13823)
julienrbrt Nov 10, 2022
62443b8
fix: bank store migration (backport #13821) (#13829)
mergify[bot] Nov 10, 2022
68e54fa
feat(types): set custom GasConfig on Context for GasKVStore (backport…
mergify[bot] Nov 11, 2022
2114ec4
chore: prepare 0.46.5 release (#13816)
julienrbrt Nov 14, 2022
2d515e0
fix: Allow underscores in EventRegex (backport #13861) (#13864)
mergify[bot] Nov 15, 2022
0b81939
fix(group): add group members weight checks (backport #13869) (#13880)
mergify[bot] Nov 16, 2022
6b633ef
fix(group)!: Fix group min execution period (backport #13876) (#13885)
mergify[bot] Nov 16, 2022
29cf4bc
feat(bank): Add helper for v0.46 denom migration (#13891)
amaury1093 Nov 16, 2022
e5fef13
chore: impove 0.46.5 release notes (#13898)
julienrbrt Nov 17, 2022
c80177e
refactor: State Streaming Docs + Explicit Config Support (backport #1…
mergify[bot] Nov 17, 2022
b88f086
chore: remove typo (#13914) (#13917)
mergify[bot] Nov 18, 2022
2f55513
fix: correctly propagate msg errors in gov (backport #13918) (#13928)
mergify[bot] Nov 18, 2022
8cce748
feat(bank): enable 0.46.5 bank migration fix through migrator keeper …
robert-zaremba Nov 18, 2022
1d9c475
Merge tag 'v0.46.6' into prov/dwedul/46.6-bump
SpicyLemon Nov 21, 2022
1b0bfe6
Update changelog for version bump.
SpicyLemon Nov 21, 2022
f85c0b8
Bring in Cosmos-SDK PR 13651 that overhauls/cleans up the GetConfig f…
SpicyLemon Nov 21, 2022
42bc817
Fix the pruning command to use the existing viper instance (that has …
SpicyLemon Nov 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

---

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
27 changes: 27 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
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