Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chia-datalayer #673

Merged
merged 199 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 198 commits
Commits
Show all changes
199 commits
Select commit Hold shift + click to select a range
fff0931
`chia-datalayer`
altendky Aug 21, 2024
0b20347
fmt
altendky Aug 21, 2024
d6a7483
parse. horribly.
altendky Aug 21, 2024
05fc451
tidy
altendky Aug 22, 2024
fb1d6c3
`KvId`
altendky Aug 22, 2024
735244c
misc
altendky Aug 22, 2024
f679fa7
more
altendky Aug 22, 2024
f57e7fe
dumps
altendky Aug 23, 2024
5ccd2cb
from to
altendky Aug 23, 2024
b9ae428
can load a simple python tree
altendky Aug 26, 2024
2a39dbd
get random leaf node
altendky Aug 26, 2024
0f3838f
preliminary python exposure
altendky Aug 27, 2024
ae67c65
add hints
altendky Aug 27, 2024
e693751
clippy
altendky Aug 27, 2024
b6f9094
black
altendky Aug 27, 2024
682fe07
misc
altendky Aug 28, 2024
4648040
insert
altendky Aug 29, 2024
444b8cd
fixup
altendky Sep 3, 2024
ccd3303
Merge branch 'main' into merkle_blob
altendky Sep 3, 2024
88bd271
split up insert
altendky Sep 5, 2024
7b99213
make it `.get_random_leaf_node_from_bytes()`
altendky Sep 5, 2024
7efc3ff
more testing
altendky Sep 5, 2024
7acf99f
Merge branch 'main' into merkle_blob
altendky Sep 6, 2024
d00dda3
tidy
altendky Sep 6, 2024
cc97f1a
less raw in the name
altendky Sep 6, 2024
99568d9
drop a little commented code
altendky Sep 6, 2024
eabb7c0
drop some `crate::`
altendky Sep 6, 2024
17c4a86
tidy
altendky Sep 6, 2024
d2c8350
refactor node common attributes to a new non-enum layer
altendky Sep 6, 2024
2ed20b6
misc
altendky Sep 6, 2024
2e40365
constrain the magic null parent value to serialized data
altendky Sep 6, 2024
e452991
yup
altendky Sep 6, 2024
bf43e9f
tidy
altendky Sep 6, 2024
32984bb
oops
altendky Sep 6, 2024
0de8a05
clippy
altendky Sep 6, 2024
03856ff
black
altendky Sep 6, 2024
7a567d9
clippy
altendky Sep 6, 2024
778fa01
clippy
altendky Sep 6, 2024
67f544b
unassert
altendky Sep 6, 2024
ca09a91
empty
altendky Sep 6, 2024
49846f3
Merge branch 'main' into merkle_blob
altendky Sep 9, 2024
d83b3df
remove some commented out code
altendky Sep 9, 2024
45ebc57
.get_block_bytes()
altendky Sep 9, 2024
b22ce17
implement delete, iterable merkle blob, and to dot
altendky Sep 10, 2024
ea5f8c8
clippy
altendky Sep 10, 2024
e548e23
comments
altendky Sep 11, 2024
a2ce26d
reuse iteration
altendky Sep 11, 2024
60baf0a
add `.calculate_lazy_hashes()`
altendky Sep 11, 2024
502b9e6
consolidate actual blob modification
altendky Sep 11, 2024
ae0087f
misc incomplete
altendky Sep 12, 2024
3935ac8
check that deleting in reverse of insertion recreates original tree
altendky Sep 13, 2024
85aefbc
make the serialization definition more clear
altendky Sep 13, 2024
2854828
simplify away from match some places
altendky Sep 13, 2024
cb90651
pass hashes by reference
altendky Sep 13, 2024
e5a916e
fix insert, and always more
altendky Sep 17, 2024
d6a1992
clippy and tweaks
altendky Sep 17, 2024
40bc208
remove redundant assertions
altendky Sep 20, 2024
a14033a
Merge branch 'main' into merkle_blob
altendky Oct 1, 2024
838c3c2
fixup hints
altendky Oct 1, 2024
744e41f
test name tweak
altendky Oct 1, 2024
e8b51a9
catch up a bit
altendky Oct 1, 2024
eda9afc
add insert location
altendky Oct 2, 2024
2c4dccb
test second node insertion and sides
altendky Oct 2, 2024
d0840c0
more choosing side insertion testing
altendky Oct 2, 2024
4d78630
fixup
altendky Oct 2, 2024
ab7d1fe
remove use hex
altendky Oct 2, 2024
bef6828
more testing
altendky Oct 4, 2024
544cf07
clippy
altendky Oct 4, 2024
49b6cac
handle unlimited depths for getting random leaf locations
altendky Oct 5, 2024
a4408c7
sha256 helpers
altendky Oct 5, 2024
37e8340
more names
altendky Oct 7, 2024
52c8edc
fixup
altendky Oct 7, 2024
e6fa08b
Merge branch 'main' into merkle_blob
altendky Oct 7, 2024
0b8b14d
tidy
altendky Oct 7, 2024
9b3fb80
remove `Node.index` field
altendky Oct 7, 2024
a4e4117
tidy
altendky Oct 7, 2024
c5c8f60
error handling tidying
altendky Oct 8, 2024
47d7edf
less allow
altendky Oct 8, 2024
9a1919b
a little less pythony
altendky Oct 8, 2024
479d879
tidy
altendky Oct 8, 2024
cc56c35
tidy
altendky Oct 8, 2024
27add2d
single tree traversal to load
altendky Oct 8, 2024
bd9d2e1
tidy
altendky Oct 8, 2024
e2d0b64
move all dot stuff to dot module
altendky Oct 10, 2024
9d790e9
less dot running for now
altendky Oct 10, 2024
1a62f56
dot unused allow
altendky Oct 10, 2024
967a10f
tidy
altendky Oct 10, 2024
cb249f6
drop next_index_to_allocate
altendky Oct 10, 2024
cc8e958
add .clear()
altendky Oct 10, 2024
bca83f8
centralize key to index insertion
altendky Oct 11, 2024
b701e08
fixup
altendky Oct 11, 2024
9451f98
tidy
altendky Oct 11, 2024
b345e5c
hashset for free indexes
altendky Oct 11, 2024
87ac5b0
merkle submodule
altendky Oct 11, 2024
f3dc814
Merge branch 'main' into merkle_blob
altendky Oct 15, 2024
564d2c2
tidy
altendky Oct 15, 2024
a34cb63
tidy
altendky Oct 15, 2024
32d8cde
catch up test
altendky Oct 16, 2024
2fa7c3a
tidy
altendky Oct 17, 2024
878b8e0
check parent child bidirectional agreement
altendky Oct 17, 2024
d6e4e4b
.get_hash()
altendky Oct 17, 2024
bf86d40
tidy
altendky Oct 17, 2024
f0fb65a
tidy
altendky Oct 17, 2024
6e01fe0
always more
altendky Oct 17, 2024
ae77486
only 14 to go
altendky Oct 17, 2024
f22ac25
Merge branch 'main' into merkle_blob
altendky Oct 18, 2024
4d42995
more
altendky Oct 18, 2024
16b3ac9
tidy
altendky Oct 18, 2024
6d92a1e
clippy
altendky Oct 18, 2024
14e451b
stub catchup
altendky Oct 21, 2024
ecb4d25
implement more;
altendky Oct 22, 2024
4f1275e
pyi
altendky Oct 22, 2024
030dfc4
unreachable
altendky Oct 23, 2024
e6ff146
s64
altendky Oct 24, 2024
c93fb55
blech
altendky Oct 24, 2024
815d5de
hints
altendky Oct 24, 2024
5d54f85
pub
altendky Oct 24, 2024
d1de37d
pub
altendky Oct 24, 2024
7881538
fixup
altendky Oct 24, 2024
102fd54
Merge branch 'main' into merkle_blob
altendky Oct 25, 2024
be43bf6
sorta kinda parallelize inserting a bunch 'test'
altendky Oct 25, 2024
de711e5
tidy
altendky Oct 25, 2024
1b61eed
.update_parent()
altendky Oct 28, 2024
a66f16d
fixup
altendky Oct 28, 2024
e3e1db6
drop check for debug assertions too
altendky Oct 28, 2024
b4ee761
rename to `.check_integrity()`
altendky Oct 28, 2024
4357391
no default iteration order
altendky Oct 28, 2024
fc4c9d9
tidy
altendky Oct 28, 2024
3eafa7f
Merge branch 'main' into merkle_blob
altendky Oct 28, 2024
0e5f879
Merge branch 'main' into merkle_blob
altendky Nov 5, 2024
f5ee0c8
complex match -> simple if else if else
altendky Nov 5, 2024
98fc0d6
add comment for `KvId` usage
altendky Nov 5, 2024
3ffd27c
rough transition from strings to an error enum
altendky Nov 5, 2024
ac1aad8
use newtype pattern for `TreeIndex`
altendky Nov 6, 2024
a997b9b
add helpers
altendky Nov 6, 2024
1b865d9
shift try into unwrap
altendky Nov 6, 2024
a40df03
big-endian is just part of the serialization definition, not a choice
altendky Nov 6, 2024
5899478
Merge pull request #781 from Chia-Network/merkle_blob-tree_index_newtype
altendky Nov 6, 2024
c0eba9f
use unit variants for node
altendky Nov 7, 2024
e6833f2
stub
altendky Nov 7, 2024
bf2622d
tidy
altendky Nov 7, 2024
5d64a2b
`.expect_leaf()`
altendky Nov 7, 2024
efecf1b
touchup
altendky Nov 7, 2024
caacd6b
add .try_into_leaf()
altendky Nov 7, 2024
466a0c9
cleanup
altendky Nov 7, 2024
db43551
Merge pull request #782 from Chia-Network/merkle_blob-node_unit_variants
altendky Nov 12, 2024
34c0caf
newtype for `KvId`
altendky Nov 12, 2024
0a194e8
doc comment
altendky Nov 12, 2024
58c79a2
Merge pull request #784 from Chia-Network/merkle_blob-kvid_newtype
altendky Nov 12, 2024
825f7ac
macro it
altendky Nov 12, 2024
9ae331f
metadata uses streamable
altendky Nov 12, 2024
2259953
and... green
altendky Nov 13, 2024
889eb7f
cleanup
altendky Nov 13, 2024
43f34b2
max data size is 53 at this point
altendky Nov 13, 2024
22e155f
tidy
altendky Nov 13, 2024
d60c5ef
fixup python test reference blob
altendky Nov 13, 2024
b376ff3
clippy
altendky Nov 13, 2024
e29b339
stop changing streamable
altendky Nov 13, 2024
6ea2c28
less into
altendky Nov 13, 2024
9ab4599
Merge pull request #788 from Chia-Network/merkle_blob-streamable
altendky Nov 13, 2024
0391c57
Merge branch 'main' into merkle_blob
altendky Nov 25, 2024
eb98a7b
tidy
altendky Nov 25, 2024
f952ded
tidy
altendky Nov 25, 2024
ff72027
Merge branch 'main' into merkle_blob
altendky Nov 25, 2024
57de97c
remove no longer used `NodeType.from_u8()` and `.to_u8()`
altendky Nov 26, 2024
a328f27
remove all unneeded `pyclass(name = "...")`
altendky Nov 26, 2024
6eff838
make `Node.set_hash()` take ownership of the passed hash
altendky Nov 26, 2024
0be9f50
make `InternalNode` and `LeafNode` fields public
altendky Nov 26, 2024
6904bcd
`pub use merkle::*;`
altendky Nov 26, 2024
72bfcbb
update datalaer version to match
altendky Nov 26, 2024
4b0ca00
`.check_integrity().expect()` not `.unwrap()`
altendky Dec 4, 2024
c6e9844
test iterators
altendky Dec 6, 2024
7867000
remove unneeded clear
altendky Dec 6, 2024
be407fd
basic merkle blob doc comment
altendky Dec 6, 2024
8b000e5
fuzzing and first fix for corrupt data to `MerkleBlob::new()`
altendky Dec 6, 2024
e324d7e
fuzzer followup
altendky Dec 9, 2024
dc79b1a
some coverage
altendky Dec 9, 2024
6f3e9a1
fixup
altendky Dec 9, 2024
f3630c0
fixup
altendky Dec 9, 2024
2dbdab6
fixup
altendky Dec 9, 2024
02eae49
black
altendky Dec 9, 2024
7e7b6bd
exercise intopy for kvid
altendky Dec 10, 2024
658e98b
more fuzzer panics turned to errors
altendky Dec 10, 2024
e6d63a5
more
altendky Dec 10, 2024
df10170
fix
altendky Dec 10, 2024
9796bdf
ugh
altendky Dec 10, 2024
a6a1913
black
altendky Dec 10, 2024
9166646
fixup
altendky Dec 10, 2024
71147a7
fixup
altendky Dec 10, 2024
4c3003c
fixup
altendky Dec 10, 2024
384c6e9
more focused fuzzing of valid length blobs
altendky Dec 10, 2024
2141f0d
stub
altendky Dec 10, 2024
6aecf29
datalayer fuzz version
altendky Dec 10, 2024
2a0b98f
datalayer fuzz version and some cfg
altendky Dec 10, 2024
952843a
put back the integrity check on drop field
altendky Dec 10, 2024
1c88151
fix
altendky Dec 10, 2024
415450a
Merge branch 'main' into merkle_blob
altendky Dec 10, 2024
05196e4
cargo.lock catchup
altendky Dec 10, 2024
f227fb0
Merge branch 'long_lived/initial_datalayer' into merkle_blob
altendky Dec 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -54,6 +54,7 @@ implicit_hasher = "allow"
chia-bls = { 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 @@ -73,6 +74,7 @@ default = [
"bls",
"client",
"consensus",
"datalayer",
"protocol",
"ssl",
"traits",
Expand All @@ -85,6 +87,7 @@ default = [
bls = ["dep:chia-bls"]
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 @@ -104,6 +107,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-ssl = { path = "./crates/chia-ssl", version = "0.11.0" }
chia-traits = { path = "./crates/chia-traits", version = "0.15.0" }
Expand All @@ -114,6 +118,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 @@ -134,6 +139,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 @@ -153,3 +159,6 @@ blocking-threadpool = "1.0.1"
libfuzzer-sys = "0.4"
wasm-bindgen = "0.2.95"
openssl = "0.10.68"
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
Loading