Skip to content
Permalink
Browse files

[storage] Introduce rusty_leveldb_sgx as persistence storage (#148)

  • Loading branch information
m4sterchain authored and mssun committed Dec 13, 2019
1 parent 42a4030 commit e8721708be6d6b633d8902b982a38fca9ead589f
Showing with 12,839 additions and 4 deletions.
  1. +1 −0 LICENSE
  2. +22 −0 licenses/LICENSE-rusty-leveldb.txt
  3. +29 −0 mesatee_utils/rusty_leveldb_sgx/Cargo.toml
  4. +22 −0 mesatee_utils/rusty_leveldb_sgx/LICENSE
  5. +42 −0 mesatee_utils/rusty_leveldb_sgx/README.md
  6. +516 −0 mesatee_utils/rusty_leveldb_sgx/src/block.rs
  7. +197 −0 mesatee_utils/rusty_leveldb_sgx/src/block_builder.rs
  8. +69 −0 mesatee_utils/rusty_leveldb_sgx/src/blockhandle.rs
  9. +410 −0 mesatee_utils/rusty_leveldb_sgx/src/cache.rs
  10. +319 −0 mesatee_utils/rusty_leveldb_sgx/src/cmp.rs
  11. +1,701 −0 mesatee_utils/rusty_leveldb_sgx/src/db_impl.rs
  12. +491 −0 mesatee_utils/rusty_leveldb_sgx/src/db_iter.rs
  13. +399 −0 mesatee_utils/rusty_leveldb_sgx/src/disk_env.rs
  14. +90 −0 mesatee_utils/rusty_leveldb_sgx/src/env.rs
  15. +17 −0 mesatee_utils/rusty_leveldb_sgx/src/env_common.rs
  16. +113 −0 mesatee_utils/rusty_leveldb_sgx/src/error.rs
  17. +321 −0 mesatee_utils/rusty_leveldb_sgx/src/filter.rs
  18. +253 −0 mesatee_utils/rusty_leveldb_sgx/src/filter_block.rs
  19. +20 −0 mesatee_utils/rusty_leveldb_sgx/src/infolog.rs
  20. +276 −0 mesatee_utils/rusty_leveldb_sgx/src/key_types.rs
  21. +99 −0 mesatee_utils/rusty_leveldb_sgx/src/lib.rs
  22. +330 −0 mesatee_utils/rusty_leveldb_sgx/src/log.rs
  23. +609 −0 mesatee_utils/rusty_leveldb_sgx/src/mem_env.rs
  24. +397 −0 mesatee_utils/rusty_leveldb_sgx/src/memtable.rs
  25. +378 −0 mesatee_utils/rusty_leveldb_sgx/src/merging_iter.rs
  26. +171 −0 mesatee_utils/rusty_leveldb_sgx/src/options.rs
  27. +607 −0 mesatee_utils/rusty_leveldb_sgx/src/skipmap.rs
  28. +150 −0 mesatee_utils/rusty_leveldb_sgx/src/snapshot.rs
  29. +96 −0 mesatee_utils/rusty_leveldb_sgx/src/table_block.rs
  30. +352 −0 mesatee_utils/rusty_leveldb_sgx/src/table_builder.rs
  31. +168 −0 mesatee_utils/rusty_leveldb_sgx/src/table_cache.rs
  32. +762 −0 mesatee_utils/rusty_leveldb_sgx/src/table_reader.rs
  33. +168 −0 mesatee_utils/rusty_leveldb_sgx/src/test_util.rs
  34. +211 −0 mesatee_utils/rusty_leveldb_sgx/src/types.rs
  35. +1,058 −0 mesatee_utils/rusty_leveldb_sgx/src/version.rs
  36. +378 −0 mesatee_utils/rusty_leveldb_sgx/src/version_edit.rs
  37. +1,338 −0 mesatee_utils/rusty_leveldb_sgx/src/version_set.rs
  38. +191 −0 mesatee_utils/rusty_leveldb_sgx/src/write_batch.rs
  39. +2 −1 tests/functional_test/sgx_trusted_lib/Cargo.toml
  40. +2 −2 tests/functional_test/sgx_trusted_lib/Enclave.config.xml
  41. +1 −0 tests/functional_test/sgx_trusted_lib/src/sgx.rs
  42. +61 −0 tests/functional_test/sgx_trusted_lib/src/tests/leveldb_test.rs
  43. +1 −0 tests/functional_test/sgx_trusted_lib/src/tests/mod.rs
  44. +1 −1 third_party/crates-sgx
@@ -229,3 +229,4 @@ MIT License
-----------

third_party/mesapy
mesatee_utils/rusty_leveldb_sgx
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2016 Google Inc. (lewinb@google.com) -- though not an official
Google product or in any way related!

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
@@ -0,0 +1,29 @@
[package]
name = "rusty-leveldb"
version = "0.3.0"
authors = ["Lewin Bormann <lbo@spheniscida.de>"]
description = "A compatible re-implementation of LevelDB in Rust"
homepage = "https://github.com/dermesser/leveldb-rs"
repository = "https://borgac.net/lbo/hg/"
readme = "README.md"
keywords = ["LevelDB", "key-value", "database", "SSTable", "Google"]
license = "MIT"
publish = true

[features]
default = []
mesalock_sgx = ["protected_fs_rs/mesalock_sgx", "sgx_libc", "sgx_tstd", "sgx_types", "sgx_trts"]

[dependencies]
crc = { version = "2.0" }
rand = { version = "0.7" }
snap = { version = "0.2" }
cfg-if = { version = "0.1.9" }
integer-encoding = { version = "1.0" }

protected_fs_rs = { path = "../protected_fs_rs", optional = true }

sgx_tstd = { version = "1.0.9", optional = true }
sgx_trts = { version = "1.0.9", optional = true }
sgx_types = { version = "1.0.9", optional = true }
sgx_libc = { version = "1.0.9", optional = true }
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2016 Google Inc. (lewinb@google.com) -- though not an official
Google product or in any way related!

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
@@ -0,0 +1,42 @@
# leveldb-rs
[![Build Status](https://ci.mesalock-linux.org/api/badges/mesalock-linux/rusty_leveldb_sgx/status.svg)](https://ci.mesalock-linux.org/mesalock-linux/rusty_leveldb_sgx)
[![crates.io](https://img.shields.io/crates/v/rusty-leveldb.svg)](https://crates.io/crates/rusty-leveldb)

A fully compatible implementation of LevelDB in Rust. (any incompatibility is a
bug!)

The implementation is very close to the original; often, you can see the same
algorithm translated 1:1, and class (struct) and method names are similar or
the same.

**NOTE: I do not endorse using this library for any data that you care about.**
I do care, however, about bug reports.

## Status

* User-facing methods exist: Read/Write/Delete; snapshots; iteration
* Compaction is supported, including manual ones.
* Fully synchronous: Efficiency gains by using non-atomic types, but writes may
occasionally block during a compaction. In --release mode, an average compaction
takes 0.2-0.5 seconds.
* Compatibility with the original: Compression is not implemented so far; this works
as long as compression is disabled in the original.
* Performance is decent; while usually not par with the original, due to multi-threading
in the original and language-inherent overhead (we are doing things the right way),
it will be enough for most use cases.
* Safe: While using many shared pointers, the implementation is generally safe. Many
places use asserts though, so you may see a crash -- in which case you should file a bug.

## Goals

Some of the goals of this implementation are

* As few copies of data as possible; most of the time, slices of bytes (`&[u8]`)
are used. Owned memory is represented as `Vec<u8>` (and then possibly borrowed
as slice).
* Correctness -- self-checking implementation, good test coverage, etc. Just
like the original implementation.
* Clarity; commented code, clear structure (hopefully doing a better job than
the original implementation).
* Coming close-ish to the original implementation; clarifying the translation of
typical C++ constructs to Rust.

0 comments on commit e872170

Please sign in to comment.
You can’t perform that action at this time.