Skip to content

Commit

Permalink
chore: use default db backend among the available ones (#212)
Browse files Browse the repository at this point in the history
* chore: use default db backend among the available ones

* chore: bump up iavl, tm-db
  • Loading branch information
Woosang Son committed Jul 8, 2021
1 parent dce3c03 commit 04c5f31
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 18 deletions.
17 changes: 14 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"github.com/line/ostracon/privval"
"github.com/line/tm-db/v2/metadb"
)

const (
Expand All @@ -25,6 +26,8 @@ const (

// DefaultLogLevel defines a default log level as INFO.
DefaultLogLevel = "info"

DefaultDBBackend = "goleveldb"
)

// NOTE: Most of the structs & relevant comments + the
Expand Down Expand Up @@ -223,8 +226,16 @@ type BaseConfig struct { //nolint: maligned
PrivKeyType string `mapstructure:"priv_key_type"`
}

// DefaultBaseConfig returns a default base configuration for a Tendermint node
// DefaultBaseConfig returns a default base configuration for a 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,
Expand All @@ -237,13 +248,13 @@ func DefaultBaseConfig() BaseConfig {
LogFormat: LogFormatPlain,
FastSyncMode: true,
FilterPeers: false,
DBBackend: "goleveldb",
DBBackend: defaultDBBackend,
DBPath: "data",
PrivKeyType: privval.PrivKeyTypeEd25519,
}
}

// TestBaseConfig returns a base configuration for testing a Tendermint node
// TestBaseConfig returns a base configuration for testing a Ostracon node
func TestBaseConfig() BaseConfig {
cfg := DefaultBaseConfig()
cfg.chainID = "ostracon_test"
Expand Down
4 changes: 2 additions & 2 deletions evidence/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ func (evpool *Pool) listEvidence(prefixKey byte, maxBytes int64) ([]types.Eviden
evList tmproto.EvidenceList // used for calculating the bytes size
)

iter, err := dbm.IteratePrefix(evpool.evidenceStore, []byte{prefixKey})
iter, err := evpool.evidenceStore.PrefixIterator([]byte{prefixKey})
if err != nil {
return nil, totalSize, fmt.Errorf("database error: %v", err)
}
Expand Down Expand Up @@ -458,7 +458,7 @@ func (evpool *Pool) listEvidence(prefixKey byte, maxBytes int64) ([]types.Eviden
}

func (evpool *Pool) removeExpiredPendingEvidence() (int64, time.Time) {
iter, err := dbm.IteratePrefix(evpool.evidenceStore, []byte{baseKeyPending})
iter, err := evpool.evidenceStore.PrefixIterator([]byte{baseKeyPending})
if err != nil {
evpool.logger.Error("Unable to iterate over pending evidence", "err", err)
return evpool.State().LastBlockHeight, evpool.State().LastBlockTime
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ require (
github.com/gtank/merlin v0.1.1
github.com/herumi/bls-eth-go-binary v0.0.0-20200923072303-32b29e5d8cbf
github.com/libp2p/go-buffer-pool v0.0.2
github.com/line/iavl/v2 v2.0.0-init.1.0.20210325055816-6304f1fd2f09
github.com/line/tm-db/v2 v2.0.0-init.1.0.20210325025547-0ea105c02281
github.com/line/iavl/v2 v2.0.0-init.1.0.20210406065347-cfd73e5acce0
github.com/line/tm-db/v2 v2.0.0-init.1.0.20210406062110-9424ca70955a
github.com/minio/highwayhash v1.0.1
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/pkg/errors v0.9.1
Expand Down
17 changes: 10 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,14 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ=
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64=
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0=
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64=
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A=
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg=
github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 h1:E2s37DuLxFhQDg5gKsWoLBOB0n+ZW8s599zru8FJ2/Y=
github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0=
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk=
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
Expand Down Expand Up @@ -298,11 +300,13 @@ github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOS
github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM=
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
github.com/line/iavl/v2 v2.0.0-init.1.0.20210325055816-6304f1fd2f09 h1:11L4wU4iYYRfOP20qo7909Q0gkd1NG8GOjSPu3Bblcg=
github.com/line/iavl/v2 v2.0.0-init.1.0.20210325055816-6304f1fd2f09/go.mod h1:lOUXCMWnB9G5wDfungP5nhnHAFgVBwB0/iqFhH44OIs=
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/iavl/v2 v2.0.0-init.1.0.20210406065347-cfd73e5acce0 h1:Pcp/mxkvFmasaiPi9DS2ZXCKOalfDGtBKYjdswmF0nI=
github.com/line/iavl/v2 v2.0.0-init.1.0.20210406065347-cfd73e5acce0/go.mod h1:Z2UTxsbKefd7bnEywGNxxmVYYGy9Ecd4nd1IZyR0bQM=
github.com/line/ostracon v0.34.9-0.20210315041958-2a1f43c788f5/go.mod h1:1THU+kF+6fxLaNYQKcdNyLCO6t9LnqSMaExDMiLozbM=
github.com/line/tm-db/v2 v2.0.0-init.1.0.20210325025547-0ea105c02281 h1:HwehzGvsgPHND01825UbjjiKgwfbqIYFAnvn6OheLQs=
github.com/line/tm-db/v2 v2.0.0-init.1.0.20210325025547-0ea105c02281/go.mod h1:TiTwPFffNAqep0nV0YWaxPjElbCp6yG4K8SCxy69mE4=
github.com/line/tm-db/v2 v2.0.0-init.1.0.20210406062110-9424ca70955a h1:qSt/WwORC5+nVRnNqx+A0oo5gOCsoVJ0HmHF5Db1YvY=
github.com/line/tm-db/v2 v2.0.0-init.1.0.20210406062110-9424ca70955a/go.mod h1:wmkyPabXjtVZ1dvRofmurjaceghywtCSYGqFuFS+TbI=
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
Expand Down Expand Up @@ -491,7 +495,6 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
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=
Expand Down
8 changes: 4 additions & 4 deletions state/txindex/kv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func (txi *TxIndex) match(

switch {
case c.Op == query.OpEqual:
it, err := dbm.IteratePrefix(txi.store, startKeyBz)
it, err := txi.store.PrefixIterator(startKeyBz)
if err != nil {
panic(err)
}
Expand All @@ -430,7 +430,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/<nil>/" won't match w/ a single row)
it, err := dbm.IteratePrefix(txi.store, startKey(c.CompositeKey))
it, err := txi.store.PrefixIterator(startKey(c.CompositeKey))
if err != nil {
panic(err)
}
Expand All @@ -454,7 +454,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 := dbm.IteratePrefix(txi.store, startKey(c.CompositeKey))
it, err := txi.store.PrefixIterator(startKey(c.CompositeKey))
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -534,7 +534,7 @@ func (txi *TxIndex) matchRange(
lowerBound := r.lowerBoundValue()
upperBound := r.upperBoundValue()

it, err := dbm.IteratePrefix(txi.store, startKey)
it, err := txi.store.PrefixIterator(startKey)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 04c5f31

Please sign in to comment.