diff --git a/CHANGELOG.md b/CHANGELOG.md index aee5d1a79b..fc45f5b999 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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* diff --git a/app/app.go b/app/app.go index 1533139bd9..9fe4a48b46 100644 --- a/app/app.go +++ b/app/app.go @@ -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" @@ -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 { diff --git a/cmd/cronosd/cmd/config.go b/cmd/cronosd/cmd/config.go new file mode 100644 index 0000000000..8711ad366e --- /dev/null +++ b/cmd/cronosd/cmd/config.go @@ -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 }} +` diff --git a/cmd/cronosd/cmd/root.go b/cmd/cronosd/cmd/root.go index 0e1d63f5a1..508462470b 100644 --- a/cmd/cronosd/cmd/root.go +++ b/cmd/cronosd/cmd/root.go @@ -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 { diff --git a/integration_tests/configs/cosmovisor.jsonnet b/integration_tests/configs/cosmovisor.jsonnet index 51c9c7c3bd..9f912f2751 100644 --- a/integration_tests/configs/cosmovisor.jsonnet +++ b/integration_tests/configs/cosmovisor.jsonnet @@ -7,6 +7,14 @@ config { 'minimum-gas-prices': '100000000000basetcro', 'iavl-lazy-loading':: super['iavl-lazy-loading'], }, + validators: [super.validators[0] { + 'app-config'+: { + versiondb:: super['versiondb'], + memiavl+: { + 'snapshot-keep-recent': 1000, + }, + }, + }] + super.validators[1:], genesis+: { app_state+: { bank+: { diff --git a/integration_tests/configs/default.jsonnet b/integration_tests/configs/default.jsonnet index 24cd3d4540..12119e20a5 100644 --- a/integration_tests/configs/default.jsonnet +++ b/integration_tests/configs/default.jsonnet @@ -37,8 +37,8 @@ 'zero-copy': true, 'snapshot-interval': 5, }, - store: { - streamers: ['versiondb'], + versiondb: { + enable: true, }, }, }, { diff --git a/integration_tests/test_basic.py b/integration_tests/test_basic.py index d25ac588f8..33eaabfe15 100644 --- a/integration_tests/test_basic.py +++ b/integration_tests/test_basic.py @@ -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, }, }, ) diff --git a/versiondb/README.md b/versiondb/README.md index 9eb3300ef5..0643667e07 100644 --- a/versiondb/README.md +++ b/versiondb/README.md @@ -12,11 +12,11 @@ After versiondb is enabled, there's no point to keep the full the archived IAVL ## Configuration -To enable versiondb, add `versiondb` to the list of `store.streamers` in `app.toml` like this: +To enable versiondb, set the `versiondb.enable` to `true` in `app.toml`: ```toml -[store] -streamers = ["versiondb"] +[versiondb] +enable = true ``` On startup, the node will create a `StreamingService` to subscribe to latest state changes in realtime and save them to versiondb, the db instance is placed at `$NODE_HOME/data/versiondb` directory, there's no way to customize the db path currently. It'll also switch grpc query service's backing store to versiondb from IAVL tree, you should migrate the legacy states in advance to make the transition smooth, otherwise, the grpc queries can't see the legacy versions.