mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
libs/db: conditional compilation (#3628)
* libs/db: conditional compilation For cleveldb: go build -tags cleveldb For boltdb: go build -tags boltdb Fixes #3611 * document db_backend param better * remove deprecated LevelDBBackend * update changelog * add missing lines * add new line * fix TestRemoteDB * add a line about boltdb tag * Revert "remove deprecated LevelDBBackend" This reverts commit 1aa85453f76605e0c4d967601bbe26240e668d51. * make PR non breaking * change DEPRECATED label format https://stackoverflow.com/a/36360323/820520
This commit is contained in:
parent
27909e5d2a
commit
a7358bc69f
@ -38,6 +38,11 @@
|
|||||||
- [rpc] \#3362 `/dial_seeds` & `/dial_peers` return errors if addresses are incorrect (except when IP lookup fails)
|
- [rpc] \#3362 `/dial_seeds` & `/dial_peers` return errors if addresses are incorrect (except when IP lookup fails)
|
||||||
- [node] \#3362 returns an error if `persistent_peers` list is invalid (except when IP lookup fails)
|
- [node] \#3362 returns an error if `persistent_peers` list is invalid (except when IP lookup fails)
|
||||||
- [p2p] \#3531 Terminate session on nonce wrapping (@climber73)
|
- [p2p] \#3531 Terminate session on nonce wrapping (@climber73)
|
||||||
|
- [libs/db] \#3611 Conditional compilation
|
||||||
|
* Use `cleveldb` tag instead of `gcc` to compile Tendermint with CLevelDB or
|
||||||
|
use `make build_c` / `make install_c` (full instructions can be found at
|
||||||
|
https://tendermint.com/docs/introduction/install.html#compile-with-cleveldb-support)
|
||||||
|
* Use `boltdb` tag to compile Tendermint with bolt db
|
||||||
|
|
||||||
### BUG FIXES:
|
### BUG FIXES:
|
||||||
- [p2p] \#3532 limit the number of attempts to connect to a peer in seed mode
|
- [p2p] \#3532 limit the number of attempts to connect to a peer in seed mode
|
||||||
|
6
Makefile
6
Makefile
@ -23,7 +23,7 @@ build:
|
|||||||
CGO_ENABLED=0 go build $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint/
|
CGO_ENABLED=0 go build $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint/
|
||||||
|
|
||||||
build_c:
|
build_c:
|
||||||
CGO_ENABLED=1 go build $(BUILD_FLAGS) -tags "$(BUILD_TAGS) gcc" -o $(OUTPUT) ./cmd/tendermint/
|
CGO_ENABLED=1 go build $(BUILD_FLAGS) -tags "$(BUILD_TAGS) cleveldb" -o $(OUTPUT) ./cmd/tendermint/
|
||||||
|
|
||||||
build_race:
|
build_race:
|
||||||
CGO_ENABLED=0 go build -race $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint
|
CGO_ENABLED=0 go build -race $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint
|
||||||
@ -32,7 +32,7 @@ install:
|
|||||||
CGO_ENABLED=0 go install $(BUILD_FLAGS) -tags $(BUILD_TAGS) ./cmd/tendermint
|
CGO_ENABLED=0 go install $(BUILD_FLAGS) -tags $(BUILD_TAGS) ./cmd/tendermint
|
||||||
|
|
||||||
install_c:
|
install_c:
|
||||||
CGO_ENABLED=1 go install $(BUILD_FLAGS) -tags "$(BUILD_TAGS) gcc" ./cmd/tendermint
|
CGO_ENABLED=1 go install $(BUILD_FLAGS) -tags "$(BUILD_TAGS) cleveldb" ./cmd/tendermint
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
### Protobuf
|
### Protobuf
|
||||||
@ -132,7 +132,7 @@ clean_certs:
|
|||||||
rm -f db/remotedb/::.crt db/remotedb/::.key
|
rm -f db/remotedb/::.crt db/remotedb/::.key
|
||||||
|
|
||||||
test_libs: gen_certs
|
test_libs: gen_certs
|
||||||
go test -tags gcc $(PACKAGES)
|
go test -tags clevedb boltdb $(PACKAGES)
|
||||||
make clean_certs
|
make clean_certs
|
||||||
|
|
||||||
grpc_dbserver:
|
grpc_dbserver:
|
||||||
|
@ -153,7 +153,18 @@ type BaseConfig struct {
|
|||||||
// and verifying their commits
|
// and verifying their commits
|
||||||
FastSync bool `mapstructure:"fast_sync"`
|
FastSync bool `mapstructure:"fast_sync"`
|
||||||
|
|
||||||
// Database backend: leveldb | memdb | cleveldb
|
// Database backend: goleveldb | cleveldb | boltdb
|
||||||
|
// * goleveldb (github.com/syndtr/goleveldb - most popular implementation)
|
||||||
|
// - pure go
|
||||||
|
// - stable
|
||||||
|
// * cleveldb (uses levigo wrapper)
|
||||||
|
// - fast
|
||||||
|
// - requires gcc
|
||||||
|
// - use cleveldb build tag (go build -tags cleveldb)
|
||||||
|
// * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt)
|
||||||
|
// - EXPERIMENTAL
|
||||||
|
// - may be faster is some use-cases (random reads - indexer)
|
||||||
|
// - use boltdb build tag (go build -tags boltdb)
|
||||||
DBBackend string `mapstructure:"db_backend"`
|
DBBackend string `mapstructure:"db_backend"`
|
||||||
|
|
||||||
// Database directory
|
// Database directory
|
||||||
@ -207,7 +218,7 @@ func DefaultBaseConfig() BaseConfig {
|
|||||||
ProfListenAddress: "",
|
ProfListenAddress: "",
|
||||||
FastSync: true,
|
FastSync: true,
|
||||||
FilterPeers: false,
|
FilterPeers: false,
|
||||||
DBBackend: "leveldb",
|
DBBackend: "goleveldb",
|
||||||
DBPath: "data",
|
DBPath: "data",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,18 @@ moniker = "{{ .BaseConfig.Moniker }}"
|
|||||||
# and verifying their commits
|
# and verifying their commits
|
||||||
fast_sync = {{ .BaseConfig.FastSync }}
|
fast_sync = {{ .BaseConfig.FastSync }}
|
||||||
|
|
||||||
# Database backend: leveldb | memdb | cleveldb
|
# Database backend: goleveldb | cleveldb | boltdb
|
||||||
|
# * goleveldb (github.com/syndtr/goleveldb - most popular implementation)
|
||||||
|
# - pure go
|
||||||
|
# - stable
|
||||||
|
# * cleveldb (uses levigo wrapper)
|
||||||
|
# - fast
|
||||||
|
# - requires gcc
|
||||||
|
# - use cleveldb build tag (go build -tags cleveldb)
|
||||||
|
# * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt)
|
||||||
|
# - EXPERIMENTAL
|
||||||
|
# - may be faster is some use-cases (random reads - indexer)
|
||||||
|
# - use boltdb build tag (go build -tags boltdb)
|
||||||
db_backend = "{{ .BaseConfig.DBBackend }}"
|
db_backend = "{{ .BaseConfig.DBBackend }}"
|
||||||
|
|
||||||
# Database directory
|
# Database directory
|
||||||
|
@ -79,9 +79,7 @@ make install
|
|||||||
|
|
||||||
Install [LevelDB](https://github.com/google/leveldb) (minimum version is 1.7).
|
Install [LevelDB](https://github.com/google/leveldb) (minimum version is 1.7).
|
||||||
|
|
||||||
### Ubuntu
|
Install LevelDB with snappy (optionally). Below are commands for Ubuntu:
|
||||||
|
|
||||||
Install LevelDB with snappy (optionally):
|
|
||||||
|
|
||||||
```
|
```
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
@ -100,23 +98,23 @@ wget https://github.com/google/leveldb/archive/v1.20.tar.gz && \
|
|||||||
rm -f v1.20.tar.gz
|
rm -f v1.20.tar.gz
|
||||||
```
|
```
|
||||||
|
|
||||||
Set database backend to cleveldb:
|
Set a database backend to `cleveldb`:
|
||||||
|
|
||||||
```
|
```
|
||||||
# config/config.toml
|
# config/config.toml
|
||||||
db_backend = "cleveldb"
|
db_backend = "cleveldb"
|
||||||
```
|
```
|
||||||
|
|
||||||
To install Tendermint, run
|
To install Tendermint, run:
|
||||||
|
|
||||||
```
|
```
|
||||||
CGO_LDFLAGS="-lsnappy" make install_c
|
CGO_LDFLAGS="-lsnappy" make install_c
|
||||||
```
|
```
|
||||||
|
|
||||||
or run
|
or run:
|
||||||
|
|
||||||
```
|
```
|
||||||
CGO_LDFLAGS="-lsnappy" make build_c
|
CGO_LDFLAGS="-lsnappy" make build_c
|
||||||
```
|
```
|
||||||
|
|
||||||
to put the binary in `./build`.
|
which puts the binary in `./build`.
|
||||||
|
@ -30,7 +30,18 @@ moniker = "anonymous"
|
|||||||
# and verifying their commits
|
# and verifying their commits
|
||||||
fast_sync = true
|
fast_sync = true
|
||||||
|
|
||||||
# Database backend: leveldb | memdb | cleveldb
|
# Database backend: goleveldb | cleveldb | boltdb
|
||||||
|
# * goleveldb (github.com/syndtr/goleveldb - most popular implementation)
|
||||||
|
# - pure go
|
||||||
|
# - stable
|
||||||
|
# * cleveldb (uses levigo wrapper)
|
||||||
|
# - fast
|
||||||
|
# - requires gcc
|
||||||
|
# - use cleveldb build tag (go build -tags cleveldb)
|
||||||
|
# * boltdb (uses etcd's fork of bolt - github.com/etcd-io/bbolt)
|
||||||
|
# - EXPERIMENTAL
|
||||||
|
# - may be faster is some use-cases (random reads - indexer)
|
||||||
|
# - use boltdb build tag (go build -tags boltdb)
|
||||||
db_backend = "leveldb"
|
db_backend = "leveldb"
|
||||||
|
|
||||||
# Database directory
|
# Database directory
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
cmn "github.com/tendermint/tendermint/libs/common"
|
cmn "github.com/tendermint/tendermint/libs/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// +build boltdb
|
||||||
|
|
||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// +build boltdb
|
||||||
|
|
||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build gcc
|
// +build cleveldb
|
||||||
|
|
||||||
package db
|
package db
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build gcc
|
// +build cleveldb
|
||||||
|
|
||||||
package db
|
package db
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ func TestCLevelDBBackend(t *testing.T) {
|
|||||||
// Can't use "" (current directory) or "./" here because levigo.Open returns:
|
// Can't use "" (current directory) or "./" here because levigo.Open returns:
|
||||||
// "Error initializing DB: IO error: test_XXX.db: Invalid argument"
|
// "Error initializing DB: IO error: test_XXX.db: Invalid argument"
|
||||||
dir := os.TempDir()
|
dir := os.TempDir()
|
||||||
db := NewDB(name, LevelDBBackend, dir)
|
db := NewDB(name, CLevelDBBackend, dir)
|
||||||
defer cleanupDBDir(dir, name)
|
defer cleanupDBDir(dir, name)
|
||||||
|
|
||||||
_, ok := db.(*CLevelDB)
|
_, ok := db.(*CLevelDB)
|
||||||
@ -103,7 +103,7 @@ func TestCLevelDBBackend(t *testing.T) {
|
|||||||
func TestCLevelDBStats(t *testing.T) {
|
func TestCLevelDBStats(t *testing.T) {
|
||||||
name := fmt.Sprintf("test_%x", cmn.RandStr(12))
|
name := fmt.Sprintf("test_%x", cmn.RandStr(12))
|
||||||
dir := os.TempDir()
|
dir := os.TempDir()
|
||||||
db := NewDB(name, LevelDBBackend, dir)
|
db := NewDB(name, CLevelDBBackend, dir)
|
||||||
defer cleanupDBDir(dir, name)
|
defer cleanupDBDir(dir, name)
|
||||||
|
|
||||||
assert.NotEmpty(t, db.Stats())
|
assert.NotEmpty(t, db.Stats())
|
||||||
|
@ -5,18 +5,37 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
//----------------------------------------
|
|
||||||
// Main entry
|
|
||||||
|
|
||||||
type DBBackendType string
|
type DBBackendType string
|
||||||
|
|
||||||
|
// These are valid backend types.
|
||||||
const (
|
const (
|
||||||
LevelDBBackend DBBackendType = "leveldb" // legacy, defaults to goleveldb unless +gcc
|
// LevelDBBackend is a legacy type. Defaults to goleveldb unless cleveldb
|
||||||
CLevelDBBackend DBBackendType = "cleveldb"
|
// build tag was used, in which it becomes cleveldb.
|
||||||
|
// Deprecated: Use concrete types (golevedb, cleveldb, etc.)
|
||||||
|
LevelDBBackend DBBackendType = "leveldb"
|
||||||
|
// GoLevelDBBackend represents goleveldb (github.com/syndtr/goleveldb - most
|
||||||
|
// popular implementation)
|
||||||
|
// - pure go
|
||||||
|
// - stable
|
||||||
GoLevelDBBackend DBBackendType = "goleveldb"
|
GoLevelDBBackend DBBackendType = "goleveldb"
|
||||||
MemDBBackend DBBackendType = "memdb"
|
// CLevelDBBackend represents cleveldb (uses levigo wrapper)
|
||||||
FSDBBackend DBBackendType = "fsdb" // using the filesystem naively
|
// - fast
|
||||||
BoltDBBackend DBBackendType = "boltdb"
|
// - requires gcc
|
||||||
|
// - use cleveldb build tag (go build -tags cleveldb)
|
||||||
|
CLevelDBBackend DBBackendType = "cleveldb"
|
||||||
|
// MemDBBackend represents in-memoty key value store, which is mostly used
|
||||||
|
// for testing.
|
||||||
|
MemDBBackend DBBackendType = "memdb"
|
||||||
|
// FSDBBackend represents filesystem database
|
||||||
|
// - EXPERIMENTAL
|
||||||
|
// - slow
|
||||||
|
FSDBBackend DBBackendType = "fsdb"
|
||||||
|
// BoltDBBackend represents bolt (uses etcd's fork of bolt -
|
||||||
|
// github.com/etcd-io/bbolt)
|
||||||
|
// - EXPERIMENTAL
|
||||||
|
// - may be faster is some use-cases (random reads - indexer)
|
||||||
|
// - use boltdb build tag (go build -tags boltdb)
|
||||||
|
BoltDBBackend DBBackendType = "boltdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
type dbCreator func(name string, dir string) (DB, error)
|
type dbCreator func(name string, dir string) (DB, error)
|
||||||
|
@ -28,7 +28,7 @@ func TestRemoteDB(t *testing.T) {
|
|||||||
client, err := remotedb.NewRemoteDB(ln.Addr().String(), cert)
|
client, err := remotedb.NewRemoteDB(ln.Addr().String(), cert)
|
||||||
require.Nil(t, err, "expecting a successful client creation")
|
require.Nil(t, err, "expecting a successful client creation")
|
||||||
dbName := "test-remote-db"
|
dbName := "test-remote-db"
|
||||||
require.Nil(t, client.InitRemote(&remotedb.Init{Name: dbName, Type: "leveldb"}))
|
require.Nil(t, client.InitRemote(&remotedb.Init{Name: dbName, Type: "goleveldb"}))
|
||||||
defer func() {
|
defer func() {
|
||||||
err := os.RemoveAll(dbName + ".db")
|
err := os.RemoveAll(dbName + ".db")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -14,7 +14,7 @@ func NewVerifier(chainID, rootDir string, client lclient.SignStatusClient, logge
|
|||||||
logger.Info("lite/proxy/NewVerifier()...", "chainID", chainID, "rootDir", rootDir, "client", client)
|
logger.Info("lite/proxy/NewVerifier()...", "chainID", chainID, "rootDir", rootDir, "client", client)
|
||||||
|
|
||||||
memProvider := lite.NewDBProvider("trusted.mem", dbm.NewMemDB()).SetLimit(cacheSize)
|
memProvider := lite.NewDBProvider("trusted.mem", dbm.NewMemDB()).SetLimit(cacheSize)
|
||||||
lvlProvider := lite.NewDBProvider("trusted.lvl", dbm.NewDB("trust-base", dbm.LevelDBBackend, rootDir))
|
lvlProvider := lite.NewDBProvider("trusted.lvl", dbm.NewDB("trust-base", dbm.GoLevelDBBackend, rootDir))
|
||||||
trust := lite.NewMultiProvider(
|
trust := lite.NewMultiProvider(
|
||||||
memProvider,
|
memProvider,
|
||||||
lvlProvider,
|
lvlProvider,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user