Skip to content

Commit

Permalink
Problem: store.streamers not exists in sdk 0.50
Browse files Browse the repository at this point in the history
Solution:
- use dedicated versiondb config section to prepare to sdk 0.50
  integration

Update CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

cleanup
  • Loading branch information
yihuang committed Apr 11, 2024
1 parent 7472947 commit d471a6b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* (test) [#1380](https://github.com/crypto-org-chain/cronos/pull/1380) Upgrade cosmovisor to 1.5.0 in integration test.
* (versiondb) [#1379](https://github.com/crypto-org-chain/cronos/pull/1379) Flush versiondb when graceful shutdown, make rocksdb upgrade smooth.
* (store) [#1378](https://github.com/crypto-org-chain/cronos/pull/1378) Upgrade rocksdb to `v8.11.3`.
* (versiondb) [#1387](https://github.com/crypto-org-chain/cronos/pull/1387) Add dedicated config section for versiondb, prepare for sdk 0.50 integration.

*April 8, 2024*

Expand Down
4 changes: 1 addition & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
"golang.org/x/exp/slices"

dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
Expand Down Expand Up @@ -860,8 +859,7 @@ func New(
}

// wire up the versiondb's `StreamingService` and `MultiStore`.
streamers := cast.ToStringSlice(appOpts.Get("store.streamers"))
if slices.Contains(streamers, "versiondb") {
if cast.ToBool(appOpts.Get("versiondb.enable")) {
var err error
app.qms, err = app.setupVersionDB(homePath, keys, tkeys, memKeys)
if err != nil {
Expand Down
18 changes: 18 additions & 0 deletions cmd/cronosd/cmd/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

type VersionDBConfig struct {
// Enable defines if the versiondb should be enabled.
Enable bool `mapstructure:"enable"`
}

func DefaultVersionDBConfig() VersionDBConfig {
return VersionDBConfig{
Enable: false,
}
}

var DefaultVersionDBTemplate = `
[versiondb]
# Enable defines if the versiondb should be enabled.
enable = {{ .VersionDB.Enable }}
`
12 changes: 7 additions & 5 deletions cmd/cronosd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,19 @@ func initAppConfig() (string, interface{}) {
type CustomAppConfig struct {
servercfg.Config

MemIAVL memiavlcfg.MemIAVLConfig `mapstructure:"memiavl"`
MemIAVL memiavlcfg.MemIAVLConfig `mapstructure:"memiavl"`
VersionDB VersionDBConfig `mapstructure:"versiondb"`
}

tpl, cfg := servercfg.AppConfig(ethermint.AttoPhoton)
tpl, cfg := servercfg.AppConfig("")

customAppConfig := CustomAppConfig{
Config: cfg.(servercfg.Config),
MemIAVL: memiavlcfg.DefaultMemIAVLConfig(),
Config: cfg.(servercfg.Config),
MemIAVL: memiavlcfg.DefaultMemIAVLConfig(),
VersionDB: DefaultVersionDBConfig(),
}

return tpl + memiavlcfg.DefaultConfigTemplate, customAppConfig
return tpl + memiavlcfg.DefaultConfigTemplate + DefaultVersionDBTemplate, customAppConfig
}

type appCreator struct {
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/configs/default.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
'zero-copy': true,
'snapshot-interval': 5,
},
store: {
streamers: ['versiondb'],
versiondb: {
enable: true,
},
},
}, {
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ def test_local_statesync(cronos, tmp_path_factory):
Path(home) / "config/app.toml",
base_port,
{
"store": {
"streamers": ["versiondb"],
"versiondb": {
"enable": True,
},
},
)
Expand Down

0 comments on commit d471a6b

Please sign in to comment.