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

catchup: into long_lived/initial_datalayer from main @ ea4928bcf6973a7e68f97a73e058b2634bd5d804 #846

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
44 changes: 22 additions & 22 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,16 @@ clvm-traits-fuzz = { path = "./crates/clvm-traits/fuzz", version = "0.16.0" }
clvm-utils-fuzz = { path = "./crates/clvm-utils/fuzz", version = "0.16.0" }
blst = { version = "0.3.12", features = ["portable"] }
clvmr = "0.10.0"
syn = "2.0.90"
syn = "2.0.95"
quote = "1.0.32"
proc-macro2 = "1.0.92"
proc-macro-crate = "1.3.1"
anyhow = "1.0.94"
anyhow = "1.0.95"
sha2 = "0.10.8"
hkdf = "0.12.0"
hex = "0.4.3"
thiserror = "1.0.69"
pyo3 = "0.22.6"
pyo3 = "0.23.3"
arbitrary = "1.4.1"
rand = "0.8.5"
criterion = "0.5.1"
Expand All @@ -153,11 +153,11 @@ num-traits = "0.2.15"
num-bigint = "0.4.5"
text-diff = "0.4.0"
lazy_static = "1.4.0"
rcgen = "0.13.1"
rcgen = "0.13.2"
rsa = "0.9.7"
time = "0.3.22"
rusqlite = "0.31.0"
clap = "4.5.22"
clap = "4.5.23"
zstd = "0.13.2"
blocking-threadpool = "1.0.1"
libfuzzer-sys = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2024 Chia Network Inc.
Copyright 2025 Chia Network Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
32 changes: 22 additions & 10 deletions crates/chia-bls/fuzz/fuzz_targets/blspy-fidelity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ fuzz_target!(|data: &[u8]| {
print(sys.executable)
"#, None, None).unwrap();
*/
let blspy = py.import_bound("blspy").unwrap();
let blspy = py.import("blspy").unwrap();
let aug = blspy.getattr("AugSchemeMPL").unwrap();

// Generate key pair from seed
let rust_sk = SecretKey::from_seed(data);
let py_sk = aug
.call_method1(
"key_gen",
PyTuple::new_bound(py, [PyBytes::new_bound(py, data)]),
PyTuple::new(py, [PyBytes::new(py, data)]).unwrap(),
)
.unwrap();

Expand All @@ -66,10 +66,14 @@ fuzz_target!(|data: &[u8]| {
let py_sk1 = aug
.call_method1(
"derive_child_sk_unhardened",
PyTuple::new_bound(
PyTuple::new(
py,
[py_sk.clone(), idx.to_object(py).bind(py).clone().into_any()],
),
[
py_sk.clone(),
idx.into_pyobject(py).unwrap().clone().into_any(),
],
)
.unwrap(),
)
.unwrap();
assert_eq!(to_bytes(&py_sk1), rust_sk1.to_bytes());
Expand All @@ -78,7 +82,11 @@ fuzz_target!(|data: &[u8]| {
let py_pk1 = aug
.call_method1(
"derive_child_pk_unhardened",
PyTuple::new_bound(py, [py_pk, idx.to_object(py).bind(py).clone().into_any()]),
PyTuple::new(
py,
[py_pk, idx.into_pyobject(py).unwrap().clone().into_any()],
)
.unwrap(),
)
.unwrap();
assert_eq!(to_bytes(&py_pk1), rust_pk1.to_bytes());
Expand All @@ -88,7 +96,7 @@ fuzz_target!(|data: &[u8]| {
let py_sig1 = aug
.call_method1(
"sign",
PyTuple::new_bound(py, [py_sk1, PyBytes::new_bound(py, data).into_any()]),
PyTuple::new(py, [py_sk1, PyBytes::new(py, data).into_any()]).unwrap(),
)
.unwrap();
assert_eq!(to_bytes(&py_sig1), rust_sig1.to_bytes());
Expand All @@ -99,7 +107,11 @@ fuzz_target!(|data: &[u8]| {
let py_sk2 = aug
.call_method1(
"derive_child_sk",
PyTuple::new_bound(py, [py_sk, idx.to_object(py).bind(py).clone().into_any()]),
PyTuple::new(
py,
[py_sk, idx.into_pyobject(py).unwrap().clone().into_any()],
)
.unwrap(),
)
.unwrap();
assert_eq!(to_bytes(&py_sk2), rust_sk2.to_bytes());
Expand All @@ -109,7 +121,7 @@ fuzz_target!(|data: &[u8]| {
let py_sig2 = aug
.call_method1(
"sign",
PyTuple::new_bound(py, [py_sk2, PyBytes::new_bound(py, data).into_any()]),
PyTuple::new(py, [py_sk2, PyBytes::new(py, data).into_any()]).unwrap(),
)
.unwrap();
assert_eq!(to_bytes(&py_sig2), rust_sig2.to_bytes());
Expand All @@ -119,7 +131,7 @@ fuzz_target!(|data: &[u8]| {
let py_agg = aug
.call_method1(
"aggregate",
PyTuple::new_bound(py, [PyList::new_bound(py, [py_sig1, py_sig2])]),
PyTuple::new(py, [PyList::new(py, [py_sig1, py_sig2]).unwrap()]).unwrap(),
)
.unwrap();
assert_eq!(to_bytes(&py_agg), rust_agg.to_bytes());
Expand Down
17 changes: 10 additions & 7 deletions crates/chia-bls/src/bls_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ impl BlsCache {
sig: &Signature,
) -> PyResult<bool> {
let pks = pks
.iter()?
.try_iter()?
.map(|item| item?.extract())
.collect::<PyResult<Vec<PublicKey>>>()?;

let msgs = msgs
.iter()?
.try_iter()?
.map(|item| item?.extract())
.collect::<PyResult<Vec<PyBackedBytes>>>()?;

Expand All @@ -184,18 +184,21 @@ impl BlsCache {
pub fn py_items(&self, py: pyo3::Python<'_>) -> PyResult<PyObject> {
use pyo3::prelude::*;
use pyo3::types::PyBytes;
let ret = PyList::empty_bound(py);
let ret = PyList::empty(py);
let c = self.cache.lock().expect("cache");
for (key, value) in &c.items {
ret.append((PyBytes::new_bound(py, key), value.clone().into_py(py)))?;
ret.append((
PyBytes::new(py, key),
value.clone().into_pyobject(py)?.into_any(),
))?;
}
Ok(ret.into())
}

#[pyo3(name = "update")]
pub fn py_update(&self, other: &Bound<'_, PySequence>) -> PyResult<()> {
let mut c = self.cache.lock().expect("cache");
for item in other.borrow().iter()? {
for item in other.borrow().try_iter()? {
let (key, value): (Vec<u8>, GTElement) = item?.extract()?;
c.put(
key.try_into()
Expand All @@ -209,11 +212,11 @@ impl BlsCache {
#[pyo3(name = "evict")]
pub fn py_evict(&self, pks: &Bound<'_, PyList>, msgs: &Bound<'_, PyList>) -> PyResult<()> {
let pks = pks
.iter()?
.try_iter()?
.map(|item| item?.extract())
.collect::<PyResult<Vec<PublicKey>>>()?;
let msgs = msgs
.iter()?
.try_iter()?
.map(|item| item?.extract())
.collect::<PyResult<Vec<PyBackedBytes>>>()?;
self.evict(pks.into_iter().zip(msgs));
Expand Down
5 changes: 4 additions & 1 deletion crates/chia-bls/src/gtelement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ mod pybindings {
impl ToJsonDict for GTElement {
fn to_json_dict(&self, py: Python<'_>) -> PyResult<PyObject> {
let bytes = self.to_bytes();
Ok(("0x".to_string() + &hex::encode(bytes)).into_py(py))
Ok(("0x".to_string() + &hex::encode(bytes))
.into_pyobject(py)?
.into_any()
.unbind())
}
}

Expand Down
22 changes: 14 additions & 8 deletions crates/chia-bls/src/public_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,10 @@ mod pybindings {
impl ToJsonDict for PublicKey {
fn to_json_dict(&self, py: Python<'_>) -> PyResult<PyObject> {
let bytes = self.to_bytes();
Ok(("0x".to_string() + &hex::encode(bytes)).into_py(py))
Ok(("0x".to_string() + &hex::encode(bytes))
.into_pyobject(py)?
.into_any()
.unbind())
}
}

Expand Down Expand Up @@ -734,7 +737,7 @@ mod tests {
mod pytests {
use super::*;
use crate::SecretKey;
use pyo3::{IntoPy, Python};
use pyo3::Python;
use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
use rstest::rstest;
Expand All @@ -750,7 +753,7 @@ mod pytests {
let pk = sk.public_key();
Python::with_gil(|py| {
let string = pk.to_json_dict(py).expect("to_json_dict");
let py_class = py.get_type_bound::<PublicKey>();
let py_class = py.get_type::<PublicKey>();
let pk2: PublicKey = PublicKey::from_json_dict(&py_class, py, string.bind(py))
.unwrap()
.extract(py)
Expand All @@ -769,11 +772,14 @@ mod pytests {
fn test_json_dict(#[case] input: &str, #[case] msg: &str) {
pyo3::prepare_freethreaded_python();
Python::with_gil(|py| {
let py_class = py.get_type_bound::<PublicKey>();
let err =
PublicKey::from_json_dict(&py_class, py, input.to_string().into_py(py).bind(py))
.unwrap_err();
assert_eq!(err.value_bound(py).to_string(), msg.to_string());
let py_class = py.get_type::<PublicKey>();
let err = PublicKey::from_json_dict(
&py_class,
py,
&input.to_string().into_pyobject(py).unwrap().into_any(),
)
.unwrap_err();
assert_eq!(err.value(py).to_string(), msg.to_string());
});
}
}
Loading
Loading