Skip to content

Commit

Permalink
Merge branch 'main' into cargo-config-speed-up-build
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored Oct 20, 2022
2 parents 4a2c4c4 + b007c3f commit f9d854b
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 12 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion forest/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ forest_chain.workspace = true
forest_chain_sync.workspace = true
forest_cli_shared.workspace = true
forest_crypto.workspace = true
forest_db.workspace = true
forest_encoding.workspace = true
forest_fil_types.workspace = true
forest_interpreter.workspace = true
Expand Down
4 changes: 3 additions & 1 deletion ipld/legacy_amt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ repository = "https://github.com/ChainSafe/forest"
ahash = { workspace = true, optional = true }
anyhow.workspace = true
cid = { workspace = true, default-features = false, features = ["std"] }
forest_db.workspace = true
forest_encoding.workspace = true
forest_ipld_blockstore.workspace = true
fvm_ipld_encoding.workspace = true
Expand All @@ -20,5 +19,8 @@ once_cell.workspace = true
serde = { workspace = true, features = ["derive"] }
thiserror.workspace = true

[dev-dependencies]
forest_db.workspace = true

[features]
go-interop = ["ahash"]
12 changes: 11 additions & 1 deletion node/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,24 @@ authors = ["ChainSafe Systems <info@chainsafe.io>"]
edition = "2021"
repository = "https://github.com/ChainSafe/forest"

[features]
default = ["snappy", "lz4", "zlib", "bzip2"]

snappy = ["rocksdb/snappy"]
lz4 = ["rocksdb/lz4"]
zlib = ["rocksdb/zlib"]
bzip2 = ["rocksdb/bzip2"]
# not included by default to reduce build time
zstd = ["rocksdb/zstd"]

[dependencies]
anyhow.workspace = true
cid = { workspace = true, default-features = false, features = ["std"] }
forest_encoding.workspace = true
fvm_ipld_blockstore.workspace = true
num_cpus.workspace = true
parking_lot = "0.12"
rocksdb = "0.19"
rocksdb = { version = "0.19", default-features = false }
serde = { workspace = true, features = ["derive"] }
thiserror.workspace = true

Expand Down
37 changes: 36 additions & 1 deletion node/db/src/rocks_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,39 @@ pub(crate) fn compaction_style_from_str(s: &str) -> anyhow::Result<Option<DBComp

/// Converts string to a compression type `RocksDB` variant.
pub(crate) fn compression_type_from_str(s: &str) -> anyhow::Result<DBCompressionType> {
let valid_options = [
#[cfg(feature = "bzip2")]
"bz2",
#[cfg(feature = "lz4")]
"lz4",
#[cfg(feature = "lz4")]
"lz4hc",
#[cfg(feature = "snappy")]
"snappy",
#[cfg(feature = "zlib")]
"zlib",
#[cfg(feature = "zstd")]
"zstd",
"none",
];
match s.to_lowercase().as_str() {
#[cfg(feature = "bzip2")]
"bz2" => Ok(DBCompressionType::Bz2),
#[cfg(feature = "lz4")]
"lz4" => Ok(DBCompressionType::Lz4),
#[cfg(feature = "lz4")]
"lz4hc" => Ok(DBCompressionType::Lz4hc),
#[cfg(feature = "snappy")]
"snappy" => Ok(DBCompressionType::Snappy),
#[cfg(feature = "zlib")]
"zlib" => Ok(DBCompressionType::Zlib),
#[cfg(feature = "zstd")]
"zstd" => Ok(DBCompressionType::Zstd),
"none" => Ok(DBCompressionType::None),
_ => Err(anyhow!("invalid compression option")),
opt => Err(anyhow!(
"invalid compression option: {opt}, valid options: {}",
valid_options.join(",")
)),
}
}

Expand Down Expand Up @@ -110,11 +134,17 @@ mod test {
#[test]
fn compression_style_from_str_test() {
let test_cases = vec![
#[cfg(feature = "bzip2")]
("bz2", Ok(DBCompressionType::Bz2)),
#[cfg(feature = "lz4")]
("lz4", Ok(DBCompressionType::Lz4)),
#[cfg(feature = "lz4")]
("lz4HC", Ok(DBCompressionType::Lz4hc)),
#[cfg(feature = "snappy")]
("SNAPPY", Ok(DBCompressionType::Snappy)),
#[cfg(feature = "zlib")]
("zlib", Ok(DBCompressionType::Zlib)),
#[cfg(feature = "zstd")]
("ZSTD", Ok(DBCompressionType::Zstd)),
("none", Ok(DBCompressionType::None)),
("cthulhu", Err(anyhow!("some error message"))),
Expand All @@ -123,6 +153,11 @@ mod test {
let actual = compression_type_from_str(input);
if let Ok(compression_type) = actual {
assert_eq!(expected.unwrap(), compression_type);
let dir = tempfile::tempdir().unwrap();
let mut opt = rocksdb::Options::default();
opt.create_if_missing(true);
opt.set_compression_type(compression_type);
rocksdb::DB::open(&opt, dir.path()).unwrap();
} else {
assert!(expected.is_err());
}
Expand Down
10 changes: 5 additions & 5 deletions node/forest_libp2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ cid = { workspace = true, default-features = false, features = ["std"] }
fnv = "1.0"
forest_blocks.workspace = true
forest_chain.workspace = true
forest_db.workspace = true
forest_encoding.workspace = true
forest_ipld_blockstore.workspace = true
forest_message.workspace = true
Expand Down Expand Up @@ -51,7 +50,8 @@ tiny-cid = "0.2"
tokio = { workspace = true, features = ["sync", "time"] }

[dev-dependencies]
async-std = { workspace = true, features = ["attributes", "unstable"] }
forest_crypto = { workspace = true, features = ["blst"] }
forest_genesis = { workspace = true, features = ["testing"] }
tokio-util = { version = "0.7.0", features = ["compat"] }
async-std = { workspace = true, features = ["attributes", "unstable"] }
forest_crypto = { workspace = true, features = ["blst"] }
forest_db.workspace = true
forest_genesis = { workspace = true, features = ["testing"] }
tokio-util = { version = "0.7.0", features = ["compat"] }
1 change: 0 additions & 1 deletion vm/interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ fil_actors_runtime.workspace = true
forest_actor_interface.workspace = true
forest_blocks.workspace = true
forest_crypto = { workspace = true, default-features = false, features = ["blst"] }
forest_db.workspace = true
forest_encoding.workspace = true
forest_fil_types.workspace = true
forest_ipld_blockstore.workspace = true
Expand Down

0 comments on commit f9d854b

Please sign in to comment.