Skip to content

Commit c2a1198

Browse files
author
yihuang
authored
Problem: versiondb config item not exists in sdk 0.50 (#1387)
* Problem: store.streamers not exists in sdk 0.50 Solution: - use dedicated versiondb config section to prepare to sdk 0.50 integration Update CHANGELOG.md Signed-off-by: yihuang <huang@crypto.com> cleanup * fix upgrade test * update readme
1 parent 9144442 commit c2a1198

File tree

8 files changed

+42
-15
lines changed

8 files changed

+42
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* (test) [#1380](https://github.com/crypto-org-chain/cronos/pull/1380) Upgrade cosmovisor to 1.5.0 in integration test.
88
* (versiondb) [#1379](https://github.com/crypto-org-chain/cronos/pull/1379) Flush versiondb when graceful shutdown, make rocksdb upgrade smooth.
99
* (store) [#1378](https://github.com/crypto-org-chain/cronos/pull/1378) Upgrade rocksdb to `v8.11.3`.
10+
* (versiondb) [#1387](https://github.com/crypto-org-chain/cronos/pull/1387) Add dedicated config section for versiondb, prepare for sdk 0.50 integration.
1011

1112
*April 8, 2024*
1213

app/app.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
1717
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
1818
runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services"
19-
"golang.org/x/exp/slices"
2019

2120
dbm "github.com/cometbft/cometbft-db"
2221
abci "github.com/cometbft/cometbft/abci/types"
@@ -860,8 +859,7 @@ func New(
860859
}
861860

862861
// wire up the versiondb's `StreamingService` and `MultiStore`.
863-
streamers := cast.ToStringSlice(appOpts.Get("store.streamers"))
864-
if slices.Contains(streamers, "versiondb") {
862+
if cast.ToBool(appOpts.Get("versiondb.enable")) {
865863
var err error
866864
app.qms, err = app.setupVersionDB(homePath, keys, tkeys, memKeys)
867865
if err != nil {

cmd/cronosd/cmd/config.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package cmd
2+
3+
type VersionDBConfig struct {
4+
// Enable defines if the versiondb should be enabled.
5+
Enable bool `mapstructure:"enable"`
6+
}
7+
8+
func DefaultVersionDBConfig() VersionDBConfig {
9+
return VersionDBConfig{
10+
Enable: false,
11+
}
12+
}
13+
14+
var DefaultVersionDBTemplate = `
15+
[versiondb]
16+
# Enable defines if the versiondb should be enabled.
17+
enable = {{ .VersionDB.Enable }}
18+
`

cmd/cronosd/cmd/root.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,19 @@ func initAppConfig() (string, interface{}) {
220220
type CustomAppConfig struct {
221221
servercfg.Config
222222

223-
MemIAVL memiavlcfg.MemIAVLConfig `mapstructure:"memiavl"`
223+
MemIAVL memiavlcfg.MemIAVLConfig `mapstructure:"memiavl"`
224+
VersionDB VersionDBConfig `mapstructure:"versiondb"`
224225
}
225226

226-
tpl, cfg := servercfg.AppConfig(ethermint.AttoPhoton)
227+
tpl, cfg := servercfg.AppConfig("")
227228

228229
customAppConfig := CustomAppConfig{
229-
Config: cfg.(servercfg.Config),
230-
MemIAVL: memiavlcfg.DefaultMemIAVLConfig(),
230+
Config: cfg.(servercfg.Config),
231+
MemIAVL: memiavlcfg.DefaultMemIAVLConfig(),
232+
VersionDB: DefaultVersionDBConfig(),
231233
}
232234

233-
return tpl + memiavlcfg.DefaultConfigTemplate, customAppConfig
235+
return tpl + memiavlcfg.DefaultConfigTemplate + DefaultVersionDBTemplate, customAppConfig
234236
}
235237

236238
type appCreator struct {

integration_tests/configs/cosmovisor.jsonnet

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ config {
77
'minimum-gas-prices': '100000000000basetcro',
88
'iavl-lazy-loading':: super['iavl-lazy-loading'],
99
},
10+
validators: [super.validators[0] {
11+
'app-config'+: {
12+
versiondb:: super['versiondb'],
13+
memiavl+: {
14+
'snapshot-keep-recent': 1000,
15+
},
16+
},
17+
}] + super.validators[1:],
1018
genesis+: {
1119
app_state+: {
1220
bank+: {

integration_tests/configs/default.jsonnet

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
'zero-copy': true,
3838
'snapshot-interval': 5,
3939
},
40-
store: {
41-
streamers: ['versiondb'],
40+
versiondb: {
41+
enable: true,
4242
},
4343
},
4444
}, {

integration_tests/test_basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,8 @@ def test_local_statesync(cronos, tmp_path_factory):
405405
Path(home) / "config/app.toml",
406406
base_port,
407407
{
408-
"store": {
409-
"streamers": ["versiondb"],
408+
"versiondb": {
409+
"enable": True,
410410
},
411411
},
412412
)

versiondb/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ After versiondb is enabled, there's no point to keep the full the archived IAVL
1212

1313
## Configuration
1414

15-
To enable versiondb, add `versiondb` to the list of `store.streamers` in `app.toml` like this:
15+
To enable versiondb, set the `versiondb.enable` to `true` in `app.toml`:
1616

1717
```toml
18-
[store]
19-
streamers = ["versiondb"]
18+
[versiondb]
19+
enable = true
2020
```
2121

2222
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.

0 commit comments

Comments
 (0)