switch from jmhodges/levigo to DataDog/leveldb

Why:
original fork is abandoned and not supported anymore.

Changes:
- LevelDB 1.19 (LevelDB and Snappy are both compiled and linked statically, so while you will not need them installed on your target machine, you should have a roughly compatible version of libstdc++.)
- snappy and lz4 libs included by default
This commit is contained in:
Anton Kaliaev 2018-09-05 16:49:34 +04:00
parent 38bced2440
commit 5bfb9001eb
No known key found for this signature in database
GPG Key ID: 7B6881D965918214
10 changed files with 70 additions and 28 deletions

16
Gopkg.lock generated
View File

@ -1,6 +1,13 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
digest = "1:5da259989116f6ab5e05a80086c639c82efdbdb799ca07183eb0b660edfd91fe"
name = "github.com/DataDog/leveldb"
packages = ["."]
pruneopts = "UT"
revision = "12a0b6e10a5bf779330ed8b7c0f1f39f212d34e2"
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:d6afaeed1502aa28e80a4ed0981d570ad91b2579193404256ce672ed0a609e0d" digest = "1:d6afaeed1502aa28e80a4ed0981d570ad91b2579193404256ce672ed0a609e0d"
@ -161,13 +168,6 @@
revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75"
version = "v1.0" version = "v1.0"
[[projects]]
digest = "1:39b27d1381a30421f9813967a5866fba35dc1d4df43a6eefe3b7a5444cb07214"
name = "github.com/jmhodges/levigo"
packages = ["."]
pruneopts = "UT"
revision = "c42d9e0ca023e2198120196f842701bb4c55d7b9"
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:a64e323dc06b73892e5bb5d040ced475c4645d456038333883f58934abbf6f72" digest = "1:a64e323dc06b73892e5bb5d040ced475c4645d456038333883f58934abbf6f72"
@ -511,6 +511,7 @@
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
input-imports = [ input-imports = [
"github.com/DataDog/leveldb",
"github.com/btcsuite/btcutil/base58", "github.com/btcsuite/btcutil/base58",
"github.com/btcsuite/btcutil/bech32", "github.com/btcsuite/btcutil/bech32",
"github.com/ebuchman/fail-test", "github.com/ebuchman/fail-test",
@ -529,7 +530,6 @@
"github.com/golang/protobuf/proto", "github.com/golang/protobuf/proto",
"github.com/golang/protobuf/ptypes/timestamp", "github.com/golang/protobuf/ptypes/timestamp",
"github.com/gorilla/websocket", "github.com/gorilla/websocket",
"github.com/jmhodges/levigo",
"github.com/pkg/errors", "github.com/pkg/errors",
"github.com/prometheus/client_golang/prometheus", "github.com/prometheus/client_golang/prometheus",
"github.com/prometheus/client_golang/prometheus/promhttp", "github.com/prometheus/client_golang/prometheus/promhttp",

View File

@ -73,8 +73,8 @@
## Pin to revision ## Pin to revision
[[override]] [[override]]
name = "github.com/jmhodges/levigo" name = "github.com/DataDog/leveldb"
revision = "c42d9e0ca023e2198120196f842701bb4c55d7b9" revision = "12a0b6e10a5bf779330ed8b7c0f1f39f212d34e2"
[[constraint]] [[constraint]]
name = "github.com/ebuchman/fail-test" name = "github.com/ebuchman/fail-test"

View File

@ -113,7 +113,7 @@ 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 // Database backend: leveldb | memdb | cleveldb
DBBackend string `mapstructure:"db_backend"` DBBackend string `mapstructure:"db_backend"`
// Database directory // Database directory
@ -587,15 +587,15 @@ type TxIndexConfig struct {
// Comma-separated list of tags to index (by default the only tag is "tx.hash") // Comma-separated list of tags to index (by default the only tag is "tx.hash")
// //
// You can also index transactions by height by adding "tx.height" tag here. // You can also index transactions by height by adding "tx.height" tag here.
// //
// It's recommended to index only a subset of tags due to possible memory // It's recommended to index only a subset of tags due to possible memory
// bloat. This is, of course, depends on the indexer's DB and the volume of // bloat. This is, of course, depends on the indexer's DB and the volume of
// transactions. // transactions.
IndexTags string `mapstructure:"index_tags"` IndexTags string `mapstructure:"index_tags"`
// When set to true, tells indexer to index all tags (predefined tags: // When set to true, tells indexer to index all tags (predefined tags:
// "tx.hash", "tx.height" and all tags from DeliverTx responses). // "tx.hash", "tx.height" and all tags from DeliverTx responses).
// //
// Note this may be not desirable (see the comment above). IndexTags has a // Note this may be not desirable (see the comment above). IndexTags has a
// precedence over IndexAllTags (i.e. when given both, IndexTags will be // precedence over IndexAllTags (i.e. when given both, IndexTags will be
// indexed). // indexed).

View File

@ -77,7 +77,7 @@ moniker = "{{ .BaseConfig.Moniker }}"
# and verifying their commits # and verifying their commits
fast_sync = {{ .BaseConfig.FastSync }} fast_sync = {{ .BaseConfig.FastSync }}
# Database backend: leveldb | memdb # Database backend: leveldb | memdb | cleveldb
db_backend = "{{ .BaseConfig.DBBackend }}" db_backend = "{{ .BaseConfig.DBBackend }}"
# Database directory # Database directory

View File

@ -48,6 +48,15 @@ to put the binary in `./build`.
The latest `tendermint version` is now installed. The latest `tendermint version` is now installed.
## Run
To start a one-node blockchain with a simple in-process application:
```
tendermint init
tendermint node --proxy_app=kvstore
```
## Reinstall ## Reinstall
If you already have Tendermint installed, and you make updates, simply If you already have Tendermint installed, and you make updates, simply
@ -66,11 +75,35 @@ make get_vendor_deps
make install make install
``` ```
## Run ## Compile with CLevelDB support
To start a one-node blockchain with a simple in-process application: Make sure you have a roughly compatible version of libstdc++ (tested with
5.3.1). For example, on Ubuntu:
``` ```
tendermint init sudo apt-get update
tendermint node --proxy_app=kvstore sudo apt-get install gcc
sudo apt-cache show libstdc++6
Version: 5.3.1-14ubuntu2
```
Check out leveldb dependency using git (for some reason dep does not check out
submodules):
```
cd vendor/github.com/DataDog && rm -rf leveldb
git clone https://github.com/DataDog/leveldb.git
```
Set database backend to cleveldb:
```
# config/config.toml
db_backend = "cleveldb"
```
To build Tendermint, run
```
CGO_ENABLED=1 CGO_CXXFLAGS_ALLOW="(-fno-builtin-memcmp|-lpthread)" CGO_CFLAGS_ALLOW="-fno-builtin-memcmp" go build -ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short=8 HEAD`" -tags "tendermint gcc" -o build/tendermint ./cmd/tendermint/
``` ```

View File

@ -30,7 +30,7 @@ moniker = "anonymous"
# and verifying their commits # and verifying their commits
fast_sync = true fast_sync = true
# Database backend: leveldb | memdb # Database backend: leveldb | memdb | cleveldb
db_backend = "leveldb" db_backend = "leveldb"
# Database directory # Database directory

4
libs/db/Makefile Normal file
View File

@ -0,0 +1,4 @@
test_gcc:
CGO_CXXFLAGS_ALLOW="(-fno-builtin-memcmp|-lpthread)" CGO_CFLAGS_ALLOW="-fno-builtin-memcmp" go test -tags gcc
.PHONY: test_gcc

View File

@ -55,9 +55,10 @@ func TestBackendsGetSetDelete(t *testing.T) {
func withDB(t *testing.T, creator dbCreator, fn func(DB)) { func withDB(t *testing.T, creator dbCreator, fn func(DB)) {
name := fmt.Sprintf("test_%x", cmn.RandStr(12)) name := fmt.Sprintf("test_%x", cmn.RandStr(12))
db, err := creator(name, "") dir := os.TempDir()
defer cleanupDBDir("", name) db, err := creator(name, dir)
assert.Nil(t, err) require.Nil(t, err)
defer cleanupDBDir(dir, name)
fn(db) fn(db)
db.Close() db.Close()
} }
@ -161,8 +162,9 @@ func TestDBIterator(t *testing.T) {
func testDBIterator(t *testing.T, backend DBBackendType) { func testDBIterator(t *testing.T, backend DBBackendType) {
name := fmt.Sprintf("test_%x", cmn.RandStr(12)) name := fmt.Sprintf("test_%x", cmn.RandStr(12))
db := NewDB(name, backend, "") dir := os.TempDir()
defer cleanupDBDir("", name) db := NewDB(name, backend, dir)
defer cleanupDBDir(dir, name)
for i := 0; i < 10; i++ { for i := 0; i < 10; i++ {
if i != 6 { // but skip 6. if i != 6 { // but skip 6.

View File

@ -7,7 +7,7 @@ import (
"fmt" "fmt"
"path/filepath" "path/filepath"
"github.com/jmhodges/levigo" levigo "github.com/DataDog/leveldb"
) )
func init() { func init() {

View File

@ -5,9 +5,11 @@ package db
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"os"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
cmn "github.com/tendermint/tendermint/libs/common" cmn "github.com/tendermint/tendermint/libs/common"
) )
@ -88,8 +90,9 @@ func bytes2Int64(buf []byte) int64 {
func TestCLevelDBBackend(t *testing.T) { func TestCLevelDBBackend(t *testing.T) {
name := fmt.Sprintf("test_%x", cmn.RandStr(12)) name := fmt.Sprintf("test_%x", cmn.RandStr(12))
db := NewDB(name, LevelDBBackend, "") dir := os.TempDir()
defer cleanupDBDir("", name) db := NewDB(name, LevelDBBackend, dir)
defer cleanupDBDir(dir, name)
_, ok := db.(*CLevelDB) _, ok := db.(*CLevelDB)
assert.True(t, ok) assert.True(t, ok)