Skip to content

Commit

Permalink
Merge pull request #673 from Chia-Network/merkle_blob
Browse files Browse the repository at this point in the history
`chia-datalayer`
  • Loading branch information
altendky authored Dec 18, 2024
2 parents 070826c + f227fb0 commit 6e9c7c4
Show file tree
Hide file tree
Showing 15 changed files with 3,077 additions and 3 deletions.
364 changes: 363 additions & 1 deletion Cargo.lock

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ chia-bls = { workspace = true, optional = true }
chia-secp = { workspace = true, optional = true }
chia-client = { workspace = true, optional = true }
chia-consensus = { workspace = true, optional = true }
chia-datalayer = { workspace = true, optional = true }
chia-protocol = { workspace = true, optional = true }
chia-ssl = { workspace = true, optional = true }
chia-traits = { workspace = true, optional = true }
Expand All @@ -75,6 +76,7 @@ default = [
"secp",
"client",
"consensus",
"datalayer",
"protocol",
"ssl",
"traits",
Expand All @@ -88,6 +90,7 @@ bls = ["dep:chia-bls", "clvm-traits/chia-bls"]
secp = ["dep:chia-secp", "clvm-traits/chia-secp"]
client = ["dep:chia-client"]
consensus = ["dep:chia-consensus"]
datalayer = ["dep:chia-datalayer"]
protocol = ["dep:chia-protocol"]
ssl = ["dep:chia-ssl"]
traits = ["dep:chia-traits"]
Expand All @@ -107,6 +110,7 @@ chia_streamable_macro = { path = "./crates/chia_streamable_macro", version = "0.
chia-bls = { path = "./crates/chia-bls", version = "0.16.0" }
chia-client = { path = "./crates/chia-client", version = "0.16.0" }
chia-consensus = { path = "./crates/chia-consensus", version = "0.16.0" }
chia-datalayer = { path = "./crates/chia-datalayer", version = "0.16.0" }
chia-protocol = { path = "./crates/chia-protocol", version = "0.16.0" }
chia-secp = { path = "./crates/chia-secp", version = "0.16.0" }
chia-ssl = { path = "./crates/chia-ssl", version = "0.11.0" }
Expand All @@ -118,6 +122,7 @@ clvm-utils = { path = "./crates/clvm-utils", version = "0.16.0" }
clvm-derive = { path = "./crates/clvm-derive", version = "0.13.0" }
chia-fuzz = { path = "./crates/chia-consensus/fuzz", version = "0.16.0" }
chia-bls-fuzz = { path = "./crates/chia-bls/fuzz", version = "0.16.0" }
chia-datalayer-fuzz = { path = "./crates/chia-datalayer/fuzz", version = "0.16.0" }
chia-protocol-fuzz = { path = "./crates/chia-protocol/fuzz", version = "0.16.0" }
chia-puzzles-fuzz = { path = "./crates/chia-puzzles/fuzz", version = "0.16.0" }
clvm-traits-fuzz = { path = "./crates/clvm-traits/fuzz", version = "0.16.0" }
Expand All @@ -138,6 +143,7 @@ arbitrary = "1.4.1"
rand = "0.8.5"
criterion = "0.5.1"
rstest = "0.22.0"
expect-test = "1.5.0"
tokio = "1.42.0"
tokio-tungstenite = "0.24.0"
futures-util = "0.3.31"
Expand All @@ -160,3 +166,6 @@ openssl = "0.10.68"
k256 = "0.13.4"
p256 = "0.13.2"
rand_chacha = "0.3.1"
open = "5.3.0"
url = "2.5.2"
percent-encoding = "2.3.1"
41 changes: 41 additions & 0 deletions crates/chia-datalayer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
name = "chia-datalayer"
version = "0.16.0"
edition = "2021"
license = "Apache-2.0"
description = "DataLayer modules for Chia blockchain"
authors = ["Chia Network, Inc. <[email protected]>"]
homepage = "https://github.com/Chia-Network/chia_rs"
repository = "https://github.com/Chia-Network/chia_rs"

[lints]
workspace = true

[features]
py-bindings = ["dep:pyo3"]

[lib]
crate-type = ["rlib"]

[dependencies]
clvmr = { workspace = true }
num-traits = { workspace = true }
pyo3 = { workspace = true, optional = true }
thiserror = { workspace = true }
chia_streamable_macro = { workspace = true }
chia-traits = { workspace = true }
chia-sha2 = { workspace = true }
chia-protocol = { workspace = true }

[dev-dependencies]
clvm-utils = { workspace = true }
expect-test = { workspace = true }
hex = { workspace = true }
hex-literal = { workspace = true }
open = { workspace = true }
percent-encoding = { workspace = true }
rstest = { workspace = true }
url = { workspace = true }

[package.metadata.cargo-machete]
ignored = ["chia-sha2"]
4 changes: 4 additions & 0 deletions crates/chia-datalayer/fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target
corpus
artifacts
coverage
21 changes: 21 additions & 0 deletions crates/chia-datalayer/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "chia-datalayer-fuzz"
version = "0.16.0"
publish = false
edition = "2021"

[package.metadata]
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.4"

[dependencies.chia-datalayer]
path = ".."

[[bin]]
name = "merkle_blob_new"
path = "fuzz_targets/merkle_blob_new.rs"
test = false
doc = false
bench = false
18 changes: 18 additions & 0 deletions crates/chia-datalayer/fuzz/fuzz_targets/merkle_blob_new.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![no_main]

use libfuzzer_sys::{arbitrary::Unstructured, fuzz_target};

use chia_datalayer::{MerkleBlob, BLOCK_SIZE};

fuzz_target!(|data: &[u8]| {
let mut unstructured = Unstructured::new(data);
let block_count = unstructured.int_in_range(0..=1000).unwrap();
let mut bytes = vec![0u8; block_count * BLOCK_SIZE];
unstructured.fill_buffer(&mut bytes).unwrap();

let Ok(mut blob) = MerkleBlob::new(bytes) else {
return;
};
blob.check_integrity_on_drop = false;
let _ = blob.check_integrity();
});
3 changes: 3 additions & 0 deletions crates/chia-datalayer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod merkle;

pub use merkle::*;
Loading

0 comments on commit 6e9c7c4

Please sign in to comment.