Skip to content

Commit

Permalink
Remove LevelDb from dependencies (#1380)
Browse files Browse the repository at this point in the history
* Remove LevelDb from dependencies

* Remove LevelDb mentions from comments and test names
  • Loading branch information
Harrm authored Oct 28, 2022
1 parent db19edf commit 10b8811
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ This command executes a KAGOME full node with an authority role.
To run a KAGOME node, you need to provide to it a genesis config, cryptographic keys and a place to store db files.
* Example of a genesis config file can be found in `examples/first_kagome_chain/localchain.json`
* Example of a base path dir can be found in `examples/first_kagome_chain/base_path`
* To create leveldb files, just provide any base path into `kagome` executable (mind that start with authority role requires keys to start).
* To create database files, just provide any base path into `kagome` executable (mind that start with authority role requires keys to start).


## Contributing Guides
Expand Down Expand Up @@ -154,7 +154,7 @@ Please refer to the [Contributor Documentation](./docs/source/development/dev-gu
* [SCALE](https://github.com/soramitsu/scale-codec-cpp) (polkadot-codec)
* Implements SCALE codec for data types serialization according to [spec](https://substrate.dev/docs/en/conceptual/core/codec).
* Storage
* Contains of key-value storage interfaces with LevelDB- and inmemory-based implementations
* Contains key-value storage interfaces with persistent and in-memory implementations
* Merkle-Patricia trie implementation, described in spec
* Clock
* Gets current time for the peer
Expand Down
4 changes: 0 additions & 4 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ find_package(Backward)
hunter_add_package(Boost COMPONENTS random filesystem program_options date_time)
find_package(Boost CONFIG REQUIRED random filesystem program_options date_time)

# https://docs.hunter.sh/en/latest/packages/pkg/leveldb.html
hunter_add_package(leveldb)
find_package(leveldb CONFIG REQUIRED)

# https://docs.hunter.sh/en/latest/packages/pkg/xxhash.html
hunter_add_package(xxhash)
find_package(xxhash CONFIG REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion core/storage/in_memory/in_memory_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace kagome::storage {
/**
* Simple storage that conforms PersistentMap interface
* Mostly needed to have an in-memory trie in tests to avoid integration with
* LevelDB
* an actual persistent database
*/
class InMemoryStorage : public storage::BufferStorage {
public:
Expand Down
2 changes: 1 addition & 1 deletion core/storage/rocksdb/rocksdb_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace kagome::storage {
}

if (s.IsIOError()) {
static log::Logger log = log::createLogger("LevelDb", "storage");
static log::Logger log = log::createLogger("RocksDb", "storage");
SL_ERROR(log, ":{}", s.ToString());
return DatabaseError::IO_ERROR;
}
Expand Down
8 changes: 4 additions & 4 deletions test/core/storage/rocksdb/rocksdb_fs_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
using namespace kagome::storage;
namespace fs = boost::filesystem;

struct LevelDB_Open : public test::BaseFS_Test {
struct RocksDb_Open : public test::BaseFS_Test {
static void SetUpTestCase() {
testutil::prepareLoggers();
}

LevelDB_Open() : test::BaseFS_Test("/tmp/kagome_rocksdb_open") {}
RocksDb_Open() : test::BaseFS_Test("/tmp/kagome_rocksdb_open") {}
};

/**
* @given options with disabled option `create_if_missing`
* @when open database
* @then database can not be opened (since there is no db already)
*/
TEST_F(LevelDB_Open, OpenNonExistingDB) {
TEST_F(RocksDb_Open, OpenNonExistingDB) {
rocksdb::Options options;
options.create_if_missing = false; // intentionally

Expand All @@ -42,7 +42,7 @@ TEST_F(LevelDB_Open, OpenNonExistingDB) {
* @when open database
* @then database is opened
*/
TEST_F(LevelDB_Open, OpenExistingDB) {
TEST_F(RocksDb_Open, OpenExistingDB) {
rocksdb::Options options;
options.create_if_missing = true; // intentionally

Expand Down
12 changes: 6 additions & 6 deletions test/core/storage/rocksdb/rocksdb_integration_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
using namespace kagome::storage;
namespace fs = boost::filesystem;

struct LevelDB_Integration_Test : public test::BaseRocksDB_Test {
struct RocksDb_Integration_Test : public test::BaseRocksDB_Test {
static void SetUpTestCase() {
testutil::prepareLoggers();
}

LevelDB_Integration_Test()
RocksDb_Integration_Test()
: test::BaseRocksDB_Test("/tmp/kagome_rocksdb_integration_test") {}

Buffer key_{1, 3, 3, 7};
Expand All @@ -36,7 +36,7 @@ struct LevelDB_Integration_Test : public test::BaseRocksDB_Test {
* @when read {key}
* @then {value} is correct
*/
TEST_F(LevelDB_Integration_Test, Put_Get) {
TEST_F(RocksDb_Integration_Test, Put_Get) {
ASSERT_OUTCOME_SUCCESS_TRY(db_->put(key_, value_));
ASSERT_OUTCOME_SUCCESS(contains, db_->contains(key_));
EXPECT_TRUE(contains);
Expand All @@ -49,7 +49,7 @@ TEST_F(LevelDB_Integration_Test, Put_Get) {
* @when read {key}
* @then get "not found"
*/
TEST_F(LevelDB_Integration_Test, Get_NonExistent) {
TEST_F(RocksDb_Integration_Test, Get_NonExistent) {
ASSERT_OUTCOME_SUCCESS(contains, db_->contains(key_));
EXPECT_FALSE(contains);
ASSERT_OUTCOME_SUCCESS_TRY(db_->remove(key_));
Expand All @@ -63,7 +63,7 @@ TEST_F(LevelDB_Integration_Test, Get_NonExistent) {
* @when create batch and write KVs
* @then data is written only after commit
*/
TEST_F(LevelDB_Integration_Test, WriteBatch) {
TEST_F(RocksDb_Integration_Test, WriteBatch) {
std::list<Buffer> keys{{0}, {1}, {2}, {3}, {4}, {5}};
Buffer toBeRemoved = {3};
std::list<Buffer> expected{{0}, {1}, {2}, {4}, {5}};
Expand Down Expand Up @@ -95,7 +95,7 @@ TEST_F(LevelDB_Integration_Test, WriteBatch) {
* @when iterate over kv pairs forward and backward
* @then we iterate over all items
*/
TEST_F(LevelDB_Integration_Test, Iterator) {
TEST_F(RocksDb_Integration_Test, Iterator) {
const size_t size = 100;
// 100 buffers of size 1 each; 0..99
std::list<Buffer> keys;
Expand Down
2 changes: 1 addition & 1 deletion test/core/storage/trie/trie_storage/trie_storage_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using kagome::subscription::SubscriptionEngine;
static Buffer kNodePrefix = "\1"_buf;

/**
* @given an empty persistent trie with LevelDb backend
* @given an empty persistent trie with RocksDb backend
* @when putting a value into it @and its intance is destroyed @and a new
* instance initialsed with the same DB
* @then the new instance contains the same data
Expand Down

0 comments on commit 10b8811

Please sign in to comment.