Skip to content

Commit

Permalink
debug/{dumpdb,storage}: support rocksdb backend
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Nov 3, 2023
1 parent 1c711bd commit 010fd2f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions go/oasis-node/cmd/debug/dumpdb/dumpdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"time"

"github.com/spf13/cobra"
Expand All @@ -14,6 +15,7 @@ import (

beacon "github.com/oasisprotocol/oasis-core/go/beacon/api"
"github.com/oasisprotocol/oasis-core/go/common/logging"
"github.com/oasisprotocol/oasis-core/go/config"
"github.com/oasisprotocol/oasis-core/go/consensus/cometbft/abci"
abciState "github.com/oasisprotocol/oasis-core/go/consensus/cometbft/abci/state"
cmtAPI "github.com/oasisprotocol/oasis-core/go/consensus/cometbft/api"
Expand All @@ -37,7 +39,7 @@ import (
scheduler "github.com/oasisprotocol/oasis-core/go/scheduler/api"
staking "github.com/oasisprotocol/oasis-core/go/staking/api"
storage "github.com/oasisprotocol/oasis-core/go/storage/api"
storageDB "github.com/oasisprotocol/oasis-core/go/storage/database"
storageDatabase "github.com/oasisprotocol/oasis-core/go/storage/database"
"github.com/oasisprotocol/oasis-core/go/storage/mkvs/checkpoint"
)

Expand Down Expand Up @@ -101,11 +103,18 @@ func doDumpDB(cmd *cobra.Command, _ []string) {
// read-only mode because it needs to truncate the value log.
//
// Hope you have backups if you ever run into this.
b := strings.ToLower(config.GlobalConfig.Storage.Backend)
switch b {
case storageDatabase.BackendNameBadgerDB, storageDatabase.BackendNameRocksDB:
default:
logger.Error("unsupported storage backend", "backend", b)
return
}
ctx := context.Background()
ldb, _, stateRoot, err := abci.InitStateStorage(
&abci.ApplicationConfig{
DataDir: filepath.Join(dataDir, cmtCommon.StateDir),
StorageBackend: storageDB.BackendNameBadgerDB, // No other backend for now.
StorageBackend: b,
MemoryOnlyStorage: false,
ReadOnlyStorage: viper.GetBool(cfgDumpReadOnlyDB),
DisableCheckpointer: true,
Expand Down
2 changes: 1 addition & 1 deletion go/oasis-node/cmd/debug/storage/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func newDirectStorageBackend(dataDir string, namespace common.Namespace) (storag
}

switch b {
case storageDatabase.BackendNameBadgerDB:
case storageDatabase.BackendNameBadgerDB, storageDatabase.BackendNameRocksDB:
cfg.DB = filepath.Join(cfg.DB, storageDatabase.DefaultFileName(cfg.Backend))
return storageDatabase.New(cfg)
default:
Expand Down

0 comments on commit 010fd2f

Please sign in to comment.