From 6cfbb568db9a9d55ab06f27d33224ab43f2d74da Mon Sep 17 00:00:00 2001 From: tnasu Date: Mon, 25 Jul 2022 14:36:24 +0900 Subject: [PATCH] Use tendermint/tm-db --- CONTRIBUTING.md | 2 +- abci/example/kvstore/kvstore.go | 5 +-- abci/example/kvstore/persistent_kvstore.go | 5 ++- blockchain/v0/reactor_test.go | 9 ++-- blockchain/v1/reactor_test.go | 9 ++-- blockchain/v2/reactor_test.go | 10 ++--- cmd/ostracon/commands/light.go | 5 +-- cmd/ostracon/commands/rollback.go | 8 ++-- config/config.go | 11 +---- consensus/byzantine_test.go | 9 ++-- consensus/common_test.go | 10 ++--- consensus/mempool_test.go | 7 ++-- consensus/reactor_test.go | 7 ++-- consensus/replay_file.go | 8 ++-- consensus/replay_test.go | 11 +++-- consensus/wal_generator.go | 5 ++- evidence/pool.go | 8 ++-- evidence/pool_test.go | 19 ++++----- evidence/reactor_test.go | 7 ++-- evidence/verify_test.go | 21 +++++----- go.mod | 5 ++- go.sum | 14 ++++--- light/client_benchmark_test.go | 8 ++-- light/client_test.go | 49 +++++++++++----------- light/detector_test.go | 19 +++++---- light/example_test.go | 7 ++-- light/store/db/db.go | 2 +- light/store/db/db_test.go | 13 +++--- node/node.go | 11 ++--- node/node_test.go | 11 +++-- p2p/trust/store.go | 2 +- p2p/trust/store_test.go | 11 ++--- rpc/core/blocks_test.go | 19 +++++---- rpc/core/tx_test.go | 9 ++-- state/export_test.go | 2 +- state/helpers_test.go | 5 +-- state/indexer/block/kv/kv.go | 16 +++---- state/indexer/block/kv/kv_test.go | 8 ++-- state/rollback_test.go | 6 +-- state/state_test.go | 7 ++-- state/store.go | 4 +- state/store_test.go | 14 +++---- state/tx_filter_test.go | 5 ++- state/txindex/indexer_service_test.go | 7 ++-- state/txindex/kv/kv.go | 10 ++--- state/txindex/kv/kv_bench_test.go | 4 +- state/txindex/kv/kv_test.go | 18 ++++---- statesync/stateprovider.go | 5 ++- store/store.go | 3 +- store/store_test.go | 25 ++++++----- test/e2e/docker/Dockerfile | 16 +------ test/maverick/consensus/replay_file.go | 8 ++-- test/maverick/consensus/wal_generator.go | 4 +- test/maverick/node/node.go | 10 ++--- 54 files changed, 258 insertions(+), 275 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b6ac0e6b4..a65da301b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -84,7 +84,7 @@ up-to-date. When updating dependencies, please only update the particular dependencies you need. Instead of running `go get -u=patch`, which will update anything, specify exactly the dependency you want to update, eg. -`GO111MODULE=on go get -u github.com/line/tm-db@main`. +`GO111MODULE=on go get -u github.com/tendermint/tm-db@master`. ## Protobuf diff --git a/abci/example/kvstore/kvstore.go b/abci/example/kvstore/kvstore.go index 4b1e76553..604861c9f 100644 --- a/abci/example/kvstore/kvstore.go +++ b/abci/example/kvstore/kvstore.go @@ -6,8 +6,7 @@ import ( "encoding/json" "fmt" - dbm "github.com/line/tm-db/v2" - "github.com/line/tm-db/v2/memdb" + dbm "github.com/tendermint/tm-db" "github.com/line/ostracon/abci/example/code" "github.com/line/ostracon/abci/types" @@ -72,7 +71,7 @@ type Application struct { } func NewApplication() *Application { - state := loadState(memdb.NewDB()) + state := loadState(dbm.NewMemDB()) return &Application{state: state} } diff --git a/abci/example/kvstore/persistent_kvstore.go b/abci/example/kvstore/persistent_kvstore.go index fcbe676e5..9a87c9671 100644 --- a/abci/example/kvstore/persistent_kvstore.go +++ b/abci/example/kvstore/persistent_kvstore.go @@ -7,12 +7,13 @@ import ( "strconv" "strings" + dbm "github.com/tendermint/tm-db" + "github.com/line/ostracon/abci/example/code" "github.com/line/ostracon/abci/types" cryptoenc "github.com/line/ostracon/crypto/encoding" "github.com/line/ostracon/libs/log" pc "github.com/line/ostracon/proto/ostracon/crypto" - "github.com/line/tm-db/v2/goleveldb" ) const ( @@ -36,7 +37,7 @@ type PersistentKVStoreApplication struct { func NewPersistentKVStoreApplication(dbDir string) *PersistentKVStoreApplication { name := "kvstore" - db, err := goleveldb.NewDB(name, dbDir) + db, err := dbm.NewGoLevelDB(name, dbDir) if err != nil { panic(err) } diff --git a/blockchain/v0/reactor_test.go b/blockchain/v0/reactor_test.go index ce5c2da93..733ea119b 100644 --- a/blockchain/v0/reactor_test.go +++ b/blockchain/v0/reactor_test.go @@ -7,10 +7,11 @@ import ( "testing" "time" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" + abci "github.com/line/ostracon/abci/types" cfg "github.com/line/ostracon/config" "github.com/line/ostracon/libs/log" @@ -69,8 +70,8 @@ func newBlockchainReactor( panic(fmt.Errorf("error start app: %w", err)) } - blockDB := memdb.NewDB() - stateDB := memdb.NewDB() + blockDB := dbm.NewMemDB() + stateDB := dbm.NewMemDB() stateStore := sm.NewStore(stateDB) blockStore := store.NewBlockStore(blockDB) @@ -83,7 +84,7 @@ func newBlockchainReactor( // NOTE we have to create and commit the blocks first because // pool.height is determined from the store. fastSync := true - db := memdb.NewDB() + db := dbm.NewMemDB() stateStore = sm.NewStore(db) blockExec := sm.NewBlockExecutor(stateStore, log.TestingLogger(), proxyApp.Consensus(), mock.Mempool{}, sm.EmptyEvidencePool{}) diff --git a/blockchain/v1/reactor_test.go b/blockchain/v1/reactor_test.go index d26c0295c..696af5dc9 100644 --- a/blockchain/v1/reactor_test.go +++ b/blockchain/v1/reactor_test.go @@ -8,10 +8,11 @@ import ( "testing" "time" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" + abci "github.com/line/ostracon/abci/types" cfg "github.com/line/ostracon/config" "github.com/line/ostracon/libs/log" @@ -99,8 +100,8 @@ func newBlockchainReactor( panic(fmt.Errorf("error start app: %w", err)) } - blockDB := memdb.NewDB() - stateDB := memdb.NewDB() + blockDB := dbm.NewMemDB() + stateDB := dbm.NewMemDB() stateStore := sm.NewStore(stateDB) blockStore := store.NewBlockStore(blockDB) @@ -113,7 +114,7 @@ func newBlockchainReactor( // NOTE we have to create and commit the blocks first because // pool.height is determined from the store. fastSync := true - db := memdb.NewDB() + db := dbm.NewMemDB() stateStore = sm.NewStore(db) blockExec := sm.NewBlockExecutor(stateStore, log.TestingLogger(), proxyApp.Consensus(), mock.Mempool{}, sm.EmptyEvidencePool{}) diff --git a/blockchain/v2/reactor_test.go b/blockchain/v2/reactor_test.go index bfd549a2b..0e69b6167 100644 --- a/blockchain/v2/reactor_test.go +++ b/blockchain/v2/reactor_test.go @@ -24,9 +24,9 @@ import ( "github.com/line/ostracon/store" "github.com/line/ostracon/types" tmtime "github.com/line/ostracon/types/time" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" ) type mockPeer struct { @@ -159,7 +159,7 @@ func newTestReactor(p testReactorParams) *BlockchainReactor { if err != nil { panic(fmt.Errorf("error start app: %w", err)) } - db := memdb.NewDB() + db := dbm.NewMemDB() stateStore := sm.NewStore(db) appl = sm.NewBlockExecutor(stateStore, p.logger, proxyApp.Consensus(), mock.Mempool{}, sm.EmptyEvidencePool{}) if err = stateStore.Save(state); err != nil { @@ -505,15 +505,15 @@ func newReactorStore( panic(fmt.Errorf("error start app: %w", err)) } - stateDB := memdb.NewDB() - blockStore := store.NewBlockStore(memdb.NewDB()) + stateDB := dbm.NewMemDB() + blockStore := store.NewBlockStore(dbm.NewMemDB()) stateStore := sm.NewStore(stateDB) state, err := stateStore.LoadFromDBOrGenesisDoc(genDoc) if err != nil { panic(fmt.Errorf("error constructing state from genesis file: %w", err)) } - db := memdb.NewDB() + db := dbm.NewMemDB() stateStore = sm.NewStore(db) blockExec := sm.NewBlockExecutor(stateStore, log.TestingLogger(), proxyApp.Consensus(), mock.Mempool{}, sm.EmptyEvidencePool{}) diff --git a/cmd/ostracon/commands/light.go b/cmd/ostracon/commands/light.go index 86678e254..0f8bae2ed 100644 --- a/cmd/ostracon/commands/light.go +++ b/cmd/ostracon/commands/light.go @@ -13,10 +13,9 @@ import ( rpchttp "github.com/line/ostracon/rpc/client/http" - "github.com/line/tm-db/v2/goleveldb" "github.com/spf13/cobra" - dbm "github.com/line/tm-db/v2" + dbm "github.com/tendermint/tm-db" "github.com/line/ostracon/libs/log" tmmath "github.com/line/ostracon/libs/math" @@ -122,7 +121,7 @@ func runProxy(cmd *cobra.Command, args []string) error { witnessesAddrs = strings.Split(witnessAddrsJoined, ",") } - db, err := goleveldb.NewDB("light-client-db", home) + db, err := dbm.NewGoLevelDB("light-client-db", home) if err != nil { return fmt.Errorf("can't create a db: %w", err) } diff --git a/cmd/ostracon/commands/rollback.go b/cmd/ostracon/commands/rollback.go index e8fe335f6..3712bec41 100644 --- a/cmd/ostracon/commands/rollback.go +++ b/cmd/ostracon/commands/rollback.go @@ -5,7 +5,7 @@ import ( "github.com/spf13/cobra" - "github.com/line/tm-db/v2/metadb" + dbm "github.com/tendermint/tm-db" cfg "github.com/line/ostracon/config" "github.com/line/ostracon/state" @@ -53,17 +53,17 @@ func RollbackState(config *cfg.Config) (int64, []byte, error) { } func loadStateAndBlockStore(config *cfg.Config) (*store.BlockStore, state.Store, error) { - dbType := metadb.BackendType(config.DBBackend) + dbType := dbm.BackendType(config.DBBackend) // Get BlockStore - blockStoreDB, err := metadb.NewDB("blockstore", dbType, config.DBDir()) + blockStoreDB, err := dbm.NewDB("blockstore", dbType, config.DBDir()) if err != nil { return nil, nil, err } blockStore := store.NewBlockStore(blockStoreDB) // Get StateStore - stateDB, err := metadb.NewDB("state", dbType, config.DBDir()) + stateDB, err := dbm.NewDB("state", dbType, config.DBDir()) if err != nil { return nil, nil, err } diff --git a/config/config.go b/config/config.go index 6512faccd..d02bc4353 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,6 @@ import ( "time" "github.com/line/ostracon/privval" - "github.com/line/tm-db/v2/metadb" ) const ( @@ -231,14 +230,6 @@ type BaseConfig struct { //nolint: maligned // DefaultBaseConfig returns a default base configuration for an Ostracon node func DefaultBaseConfig() BaseConfig { - dbs := metadb.AvailableDBBackends() - defaultDBBackend := DefaultDBBackend - for _, b := range dbs { - defaultDBBackend = string(b) - if defaultDBBackend == DefaultDBBackend { - break - } - } return BaseConfig{ Genesis: defaultGenesisJSONPath, PrivValidatorKey: defaultPrivValKeyPath, @@ -251,7 +242,7 @@ func DefaultBaseConfig() BaseConfig { LogFormat: LogFormatPlain, FastSyncMode: true, FilterPeers: false, - DBBackend: defaultDBBackend, + DBBackend: DefaultDBBackend, DBPath: "data", PrivKeyType: privval.PrivKeyTypeEd25519, } diff --git a/consensus/byzantine_test.go b/consensus/byzantine_test.go index 559cf5651..dd51411db 100644 --- a/consensus/byzantine_test.go +++ b/consensus/byzantine_test.go @@ -9,10 +9,11 @@ import ( "testing" "time" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" + config2 "github.com/line/ostracon/config" abcicli "github.com/line/ostracon/abci/client" @@ -50,7 +51,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) { for i := 0; i < nValidators; i++ { logger := consensusLogger().With("test", "byzantine", "validator", i) - stateDB := memdb.NewDB() // each state needs its own db + stateDB := dbm.NewMemDB() // each state needs its own db stateStore := sm.NewStore(stateDB) state, _ := stateStore.LoadFromDBOrGenesisDoc(genDoc) thisConfig := ResetConfig(fmt.Sprintf("%s_%d", testName, i)) @@ -60,7 +61,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) { vals := types.OC2PB.ValidatorUpdates(state.Validators) app.InitChain(abci.RequestInitChain{Validators: vals}) - blockDB := memdb.NewDB() + blockDB := dbm.NewMemDB() blockStore := store.NewBlockStore(blockDB) // one for mempool, one for consensus @@ -76,7 +77,7 @@ func TestByzantinePrevoteEquivocation(t *testing.T) { } // Make a full instance of the evidence pool - evidenceDB := memdb.NewDB() + evidenceDB := dbm.NewMemDB() evpool, err := evidence.NewPool(evidenceDB, stateStore, blockStore) require.NoError(t, err) evpool.SetLogger(logger.With("module", "evidence")) diff --git a/consensus/common_test.go b/consensus/common_test.go index 28d7ab6a3..19c82dbca 100644 --- a/consensus/common_test.go +++ b/consensus/common_test.go @@ -15,13 +15,11 @@ import ( "time" "github.com/go-kit/log/term" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/require" - dbm "github.com/line/tm-db/v2" + dbm "github.com/tendermint/tm-db" abcicli "github.com/line/ostracon/abci/client" - "github.com/line/ostracon/abci/example/counter" "github.com/line/ostracon/abci/example/kvstore" abci "github.com/line/ostracon/abci/types" @@ -409,7 +407,7 @@ func newStateWithConfig( pv types.PrivValidator, app abci.Application, ) *State { - blockDB := memdb.NewDB() + blockDB := dbm.NewMemDB() return newStateWithConfigAndBlockStore(thisConfig, state, pv, app, blockDB) } @@ -841,7 +839,7 @@ func randConsensusNet(nValidators int, testName string, tickerFunc func() Timeou logger := consensusLogger() configRootDirs := make([]string, 0, nValidators) for i := 0; i < nValidators; i++ { - stateDB := memdb.NewDB() // each state needs its own db + stateDB := dbm.NewMemDB() // each state needs its own db stateStore := sm.NewStore(stateDB) state, err := stateStore.LoadFromDBOrGenesisDoc(genDoc) if err != nil { @@ -919,7 +917,7 @@ func createPeersAndValidators(nValidators, nPeers int, testName string, var peer0Config *cfg.Config configRootDirs := make([]string, 0, nPeers) for i := 0; i < nPeers; i++ { - stateDB := memdb.NewDB() // each state needs its own db + stateDB := dbm.NewMemDB() // each state needs its own db stateStore := sm.NewStore(stateDB) state, _ := stateStore.LoadFromDBOrGenesisDoc(genDoc) thisConfig := ResetConfig(fmt.Sprintf("%s_%d", testName, i)) diff --git a/consensus/mempool_test.go b/consensus/mempool_test.go index 73beb8990..ad9a4e5e5 100644 --- a/consensus/mempool_test.go +++ b/consensus/mempool_test.go @@ -8,10 +8,11 @@ import ( "testing" "time" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" + "github.com/line/ostracon/abci/example/code" abci "github.com/line/ostracon/abci/types" mempl "github.com/line/ostracon/mempool" @@ -112,7 +113,7 @@ func deliverTxsRange(cs *State, start, end int) { func TestMempoolTxConcurrentWithCommit(t *testing.T) { state, privVals := randGenesisState(1, false, 10, nil) - blockDB := memdb.NewDB() + blockDB := dbm.NewMemDB() stateStore := sm.NewStore(blockDB) cs := newStateWithConfigAndBlockStore(config, state, privVals[0], NewCounterApplication(), blockDB) err := stateStore.Save(state) @@ -137,7 +138,7 @@ func TestMempoolTxConcurrentWithCommit(t *testing.T) { func TestMempoolRmBadTx(t *testing.T) { state, privVals := randGenesisState(1, false, 10, nil) app := NewCounterApplication() - blockDB := memdb.NewDB() + blockDB := dbm.NewMemDB() stateStore := sm.NewStore(blockDB) cs := newStateWithConfigAndBlockStore(config, state, privVals[0], app, blockDB) err := stateStore.Save(state) diff --git a/consensus/reactor_test.go b/consensus/reactor_test.go index d4bd4a610..a11f22713 100644 --- a/consensus/reactor_test.go +++ b/consensus/reactor_test.go @@ -11,11 +11,12 @@ import ( "testing" "time" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" + abcicli "github.com/line/ostracon/abci/client" "github.com/line/ostracon/abci/example/kvstore" abci "github.com/line/ostracon/abci/types" @@ -134,7 +135,7 @@ func TestReactorWithEvidence(t *testing.T) { css := make([]*State, nValidators) logger := consensusLogger() for i := 0; i < nValidators; i++ { - stateDB := memdb.NewDB() // each state needs its own db + stateDB := dbm.NewMemDB() // each state needs its own db stateStore := sm.NewStore(stateDB) state, _ := stateStore.LoadFromDBOrGenesisDoc(genDoc) thisConfig := ResetConfig(fmt.Sprintf("%s_%d", testName, i)) @@ -148,7 +149,7 @@ func TestReactorWithEvidence(t *testing.T) { // duplicate code from: // css[i] = newStateWithConfig(thisConfig, state, privVals[i], app) - blockDB := memdb.NewDB() + blockDB := dbm.NewMemDB() blockStore := store.NewBlockStore(blockDB) // one for mempool, one for consensus diff --git a/consensus/replay_file.go b/consensus/replay_file.go index 8c684e532..43e0ae4e0 100644 --- a/consensus/replay_file.go +++ b/consensus/replay_file.go @@ -10,7 +10,7 @@ import ( "strconv" "strings" - "github.com/line/tm-db/v2/metadb" + dbm "github.com/tendermint/tm-db" cfg "github.com/line/ostracon/config" "github.com/line/ostracon/libs/log" @@ -284,16 +284,16 @@ func (pb *playback) replayConsoleLoop() int { // convenience for replay mode func newConsensusStateForReplay(config cfg.BaseConfig, csConfig *cfg.ConsensusConfig) *State { - dbType := metadb.BackendType(config.DBBackend) + dbType := dbm.BackendType(config.DBBackend) // Get BlockStore - blockStoreDB, err := metadb.NewDB("blockstore", dbType, config.DBDir()) + blockStoreDB, err := dbm.NewDB("blockstore", dbType, config.DBDir()) if err != nil { tmos.Exit(err.Error()) } blockStore := store.NewBlockStore(blockStoreDB) // Get State - stateDB, err := metadb.NewDB("state", dbType, config.DBDir()) + stateDB, err := dbm.NewDB("state", dbType, config.DBDir()) if err != nil { tmos.Exit(err.Error()) } diff --git a/consensus/replay_test.go b/consensus/replay_test.go index c6d5a9af0..eeb82ffb2 100644 --- a/consensus/replay_test.go +++ b/consensus/replay_test.go @@ -14,10 +14,9 @@ import ( "time" "github.com/gogo/protobuf/proto" - dbm "github.com/line/tm-db/v2" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" "github.com/line/ostracon/abci/example/kvstore" abci "github.com/line/ostracon/abci/types" @@ -169,7 +168,7 @@ LOOP: t.Logf("====== LOOP %d\n", i) // create consensus state from a clean slate - blockDB := memdb.NewDB() + blockDB := dbm.NewMemDB() stateDB := blockDB stateStore := sm.NewStore(stateDB) state, err := sm.MakeGenesisStateFromFile(consensusReplayConfig.GenesisFile()) @@ -675,7 +674,7 @@ func testHandshakeReplay(t *testing.T, config *cfg.Config, nBlocks int, mode uin if testValidatorsChange { testConfig := ResetConfig(fmt.Sprintf("%s_%v_m", t.Name(), mode)) defer os.RemoveAll(testConfig.RootDir) - stateDB = memdb.NewDB() + stateDB = dbm.NewMemDB() // Make the global variable "sim" be initialized forcefully by calling "TestSimulateValidatorChange()" // if it is not initialized as in unit execution. @@ -732,7 +731,7 @@ func testHandshakeReplay(t *testing.T, config *cfg.Config, nBlocks int, mode uin // run nBlocks against a new client to build up the app state. // use a throwaway ostracon state proxyApp := proxy.NewAppConns(clientCreator2) - stateDB1 := memdb.NewDB() + stateDB1 := dbm.NewMemDB() stateStore := sm.NewStore(stateDB1) err := stateStore.Save(genesisState) require.NoError(t, err) @@ -1171,7 +1170,7 @@ func stateAndStore( config *cfg.Config, pubKey crypto.PubKey, appVersion uint64) (dbm.DB, sm.State, *mockBlockStore) { - stateDB := memdb.NewDB() + stateDB := dbm.NewMemDB() stateStore := sm.NewStore(stateDB) state, _ := sm.MakeGenesisStateFromFile(config.GenesisFile()) state.Version.Consensus.App = appVersion diff --git a/consensus/wal_generator.go b/consensus/wal_generator.go index 0575e4d47..57632e28e 100644 --- a/consensus/wal_generator.go +++ b/consensus/wal_generator.go @@ -9,6 +9,8 @@ import ( "testing" "time" + db "github.com/tendermint/tm-db" + "github.com/line/ostracon/abci/example/kvstore" cfg "github.com/line/ostracon/config" "github.com/line/ostracon/libs/log" @@ -18,7 +20,6 @@ import ( sm "github.com/line/ostracon/state" "github.com/line/ostracon/store" "github.com/line/ostracon/types" - "github.com/line/tm-db/v2/memdb" "github.com/pkg/errors" ) @@ -49,7 +50,7 @@ func WALGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) { if err != nil { return fmt.Errorf("failed to read genesis file: %w", err) } - blockStoreDB := memdb.NewDB() + blockStoreDB := db.NewMemDB() stateDB := blockStoreDB stateStore := sm.NewStore(stateDB) state, err := sm.MakeGenesisState(genDoc) diff --git a/evidence/pool.go b/evidence/pool.go index ddb0fbbb6..a8c5992e0 100644 --- a/evidence/pool.go +++ b/evidence/pool.go @@ -10,9 +10,9 @@ import ( "github.com/gogo/protobuf/proto" gogotypes "github.com/gogo/protobuf/types" - dbm "github.com/line/tm-db/v2" + dbm "github.com/tendermint/tm-db" - clist "github.com/line/ostracon/libs/clist" + "github.com/line/ostracon/libs/clist" "github.com/line/ostracon/libs/log" tmproto "github.com/line/ostracon/proto/ostracon/types" sm "github.com/line/ostracon/state" @@ -365,7 +365,7 @@ func (evpool *Pool) listEvidence(prefixKey byte, maxBytes int64) ([]types.Eviden evList tmproto.EvidenceList // used for calculating the bytes size ) - iter, err := evpool.evidenceStore.PrefixIterator([]byte{prefixKey}) + iter, err := dbm.IteratePrefix(evpool.evidenceStore, []byte{prefixKey}) if err != nil { return nil, totalSize, fmt.Errorf("database error: %v", err) } @@ -401,7 +401,7 @@ func (evpool *Pool) listEvidence(prefixKey byte, maxBytes int64) ([]types.Eviden } func (evpool *Pool) removeExpiredPendingEvidence() (int64, time.Time) { - iter, err := evpool.evidenceStore.PrefixIterator([]byte{baseKeyPending}) + iter, err := dbm.IteratePrefix(evpool.evidenceStore, []byte{baseKeyPending}) if err != nil { evpool.logger.Error("Unable to iterate over pending evidence", "err", err) return evpool.State().LastBlockHeight, evpool.State().LastBlockTime diff --git a/evidence/pool_test.go b/evidence/pool_test.go index ca9a76441..826f5c6da 100644 --- a/evidence/pool_test.go +++ b/evidence/pool_test.go @@ -9,13 +9,12 @@ import ( "github.com/line/ostracon/crypto/bls" "github.com/line/ostracon/crypto/composite" "github.com/line/ostracon/crypto/ed25519" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - dbm "github.com/line/tm-db/v2" + dbm "github.com/tendermint/tm-db" "github.com/line/ostracon/evidence" "github.com/line/ostracon/evidence/mocks" @@ -46,7 +45,7 @@ func TestEvidencePoolBasic(t *testing.T) { var ( height = int64(1) stateStore = &smmocks.Store{} - evidenceDB = memdb.NewDB() + evidenceDB = dbm.NewMemDB() blockStore = &mocks.BlockStore{} ) @@ -119,7 +118,7 @@ func TestAddExpiredEvidence(t *testing.T) { val = types.NewMockPV(types.PrivKeyComposite) // TODO 🏺 need to test by all key types height = int64(30) stateStore = initializeValidatorState(val, height) - evidenceDB = memdb.NewDB() + evidenceDB = dbm.NewMemDB() blockStore = &mocks.BlockStore{} expiredEvidenceTime = time.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC) expiredHeight = int64(2) @@ -286,7 +285,7 @@ func TestLightClientAttackEvidenceLifecycle(t *testing.T) { blockStore.On("LoadBlockCommit", height).Return(trusted.Commit) blockStore.On("LoadBlockCommit", commonHeight).Return(common.Commit) - pool, err := evidence.NewPool(memdb.NewDB(), stateStore, blockStore) + pool, err := evidence.NewPool(dbm.NewMemDB(), stateStore, blockStore) require.NoError(t, err) pool.SetLogger(log.TestingLogger()) @@ -327,11 +326,11 @@ func TestRecoverPendingEvidence(t *testing.T) { height := int64(10) val := types.NewMockPV(types.PrivKeyComposite) // TODO 🏺 need to test by all key types valAddress := val.PrivKey.PubKey().Address() - evidenceDB := memdb.NewDB() + evidenceDB := dbm.NewMemDB() stateStore := initializeValidatorState(val, height) state, err := stateStore.Load() require.NoError(t, err) - blockStore := initializeBlockStore(memdb.NewDB(), state, valAddress) + blockStore := initializeBlockStore(dbm.NewMemDB(), state, valAddress) // create previous pool and populate it pool, err := evidence.NewPool(evidenceDB, stateStore, blockStore) require.NoError(t, err) @@ -372,7 +371,7 @@ func TestRecoverPendingEvidence(t *testing.T) { } func initializeStateFromValidatorSet(valSet *types.ValidatorSet, height int64) sm.Store { - stateDB := memdb.NewDB() + stateDB := dbm.NewMemDB() stateStore := sm.NewStore(stateDB) state := sm.State{ ChainID: evidenceChainID, @@ -459,10 +458,10 @@ func makeCommit(height int64, valAddr []byte) *types.Commit { func defaultTestPool(height int64) (*evidence.Pool, types.MockPV) { val := types.NewMockPV(types.PrivKeyComposite) // TODO 🏺 need to test by all key types valAddress := val.PrivKey.PubKey().Address() - evidenceDB := memdb.NewDB() + evidenceDB := dbm.NewMemDB() stateStore := initializeValidatorState(val, height) state, _ := stateStore.Load() - blockStore := initializeBlockStore(memdb.NewDB(), state, valAddress) + blockStore := initializeBlockStore(dbm.NewMemDB(), state, valAddress) pool, err := evidence.NewPool(evidenceDB, stateStore, blockStore) if err != nil { panic("test evidence pool could not be created") diff --git a/evidence/reactor_test.go b/evidence/reactor_test.go index ee0342f8a..03b71b69e 100644 --- a/evidence/reactor_test.go +++ b/evidence/reactor_test.go @@ -9,11 +9,12 @@ import ( "github.com/fortytw2/leaktest" "github.com/go-kit/log/term" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" + cfg "github.com/line/ostracon/config" "github.com/line/ostracon/crypto" "github.com/line/ostracon/crypto/tmhash" @@ -189,7 +190,7 @@ func TestReactorsGossipNoCommittedEvidence(t *testing.T) { func TestReactorBroadcastEvidenceMemoryLeak(t *testing.T) { config := cfg.TestConfig() evidenceTime := time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC) - evidenceDB := memdb.NewDB() + evidenceDB := dbm.NewMemDB() blockStore := &mocks.BlockStore{} blockStore.On("LoadBlockMeta", mock.AnythingOfType("int64")).Return( &types.BlockMeta{Header: types.Header{Time: evidenceTime}}, @@ -246,7 +247,7 @@ func makeAndConnectReactorsAndPools(config *cfg.Config, stateStores []sm.Store) evidenceTime := time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC) for i := 0; i < N; i++ { - evidenceDB := memdb.NewDB() + evidenceDB := dbm.NewMemDB() blockStore := &mocks.BlockStore{} blockStore.On("LoadBlockMeta", mock.AnythingOfType("int64")).Return( &types.BlockMeta{Header: types.Header{Time: evidenceTime}}, diff --git a/evidence/verify_test.go b/evidence/verify_test.go index c8d4b04a6..f7dcf2e0d 100644 --- a/evidence/verify_test.go +++ b/evidence/verify_test.go @@ -9,11 +9,12 @@ import ( "github.com/line/ostracon/light" "github.com/coniks-sys/coniks-go/crypto/vrf" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" + "github.com/line/ostracon/crypto" "github.com/line/ostracon/crypto/tmhash" "github.com/line/ostracon/evidence" @@ -182,7 +183,7 @@ func TestVerify_LunaticAttackAgainstState(t *testing.T) { blockStore.On("LoadBlockMeta", height).Return(&types.BlockMeta{Header: *trusted.Header}) blockStore.On("LoadBlockCommit", commonHeight).Return(common.Commit) blockStore.On("LoadBlockCommit", height).Return(trusted.Commit) - pool, err := evidence.NewPool(memdb.NewDB(), stateStore, blockStore) + pool, err := evidence.NewPool(dbm.NewMemDB(), stateStore, blockStore) require.NoError(t, err) pool.SetLogger(log.TestingLogger()) @@ -205,20 +206,20 @@ func TestVerify_LunaticAttackAgainstState(t *testing.T) { // duplicate evidence should be rejected evList = types.EvidenceList{ev, ev} - pool, err = evidence.NewPool(memdb.NewDB(), stateStore, blockStore) + pool, err = evidence.NewPool(dbm.NewMemDB(), stateStore, blockStore) require.NoError(t, err) assert.Error(t, pool.CheckEvidence(evList)) // If evidence is submitted with an altered timestamp it should return an error ev.Timestamp = defaultEvidenceTime.Add(1 * time.Minute) - pool, err = evidence.NewPool(memdb.NewDB(), stateStore, blockStore) + pool, err = evidence.NewPool(dbm.NewMemDB(), stateStore, blockStore) require.NoError(t, err) assert.Error(t, pool.AddEvidence(ev)) ev.Timestamp = defaultEvidenceTime // Evidence submitted with a different validator power should fail ev.TotalVotingPower = 1 - pool, err = evidence.NewPool(memdb.NewDB(), stateStore, blockStore) + pool, err = evidence.NewPool(dbm.NewMemDB(), stateStore, blockStore) require.NoError(t, err) assert.Error(t, pool.AddEvidence(ev)) ev.TotalVotingPower = common.VoterSet.TotalVotingPower() @@ -263,7 +264,7 @@ func TestVerify_ForwardLunaticAttack(t *testing.T) { blockStore.On("LoadBlockCommit", commonHeight).Return(common.Commit) blockStore.On("LoadBlockCommit", nodeHeight).Return(trusted.Commit) blockStore.On("Height").Return(nodeHeight) - pool, err := evidence.NewPool(memdb.NewDB(), stateStore, blockStore) + pool, err := evidence.NewPool(dbm.NewMemDB(), stateStore, blockStore) require.NoError(t, err) // check that the evidence pool correctly verifies the evidence @@ -281,7 +282,7 @@ func TestVerify_ForwardLunaticAttack(t *testing.T) { oldBlockStore.On("Height").Return(nodeHeight) require.Equal(t, defaultEvidenceTime, oldBlockStore.LoadBlockMeta(nodeHeight).Header.Time) - pool, err = evidence.NewPool(memdb.NewDB(), stateStore, oldBlockStore) + pool, err = evidence.NewPool(dbm.NewMemDB(), stateStore, oldBlockStore) require.NoError(t, err) assert.Error(t, pool.CheckEvidence(types.EvidenceList{ev})) } @@ -380,7 +381,7 @@ func TestVerifyLightClientAttack_Equivocation(t *testing.T) { blockStore.On("LoadBlockMeta", int64(10)).Return(&types.BlockMeta{Header: *trustedHeader}) blockStore.On("LoadBlockCommit", int64(10)).Return(trustedCommit) - pool, err := evidence.NewPool(memdb.NewDB(), stateStore, blockStore) + pool, err := evidence.NewPool(dbm.NewMemDB(), stateStore, blockStore) require.NoError(t, err) pool.SetLogger(log.TestingLogger()) @@ -476,7 +477,7 @@ func TestVerifyLightClientAttack_Amnesia(t *testing.T) { blockStore.On("LoadBlockMeta", int64(10)).Return(&types.BlockMeta{Header: *trustedHeader}) blockStore.On("LoadBlockCommit", int64(10)).Return(trustedCommit) - pool, err := evidence.NewPool(memdb.NewDB(), stateStore, blockStore) + pool, err := evidence.NewPool(dbm.NewMemDB(), stateStore, blockStore) require.NoError(t, err) pool.SetLogger(log.TestingLogger()) @@ -573,7 +574,7 @@ func TestVerifyDuplicateVoteEvidence(t *testing.T) { blockStore := &mocks.BlockStore{} blockStore.On("LoadBlockMeta", int64(10)).Return(&types.BlockMeta{Header: types.Header{Time: defaultEvidenceTime}}) - pool, err := evidence.NewPool(memdb.NewDB(), stateStore, blockStore) + pool, err := evidence.NewPool(dbm.NewMemDB(), stateStore, blockStore) require.NoError(t, err) evList := types.EvidenceList{goodEv} diff --git a/go.mod b/go.mod index 4ae39e3e9..8593907b9 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,9 @@ require ( github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce github.com/cenkalti/backoff v2.2.1+incompatible // indirect github.com/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71 + github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect + github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect + github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect github.com/fortytw2/leaktest v1.3.0 github.com/go-kit/kit v0.12.0 github.com/go-kit/log v0.2.1 @@ -25,7 +28,6 @@ require ( github.com/herumi/bls-eth-go-binary v0.0.0-20220509081320-2d8ab06de53c github.com/lib/pq v1.10.6 github.com/libp2p/go-buffer-pool v0.1.0 - github.com/line/tm-db/v2 v2.0.0-init.1.0.20220121012851-61d2bc1d9486 github.com/minio/highwayhash v1.0.2 github.com/ory/dockertest v3.3.5+incompatible github.com/pkg/errors v0.9.1 @@ -39,6 +41,7 @@ require ( github.com/spf13/viper v1.12.0 github.com/stretchr/testify v1.8.0 github.com/tendermint/go-amino v0.16.0 + github.com/tendermint/tm-db v0.6.6 github.com/yahoo/coname v0.0.0-20170609175141-84592ddf8673 // indirect golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 diff --git a/go.sum b/go.sum index 02da0e9fe..d91611b99 100644 --- a/go.sum +++ b/go.sum @@ -488,10 +488,6 @@ github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs= github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= -github.com/line/gorocksdb v0.0.0-20210406043732-d4bea34b6d55 h1:cXVtMiJkvQ4kn0pxM2svH1ncJbFgQsLHtnFC9qJj2VM= -github.com/line/gorocksdb v0.0.0-20210406043732-d4bea34b6d55/go.mod h1:DHRJroSL7NaRkpvocRx3OtRsleXVsYSxBI9SfHFlTQ0= -github.com/line/tm-db/v2 v2.0.0-init.1.0.20220121012851-61d2bc1d9486 h1:uvXQdcWaUyNsgkXBz375FpQ285WEJaLXhQ5HtoNK/GU= -github.com/line/tm-db/v2 v2.0.0-init.1.0.20220121012851-61d2bc1d9486/go.mod h1:wmkyPabXjtVZ1dvRofmurjaceghywtCSYGqFuFS+TbI= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= @@ -712,8 +708,12 @@ github.com/subosito/gotenv v1.3.0/go.mod h1:YzJjq/33h7nrwdY+iHMhEOEEbW0ovIz0tB6t github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca h1:Ld/zXl5t4+D69SiV4JoN7kkfvJdOWlPpfxrzxpLMoUk= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= +github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= +github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= +github.com/tendermint/tm-db v0.6.6 h1:EzhaOfR0bdKyATqcd5PNeyeq8r+V4bRPHBfyFdD9kGM= +github.com/tendermint/tm-db v0.6.6/go.mod h1:wP8d49A85B7/erz/r4YbKssKw6ylsO/hKtFk7E1aWZI= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= @@ -735,8 +735,8 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0= -go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= +go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= +go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/api/v3 v3.5.4/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A= go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= @@ -979,6 +979,7 @@ golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1275,6 +1276,7 @@ google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnD google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= diff --git a/light/client_benchmark_test.go b/light/client_benchmark_test.go index e09be1628..60484acb7 100644 --- a/light/client_benchmark_test.go +++ b/light/client_benchmark_test.go @@ -7,7 +7,7 @@ import ( "github.com/line/ostracon/libs/sync" - "github.com/line/tm-db/v2/memdb" + dbm "github.com/tendermint/tm-db" "github.com/line/ostracon/libs/log" "github.com/line/ostracon/light" @@ -52,7 +52,7 @@ func BenchmarkSequence(b *testing.B) { }, benchmarkFullNode, []provider.Provider{benchmarkFullNode}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), types.DefaultVoterParams(), light.Logger(log.TestingLogger()), light.SequentialVerification(), @@ -82,7 +82,7 @@ func BenchmarkBisection(b *testing.B) { }, benchmarkFullNode, []provider.Provider{benchmarkFullNode}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), types.DefaultVoterParams(), light.Logger(log.TestingLogger()), ) @@ -112,7 +112,7 @@ func BenchmarkBackwards(b *testing.B) { }, benchmarkFullNode, []provider.Provider{benchmarkFullNode}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), types.DefaultVoterParams(), light.Logger(log.TestingLogger()), ) diff --git a/light/client_test.go b/light/client_test.go index 518e08f9f..db54bbf2c 100644 --- a/light/client_test.go +++ b/light/client_test.go @@ -8,7 +8,6 @@ import ( "time" tmrand "github.com/line/ostracon/libs/rand" - "github.com/line/tm-db/v2/memdb" "github.com/line/ostracon/crypto/ed25519" "github.com/line/ostracon/crypto/vrf" @@ -21,6 +20,8 @@ import ( "github.com/line/ostracon/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + dbm "github.com/tendermint/tm-db" ) const ( @@ -297,7 +298,7 @@ func TestClient_SequentialVerification(t *testing.T) { tc.vals, tc.voters, )}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), voterParam, light.SequentialVerification(), light.Logger(log.TestingLogger()), @@ -473,7 +474,7 @@ func TestClient_SkippingVerification(t *testing.T) { tc.vals, tc.voters, )}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), voterParam, light.SkippingVerification(light.DefaultTrustLevel), light.Logger(log.TestingLogger()), @@ -512,7 +513,7 @@ func TestClientLargeBisectionVerification(t *testing.T) { }, veryLargeFullNode, []provider.Provider{veryLargeFullNode}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), voterParam, light.SequentialVerification(), ) @@ -535,7 +536,7 @@ func TestClientBisectionBetweenTrustedHeaders(t *testing.T) { }, fullNode, []provider.Provider{fullNode}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), voterParam, light.SequentialVerification(), ) @@ -560,7 +561,7 @@ func TestClient_Cleanup(t *testing.T) { trustOptions, fullNode, []provider.Provider{fullNode}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), voterParam, light.Logger(log.TestingLogger()), ) @@ -581,7 +582,7 @@ func TestClient_Cleanup(t *testing.T) { func TestClientRestoresTrustedHeaderAfterStartup1(t *testing.T) { // 1. options.Hash == trustedHeader.Hash { - trustedStore := dbs.New(memdb.NewDB(), chainID) + trustedStore := dbs.New(dbm.NewMemDB(), chainID) err := trustedStore.SaveLightBlock(l1) require.NoError(t, err) @@ -606,7 +607,7 @@ func TestClientRestoresTrustedHeaderAfterStartup1(t *testing.T) { // 2. options.Hash != trustedHeader.Hash { - trustedStore := dbs.New(memdb.NewDB(), chainID) + trustedStore := dbs.New(dbm.NewMemDB(), chainID) err := trustedStore.SaveLightBlock(l1) require.NoError(t, err) @@ -656,7 +657,7 @@ func TestClientRestoresTrustedHeaderAfterStartup1(t *testing.T) { func TestClientRestoresTrustedHeaderAfterStartup2(t *testing.T) { // 1. options.Hash == trustedHeader.Hash { - trustedStore := dbs.New(memdb.NewDB(), chainID) + trustedStore := dbs.New(dbm.NewMemDB(), chainID) err := trustedStore.SaveLightBlock(l1) require.NoError(t, err) @@ -687,7 +688,7 @@ func TestClientRestoresTrustedHeaderAfterStartup2(t *testing.T) { // 2. options.Hash != trustedHeader.Hash // This could happen if previous provider was lying to us. { - trustedStore := dbs.New(memdb.NewDB(), chainID) + trustedStore := dbs.New(dbm.NewMemDB(), chainID) err := trustedStore.SaveLightBlock(l1) require.NoError(t, err) @@ -741,7 +742,7 @@ func TestClientRestoresTrustedHeaderAfterStartup3(t *testing.T) { // 1. options.Hash == trustedHeader.Hash { // load the first three headers into the trusted store - trustedStore := dbs.New(memdb.NewDB(), chainID) + trustedStore := dbs.New(dbm.NewMemDB(), chainID) err := trustedStore.SaveLightBlock(l1) require.NoError(t, err) @@ -780,7 +781,7 @@ func TestClientRestoresTrustedHeaderAfterStartup3(t *testing.T) { // 2. options.Hash != trustedHeader.Hash // This could happen if previous provider was lying to us. { - trustedStore := dbs.New(memdb.NewDB(), chainID) + trustedStore := dbs.New(dbm.NewMemDB(), chainID) err := trustedStore.SaveLightBlock(l1) require.NoError(t, err) @@ -844,7 +845,7 @@ func TestClient_Update(t *testing.T) { trustOptions, fullNode, []provider.Provider{fullNode}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), voterParam, light.Logger(log.TestingLogger()), ) @@ -866,7 +867,7 @@ func TestClient_Concurrency(t *testing.T) { trustOptions, fullNode, []provider.Provider{fullNode}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), voterParam, light.Logger(log.TestingLogger()), ) @@ -908,7 +909,7 @@ func TestClientReplacesPrimaryWithWitnessIfPrimaryIsUnavailable(t *testing.T) { trustOptions, deadNode, []provider.Provider{fullNode, fullNode}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), voterParam, light.Logger(log.TestingLogger()), light.MaxRetryAttempts(1), @@ -936,7 +937,7 @@ func TestClient_BackwardsVerification(t *testing.T) { }, largeFullNode, []provider.Provider{largeFullNode}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), voterParam, light.Logger(log.TestingLogger()), ) @@ -1023,7 +1024,7 @@ func TestClient_BackwardsVerification(t *testing.T) { }, tc.provider, []provider.Provider{tc.provider}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), voterParam, light.Logger(log.TestingLogger()), ) @@ -1037,7 +1038,7 @@ func TestClient_BackwardsVerification(t *testing.T) { func TestClient_NewClientFromTrustedStore(t *testing.T) { // 1) Initiate DB and fill with a "trusted" header - db := dbs.New(memdb.NewDB(), chainID) + db := dbs.New(dbm.NewMemDB(), chainID) err := db.SaveLightBlock(l1) require.NoError(t, err) @@ -1105,7 +1106,7 @@ func TestClientRemovesWitnessIfItSendsUsIncorrectHeader(t *testing.T) { trustOptions, fullNode, []provider.Provider{badProvider1, badProvider2}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), voterParam, light.Logger(log.TestingLogger()), light.MaxRetryAttempts(1), @@ -1161,7 +1162,7 @@ func TestClient_TrustedValidatorSet(t *testing.T) { trustOptions, fullNode, []provider.Provider{badVoterSetNode, fullNode}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), voterParam, light.Logger(log.TestingLogger()), ) @@ -1180,7 +1181,7 @@ func TestClientPrunesHeadersAndValidatorSets(t *testing.T) { trustOptions, fullNode, []provider.Provider{fullNode}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), voterParam, light.Logger(log.TestingLogger()), light.PruningSize(1), @@ -1270,7 +1271,7 @@ func TestClientEnsureValidHeadersAndValSets(t *testing.T) { trustOptions, badNode, []provider.Provider{badNode, badNode}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), voterParam, light.MaxRetryAttempts(1), ) @@ -1304,7 +1305,7 @@ func TestClientHandlesContexts(t *testing.T) { }, p, []provider.Provider{p, p}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), voterParam, ) require.Error(t, ctxTimeOut.Err()) @@ -1322,7 +1323,7 @@ func TestClientHandlesContexts(t *testing.T) { }, p, []provider.Provider{p, p}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), voterParam, ) require.NoError(t, err) diff --git a/light/detector_test.go b/light/detector_test.go index d75a450e4..25f55fad0 100644 --- a/light/detector_test.go +++ b/light/detector_test.go @@ -4,10 +4,11 @@ import ( "testing" "time" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" + "github.com/line/ostracon/libs/log" "github.com/line/ostracon/light" "github.com/line/ostracon/light/provider" @@ -75,7 +76,7 @@ func TestLightClientAttackEvidence_Lunatic(t *testing.T) { }, primary, []provider.Provider{witness}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), types.DefaultVoterParams(), light.Logger(log.TestingLogger()), light.MaxRetryAttempts(1), @@ -167,7 +168,7 @@ func TestLightClientAttackEvidence_Equivocation(t *testing.T) { }, primary, []provider.Provider{witness}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), types.DefaultVoterParams(), light.Logger(log.TestingLogger()), light.MaxRetryAttempts(1), @@ -274,7 +275,7 @@ func TestLightClientAttackEvidence_ForwardLunatic(t *testing.T) { }, primary, []provider.Provider{witness, accomplice}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), types.DefaultVoterParams(), light.Logger(log.TestingLogger()), light.MaxClockDrift(1*time.Second), @@ -338,7 +339,7 @@ func TestLightClientAttackEvidence_ForwardLunatic(t *testing.T) { }, primary, []provider.Provider{laggingWitness, accomplice}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), types.DefaultVoterParams(), light.Logger(log.TestingLogger()), light.MaxClockDrift(1*time.Second), @@ -370,7 +371,7 @@ func TestClientDivergentTraces1(t *testing.T) { }, primary, []provider.Provider{witness}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), types.DefaultVoterParams(), light.Logger(log.TestingLogger()), light.MaxRetryAttempts(1), @@ -395,7 +396,7 @@ func TestClientDivergentTraces2(t *testing.T) { }, primary, []provider.Provider{deadNode, deadNode, primary}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), types.DefaultVoterParams(), light.Logger(log.TestingLogger()), light.MaxRetryAttempts(1), @@ -432,7 +433,7 @@ func TestClientDivergentTraces3(t *testing.T) { }, primary, []provider.Provider{witness}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), types.DefaultVoterParams(), light.Logger(log.TestingLogger()), light.MaxRetryAttempts(1), @@ -471,7 +472,7 @@ func TestClientDivergentTraces4(t *testing.T) { }, primary, []provider.Provider{witness}, - dbs.New(memdb.NewDB(), chainID), + dbs.New(dbm.NewMemDB(), chainID), types.DefaultVoterParams(), light.Logger(log.TestingLogger()), ) diff --git a/light/example_test.go b/light/example_test.go index eee1d4d8a..4b592a943 100644 --- a/light/example_test.go +++ b/light/example_test.go @@ -9,8 +9,9 @@ import ( "testing" "time" + dbm "github.com/tendermint/tm-db" + "github.com/line/ostracon/types" - "github.com/line/tm-db/v2/goleveldb" "github.com/line/ostracon/abci/example/kvstore" "github.com/line/ostracon/libs/log" @@ -47,7 +48,7 @@ func ExampleClient_Update() { stdlog.Fatal(err) } - db, err := goleveldb.NewDB("light-client-db", dbDir) + db, err := dbm.NewGoLevelDB("light-client-db", dbDir) if err != nil { stdlog.Fatal(err) } @@ -116,7 +117,7 @@ func ExampleClient_VerifyLightBlockAtHeight() { stdlog.Fatal(err) } - db, err := goleveldb.NewDB("light-client-db", dbDir) + db, err := dbm.NewGoLevelDB("light-client-db", dbDir) if err != nil { stdlog.Fatal(err) } diff --git a/light/store/db/db.go b/light/store/db/db.go index 27b41664d..d53ef8cfd 100644 --- a/light/store/db/db.go +++ b/light/store/db/db.go @@ -6,7 +6,7 @@ import ( "regexp" "strconv" - dbm "github.com/line/tm-db/v2" + dbm "github.com/tendermint/tm-db" tmsync "github.com/line/ostracon/libs/sync" "github.com/line/ostracon/light/store" diff --git a/light/store/db/db_test.go b/light/store/db/db_test.go index 89b8b5cf4..33dc3c086 100644 --- a/light/store/db/db_test.go +++ b/light/store/db/db_test.go @@ -5,10 +5,11 @@ import ( "testing" "time" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" + "github.com/line/ostracon/crypto" "github.com/line/ostracon/crypto/tmhash" tmrand "github.com/line/ostracon/libs/rand" @@ -18,7 +19,7 @@ import ( ) func TestLast_FirstLightBlockHeight(t *testing.T) { - dbStore := New(memdb.NewDB(), "TestLast_FirstLightBlockHeight") + dbStore := New(dbm.NewMemDB(), "TestLast_FirstLightBlockHeight") // Empty store height, err := dbStore.LastLightBlockHeight() @@ -43,7 +44,7 @@ func TestLast_FirstLightBlockHeight(t *testing.T) { } func Test_SaveLightBlock(t *testing.T) { - dbStore := New(memdb.NewDB(), "Test_SaveLightBlockAndValidatorSet") + dbStore := New(dbm.NewMemDB(), "Test_SaveLightBlockAndValidatorSet") // Empty store h, err := dbStore.LightBlock(1) @@ -73,7 +74,7 @@ func Test_SaveLightBlock(t *testing.T) { } func Test_LightBlockBefore(t *testing.T) { - dbStore := New(memdb.NewDB(), "Test_LightBlockBefore") + dbStore := New(dbm.NewMemDB(), "Test_LightBlockBefore") assert.Panics(t, func() { _, _ = dbStore.LightBlockBefore(0) @@ -91,7 +92,7 @@ func Test_LightBlockBefore(t *testing.T) { } func Test_Prune(t *testing.T) { - dbStore := New(memdb.NewDB(), "Test_Prune") + dbStore := New(dbm.NewMemDB(), "Test_Prune") // Empty store assert.EqualValues(t, 0, dbStore.Size()) @@ -128,7 +129,7 @@ func Test_Prune(t *testing.T) { } func Test_Concurrency(t *testing.T) { - dbStore := New(memdb.NewDB(), "Test_Prune") + dbStore := New(dbm.NewMemDB(), "Test_Prune") var wg sync.WaitGroup for i := 1; i <= 100; i++ { diff --git a/node/node.go b/node/node.go index fe799bd47..dcb1736cd 100644 --- a/node/node.go +++ b/node/node.go @@ -10,13 +10,10 @@ import ( "strings" "time" - "github.com/line/tm-db/v2/metadb" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/rs/cors" - - dbm "github.com/line/tm-db/v2" - pdbm "github.com/line/tm-db/v2/prefixdb" + dbm "github.com/tendermint/tm-db" abci "github.com/line/ostracon/abci/types" bcv0 "github.com/line/ostracon/blockchain/v0" @@ -72,8 +69,8 @@ type DBProvider func(*DBContext) (dbm.DB, error) // DefaultDBProvider returns a database using the DBBackend and DBDir // specified in the ctx.Config. func DefaultDBProvider(ctx *DBContext) (dbm.DB, error) { - dbType := metadb.BackendType(ctx.Config.DBBackend) - return metadb.NewDB(ctx.ID, dbType, ctx.Config.DBDir()) + dbType := dbm.BackendType(ctx.Config.DBBackend) + return dbm.NewDB(ctx.ID, dbType, ctx.Config.DBDir()) } // GenesisDocProvider returns a GenesisDoc. @@ -319,7 +316,7 @@ func createAndStartIndexerService( } txIndexer = kv.NewTxIndex(store) - blockIndexer = blockidxkv.New(pdbm.NewDB(store, []byte("block_events"))) + blockIndexer = blockidxkv.New(dbm.NewPrefixDB(store, []byte("block_events"))) case "psql": if config.TxIndex.PsqlConn == "" { diff --git a/node/node_test.go b/node/node_test.go index 52c8cc494..8c619347e 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -12,11 +12,10 @@ import ( "github.com/ory/dockertest" "github.com/ory/dockertest/docker" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - dbm "github.com/line/tm-db/v2" + dbm "github.com/tendermint/tm-db" "github.com/line/ostracon/abci/example/kvstore" cfg "github.com/line/ostracon/config" @@ -144,7 +143,7 @@ func TestNodeSetAppVersion(t *testing.T) { require.NoError(t, err) // default config uses the kvstore app - var appVersion uint64 = kvstore.ProtocolVersion + var appVersion = kvstore.ProtocolVersion // check version is set in state state, err := n.stateStore.Load() @@ -276,8 +275,8 @@ func TestCreateProposalBlock(t *testing.T) { mempool.SetLogger(logger) // Make EvidencePool - evidenceDB := memdb.NewDB() - blockStore := store.NewBlockStore(memdb.NewDB()) + evidenceDB := dbm.NewMemDB() + blockStore := store.NewBlockStore(dbm.NewMemDB()) evidencePool, err := evidence.NewPool(evidenceDB, stateStore, blockStore) require.NoError(t, err) evidencePool.SetLogger(logger) @@ -564,7 +563,7 @@ func state(nVals int, height int64) (sm.State, dbm.DB, []types.PrivValidator) { }) // save validators to db for 2 heights - stateDB := memdb.NewDB() + stateDB := dbm.NewMemDB() stateStore := sm.NewStore(stateDB) if err := stateStore.Save(s); err != nil { panic(err) diff --git a/p2p/trust/store.go b/p2p/trust/store.go index 779b49a30..e5ca49d94 100644 --- a/p2p/trust/store.go +++ b/p2p/trust/store.go @@ -8,7 +8,7 @@ import ( "fmt" "time" - dbm "github.com/line/tm-db/v2" + dbm "github.com/tendermint/tm-db" "github.com/line/ostracon/libs/service" tmsync "github.com/line/ostracon/libs/sync" diff --git a/p2p/trust/store_test.go b/p2p/trust/store_test.go index ea07f6a36..ac109e8fd 100644 --- a/p2p/trust/store_test.go +++ b/p2p/trust/store_test.go @@ -10,9 +10,10 @@ import ( "testing" "github.com/line/ostracon/libs/log" - "github.com/line/tm-db/v2/metadb" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" ) func TestTrustMetricStoreSaveLoad(t *testing.T) { @@ -20,7 +21,7 @@ func TestTrustMetricStoreSaveLoad(t *testing.T) { require.NoError(t, err) defer os.Remove(dir) - historyDB, err := metadb.NewDB("trusthistory", "goleveldb", dir) + historyDB, err := dbm.NewDB("trusthistory", "goleveldb", dir) require.NoError(t, err) // 0 peers saved @@ -83,7 +84,7 @@ func TestTrustMetricStoreSaveLoad(t *testing.T) { } func TestTrustMetricStoreConfig(t *testing.T) { - historyDB, err := metadb.NewDB("", "memdb", "") + historyDB, err := dbm.NewDB("", "memdb", "") require.NoError(t, err) config := MetricConfig{ @@ -108,7 +109,7 @@ func TestTrustMetricStoreConfig(t *testing.T) { } func TestTrustMetricStoreLookup(t *testing.T) { - historyDB, err := metadb.NewDB("", "memdb", "") + historyDB, err := dbm.NewDB("", "memdb", "") require.NoError(t, err) store := NewTrustMetricStore(historyDB, DefaultConfig()) @@ -131,7 +132,7 @@ func TestTrustMetricStoreLookup(t *testing.T) { } func TestTrustMetricStorePeerScore(t *testing.T) { - historyDB, err := metadb.NewDB("", "memdb", "") + historyDB, err := dbm.NewDB("", "memdb", "") require.NoError(t, err) store := NewTrustMetricStore(historyDB, DefaultConfig()) diff --git a/rpc/core/blocks_test.go b/rpc/core/blocks_test.go index 636d4b6e4..744498398 100644 --- a/rpc/core/blocks_test.go +++ b/rpc/core/blocks_test.go @@ -1,7 +1,7 @@ package core import ( - errors "errors" + "errors" "fmt" "os" "testing" @@ -16,10 +16,11 @@ import ( blockidxnull "github.com/line/ostracon/state/indexer/block/null" "github.com/line/ostracon/store" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" + abci "github.com/line/ostracon/abci/types" tmstate "github.com/line/ostracon/proto/ostracon/state" ctypes "github.com/line/ostracon/rpc/core/types" @@ -92,7 +93,7 @@ func TestBlockResults(t *testing.T) { } env = &Environment{} - env.StateStore = sm.NewStore(memdb.NewDB()) + env.StateStore = sm.NewStore(dbm.NewMemDB()) err := env.StateStore.SaveABCIResponses(100, results) require.NoError(t, err) env.BlockStore = mockBlockStore{height: 100} @@ -240,7 +241,7 @@ func TestBlockSearch_errors(t *testing.T) { { // error: switch orderBy env = &Environment{} - env.BlockIndexer = blockidxkv.New(memdb.NewDB()) + env.BlockIndexer = blockidxkv.New(dbm.NewMemDB()) q = fmt.Sprintf("%s>%d", types.BlockHeightKey, 1) res, err := BlockSearch(ctx, q, &page, &perPage, orderBy) @@ -254,7 +255,7 @@ func TestBlockSearch_errors(t *testing.T) { { // error: validatePage(pagePtr, perPage, totalCount) env = &Environment{} - env.BlockIndexer = blockidxkv.New(memdb.NewDB()) + env.BlockIndexer = blockidxkv.New(dbm.NewMemDB()) q = fmt.Sprintf("%s>%d", types.BlockHeightKey, 1) orderBy = TestOrderByDesc @@ -271,10 +272,10 @@ func TestBlockSearch_errors(t *testing.T) { func makeTestState() (sm.State, func()) { config := cfg.ResetTestRoot("rpc_core_test") env = &Environment{} - env.StateStore = sm.NewStore(memdb.NewDB()) - env.BlockStore = store.NewBlockStore(memdb.NewDB()) - env.BlockIndexer = blockidxkv.New(memdb.NewDB()) - env.TxIndexer = txidxkv.NewTxIndex(memdb.NewDB()) + env.StateStore = sm.NewStore(dbm.NewMemDB()) + env.BlockStore = store.NewBlockStore(dbm.NewMemDB()) + env.BlockIndexer = blockidxkv.New(dbm.NewMemDB()) + env.TxIndexer = txidxkv.NewTxIndex(dbm.NewMemDB()) state, _ := env.StateStore.LoadFromDBOrGenesisFile(config.GenesisFile()) return state, func() { os.RemoveAll(config.RootDir) } diff --git a/rpc/core/tx_test.go b/rpc/core/tx_test.go index 3a0e8d2bd..d7d58502e 100644 --- a/rpc/core/tx_test.go +++ b/rpc/core/tx_test.go @@ -8,9 +8,10 @@ import ( "testing" "time" + dbm "github.com/tendermint/tm-db" + txidxkv "github.com/line/ostracon/state/txindex/kv" txidxnull "github.com/line/ostracon/state/txindex/null" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/require" rpctypes "github.com/line/ostracon/rpc/jsonrpc/types" @@ -184,7 +185,7 @@ func TestTxSearch_errors(t *testing.T) { { // error: lookForHash env = &Environment{} - env.TxIndexer = txidxkv.NewTxIndex(memdb.NewDB()) + env.TxIndexer = txidxkv.NewTxIndex(dbm.NewMemDB()) q = fmt.Sprintf("%s=%s", types.TxHashKey, "'1'") res, err := TxSearch(ctx, q, prove, &page, &perPage, orderBy) @@ -198,7 +199,7 @@ func TestTxSearch_errors(t *testing.T) { { // error: switch orderBy env = &Environment{} - env.TxIndexer = txidxkv.NewTxIndex(memdb.NewDB()) + env.TxIndexer = txidxkv.NewTxIndex(dbm.NewMemDB()) q = fmt.Sprintf("%s=%s", types.TxHashKey, "'1234567890abcdef'") res, err := TxSearch(ctx, q, prove, &page, &perPage, orderBy) @@ -212,7 +213,7 @@ func TestTxSearch_errors(t *testing.T) { { // error: validatePage(pagePtr, perPage, totalCount) env = &Environment{} - env.TxIndexer = txidxkv.NewTxIndex(memdb.NewDB()) + env.TxIndexer = txidxkv.NewTxIndex(dbm.NewMemDB()) q = fmt.Sprintf("%s=%s", types.TxHashKey, "'1234567890abcdef'") orderBy = TestOrderByAsc diff --git a/state/export_test.go b/state/export_test.go index 88be9f765..c4876a95b 100644 --- a/state/export_test.go +++ b/state/export_test.go @@ -1,7 +1,7 @@ package state import ( - dbm "github.com/line/tm-db/v2" + dbm "github.com/tendermint/tm-db" abci "github.com/line/ostracon/abci/types" tmstate "github.com/line/ostracon/proto/ostracon/state" diff --git a/state/helpers_test.go b/state/helpers_test.go index 0f26bf1ca..ce42eb926 100644 --- a/state/helpers_test.go +++ b/state/helpers_test.go @@ -5,8 +5,7 @@ import ( "fmt" "time" - dbm "github.com/line/tm-db/v2" - "github.com/line/tm-db/v2/memdb" + dbm "github.com/tendermint/tm-db" abci "github.com/line/ostracon/abci/types" "github.com/line/ostracon/crypto" @@ -124,7 +123,7 @@ func makeState(nVals, height int) (sm.State, dbm.DB, map[string]types.PrivValida AppHash: nil, }) - stateDB := memdb.NewDB() + stateDB := dbm.NewMemDB() stateStore := sm.NewStore(stateDB) if err := stateStore.Save(s); err != nil { panic(err) diff --git a/state/indexer/block/kv/kv.go b/state/indexer/block/kv/kv.go index b8296e584..7f93478d1 100644 --- a/state/indexer/block/kv/kv.go +++ b/state/indexer/block/kv/kv.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/google/orderedcode" - db "github.com/line/tm-db/v2" + dbm "github.com/tendermint/tm-db" abci "github.com/line/ostracon/abci/types" "github.com/line/ostracon/libs/pubsub/query" @@ -23,10 +23,10 @@ var _ indexer.BlockIndexer = (*BlockerIndexer)(nil) // events with an underlying KV store. Block events are indexed by their height, // such that matching search criteria returns the respective block height(s). type BlockerIndexer struct { - store db.DB + store dbm.DB } -func New(store db.DB) *BlockerIndexer { +func New(store dbm.DB) *BlockerIndexer { return &BlockerIndexer{ store: store, } @@ -234,7 +234,7 @@ func (idx *BlockerIndexer) matchRange( lowerBound := qr.LowerBoundValue() upperBound := qr.UpperBoundValue() - it, err := idx.store.PrefixIterator(startKey) + it, err := dbm.IteratePrefix(idx.store, startKey) if err != nil { return nil, fmt.Errorf("failed to create prefix iterator: %w", err) } @@ -342,7 +342,7 @@ func (idx *BlockerIndexer) match( switch { case c.Op == query.OpEqual: - it, err := idx.store.PrefixIterator(startKeyBz) + it, err := dbm.IteratePrefix(idx.store, startKeyBz) if err != nil { return nil, fmt.Errorf("failed to create prefix iterator: %w", err) } @@ -366,7 +366,7 @@ func (idx *BlockerIndexer) match( return nil, err } - it, err := idx.store.PrefixIterator(prefix) + it, err := dbm.IteratePrefix(idx.store, prefix) if err != nil { return nil, fmt.Errorf("failed to create prefix iterator: %w", err) } @@ -393,7 +393,7 @@ func (idx *BlockerIndexer) match( return nil, err } - it, err := idx.store.PrefixIterator(prefix) + it, err := dbm.IteratePrefix(idx.store, prefix) if err != nil { return nil, fmt.Errorf("failed to create prefix iterator: %w", err) } @@ -453,7 +453,7 @@ func (idx *BlockerIndexer) match( return filteredHeights, nil } -func (idx *BlockerIndexer) indexEvents(batch db.Batch, events []abci.Event, typ string, height int64) error { +func (idx *BlockerIndexer) indexEvents(batch dbm.Batch, events []abci.Event, typ string, height int64) error { heightBz := int64ToBytes(height) for _, event := range events { diff --git a/state/indexer/block/kv/kv_test.go b/state/indexer/block/kv/kv_test.go index 4239e6c43..6173197ff 100644 --- a/state/indexer/block/kv/kv_test.go +++ b/state/indexer/block/kv/kv_test.go @@ -5,17 +5,17 @@ import ( "fmt" "testing" + "github.com/stretchr/testify/require" + db "github.com/tendermint/tm-db" + abci "github.com/line/ostracon/abci/types" "github.com/line/ostracon/libs/pubsub/query" blockidxkv "github.com/line/ostracon/state/indexer/block/kv" "github.com/line/ostracon/types" - dbm "github.com/line/tm-db/v2/memdb" - dbp "github.com/line/tm-db/v2/prefixdb" - "github.com/stretchr/testify/require" ) func TestBlockIndexer(t *testing.T) { - store := dbp.NewDB(dbm.NewDB(), []byte("block_events")) + store := db.NewPrefixDB(db.NewMemDB(), []byte("block_events")) indexer := blockidxkv.New(store) require.NoError(t, indexer.Index(types.EventDataNewBlockHeader{ Header: types.Header{Height: 1}, diff --git a/state/rollback_test.go b/state/rollback_test.go index 7daf69253..cf1557423 100644 --- a/state/rollback_test.go +++ b/state/rollback_test.go @@ -4,8 +4,8 @@ import ( "crypto/rand" "testing" - dbm "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" "github.com/line/ostracon/crypto" "github.com/line/ostracon/crypto/tmhash" @@ -89,7 +89,7 @@ func TestRollback(t *testing.T) { } func TestRollbackNoState(t *testing.T) { - stateStore := state.NewStore(dbm.NewDB()) + stateStore := state.NewStore(dbm.NewMemDB()) blockStore := &mocks.BlockStore{} _, _, err := state.Rollback(blockStore, stateStore) @@ -128,7 +128,7 @@ func TestRollbackDifferentStateHeight(t *testing.T) { } func setupStateStore(t *testing.T, height int64) state.Store { - stateStore := state.NewStore(dbm.NewDB()) + stateStore := state.NewStore(dbm.NewMemDB()) previousValSet, _ := types.RandValidatorSet(5, 10) previousVoterSet := types.SelectVoter(previousValSet, proofHash, voterParams) diff --git a/state/state_test.go b/state/state_test.go index e72ef430d..c1122b125 100644 --- a/state/state_test.go +++ b/state/state_test.go @@ -8,13 +8,12 @@ import ( "testing" "time" - "github.com/line/tm-db/v2/metadb" "gonum.org/v1/gonum/stat/distuv" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - dbm "github.com/line/tm-db/v2" + dbm "github.com/tendermint/tm-db" abci "github.com/line/ostracon/abci/types" cfg "github.com/line/ostracon/config" @@ -31,8 +30,8 @@ import ( // setupTestCase does setup common to all test cases. func setupTestCase(t *testing.T) (func(t *testing.T), dbm.DB, sm.State) { config := cfg.ResetTestRoot("state_") - dbType := metadb.BackendType(config.DBBackend) - stateDB, err := metadb.NewDB("state", dbType, config.DBDir()) + dbType := dbm.BackendType(config.DBBackend) + stateDB, err := dbm.NewDB("state", dbType, config.DBDir()) stateStore := sm.NewStore(stateDB) require.NoError(t, err) state, err := stateStore.LoadFromDBOrGenesisFile(config.GenesisFile()) diff --git a/state/store.go b/state/store.go index 69b1f1b86..ffcc4499e 100644 --- a/state/store.go +++ b/state/store.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/gogo/protobuf/proto" - dbm "github.com/line/tm-db/v2" + dbm "github.com/tendermint/tm-db" abci "github.com/line/ostracon/abci/types" tmmath "github.com/line/ostracon/libs/math" @@ -82,7 +82,7 @@ type Store interface { Close() error } -// dbStore wraps a db (github.com/line/tm-db/v2) +// dbStore wraps a db (github.com/tendermint/tm-db) type dbStore struct { db dbm.DB } diff --git a/state/store_test.go b/state/store_test.go index c17e902d4..70e73f35d 100644 --- a/state/store_test.go +++ b/state/store_test.go @@ -5,11 +5,11 @@ import ( "os" "testing" - "github.com/line/tm-db/v2/memdb" - "github.com/line/tm-db/v2/metadb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" + abci "github.com/line/ostracon/abci/types" cfg "github.com/line/ostracon/config" "github.com/line/ostracon/crypto" @@ -22,7 +22,7 @@ import ( ) func TestStoreLoadValidators(t *testing.T) { - stateDB := memdb.NewDB() + stateDB := dbm.NewMemDB() stateStore := sm.NewStore(stateDB) val, _ := types.RandValidator(true, 10) vals := types.NewValidatorSet([]*types.Validator{val}) @@ -47,7 +47,7 @@ func TestStoreLoadValidators(t *testing.T) { } func TestStoreLoadVoters(t *testing.T) { - stateDB := memdb.NewDB() + stateDB := dbm.NewMemDB() stateStore := sm.NewStore(stateDB) val, _ := types.RandValidator(true, 10) vals := types.NewValidatorSet([]*types.Validator{val}) @@ -123,8 +123,8 @@ func BenchmarkLoadValidators(b *testing.B) { config := cfg.ResetTestRoot("state_") defer os.RemoveAll(config.RootDir) - dbType := metadb.BackendType(config.DBBackend) - stateDB, err := metadb.NewDB("state", dbType, config.DBDir()) + dbType := dbm.BackendType(config.DBBackend) + stateDB, err := dbm.NewDB("state", dbType, config.DBDir()) require.NoError(b, err) stateStore := sm.NewStore(stateDB) state, err := stateStore.LoadFromDBOrGenesisFile(config.GenesisFile()) @@ -204,7 +204,7 @@ func TestPruneStates(t *testing.T) { for name, tc := range testcases { tc := tc t.Run(name, func(t *testing.T) { - db := memdb.NewDB() + db := dbm.NewMemDB() stateStore := sm.NewStore(db) pk := ed25519.GenPrivKey().PubKey() diff --git a/state/tx_filter_test.go b/state/tx_filter_test.go index a1446be39..12532f2e5 100644 --- a/state/tx_filter_test.go +++ b/state/tx_filter_test.go @@ -4,10 +4,11 @@ import ( "os" "testing" - "github.com/line/tm-db/v2/metadb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" + tmrand "github.com/line/ostracon/libs/rand" sm "github.com/line/ostracon/state" "github.com/line/ostracon/types" @@ -30,7 +31,7 @@ func TestTxFilter(t *testing.T) { } for i, tc := range testCases { - stateDB, err := metadb.NewDB("state", "memdb", os.TempDir()) + stateDB, err := dbm.NewDB("state", "memdb", os.TempDir()) require.NoError(t, err) stateStore := sm.NewStore(stateDB) state, err := stateStore.LoadFromDBOrGenesisDoc(genDoc) diff --git a/state/txindex/indexer_service_test.go b/state/txindex/indexer_service_test.go index 7ee97c012..ba1c3f8fa 100644 --- a/state/txindex/indexer_service_test.go +++ b/state/txindex/indexer_service_test.go @@ -4,9 +4,8 @@ import ( "testing" "time" - "github.com/line/tm-db/v2/memdb" - "github.com/line/tm-db/v2/prefixdb" "github.com/stretchr/testify/require" + db "github.com/tendermint/tm-db" abci "github.com/line/ostracon/abci/types" "github.com/line/ostracon/libs/log" @@ -29,9 +28,9 @@ func TestIndexerServiceIndexesBlocks(t *testing.T) { }) // tx indexer - store := memdb.NewDB() + store := db.NewMemDB() txIndexer := kv.NewTxIndex(store) - blockIndexer := blockidxkv.New(prefixdb.NewDB(store, []byte("block_events"))) + blockIndexer := blockidxkv.New(db.NewPrefixDB(store, []byte("block_events"))) service := txindex.NewIndexerService(txIndexer, blockIndexer, eventBus) service.SetLogger(log.TestingLogger()) diff --git a/state/txindex/kv/kv.go b/state/txindex/kv/kv.go index 46b3cf847..6855cf244 100644 --- a/state/txindex/kv/kv.go +++ b/state/txindex/kv/kv.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/gogo/protobuf/proto" - dbm "github.com/line/tm-db/v2" + dbm "github.com/tendermint/tm-db" abci "github.com/line/ostracon/abci/types" "github.com/line/ostracon/libs/pubsub/query" @@ -312,7 +312,7 @@ func (txi *TxIndex) match( switch { case c.Op == query.OpEqual: - it, err := txi.store.PrefixIterator(startKeyBz) + it, err := dbm.IteratePrefix(txi.store, startKeyBz) if err != nil { panic(err) } @@ -335,7 +335,7 @@ func (txi *TxIndex) match( case c.Op == query.OpExists: // XXX: can't use startKeyBz here because c.Operand is nil // (e.g. "account.owner//" won't match w/ a single row) - it, err := txi.store.PrefixIterator(startKey(c.CompositeKey)) + it, err := dbm.IteratePrefix(txi.store, startKey(c.CompositeKey)) if err != nil { panic(err) } @@ -359,7 +359,7 @@ func (txi *TxIndex) match( // XXX: startKey does not apply here. // For example, if startKey = "account.owner/an/" and search query = "account.owner CONTAINS an" // we can't iterate with prefix "account.owner/an/" because we might miss keys like "account.owner/Ulan/" - it, err := txi.store.PrefixIterator(startKey(c.CompositeKey)) + it, err := dbm.IteratePrefix(txi.store, startKey(c.CompositeKey)) if err != nil { panic(err) } @@ -439,7 +439,7 @@ func (txi *TxIndex) matchRange( lowerBound := qr.LowerBoundValue() upperBound := qr.UpperBoundValue() - it, err := txi.store.PrefixIterator(startKey) + it, err := dbm.IteratePrefix(txi.store, startKey) if err != nil { panic(err) } diff --git a/state/txindex/kv/kv_bench_test.go b/state/txindex/kv/kv_bench_test.go index 0471089d8..9f49cf4b9 100644 --- a/state/txindex/kv/kv_bench_test.go +++ b/state/txindex/kv/kv_bench_test.go @@ -7,7 +7,7 @@ import ( "io/ioutil" "testing" - "github.com/line/tm-db/v2/goleveldb" + dbm "github.com/tendermint/tm-db" abci "github.com/line/ostracon/abci/types" "github.com/line/ostracon/libs/pubsub/query" @@ -20,7 +20,7 @@ func BenchmarkTxSearch(b *testing.B) { b.Errorf("failed to create temporary directory: %s", err) } - db, err := goleveldb.NewDB("benchmark_tx_search_test", dbDir) + db, err := dbm.NewGoLevelDB("benchmark_tx_search_test", dbDir) if err != nil { b.Errorf("failed to create database: %s", err) } diff --git a/state/txindex/kv/kv_test.go b/state/txindex/kv/kv_test.go index eff276d41..3dd8cd2f7 100644 --- a/state/txindex/kv/kv_test.go +++ b/state/txindex/kv/kv_test.go @@ -8,11 +8,11 @@ import ( "testing" "github.com/gogo/protobuf/proto" - "github.com/line/tm-db/v2/memdb" - "github.com/line/tm-db/v2/metadb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + db "github.com/tendermint/tm-db" + abci "github.com/line/ostracon/abci/types" "github.com/line/ostracon/libs/pubsub/query" tmrand "github.com/line/ostracon/libs/rand" @@ -21,7 +21,7 @@ import ( ) func TestTxIndex(t *testing.T) { - indexer := NewTxIndex(memdb.NewDB()) + indexer := NewTxIndex(db.NewMemDB()) tx := types.Tx("HELLO WORLD") txResult := &abci.TxResult{ @@ -67,7 +67,7 @@ func TestTxIndex(t *testing.T) { } func TestTxSearch(t *testing.T) { - indexer := NewTxIndex(memdb.NewDB()) + indexer := NewTxIndex(db.NewMemDB()) txResult := txResultWithEvents([]abci.Event{ {Type: "account", Attributes: []abci.EventAttribute{{Key: []byte("number"), Value: []byte("1"), Index: true}}}, @@ -141,7 +141,7 @@ func TestTxSearch(t *testing.T) { } func TestTxSearchWithCancelation(t *testing.T) { - indexer := NewTxIndex(memdb.NewDB()) + indexer := NewTxIndex(db.NewMemDB()) txResult := txResultWithEvents([]abci.Event{ {Type: "account", Attributes: []abci.EventAttribute{{Key: []byte("number"), Value: []byte("1"), Index: true}}}, @@ -159,7 +159,7 @@ func TestTxSearchWithCancelation(t *testing.T) { } func TestTxSearchDeprecatedIndexing(t *testing.T) { - indexer := NewTxIndex(memdb.NewDB()) + indexer := NewTxIndex(db.NewMemDB()) // index tx using events indexing (composite key) txResult1 := txResultWithEvents([]abci.Event{ @@ -238,7 +238,7 @@ func TestTxSearchDeprecatedIndexing(t *testing.T) { } func TestTxSearchOneTxWithMultipleSameTagsButDifferentValues(t *testing.T) { - indexer := NewTxIndex(memdb.NewDB()) + indexer := NewTxIndex(db.NewMemDB()) txResult := txResultWithEvents([]abci.Event{ {Type: "account", Attributes: []abci.EventAttribute{{Key: []byte("number"), Value: []byte("1"), Index: true}}}, @@ -260,7 +260,7 @@ func TestTxSearchOneTxWithMultipleSameTagsButDifferentValues(t *testing.T) { } func TestTxSearchMultipleTxs(t *testing.T) { - indexer := NewTxIndex(memdb.NewDB()) + indexer := NewTxIndex(db.NewMemDB()) // indexed first, but bigger height (to test the order of transactions) txResult := txResultWithEvents([]abci.Event{ @@ -333,7 +333,7 @@ func benchmarkTxIndex(txsCount int64, b *testing.B) { require.NoError(b, err) defer os.RemoveAll(dir) - store, err := metadb.NewDB("tx_index", "goleveldb", dir) + store, err := db.NewDB("tx_index", "goleveldb", dir) require.NoError(b, err) indexer := NewTxIndex(store) diff --git a/statesync/stateprovider.go b/statesync/stateprovider.go index cea707b94..a589b1b08 100644 --- a/statesync/stateprovider.go +++ b/statesync/stateprovider.go @@ -6,6 +6,8 @@ import ( "strings" "time" + dbm "github.com/tendermint/tm-db" + "github.com/line/ostracon/crypto/vrf" "github.com/line/ostracon/libs/log" tmsync "github.com/line/ostracon/libs/sync" @@ -19,7 +21,6 @@ import ( sm "github.com/line/ostracon/state" "github.com/line/ostracon/types" "github.com/line/ostracon/version" - "github.com/line/tm-db/v2/memdb" ) //go:generate mockery --case underscore --name StateProvider @@ -82,7 +83,7 @@ func NewLightClientStateProvider( } lc, err := light.NewClient(ctx, chainID, trustOptions, providers[0], providers[1:], - lightdb.New(memdb.NewDB(), ""), voterParams, light.Logger(logger), light.MaxRetryAttempts(5)) + lightdb.New(dbm.NewMemDB(), ""), voterParams, light.Logger(logger), light.MaxRetryAttempts(5)) if err != nil { return nil, err } diff --git a/store/store.go b/store/store.go index 3313dfc79..51d8ad27b 100644 --- a/store/store.go +++ b/store/store.go @@ -5,8 +5,7 @@ import ( "strconv" "github.com/gogo/protobuf/proto" - - dbm "github.com/line/tm-db/v2" + dbm "github.com/tendermint/tm-db" tmsync "github.com/line/ostracon/libs/sync" tmstore "github.com/line/ostracon/proto/ostracon/store" diff --git a/store/store_test.go b/store/store_test.go index 404ad85fb..c5672f86b 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -10,10 +10,9 @@ import ( "time" "github.com/gogo/protobuf/proto" - dbm "github.com/line/tm-db/v2" - "github.com/line/tm-db/v2/memdb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + dbm "github.com/tendermint/tm-db" cfg "github.com/line/ostracon/config" "github.com/line/ostracon/crypto" @@ -58,10 +57,10 @@ func makeBlock(height int64, state sm.State, lastCommit *types.Commit) *types.Bl func makeStateAndBlockStore(logger log.Logger) (sm.State, *BlockStore, cleanupFunc) { config := cfg.ResetTestRoot("blockchain_reactor_test") - // blockDB := dbm.NewDebugDB("blockDB", memdb.NewDB()) - // stateDB := dbm.NewDebugDB("stateDB", memdb.NewDB()) - blockDB := memdb.NewDB() - stateDB := memdb.NewDB() + // blockDB := dbm.NewDebugDB("blockDB", dbm.NewMemDB()) + // stateDB := dbm.NewDebugDB("stateDB", dbm.NewMemDB()) + blockDB := dbm.NewMemDB() + stateDB := dbm.NewMemDB() stateStore := sm.NewStore(stateDB) state, err := stateStore.LoadFromDBOrGenesisFile(config.GenesisFile()) if err != nil { @@ -86,7 +85,7 @@ func TestLoadBlockStoreState(t *testing.T) { } for _, tc := range testCases { - db := memdb.NewDB() + db := dbm.NewMemDB() SaveBlockStoreState(tc.bss, db) retrBSJ := LoadBlockStoreState(db) assert.Equal(t, tc.want, retrBSJ, "expected the retrieved DBs to match: %s", tc.testName) @@ -94,7 +93,7 @@ func TestLoadBlockStoreState(t *testing.T) { } func TestNewBlockStore(t *testing.T) { - db := memdb.NewDB() + db := dbm.NewMemDB() bss := tmstore.BlockStoreState{Base: 100, Height: 10000} bz, _ := proto.Marshal(&bss) err := db.Set(blockStoreKey, bz) @@ -131,7 +130,7 @@ func TestNewBlockStore(t *testing.T) { } func freshBlockStore() (*BlockStore, dbm.DB) { - db := memdb.NewDB() + db := dbm.NewMemDB() return NewBlockStore(db), db } @@ -371,10 +370,10 @@ func TestBlockStoreSaveLoadBlock(t *testing.T) { func TestLoadBaseMeta(t *testing.T) { config := cfg.ResetTestRoot("blockchain_reactor_test") defer os.RemoveAll(config.RootDir) - stateStore := sm.NewStore(memdb.NewDB()) + stateStore := sm.NewStore(dbm.NewMemDB()) state, err := stateStore.LoadFromDBOrGenesisFile(config.GenesisFile()) require.NoError(t, err) - bs := NewBlockStore(memdb.NewDB()) + bs := NewBlockStore(dbm.NewMemDB()) for h := int64(1); h <= 10; h++ { block := makeBlock(h, state, new(types.Commit)) @@ -427,10 +426,10 @@ func TestLoadBlockPart(t *testing.T) { func TestPruneBlocks(t *testing.T) { config := cfg.ResetTestRoot("blockchain_reactor_test") defer os.RemoveAll(config.RootDir) - stateStore := sm.NewStore(memdb.NewDB()) + stateStore := sm.NewStore(dbm.NewMemDB()) state, err := stateStore.LoadFromDBOrGenesisFile(config.GenesisFile()) require.NoError(t, err) - db := memdb.NewDB() + db := dbm.NewMemDB() bs := NewBlockStore(db) assert.EqualValues(t, 0, bs.Base()) assert.EqualValues(t, 0, bs.Height()) diff --git a/test/e2e/docker/Dockerfile b/test/e2e/docker/Dockerfile index 280128e2b..0e68b16a1 100644 --- a/test/e2e/docker/Dockerfile +++ b/test/e2e/docker/Dockerfile @@ -4,24 +4,10 @@ FROM golang:1.15 RUN apt-get -qq update -y && apt-get -qq upgrade -y >/dev/null -RUN apt-get -qq install -y libleveldb-dev make libc-dev libtool >/dev/null +RUN apt-get -qq install -y libleveldb-dev librocksdb-dev make libc-dev libtool >/dev/null ARG SRCDIR=/src/ostracon -# There is currently no librocksdb-dev v6.17.3 or higher that is necessary by line/gorocksdb. -# So we download rocksdb and build it. -# See: -# - line/gorocksdb: https://github.com/line/gorocksdb/pull/3 -# - line/tm-db: https://github.com/line/tm-db/blob/main/tools/Dockerfile -ARG ROCKSDB_VERSION=6.20.3 -ARG ROCKSDB_FILE=rocksdb-v${ROCKSDB_VERSION}.tar.gz -ARG ROCKSDB_DIR=rocksdb-${ROCKSDB_VERSION} -RUN wget -O ${ROCKSDB_FILE} https://github.com/facebook/rocksdb/archive/v${ROCKSDB_VERSION}.tar.gz -RUN tar -zxvf ${ROCKSDB_FILE} -RUN cd ${ROCKSDB_DIR} && make -j2 shared_lib && make install-shared -RUN cp /usr/local/lib/librocksdb.so* /usr/lib -RUN rm -rf ${ROCKSDB_FILE} ${ROCKSDB_DIR} - # Build/Install libsodium separately (for layer caching) ARG VRF_ROOT=crypto/vrf/internal/vrf ARG LIBSODIUM_ROOT=${VRF_ROOT}/libsodium diff --git a/test/maverick/consensus/replay_file.go b/test/maverick/consensus/replay_file.go index b7474de35..a9b4d0d70 100644 --- a/test/maverick/consensus/replay_file.go +++ b/test/maverick/consensus/replay_file.go @@ -10,7 +10,7 @@ import ( "strconv" "strings" - "github.com/line/tm-db/v2/metadb" + dbm "github.com/tendermint/tm-db" cfg "github.com/line/ostracon/config" tmcon "github.com/line/ostracon/consensus" @@ -285,16 +285,16 @@ func (pb *playback) replayConsoleLoop() int { // convenience for replay mode func newConsensusStateForReplay(config cfg.BaseConfig, csConfig *cfg.ConsensusConfig) *State { - dbType := metadb.BackendType(config.DBBackend) + dbType := dbm.BackendType(config.DBBackend) // Get BlockStore - blockStoreDB, err := metadb.NewDB("blockstore", dbType, config.DBDir()) + blockStoreDB, err := dbm.NewDB("blockstore", dbType, config.DBDir()) if err != nil { tmos.Exit(err.Error()) } blockStore := store.NewBlockStore(blockStoreDB) // Get State - stateDB, err := metadb.NewDB("state", dbType, config.DBDir()) + stateDB, err := dbm.NewDB("state", dbType, config.DBDir()) if err != nil { tmos.Exit(err.Error()) } diff --git a/test/maverick/consensus/wal_generator.go b/test/maverick/consensus/wal_generator.go index e5cac8a57..ea050c5e2 100644 --- a/test/maverick/consensus/wal_generator.go +++ b/test/maverick/consensus/wal_generator.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/line/tm-db/v2/memdb" + db "github.com/tendermint/tm-db" "github.com/line/ostracon/abci/example/kvstore" cfg "github.com/line/ostracon/config" @@ -50,7 +50,7 @@ func WALGenerateNBlocks(t *testing.T, wr io.Writer, numBlocks int) (err error) { if err != nil { return fmt.Errorf("failed to read genesis file: %w", err) } - blockStoreDB := memdb.NewDB() + blockStoreDB := db.NewMemDB() stateDB := blockStoreDB stateStore := sm.NewStore(stateDB) state, err := sm.MakeGenesisState(genDoc) diff --git a/test/maverick/node/node.go b/test/maverick/node/node.go index 60b9d5470..90ededa2b 100644 --- a/test/maverick/node/node.go +++ b/test/maverick/node/node.go @@ -12,13 +12,11 @@ import ( "strings" "time" - "github.com/line/tm-db/v2/metadb" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/rs/cors" - dbm "github.com/line/tm-db/v2" - pdbm "github.com/line/tm-db/v2/prefixdb" + dbm "github.com/tendermint/tm-db" abci "github.com/line/ostracon/abci/types" bcv0 "github.com/line/ostracon/blockchain/v0" @@ -100,8 +98,8 @@ type DBProvider func(*DBContext) (dbm.DB, error) // DefaultDBProvider returns a database using the DBBackend and DBDir // specified in the ctx.Config. func DefaultDBProvider(ctx *DBContext) (dbm.DB, error) { - dbType := metadb.BackendType(ctx.Config.DBBackend) - return metadb.NewDB(ctx.ID, dbType, ctx.Config.DBDir()) + dbType := dbm.BackendType(ctx.Config.DBBackend) + return dbm.NewDB(ctx.ID, dbType, ctx.Config.DBDir()) } // GenesisDocProvider returns a GenesisDoc. @@ -320,7 +318,7 @@ func createAndStartIndexerService( } txIndexer = kv.NewTxIndex(store) - blockIndexer = blockidxkv.New(pdbm.NewDB(store, []byte("block_events"))) + blockIndexer = blockidxkv.New(dbm.NewPrefixDB(store, []byte("block_events"))) default: txIndexer = &null.TxIndex{} blockIndexer = &blockidxnull.BlockerIndexer{}