Skip to content

Commit

Permalink
refactor(db)!: remove support for cleveldb, boltdb, rocksdb, badgerdb (
Browse files Browse the repository at this point in the history
…#974)

* build(deps): replace tendermint/tm-db with cometbft/cometbft-db

* build(deps): replace tm-db with cometbft-db

* build(deps): change version of cometbft-db o 1.0.1

* build(deps): bump golang from 1.23 to 1.23.2

* refactor(db)!: remove support for cleveldb, boltdb, rocksdb, badgerdb

* fix(config): allow memdb in tests
  • Loading branch information
lklimek authored Nov 6, 2024
1 parent bd8c7e4 commit 52ea7e5
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 117 deletions.
22 changes: 0 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,28 +65,6 @@ ifeq (race,$(findstring race,$(TENDERMINT_BUILD_OPTIONS)))
BUILD_FLAGS += -race
endif

# handle cleveldb
ifeq (cleveldb,$(findstring cleveldb,$(TENDERMINT_BUILD_OPTIONS)))
CGO_ENABLED=1
BUILD_TAGS += cleveldb
endif

# handle badgerdb
ifeq (badgerdb,$(findstring badgerdb,$(TENDERMINT_BUILD_OPTIONS)))
BUILD_TAGS += badgerdb
endif

# handle rocksdb
ifeq (rocksdb,$(findstring rocksdb,$(TENDERMINT_BUILD_OPTIONS)))
CGO_ENABLED=1
BUILD_TAGS += rocksdb
endif

# handle boltdb
ifeq (boltdb,$(findstring boltdb,$(TENDERMINT_BUILD_OPTIONS)))
BUILD_TAGS += boltdb
endif

# allow users to pass additional flags via the conventional LDFLAGS variable
LD_FLAGS += $(LDFLAGS)

Expand Down
2 changes: 0 additions & 2 deletions cmd/tenderdash/commands/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ func MakeInspectCommand(conf *config.Config, logger log.Logger) *cobra.Command {
}
cmd.Flags().String("rpc.laddr",
conf.RPC.ListenAddress, "RPC listenener address. Port required")
cmd.Flags().String("db-backend",
conf.DBBackend, "database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb")
cmd.Flags().String("db-dir", conf.DBPath, "database directory")

return cmd
Expand Down
4 changes: 0 additions & 4 deletions cmd/tenderdash/commands/run_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ func AddNodeFlags(cmd *cobra.Command, conf *cfg.Config) {
}

func addDBFlags(cmd *cobra.Command, conf *cfg.Config) {
cmd.Flags().String(
"db-backend",
conf.DBBackend,
"database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb")
cmd.Flags().String(
"db-dir",
conf.DBPath,
Expand Down
29 changes: 13 additions & 16 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path/filepath"
"strings"
"testing"
"time"

"github.com/dashpay/dashd-go/btcjson"
Expand Down Expand Up @@ -197,25 +198,12 @@ type BaseConfig struct { //nolint: maligned
// - No priv_validator_key.json, priv_validator_state.json
Mode string `mapstructure:"mode"`

// Database backend: goleveldb | cleveldb | boltdb | rocksdb
// Database backend: only goleveldb is supported
// * 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)
// * rocksdb (uses github.com/tecbot/gorocksdb)
// - EXPERIMENTAL
// - requires gcc
// - use rocksdb build tag (go build -tags rocksdb)
// * badgerdb (uses github.com/dgraph-io/badger)
// - EXPERIMENTAL
// - use badgerdb build tag (go build -tags badgerdb)
//
// Note: we don't remove it from config as we also use `memdb` in some tests.
DBBackend string `mapstructure:"db-backend"`

// Database directory
Expand Down Expand Up @@ -356,6 +344,15 @@ func (cfg BaseConfig) ValidateBasic() error {
return errors.New("deadlock-detection can't be negative")
}

backends := map[string]bool{"goleveldb": true}
if testing.Testing() {
backends["memdb"] = true
}
// check if db_backends contains the db backend
if !backends[cfg.DBBackend] {
return fmt.Errorf("unsupported db backend: %s, only goleveldb is supported", cfg.DBBackend)
}

return nil
}

Expand Down
17 changes: 1 addition & 16 deletions config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,10 @@ moniker = "{{ .BaseConfig.Moniker }}"
# - No priv_validator_key.json, priv_validator_state.json
mode = "{{ .BaseConfig.Mode }}"
# Database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb
# Database backend: only goleveldb supported
# * 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)
# * rocksdb (uses github.com/tecbot/gorocksdb)
# - EXPERIMENTAL
# - requires gcc
# - use rocksdb build tag (go build -tags rocksdb)
# * badgerdb (uses github.com/dgraph-io/badger)
# - EXPERIMENTAL
# - use badgerdb build tag (go build -tags badgerdb)
db-backend = "{{ .BaseConfig.DBBackend }}"
# Database directory
Expand Down
35 changes: 11 additions & 24 deletions docs/nodes/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,10 @@ moniker = "sidewinder"
# - No priv_validator_key.json, priv_validator_state.json
mode = "validator"

# Database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb
# Database backend: goleveldb
# * 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)
# * rocksdb (uses github.com/tecbot/gorocksdb)
# - EXPERIMENTAL
# - requires gcc
# - use rocksdb build tag (go build -tags rocksdb)
# * badgerdb (uses github.com/dgraph-io/badger)
# - EXPERIMENTAL
# - use badgerdb build tag (go build -tags badgerdb)
db-backend = "goleveldb"

# Database directory
Expand Down Expand Up @@ -533,29 +518,31 @@ Tendermint will only create blocks if there are transactions, or after waiting
This section will cover settings within the p2p section of the `config.toml`.

- `external-address` = is the address that will be advertised for other nodes to use. We recommend setting this field with your public IP and p2p port.
- > We recommend setting an external address. When used in a private network, Tendermint Core currently doesn't advertise the node's public address. There is active and ongoing work to improve the P2P system, but this is a helpful workaround for now.
- > We recommend setting an external address. When used in a private network, Tendermint Core currently doesn't advertise the node's public address. There is active and ongoing work to improve the P2P system, but this is a helpful workaround for now.
- `persistent-peers` = is a list of comma separated peers that you will always want to be connected to. If you're already connected to the maximum number of peers, persistent peers will not be added.
- `pex` = turns the peer exchange reactor on or off. Validator node will want the `pex` turned off so it would not begin gossiping to unknown peers on the network. PeX can also be turned off for statically configured networks with fixed network connectivity. For full nodes on open, dynamic networks, it should be turned on.
- `private-peer-ids` = is a comma-separated list of node ids that will _not_ be exposed to other peers (i.e., you will not tell other peers about the ids in this list). This can be filled with a validator's node id.

Recently the Tendermint Team conducted a refactor of the p2p layer. This lead to multiple config parameters being deprecated and/or replaced.
Recently the Tendermint Team conducted a refactor of the p2p layer. This lead to multiple config parameters being deprecated and/or replaced.

We will cover the new and deprecated parameters below.

### New Parameters

There are three new parameters, which are enabled if use-legacy is set to false.

- `queue-type` = sets a type of queue to use in the p2p layer. There are three options available `fifo`, `priority` and `wdrr`. The default is priority
- `bootstrap-peers` = is a list of comma seperated peers which will be used to bootstrap the address book.
- `bootstrap-peers` = is a list of comma seperated peers which will be used to bootstrap the address book.
- `max-connections` = is the max amount of allowed inbound and outbound connections.

### Deprecated Parameters

> Note: For Tendermint 0.35, there are two p2p implementations. The old version is used by default with the deprecated fields. The new implementation uses different config parameters, explained above.
- `max-num-inbound-peers` = is the maximum number of peers you will accept inbound connections from at one time (where they dial your address and initiate the connection). *This was replaced by `max-connections`*
- `max-num-outbound-peers` = is the maximum number of peers you will initiate outbound connects to at one time (where you dial their address and initiate the connection).*This was replaced by `max-connections`*
- `unconditional-peer-ids` = is similar to `persistent-peers` except that these peers will be connected to even if you are already connected to the maximum number of peers. This can be a validator node ID on your sentry node. *Deprecated*
- `seeds` = is a list of comma separated seed nodes that you will connect upon a start and ask for peers. A seed node is a node that does not participate in consensus but only helps propagate peers to nodes in the networks *Deprecated, replaced by bootstrap peers*
- `max-num-inbound-peers` = is the maximum number of peers you will accept inbound connections from at one time (where they dial your address and initiate the connection). _This was replaced by `max-connections`_
- `max-num-outbound-peers` = is the maximum number of peers you will initiate outbound connects to at one time (where you dial their address and initiate the connection)._This was replaced by `max-connections`_
- `unconditional-peer-ids` = is similar to `persistent-peers` except that these peers will be connected to even if you are already connected to the maximum number of peers. This can be a validator node ID on your sentry node. _Deprecated_
- `seeds` = is a list of comma separated seed nodes that you will connect upon a start and ask for peers. A seed node is a node that does not participate in consensus but only helps propagate peers to nodes in the networks _Deprecated, replaced by bootstrap peers_

## Indexing Settings

Expand Down Expand Up @@ -590,7 +577,7 @@ the `psql` indexer type.
Example:

```shell
$ psql ... -f state/indexer/sink/psql/schema.sql
psql ... -f state/indexer/sink/psql/schema.sql
```

## Unsafe Consensus Timeout Overrides
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ docker:
-f docker/Dockerfile ../..

node:
GOTRACEBACK=crash $(GO) build -gcflags="all=-N -l" -o build/node -tags badgerdb,boltdb,cleveldb,deadlock ./node
GOTRACEBACK=crash $(GO) build -gcflags="all=-N -l" -o build/node -tags deadlock ./node

e2e/app/compile:
docker run --rm -it --entrypoint "/src/tenderdash/test/e2e/entrypoint.sh" -w "/src/tenderdash/test/e2e" -v $(ROOT_PATH)/test/e2e:/src/tenderdash/test/e2e tenderdash/e2e-node
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ To analyze core dumps:
1. Examine [Dockerfile](docker/Dockerfile) to ensure `ENV TENDERMINT_BUILD_OPTIONS` contains `nostrip` option AND `GOTRACEBACK` is set to `crash`, for example:

```docker
ENV TENDERMINT_BUILD_OPTIONS badgerdb,boltdb,cleveldb,rocksdb,nostrip
ENV TENDERMINT_BUILD_OPTIONS nostrip
ENV GOTRACEBACK=crash
```

Expand Down Expand Up @@ -255,9 +255,9 @@ Docker does not enable IPv6 by default. To do so, enter the following in

It is also possible to run a simple benchmark on a testnet. This is done through the `benchmark` command. This manages the entire process: setting up the environment, starting the test net, waiting for a considerable amount of blocks to be used (currently 100), and then returning the following metrics from the sample of the blockchain:

- Average time to produce a block
- Standard deviation of producing a block
- Minimum and maximum time to produce a block
* Average time to produce a block
* Standard deviation of producing a block
* Minimum and maximum time to produce a block

## Running Individual Nodes

Expand Down
3 changes: 0 additions & 3 deletions test/e2e/generator/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ var (
// The following specify randomly chosen values for testnet nodes.
nodeDatabases = weightedChoice{
"goleveldb": 35,
"badgerdb": 35,
"boltdb": 15,
"cleveldb": 5,
}
ABCIProtocols = weightedChoice{
"tcp": 20,
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/networks/ci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

evidence = 5
initial_height = 1000
initial_state = {initial01 = "a", initial02 = "b", initial03 = "c"}
initial_state = { initial01 = "a", initial02 = "b", initial03 = "c" }
queue_type = "simple-priority"
abci_protocol = "builtin"
initial_core_chain_locked_height = 3400
Expand Down Expand Up @@ -41,15 +41,15 @@ block_sync = "v0"
perturb = ["disconnect"]

[node.validator02]
database = "cleveldb"
database = "goleveldb"
persist_interval = 0
perturb = ["restart"]
privval_protocol = "tcp"
seeds = ["seed01"]
block_sync = "v0"

[node.validator03]
database = "badgerdb"
database = "goleveldb"
seeds = ["seed01"]
persist_interval = 3
perturb = ["kill"]
Expand All @@ -59,24 +59,24 @@ retain_blocks = 10

[node.validator04]
snapshot_interval = 5
database = "badgerdb"
database = "goleveldb"
persistent_peers = ["validator01"]
perturb = ["pause"]
block_sync = "v0"
privval_protocol = "tcp"

[node.validator05]
block_sync = "v0"
database = "badgerdb"
database = "goleveldb"
state_sync = "p2p"
start_at = 1005 # Becomes part of the validator set at 1010
start_at = 1005 # Becomes part of the validator set at 1010
perturb = ["pause", "disconnect", "restart"]

[node.full01]
mode = "full"
start_at = 1010
block_sync = "v0"
database = "boltdb"
database = "goleveldb"
persistent_peers = ["validator01", "validator02", "validator03", "validator04"]
perturb = ["restart"]
retain_blocks = 10
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/networks/dashcore.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ privval_protocol = "dashcore"

[node.validator02]
seeds = ["seed01"]
database = "boltdb"
database = "goleveldb"
abci_protocol = "tcp"
privval_protocol = "dashcore"
persist_interval = 0
perturb = ["restart"]

[node.validator03]
seeds = ["seed01"]
database = "badgerdb"
database = "goleveldb"
# FIXME: should be grpc, disabled due to https://github.com/tendermint/tendermint/issues/5439
#abci_protocol = "grpc"
privval_protocol = "dashcore"
Expand All @@ -74,15 +74,15 @@ perturb = ["kill"]

[node.validator04]
persistent_peers = ["validator01"]
database = "badgerdb"
database = "goleveldb"
abci_protocol = "builtin"
privval_protocol = "dashcore"
perturb = ["pause"]

[node.validator05]
start_at = 1005 # Becomes part of the validator set at 1010
seeds = ["seed01"]
database = "cleveldb"
database = "goleveldb"
block_sync = "v0"
state_sync = "p2p"
privval_protocol = "dashcore"
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/networks/island.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
initial_height = 1000
initial_state = {items={ initial01 = "a", initial02 = "b", initial03 = "c" }}
initial_state = { items = { initial01 = "a", initial02 = "b", initial03 = "c" } }
initial_core_chain_locked_height = 3400

[chainlock_updates]
Expand Down Expand Up @@ -42,40 +42,40 @@ perturb = ["disconnect"]
privval_protocol = "dashcore"

[node.validator02]
database = "boltdb"
database = "goleveldb"
abci_protocol = "tcp"
privval_protocol = "dashcore"
persist_interval = 0
perturb = ["restart"]

[node.validator03]
database = "badgerdb"
database = "goleveldb"
privval_protocol = "dashcore"
persist_interval = 3
retain_blocks = 3
perturb = ["kill"]

[node.validator04]
database = "badgerdb"
database = "goleveldb"
abci_protocol = "builtin"
privval_protocol = "dashcore"
perturb = ["pause"]

[node.validator05]
start_at = 1005
database = "cleveldb"
database = "goleveldb"
fast_sync = "v0"
privval_protocol = "dashcore"
perturb = ["kill", "pause", "disconnect", "restart"]

[node.validator06]
database = "cleveldb"
database = "goleveldb"
fast_sync = "v0"
privval_protocol = "dashcore"

[node.validator07]
start_at = 1005
database = "cleveldb"
database = "goleveldb"
fast_sync = "v0"
privval_protocol = "dashcore"
perturb = ["pause"]
Loading

0 comments on commit 52ea7e5

Please sign in to comment.