Skip to content

cometbft/cometbft-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

1541916 · Mar 3, 2025
Feb 28, 2025
Mar 3, 2025
Feb 19, 2025
Apr 26, 2023
Jan 29, 2025
Nov 8, 2021
Feb 28, 2025
Jan 17, 2023
Jan 17, 2023
Feb 12, 2025
Sep 9, 2024
Feb 12, 2025
Nov 16, 2023
Sep 20, 2024
Jul 15, 2024
Aug 9, 2024
Aug 9, 2024
Aug 9, 2024
Aug 9, 2024
Aug 9, 2024
Aug 9, 2024
Aug 9, 2024
Aug 9, 2024
Jan 25, 2024
Sep 20, 2024
Sep 23, 2024
Nov 15, 2021
Feb 27, 2025
Feb 27, 2025
Sep 23, 2024
Sep 23, 2024
Feb 12, 2025
Sep 23, 2024
Sep 20, 2024
Sep 20, 2024
Feb 12, 2025
Nov 15, 2021
Feb 12, 2025
Sep 20, 2024
Sep 20, 2024
Nov 15, 2021
Feb 27, 2023
Jan 24, 2024
Feb 7, 2024
Apr 13, 2023
Jul 15, 2024
Jan 12, 2023
Sep 20, 2024
Sep 20, 2024
Sep 20, 2024
Aug 9, 2024

Repository files navigation

CometBFT DB

version license API Reference codecov Lint Test

A fork of tm-db.

Common database interface for various database backends. Primarily meant for applications built on CometBFT, such as the Cosmos SDK.

NB: As per cometbft/cometbft#48, the CometBFT team plans on eventually totally deprecating and removing this library from CometBFT. As such, we do not recommend depending on this library for new projects.

Minimum Go Version

Go 1.23+

Supported Database Backends

  • GoLevelDB [stable]: A pure Go implementation of LevelDB (see below). Currently the default on-disk database used in the Cosmos SDK.

  • MemDB [stable]: An in-memory database using Google's B-tree package. Has very high performance both for reads, writes, and range scans, but is not durable and will lose all data on process exit. Does not support transactions. Suitable for e.g. caches, working sets, and tests. Used for IAVL working sets when the pruning strategy allows it.

  • LevelDB [DEPRECATED]: A Go wrapper around LevelDB. Uses LSM-trees for on-disk storage, which have good performance for write-heavy workloads, particularly on spinning disks, but requires periodic compaction to maintain decent read performance and reclaim disk space. Does not support transactions.

  • BoltDB [DEPRECATED]: A fork of BoltDB. Uses B+trees for on-disk storage, which have good performance for read-heavy workloads and range scans. Supports serializable ACID transactions.

  • RocksDB [experimental]: A Go wrapper around RocksDB. Similarly to LevelDB (above) it uses LSM-trees for on-disk storage, but is optimized for fast storage media such as SSDs and memory. Supports atomic transactions, but not full ACID transactions.

  • BadgerDB [experimental]: A key-value database written as a pure-Go alternative to e.g. LevelDB and RocksDB, with LSM-tree storage. Makes use of multiple goroutines for performance, and includes advanced features such as serializable ACID transactions, write batches, compression, and more.

  • PebbleDB [experimental]: Pebble is a LevelDB/RocksDB inspired key-value store focused on performance and internal usage by CockroachDB. Pebble inherits the RocksDB file formats and a few extensions such as range deletion tombstones, table-level bloom filters, and updates to the MANIFEST format.

    CAVEAT: there are reports of broken upgrade process when using Cosmos SDK.

Meta-databases

  • PrefixDB [stable]: A database which wraps another database and uses a static prefix for all keys. This allows multiple logical databases to be stored in a common underlying databases by using different namespaces. Used by the Cosmos SDK to give different modules their own namespaced database in a single application database.

Tests

To test common databases, run make test. If all databases are available on the local machine, use make test-all to test them all.

To test all databases within a Docker container, run:

make docker-test-image
make docker-test