diff --git a/Gopkg.lock b/Gopkg.lock index 8deb06378..9a27f344a 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1,6 +1,13 @@ # 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]] branch = "master" digest = "1:d6afaeed1502aa28e80a4ed0981d570ad91b2579193404256ce672ed0a609e0d" @@ -161,13 +168,6 @@ revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" -[[projects]] - digest = "1:39b27d1381a30421f9813967a5866fba35dc1d4df43a6eefe3b7a5444cb07214" - name = "github.com/jmhodges/levigo" - packages = ["."] - pruneopts = "UT" - revision = "c42d9e0ca023e2198120196f842701bb4c55d7b9" - [[projects]] branch = "master" digest = "1:a64e323dc06b73892e5bb5d040ced475c4645d456038333883f58934abbf6f72" @@ -511,6 +511,7 @@ analyzer-name = "dep" analyzer-version = 1 input-imports = [ + "github.com/DataDog/leveldb", "github.com/btcsuite/btcutil/base58", "github.com/btcsuite/btcutil/bech32", "github.com/ebuchman/fail-test", @@ -529,7 +530,6 @@ "github.com/golang/protobuf/proto", "github.com/golang/protobuf/ptypes/timestamp", "github.com/gorilla/websocket", - "github.com/jmhodges/levigo", "github.com/pkg/errors", "github.com/prometheus/client_golang/prometheus", "github.com/prometheus/client_golang/prometheus/promhttp", diff --git a/Gopkg.toml b/Gopkg.toml index d3bca19e8..cda7988c5 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -73,8 +73,8 @@ ## Pin to revision [[override]] - name = "github.com/jmhodges/levigo" - revision = "c42d9e0ca023e2198120196f842701bb4c55d7b9" + name = "github.com/DataDog/leveldb" + revision = "12a0b6e10a5bf779330ed8b7c0f1f39f212d34e2" [[constraint]] name = "github.com/ebuchman/fail-test" diff --git a/config/config.go b/config/config.go index c0882546f..d0e075477 100644 --- a/config/config.go +++ b/config/config.go @@ -113,7 +113,7 @@ type BaseConfig struct { // and verifying their commits FastSync bool `mapstructure:"fast_sync"` - // Database backend: leveldb | memdb + // Database backend: leveldb | memdb | cleveldb DBBackend string `mapstructure:"db_backend"` // Database directory @@ -587,15 +587,15 @@ type TxIndexConfig struct { // 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. - // + // // 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 // transactions. IndexTags string `mapstructure:"index_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 // precedence over IndexAllTags (i.e. when given both, IndexTags will be // indexed). diff --git a/config/toml.go b/config/toml.go index 2a35d7c36..9beb9d799 100644 --- a/config/toml.go +++ b/config/toml.go @@ -77,7 +77,7 @@ moniker = "{{ .BaseConfig.Moniker }}" # and verifying their commits fast_sync = {{ .BaseConfig.FastSync }} -# Database backend: leveldb | memdb +# Database backend: leveldb | memdb | cleveldb db_backend = "{{ .BaseConfig.DBBackend }}" # Database directory diff --git a/docs/introduction/install.md b/docs/introduction/install.md index 10b66dad0..925ed2a80 100644 --- a/docs/introduction/install.md +++ b/docs/introduction/install.md @@ -48,6 +48,15 @@ to put the binary in `./build`. 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 If you already have Tendermint installed, and you make updates, simply @@ -66,11 +75,35 @@ make get_vendor_deps 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 -tendermint node --proxy_app=kvstore +sudo apt-get update +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/ ``` diff --git a/docs/tendermint-core/configuration.md b/docs/tendermint-core/configuration.md index 7e20277f4..29db12125 100644 --- a/docs/tendermint-core/configuration.md +++ b/docs/tendermint-core/configuration.md @@ -30,7 +30,7 @@ moniker = "anonymous" # and verifying their commits fast_sync = true -# Database backend: leveldb | memdb +# Database backend: leveldb | memdb | cleveldb db_backend = "leveldb" # Database directory diff --git a/libs/db/Makefile b/libs/db/Makefile new file mode 100644 index 000000000..e0cd45b0a --- /dev/null +++ b/libs/db/Makefile @@ -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 diff --git a/libs/db/backend_test.go b/libs/db/backend_test.go index 496f4c410..a93698226 100644 --- a/libs/db/backend_test.go +++ b/libs/db/backend_test.go @@ -55,9 +55,10 @@ func TestBackendsGetSetDelete(t *testing.T) { func withDB(t *testing.T, creator dbCreator, fn func(DB)) { name := fmt.Sprintf("test_%x", cmn.RandStr(12)) - db, err := creator(name, "") - defer cleanupDBDir("", name) - assert.Nil(t, err) + dir := os.TempDir() + db, err := creator(name, dir) + require.Nil(t, err) + defer cleanupDBDir(dir, name) fn(db) db.Close() } @@ -161,8 +162,9 @@ func TestDBIterator(t *testing.T) { func testDBIterator(t *testing.T, backend DBBackendType) { name := fmt.Sprintf("test_%x", cmn.RandStr(12)) - db := NewDB(name, backend, "") - defer cleanupDBDir("", name) + dir := os.TempDir() + db := NewDB(name, backend, dir) + defer cleanupDBDir(dir, name) for i := 0; i < 10; i++ { if i != 6 { // but skip 6. diff --git a/libs/db/c_level_db.go b/libs/db/c_level_db.go index 307461261..10f03aa0c 100644 --- a/libs/db/c_level_db.go +++ b/libs/db/c_level_db.go @@ -7,7 +7,7 @@ import ( "fmt" "path/filepath" - "github.com/jmhodges/levigo" + levigo "github.com/DataDog/leveldb" ) func init() { diff --git a/libs/db/c_level_db_test.go b/libs/db/c_level_db_test.go index d01a85e9d..c81b4185a 100644 --- a/libs/db/c_level_db_test.go +++ b/libs/db/c_level_db_test.go @@ -5,9 +5,11 @@ package db import ( "bytes" "fmt" + "os" "testing" "github.com/stretchr/testify/assert" + cmn "github.com/tendermint/tendermint/libs/common" ) @@ -88,8 +90,9 @@ func bytes2Int64(buf []byte) int64 { func TestCLevelDBBackend(t *testing.T) { name := fmt.Sprintf("test_%x", cmn.RandStr(12)) - db := NewDB(name, LevelDBBackend, "") - defer cleanupDBDir("", name) + dir := os.TempDir() + db := NewDB(name, LevelDBBackend, dir) + defer cleanupDBDir(dir, name) _, ok := db.(*CLevelDB) assert.True(t, ok)