diff --git a/Cargo.lock b/Cargo.lock index ed9c651d2..93d6d3184 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -612,7 +612,7 @@ version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", "syn", @@ -1165,12 +1165,6 @@ dependencies = [ "hashbrown", ] -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -1379,16 +1373,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "log" version = "0.4.22" @@ -1619,29 +1603,6 @@ dependencies = [ "sha2", ] -[[package]] -name = "parking_lot" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - [[package]] name = "pem" version = "3.0.4" @@ -1795,9 +1756,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.21.2" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8" +checksum = "3d922163ba1f79c04bc49073ba7b32fd5a8d3b76a87c955921234b8e77333c51" dependencies = [ "cfg-if", "indoc", @@ -1805,7 +1766,7 @@ dependencies = [ "libc", "memoffset", "num-bigint", - "parking_lot", + "once_cell", "portable-atomic", "pyo3-build-config", "pyo3-ffi", @@ -1815,9 +1776,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.21.2" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50" +checksum = "bc38c5feeb496c8321091edf3d63e9a6829eab4b863b4a6a65f26f3e9cc6b179" dependencies = [ "once_cell", "target-lexicon", @@ -1825,9 +1786,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.21.2" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01be5843dc60b916ab4dad1dca6d20b9b4e6ddc8e15f50c47fe6d85f1fb97403" +checksum = "94845622d88ae274d2729fcefc850e63d7a3ddff5e3ce11bd88486db9f1d357d" dependencies = [ "libc", "pyo3-build-config", @@ -1835,9 +1796,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.21.2" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77b34069fc0682e11b31dbd10321cbf94808394c56fd996796ce45217dfac53c" +checksum = "e655aad15e09b94ffdb3ce3d217acf652e26bbc37697ef012f5e5e348c716e5e" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -1847,11 +1808,11 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.21.2" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08260721f32db5e1a5beae69a55553f56b99bd0e1c3e6e0a5e8851a9d0f5a85c" +checksum = "ae1e3f09eecd94618f60a455a23def79f79eba4dc561a97324bf9ac8c6df30ce" dependencies = [ - "heck 0.4.1", + "heck", "proc-macro2", "pyo3-build-config", "quote", @@ -1931,15 +1892,6 @@ dependencies = [ "yasna", ] -[[package]] -name = "redox_syscall" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" -dependencies = [ - "bitflags", -] - [[package]] name = "regex" version = "1.10.5" @@ -2109,12 +2061,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "sec1" version = "0.7.3" diff --git a/Cargo.toml b/Cargo.toml index 0864aa2c7..a1cbc6669 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -124,7 +124,7 @@ sha2 = "0.10.8" hkdf = "0.12.0" hex = "0.4.3" thiserror = "1.0.63" -pyo3 = "0.21.2" +pyo3 = "0.22.5" arbitrary = "1.3.2" lru = "0.12.4" rand = "0.8.5" diff --git a/crates/chia-bls/src/secret_key.rs b/crates/chia-bls/src/secret_key.rs index 591787aa4..9c9998122 100644 --- a/crates/chia-bls/src/secret_key.rs +++ b/crates/chia-bls/src/secret_key.rs @@ -248,6 +248,7 @@ impl SecretKey { #[classattr] pub const PRIVATE_KEY_SIZE: usize = 32; + #[pyo3(signature = (msg, final_pk=None))] pub fn sign(&self, msg: &[u8], final_pk: Option) -> crate::Signature { match final_pk { Some(prefix) => { diff --git a/crates/chia-protocol/src/bytes.rs b/crates/chia-protocol/src/bytes.rs index aaf87b2ca..ac3e929fc 100644 --- a/crates/chia-protocol/src/bytes.rs +++ b/crates/chia-protocol/src/bytes.rs @@ -422,7 +422,7 @@ impl ChiaToPython for BytesImpl { #[cfg(feature = "py-bindings")] impl<'py, const N: usize> FromPyObject<'py> for BytesImpl { - fn extract(obj: &'py PyAny) -> PyResult { + fn extract_bound(obj: &Bound<'py, PyAny>) -> PyResult { let b = obj.downcast::()?; let slice: &[u8] = b.as_bytes(); let buf: [u8; N] = slice.try_into()?; @@ -453,7 +453,7 @@ impl ChiaToPython for Bytes { #[cfg(feature = "py-bindings")] impl<'py> FromPyObject<'py> for Bytes { - fn extract(obj: &'py PyAny) -> PyResult { + fn extract_bound(obj: &Bound<'py, PyAny>) -> PyResult { let b = obj.downcast::()?; Ok(Bytes(b.as_bytes().to_vec())) } diff --git a/crates/chia_py_streamable_macro/src/lib.rs b/crates/chia_py_streamable_macro/src/lib.rs index 1d77d83d6..9edb3ce06 100644 --- a/crates/chia_py_streamable_macro/src/lib.rs +++ b/crates/chia_py_streamable_macro/src/lib.rs @@ -47,7 +47,8 @@ pub fn py_streamable_macro(input: proc_macro::TokenStream) -> proc_macro::TokenS syn::Data::Enum(_) => { return quote! { impl<'a> pyo3::conversion::FromPyObject<'a> for #ident { - fn extract(ob: &'a pyo3::PyAny) -> pyo3::PyResult { + fn extract_bound(ob: &pyo3::Bound<'a, pyo3::PyAny>) -> pyo3::PyResult { + use pyo3::types::PyAnyMethods; let v: u8 = ob.extract()?; ::parse::(&mut std::io::Cursor::<&[u8]>::new(&[v])).map_err(|e| e.into()) } @@ -132,11 +133,13 @@ pub fn py_streamable_macro(input: proc_macro::TokenStream) -> proc_macro::TokenS #[pyo3::pymethods] impl #ident { #[pyo3(signature = (**kwargs))] - fn replace(&self, kwargs: Option<&pyo3::types::PyDict>) -> pyo3::PyResult { + fn replace(&self, kwargs: Option<&pyo3::Bound>) -> pyo3::PyResult { let mut ret = self.clone(); if let Some(kwargs) = kwargs { - let iter: pyo3::types::iter::PyDictIterator = kwargs.iter(); + use pyo3::prelude::PyDictMethods; + let iter = kwargs.iter(); for (field, value) in iter { + use pyo3::prelude::PyAnyMethods; let field = field.extract::()?; match field.as_str() { #(stringify!(#fnames_maybe_upper) => { @@ -306,7 +309,7 @@ pub fn py_streamable_macro(input: proc_macro::TokenStream) -> proc_macro::TokenS self.py_to_bytes(py) } - pub fn __deepcopy__<'p>(&self, memo: &pyo3::PyAny) -> pyo3::PyResult { + pub fn __deepcopy__<'p>(&self, memo: &pyo3::Bound) -> pyo3::PyResult { Ok(self.clone()) } @@ -323,9 +326,10 @@ pub fn py_streamable_macro(input: proc_macro::TokenStream) -> proc_macro::TokenS impl #ident { pub fn __setstate__( &mut self, - state: &pyo3::types::PyBytes, + state: &pyo3::Bound, ) -> pyo3::PyResult<()> { use chia_traits::Streamable; + use pyo3::types::PyBytesMethods; *self = Self::parse::(&mut std::io::Cursor::new(state.as_bytes()))?; diff --git a/wheel/src/api.rs b/wheel/src/api.rs index 3802c2023..581e1e73d 100644 --- a/wheel/src/api.rs +++ b/wheel/src/api.rs @@ -78,10 +78,11 @@ use chia_bls::{ #[pyfunction] pub fn compute_merkle_set_root<'p>( py: Python<'p>, - values: Vec<&'p PyBytes>, + values: Vec>, ) -> PyResult> { let mut buffer = Vec::<[u8; 32]>::with_capacity(values.len()); for b in values { + use pyo3::types::PyBytesMethods; buffer.push(b.as_bytes().try_into()?); } Ok(PyBytes::new_bound(