From c70ad953ba423302ae9793254edb8866a22c05a0 Mon Sep 17 00:00:00 2001 From: ptrus Date: Sat, 4 Nov 2023 15:35:53 +0100 Subject: [PATCH] Don't harcdode badger in abci.ApplicationConfig --- go/consensus/cometbft/db/init.go | 5 ----- go/consensus/cometbft/full/archive.go | 2 +- go/consensus/cometbft/full/full.go | 2 +- go/oasis-node/node_test.go | 2 +- go/worker/storage/init.go | 5 +---- 5 files changed, 4 insertions(+), 12 deletions(-) diff --git a/go/consensus/cometbft/db/init.go b/go/consensus/cometbft/db/init.go index 167c7dcfb0a..0fffd6b57ad 100644 --- a/go/consensus/cometbft/db/init.go +++ b/go/consensus/cometbft/db/init.go @@ -8,11 +8,6 @@ import ( "github.com/oasisprotocol/oasis-core/go/consensus/cometbft/db/badger" ) -// GetBackendName returns the currently configured CometBFT database backend. -func GetBackendName() string { - return badger.BackendName -} - // GetProvider returns the currently configured CometBFT DBProvider. func GetProvider() (node.DBProvider, error) { return badger.DBProvider, nil diff --git a/go/consensus/cometbft/full/archive.go b/go/consensus/cometbft/full/archive.go index 44eaf47793b..f3eb97eb2f0 100644 --- a/go/consensus/cometbft/full/archive.go +++ b/go/consensus/cometbft/full/archive.go @@ -160,7 +160,7 @@ func NewArchive( appConfig := &abci.ApplicationConfig{ DataDir: filepath.Join(srv.dataDir, tmcommon.StateDir), - StorageBackend: db.GetBackendName(), + StorageBackend: config.GlobalConfig.Storage.Backend, Pruning: abci.PruneConfig{ Strategy: abci.PruneNone, PruneInterval: time.Hour * 100, // Irrelevant as pruning is disabled. diff --git a/go/consensus/cometbft/full/full.go b/go/consensus/cometbft/full/full.go index 69efb59a3c3..6998881f290 100644 --- a/go/consensus/cometbft/full/full.go +++ b/go/consensus/cometbft/full/full.go @@ -537,7 +537,7 @@ func (t *fullService) lazyInit() error { // nolint: gocyclo appConfig := &abci.ApplicationConfig{ DataDir: filepath.Join(t.dataDir, tmcommon.StateDir), - StorageBackend: db.GetBackendName(), + StorageBackend: config.GlobalConfig.Storage.Backend, Pruning: pruneCfg, HaltEpoch: beaconAPI.EpochTime(config.GlobalConfig.Consensus.HaltEpoch), HaltHeight: config.GlobalConfig.Consensus.HaltHeight, diff --git a/go/oasis-node/node_test.go b/go/oasis-node/node_test.go index 08e5d80b3ec..b028465804e 100644 --- a/go/oasis-node/node_test.go +++ b/go/oasis-node/node_test.go @@ -141,7 +141,7 @@ func newTestNode(t *testing.T) *testNode { config.GlobalConfig.Common.Debug.AllowRoot = true config.GlobalConfig.Mode = config.ModeCompute config.GlobalConfig.Runtime.Provisioner = runtimeConfig.RuntimeProvisionerMock - config.GlobalConfig.Storage.Backend = "badger" + config.GlobalConfig.Storage.Backend = "rocksdb" config.GlobalConfig.Storage.PublicRPCEnabled = true config.GlobalConfig.Consensus.ListenAddress = "tcp://0.0.0.0:27565" config.GlobalConfig.Consensus.SupplementarySanity.Enabled = true diff --git a/go/worker/storage/init.go b/go/worker/storage/init.go index be46d401592..6def3877938 100644 --- a/go/worker/storage/init.go +++ b/go/worker/storage/init.go @@ -44,10 +44,7 @@ func NewLocalBackend( impl api.LocalBackend ) switch cfg.Backend { - case database.BackendNameBadgerDB: - cfg.DB = GetLocalBackendDBDir(dataDir, cfg.Backend) - impl, err = database.New(cfg) - case database.BackendNameRocksDB: + case database.BackendNameBadgerDB, database.BackendNameRocksDB: cfg.DB = GetLocalBackendDBDir(dataDir, cfg.Backend) impl, err = database.New(cfg) default: