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

Problem: versiondb config item not exists in sdk 0.50 #1387

Merged
merged 4 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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")) {
yihuang marked this conversation as resolved.
Show resolved Hide resolved
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
8 changes: 8 additions & 0 deletions integration_tests/configs/cosmovisor.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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+: {
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
6 changes: 3 additions & 3 deletions versiondb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading