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

db: remove tm-db #241

Merged
merged 21 commits into from
Apr 16, 2021
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
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
go-version: 1.15
- name: test & coverage report creation
run: |
cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 8m -race -coverprofile=${{ matrix.part }}profile.out -covermode=atomic
CGO_ENABLED=0 cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 8m -race -coverprofile=${{ matrix.part }}profile.out -covermode=atomic
if: env.GIT_DIFF
- uses: actions/upload-artifact@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: golangci/[email protected]
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.31
version: v1.38
args: --timeout 10m
github-token: ${{ secrets.github_token }}
if: env.GIT_DIFF
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ linters:
# - maligned
- nakedret
- prealloc
- scopelint
- exportloopref
- staticcheck
- structcheck
- stylecheck
Expand Down
6 changes: 3 additions & 3 deletions abci/example/kvstore/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"encoding/json"
"fmt"

dbm "github.com/tendermint/tm-db"

"github.com/lazyledger/lazyledger-core/abci/example/code"
"github.com/lazyledger/lazyledger-core/abci/types"
dbm "github.com/lazyledger/lazyledger-core/libs/db"
memdb "github.com/lazyledger/lazyledger-core/libs/db/memdb"
"github.com/lazyledger/lazyledger-core/version"
)

Expand Down Expand Up @@ -71,7 +71,7 @@ type Application struct {
}

func NewApplication() *Application {
state := loadState(dbm.NewMemDB())
state := loadState(memdb.NewDB())
return &Application{state: state}
}

Expand Down
5 changes: 2 additions & 3 deletions abci/example/kvstore/persistent_kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import (
"strconv"
"strings"

dbm "github.com/tendermint/tm-db"

"github.com/lazyledger/lazyledger-core/abci/example/code"
"github.com/lazyledger/lazyledger-core/abci/types"
cryptoenc "github.com/lazyledger/lazyledger-core/crypto/encoding"
dbb "github.com/lazyledger/lazyledger-core/libs/db/badgerdb"
"github.com/lazyledger/lazyledger-core/libs/log"
pc "github.com/lazyledger/lazyledger-core/proto/tendermint/crypto"
)
Expand All @@ -37,7 +36,7 @@ type PersistentKVStoreApplication struct {

func NewPersistentKVStoreApplication(dbDir string) *PersistentKVStoreApplication {
name := "kvstore"
db, err := dbm.NewGoLevelDB(name, dbDir)
db, err := dbb.NewDB(name, dbDir)
if err != nil {
panic(err)
}
Expand Down
9 changes: 4 additions & 5 deletions blockchain/v0/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

dbm "github.com/tendermint/tm-db"

abci "github.com/lazyledger/lazyledger-core/abci/types"
cfg "github.com/lazyledger/lazyledger-core/config"
"github.com/lazyledger/lazyledger-core/libs/db/memdb"
"github.com/lazyledger/lazyledger-core/libs/log"
"github.com/lazyledger/lazyledger-core/mempool/mock"
"github.com/lazyledger/lazyledger-core/p2p"
Expand Down Expand Up @@ -69,8 +68,8 @@ func newBlockchainReactor(
panic(fmt.Errorf("error start app: %w", err))
}

blockDB := dbm.NewMemDB()
stateDB := dbm.NewMemDB()
blockDB := memdb.NewDB()
stateDB := memdb.NewDB()
stateStore := sm.NewStore(stateDB)
blockStore := store.NewBlockStore(blockDB)

Expand All @@ -83,7 +82,7 @@ func newBlockchainReactor(
// NOTE we have to create and commit the blocks first because
// pool.height is determined from the store.
fastSync := true
db := dbm.NewMemDB()
db := memdb.NewDB()
stateStore = sm.NewStore(db)
blockExec := sm.NewBlockExecutor(stateStore, log.TestingLogger(), proxyApp.Consensus(),
mock.Mempool{}, sm.EmptyEvidencePool{})
Expand Down
13 changes: 8 additions & 5 deletions blockchain/v2/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
dbm "github.com/tendermint/tm-db"

abci "github.com/lazyledger/lazyledger-core/abci/types"
"github.com/lazyledger/lazyledger-core/behaviour"
bc "github.com/lazyledger/lazyledger-core/blockchain"
cfg "github.com/lazyledger/lazyledger-core/config"
"github.com/lazyledger/lazyledger-core/libs/db/memdb"
"github.com/lazyledger/lazyledger-core/libs/log"
"github.com/lazyledger/lazyledger-core/libs/service"
"github.com/lazyledger/lazyledger-core/mempool/mock"
Expand Down Expand Up @@ -65,14 +65,17 @@ type mockBlockStore struct {
blocks map[int64]*types.Block
}

//nolint:unused
func (ml *mockBlockStore) Height() int64 {
return int64(len(ml.blocks))
}

//nolint:unused
func (ml *mockBlockStore) LoadBlock(height int64) *types.Block {
return ml.blocks[height]
}

//nolint:unused
func (ml *mockBlockStore) SaveBlock(block *types.Block, part *types.PartSet, commit *types.Commit) {
ml.blocks[block.Height] = block
}
Expand Down Expand Up @@ -166,7 +169,7 @@ func newTestReactor(p testReactorParams) *BlockchainReactor {
if err != nil {
panic(fmt.Errorf("error start app: %w", err))
}
db := dbm.NewMemDB()
db := memdb.NewDB()
stateStore := sm.NewStore(db)
appl = sm.NewBlockExecutor(stateStore, p.logger, proxyApp.Consensus(), mock.Mempool{}, sm.EmptyEvidencePool{})
if err = stateStore.Save(state); err != nil {
Expand Down Expand Up @@ -511,15 +514,15 @@ func newReactorStore(
panic(fmt.Errorf("error start app: %w", err))
}

stateDB := dbm.NewMemDB()
blockStore := store.NewBlockStore(dbm.NewMemDB())
stateDB := memdb.NewDB()
blockStore := store.NewBlockStore(memdb.NewDB())
stateStore := sm.NewStore(stateDB)
state, err := stateStore.LoadFromDBOrGenesisDoc(genDoc)
if err != nil {
panic(fmt.Errorf("error constructing state from genesis file: %w", err))
}

db := dbm.NewMemDB()
db := memdb.NewDB()
stateStore = sm.NewStore(db)
blockExec := sm.NewBlockExecutor(stateStore, log.TestingLogger(), proxyApp.Consensus(),
mock.Mempool{}, sm.EmptyEvidencePool{})
Expand Down
6 changes: 3 additions & 3 deletions cmd/tendermint/commands/light.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (

"github.com/spf13/cobra"

dbm "github.com/tendermint/tm-db"

"github.com/lazyledger/lazyledger-core/crypto/merkle"
dbm "github.com/lazyledger/lazyledger-core/libs/db"
"github.com/lazyledger/lazyledger-core/libs/db/badgerdb"
"github.com/lazyledger/lazyledger-core/libs/log"
tmmath "github.com/lazyledger/lazyledger-core/libs/math"
tmos "github.com/lazyledger/lazyledger-core/libs/os"
Expand Down Expand Up @@ -122,7 +122,7 @@ func runProxy(cmd *cobra.Command, args []string) error {
witnessesAddrs = strings.Split(witnessAddrsJoined, ",")
}

db, err := dbm.NewGoLevelDB("light-client-db", dir)
db, err := badgerdb.NewDB("light-client-db", dir)
if err != nil {
return fmt.Errorf("can't create a db: %w", err)
}
Expand Down
4 changes: 0 additions & 4 deletions cmd/tendermint/commands/run_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ func AddNodeFlags(cmd *cobra.Command) {
"the possible interval between empty blocks")

// db flags
cmd.Flags().String(
"db-backend",
config.DBBackend,
"database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb")
cmd.Flags().String(
"db-dir",
config.DBPath,
Expand Down
23 changes: 0 additions & 23 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,27 +165,6 @@ type BaseConfig struct { //nolint: maligned
// and verifying their commits
FastSyncMode bool `mapstructure:"fast-sync"`

// Database backend: goleveldb | cleveldb | boltdb | rocksdb
// * goleveldb (github.com/syndtr/goleveldb - most popular implementation)
// - pure go
// - stable
// * cleveldb (uses levigo wrapper)
// - fast
// - requires gcc
// - use cleveldb build tag (go build -tags cleveldb)
// * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt)
// - EXPERIMENTAL
// - may be faster is some use-cases (random reads - indexer)
// - use boltdb build tag (go build -tags boltdb)
// * rocksdb (uses github.com/tecbot/gorocksdb)
// - EXPERIMENTAL
// - requires gcc
// - use rocksdb build tag (go build -tags rocksdb)
// * badgerdb (uses github.com/dgraph-io/badger)
// - EXPERIMENTAL
// - use badgerdb build tag (go build -tags badgerdb)
DBBackend string `mapstructure:"db-backend"`

// Database directory
DBPath string `mapstructure:"db-dir"`

Expand Down Expand Up @@ -233,7 +212,6 @@ func DefaultBaseConfig() BaseConfig {
LogFormat: LogFormatPlain,
FastSyncMode: true,
FilterPeers: false,
DBBackend: "goleveldb",
DBPath: "data",
}
}
Expand All @@ -244,7 +222,6 @@ func TestBaseConfig() BaseConfig {
cfg.chainID = "tendermint_test"
cfg.ProxyApp = "kvstore"
cfg.FastSyncMode = false
cfg.DBBackend = "memdb"
return cfg
}

Expand Down
21 changes: 0 additions & 21 deletions config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,6 @@ moniker = "{{ .BaseConfig.Moniker }}"
# and verifying their commits
fast-sync = {{ .BaseConfig.FastSyncMode }}

# Database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb
# * goleveldb (github.com/syndtr/goleveldb - most popular implementation)
# - pure go
# - stable
# * cleveldb (uses levigo wrapper)
# - fast
# - requires gcc
# - use cleveldb build tag (go build -tags cleveldb)
# * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt)
# - EXPERIMENTAL
# - may be faster is some use-cases (random reads - indexer)
# - use boltdb build tag (go build -tags boltdb)
# * rocksdb (uses github.com/tecbot/gorocksdb)
# - EXPERIMENTAL
# - requires gcc
# - use rocksdb build tag (go build -tags rocksdb)
# * badgerdb (uses github.com/dgraph-io/badger)
# - EXPERIMENTAL
# - use badgerdb build tag (go build -tags badgerdb)
db-backend = "{{ .BaseConfig.DBBackend }}"

# Database directory
db-dir = "{{ js .BaseConfig.DBPath }}"

Expand Down
9 changes: 4 additions & 5 deletions consensus/byzantine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

dbm "github.com/tendermint/tm-db"

abcicli "github.com/lazyledger/lazyledger-core/abci/client"
abci "github.com/lazyledger/lazyledger-core/abci/types"
"github.com/lazyledger/lazyledger-core/evidence"
"github.com/lazyledger/lazyledger-core/libs/db/memdb"
"github.com/lazyledger/lazyledger-core/libs/log"
"github.com/lazyledger/lazyledger-core/libs/service"
tmsync "github.com/lazyledger/lazyledger-core/libs/sync"
Expand Down Expand Up @@ -45,7 +44,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {

for i := 0; i < nValidators; i++ {
logger := consensusLogger().With("test", "byzantine", "validator", i)
stateDB := dbm.NewMemDB() // each state needs its own db
stateDB := memdb.NewDB() // each state needs its own db
stateStore := sm.NewStore(stateDB)
state, _ := stateStore.LoadFromDBOrGenesisDoc(genDoc)
thisConfig := ResetConfig(fmt.Sprintf("%s_%d", testName, i))
Expand All @@ -55,7 +54,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
vals := types.TM2PB.ValidatorUpdates(state.Validators)
app.InitChain(abci.RequestInitChain{Validators: vals})

blockDB := dbm.NewMemDB()
blockDB := memdb.NewDB()
blockStore := store.NewBlockStore(blockDB)

// one for mempool, one for consensus
Expand All @@ -71,7 +70,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) {
}

// Make a full instance of the evidence pool
evidenceDB := dbm.NewMemDB()
evidenceDB := memdb.NewDB()
evpool, err := evidence.NewPool(evidenceDB, stateStore, blockStore)
require.NoError(t, err)
evpool.SetLogger(logger.With("module", "evidence"))
Expand Down
12 changes: 6 additions & 6 deletions consensus/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ import (

"path"

dbm "github.com/tendermint/tm-db"

abcicli "github.com/lazyledger/lazyledger-core/abci/client"
"github.com/lazyledger/lazyledger-core/abci/example/counter"
"github.com/lazyledger/lazyledger-core/abci/example/kvstore"
abci "github.com/lazyledger/lazyledger-core/abci/types"
cfg "github.com/lazyledger/lazyledger-core/config"
cstypes "github.com/lazyledger/lazyledger-core/consensus/types"
tmbytes "github.com/lazyledger/lazyledger-core/libs/bytes"
dbm "github.com/lazyledger/lazyledger-core/libs/db"
"github.com/lazyledger/lazyledger-core/libs/db/memdb"
"github.com/lazyledger/lazyledger-core/libs/log"
tmos "github.com/lazyledger/lazyledger-core/libs/os"
tmpubsub "github.com/lazyledger/lazyledger-core/libs/pubsub"
Expand All @@ -52,7 +52,7 @@ type cleanupFunc func()
var (
config *cfg.Config // NOTE: must be reset for each _test.go file
consensusReplayConfig *cfg.Config
ensureTimeout = time.Millisecond * 200
ensureTimeout = 600 * time.Millisecond
)

func ensureDir(dir string, mode os.FileMode) {
Expand Down Expand Up @@ -363,7 +363,7 @@ func newStateWithConfig(
pv types.PrivValidator,
app abci.Application,
) *State {
blockDB := dbm.NewMemDB()
blockDB := memdb.NewDB()
return newStateWithConfigAndBlockStore(thisConfig, state, pv, app, blockDB)
}

Expand Down Expand Up @@ -685,7 +685,7 @@ func randConsensusNet(nValidators int, testName string, tickerFunc func() Timeou
logger := consensusLogger()
configRootDirs := make([]string, 0, nValidators)
for i := 0; i < nValidators; i++ {
stateDB := dbm.NewMemDB() // each state needs its own db
stateDB := memdb.NewDB() // each state needs its own db
stateStore := sm.NewStore(stateDB)
state, _ := stateStore.LoadFromDBOrGenesisDoc(genDoc)
thisConfig := ResetConfig(fmt.Sprintf("%s_%d", testName, i))
Expand Down Expand Up @@ -723,7 +723,7 @@ func randConsensusNetWithPeers(
var peer0Config *cfg.Config
configRootDirs := make([]string, 0, nPeers)
for i := 0; i < nPeers; i++ {
stateDB := dbm.NewMemDB() // each state needs its own db
stateDB := memdb.NewDB() // each state needs its own db
stateStore := sm.NewStore(stateDB)
state, _ := stateStore.LoadFromDBOrGenesisDoc(genDoc)
thisConfig := ResetConfig(fmt.Sprintf("%s_%d", testName, i))
Expand Down
7 changes: 3 additions & 4 deletions consensus/mempool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

dbm "github.com/tendermint/tm-db"

"github.com/lazyledger/lazyledger-core/abci/example/code"
abci "github.com/lazyledger/lazyledger-core/abci/types"
"github.com/lazyledger/lazyledger-core/libs/db/memdb"
mempl "github.com/lazyledger/lazyledger-core/mempool"
sm "github.com/lazyledger/lazyledger-core/state"
"github.com/lazyledger/lazyledger-core/types"
Expand Down Expand Up @@ -114,7 +113,7 @@ func deliverTxsRange(cs *State, start, end int) {

func TestMempoolTxConcurrentWithCommit(t *testing.T) {
state, privVals := randGenesisState(1, false, 10)
blockDB := dbm.NewMemDB()
blockDB := memdb.NewDB()
stateStore := sm.NewStore(blockDB)
cs := newStateWithConfigAndBlockStore(config, state, privVals[0], NewCounterApplication(), blockDB)
err := stateStore.Save(state)
Expand All @@ -139,7 +138,7 @@ func TestMempoolTxConcurrentWithCommit(t *testing.T) {
func TestMempoolRmBadTx(t *testing.T) {
state, privVals := randGenesisState(1, false, 10)
app := NewCounterApplication()
blockDB := dbm.NewMemDB()
blockDB := memdb.NewDB()
stateStore := sm.NewStore(blockDB)
cs := newStateWithConfigAndBlockStore(config, state, privVals[0], app, blockDB)
err := stateStore.Save(state)
Expand Down
Loading