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

chore: bump up tm-db and iavl #201

Merged
merged 2 commits into from
Mar 25, 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
9 changes: 5 additions & 4 deletions abci/example/kvstore/kvstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (
"encoding/json"
"fmt"

dbm "github.com/line/tm-db/v2"
tmdb "github.com/line/tm-db/v2"
"github.com/line/tm-db/v2/memdb"

"github.com/line/ostracon/abci/example/code"
"github.com/line/ostracon/abci/types"
Expand All @@ -21,13 +22,13 @@ var (
)

type State struct {
db dbm.DB
db tmdb.DB
Size int64 `json:"size"`
Height int64 `json:"height"`
AppHash []byte `json:"app_hash"`
}

func loadState(db dbm.DB) State {
func loadState(db tmdb.DB) State {
var state State
state.db = db
stateBytes, err := db.Get(stateKey)
Expand Down Expand Up @@ -71,7 +72,7 @@ type Application struct {
}

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

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

dbm "github.com/line/tm-db/v2"
"github.com/line/tm-db/v2/goleveldb"

"github.com/line/ostracon/abci/example/code"
"github.com/line/ostracon/abci/types"
Expand Down Expand Up @@ -37,7 +37,7 @@ type PersistentKVStoreApplication struct {

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

dbm "github.com/line/tm-db/v2"
"github.com/line/tm-db/v2/memdb"

abci "github.com/line/ostracon/abci/types"
cfg "github.com/line/ostracon/config"
Expand Down Expand Up @@ -68,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 @@ -82,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
8 changes: 4 additions & 4 deletions blockchain/v1/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

dbm "github.com/line/tm-db/v2"
"github.com/line/tm-db/v2/memdb"

abci "github.com/line/ostracon/abci/types"
cfg "github.com/line/ostracon/config"
Expand Down Expand Up @@ -100,8 +100,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 @@ -114,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 := dbm.NewMemDB()
db := memdb.NewDB()
stateStore = sm.NewStore(db)
blockExec := sm.NewBlockExecutor(stateStore, log.TestingLogger(), proxyApp.Consensus(),
mock.Mempool{}, sm.EmptyEvidencePool{})
Expand Down
11 changes: 6 additions & 5 deletions blockchain/v2/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
"testing"
"time"

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

"github.com/line/tm-db/v2/memdb"

abci "github.com/line/ostracon/abci/types"
"github.com/line/ostracon/behaviour"
bc "github.com/line/ostracon/blockchain"
Expand Down Expand Up @@ -155,7 +156,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 @@ -499,15 +500,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
9 changes: 5 additions & 4 deletions cmd/tendermint/commands/light.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import (

"github.com/spf13/cobra"

dbm "github.com/line/tm-db/v2"
tmdb "github.com/line/tm-db/v2"
"github.com/line/tm-db/v2/goleveldb"

"github.com/line/ostracon/crypto/merkle"
"github.com/line/ostracon/libs/log"
Expand Down Expand Up @@ -122,7 +123,7 @@ func runProxy(cmd *cobra.Command, args []string) error {
witnessesAddrs = strings.Split(witnessAddrsJoined, ",")
}

db, err := dbm.NewGoLevelDB("light-client-db", home)
db, err := goleveldb.NewDB("light-client-db", home)
if err != nil {
return fmt.Errorf("can't create a db: %w", err)
}
Expand Down Expand Up @@ -240,7 +241,7 @@ func runProxy(cmd *cobra.Command, args []string) error {
return nil
}

func checkForExistingProviders(db dbm.DB) (string, []string, error) {
func checkForExistingProviders(db tmdb.DB) (string, []string, error) {
primaryBytes, err := db.Get(primaryKey)
if err != nil {
return "", []string{""}, err
Expand All @@ -253,7 +254,7 @@ func checkForExistingProviders(db dbm.DB) (string, []string, error) {
return string(primaryBytes), witnessesAddrs, nil
}

func saveProviders(db dbm.DB, primaryAddr, witnessesAddrs string) error {
func saveProviders(db tmdb.DB, primaryAddr, witnessesAddrs string) error {
err := db.Set(primaryKey, []byte(primaryAddr))
if err != nil {
return fmt.Errorf("failed to save primary provider: %w", err)
Expand Down
8 changes: 4 additions & 4 deletions consensus/byzantine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

dbm "github.com/line/tm-db/v2"
"github.com/line/tm-db/v2/memdb"

abcicli "github.com/line/ostracon/abci/client"
abci "github.com/line/ostracon/abci/types"
Expand Down Expand Up @@ -45,7 +45,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 +55,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 +71,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
14 changes: 7 additions & 7 deletions consensus/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
"sort"
"sync"
Expand All @@ -15,9 +16,8 @@ import (
"github.com/go-kit/kit/log/term"
"github.com/stretchr/testify/require"

"path"

dbm "github.com/line/tm-db/v2"
tmdb "github.com/line/tm-db/v2"
"github.com/line/tm-db/v2/memdb"

abcicli "github.com/line/ostracon/abci/client"
"github.com/line/ostracon/abci/example/counter"
Expand Down Expand Up @@ -360,7 +360,7 @@ func newStateWithConfig(
pv types.PrivValidator,
app abci.Application,
) *State {
blockDB := dbm.NewMemDB()
blockDB := memdb.NewDB()
return newStateWithConfigAndBlockStore(thisConfig, state, pv, app, blockDB)
}

Expand All @@ -369,7 +369,7 @@ func newStateWithConfigAndBlockStore(
state sm.State,
pv types.PrivValidator,
app abci.Application,
blockDB dbm.DB,
blockDB tmdb.DB,
) *State {
// Get BlockStore
blockStore := store.NewBlockStore(blockDB)
Expand Down Expand Up @@ -679,7 +679,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 @@ -717,7 +717,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
6 changes: 3 additions & 3 deletions consensus/mempool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

dbm "github.com/line/tm-db/v2"
"github.com/line/tm-db/v2/memdb"

"github.com/line/ostracon/abci/example/code"
abci "github.com/line/ostracon/abci/types"
Expand Down Expand Up @@ -112,7 +112,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 @@ -137,7 +137,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
6 changes: 3 additions & 3 deletions consensus/reactor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

dbm "github.com/line/tm-db/v2"
"github.com/line/tm-db/v2/memdb"

abcicli "github.com/line/ostracon/abci/client"
"github.com/line/ostracon/abci/example/kvstore"
Expand Down Expand Up @@ -135,7 +135,7 @@ func TestReactorWithEvidence(t *testing.T) {
css := make([]*State, nValidators)
logger := consensusLogger()
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 All @@ -149,7 +149,7 @@ func TestReactorWithEvidence(t *testing.T) {
// duplicate code from:
// css[i] = newStateWithConfig(thisConfig, state, privVals[i], app)

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

// one for mempool, one for consensus
Expand Down
8 changes: 4 additions & 4 deletions consensus/replay_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strconv"
"strings"

dbm "github.com/line/tm-db/v2"
"github.com/line/tm-db/v2/metadb"

cfg "github.com/line/ostracon/config"
"github.com/line/ostracon/libs/log"
Expand Down Expand Up @@ -284,16 +284,16 @@ func (pb *playback) replayConsoleLoop() int {

// convenience for replay mode
func newConsensusStateForReplay(config cfg.BaseConfig, csConfig *cfg.ConsensusConfig) *State {
dbType := dbm.BackendType(config.DBBackend)
dbType := metadb.BackendType(config.DBBackend)
// Get BlockStore
blockStoreDB, err := dbm.NewDB("blockstore", dbType, config.DBDir())
blockStoreDB, err := metadb.NewDB("blockstore", dbType, config.DBDir())
if err != nil {
tmos.Exit(err.Error())
}
blockStore := store.NewBlockStore(blockStoreDB)

// Get State
stateDB, err := dbm.NewDB("state", dbType, config.DBDir())
stateDB, err := metadb.NewDB("state", dbType, config.DBDir())
if err != nil {
tmos.Exit(err.Error())
}
Expand Down
Loading