diff --git a/Cargo.lock b/Cargo.lock index f89af024b..cb7e50196 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -287,9 +287,9 @@ dependencies = [ [[package]] name = "chia-bls" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba003303bda3019f2fe94e5478555a96addff1d6a1ea84bfe207b3f075cd8420" +checksum = "1cbbce0107fa3911890f1a204a147c6d07116687658a6af95690e64fc21ff782" dependencies = [ "anyhow", "arbitrary", @@ -304,7 +304,7 @@ dependencies = [ [[package]] name = "chia-bls" -version = "0.4.0" +version = "0.5.0" dependencies = [ "anyhow", "arbitrary", @@ -326,14 +326,14 @@ dependencies = [ name = "chia-bls-fuzz" version = "0.0.0" dependencies = [ - "chia-bls 0.4.0", + "chia-bls 0.5.0", "libfuzzer-sys", "pyo3", ] [[package]] name = "chia-client" -version = "0.4.0" +version = "0.5.0" dependencies = [ "chia-protocol", "chia-traits 0.5.0", @@ -363,7 +363,7 @@ name = "chia-protocol" version = "0.5.0" dependencies = [ "arbitrary", - "chia-bls 0.4.0", + "chia-bls 0.5.0", "chia-traits 0.5.0", "chia_py_streamable_macro", "chia_streamable_macro 0.3.0", @@ -408,7 +408,7 @@ name = "chia-tools" version = "0.5.0" dependencies = [ "chia", - "chia-bls 0.4.0", + "chia-bls 0.5.0", "chia-protocol", "chia-traits 0.5.0", "chia-wallet", @@ -452,7 +452,7 @@ name = "chia-wallet" version = "0.5.0" dependencies = [ "arbitrary", - "chia-bls 0.4.0", + "chia-bls 0.5.0", "chia-protocol", "clvm-traits", "clvm-utils", @@ -465,7 +465,7 @@ dependencies = [ [[package]] name = "chia-wallet-fuzz" -version = "0.4.0" +version = "0.5.0" dependencies = [ "chia-wallet", "clvm-traits", @@ -597,10 +597,11 @@ dependencies = [ [[package]] name = "clvm-traits" -version = "0.3.3" +version = "0.5.0" dependencies = [ - "chia-bls 0.4.0", + "chia-bls 0.5.0", "clvm-derive", + "clvmr", "hex", "hex-literal", "num-bigint", @@ -610,7 +611,7 @@ dependencies = [ [[package]] name = "clvm-utils" -version = "0.4.0" +version = "0.5.0" dependencies = [ "clvm-traits", "clvmr", @@ -631,12 +632,11 @@ dependencies = [ [[package]] name = "clvmr" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "797ae1b4229262bd4987523a8f75e49d4800338db5feb2b39612edbfa8934186" +checksum = "9703ae71967bce4aa064bcdcb4103b065b2e40ae710729f42697e94bff43553f" dependencies = [ - "chia-bls 0.3.3", - "clvm-traits", + "chia-bls 0.4.0", "k256", "lazy_static", "num-bigint", diff --git a/Cargo.toml b/Cargo.toml index 87581d930..aeaf4fe98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,12 +37,12 @@ repository = "https://github.com/Chia-Network/chia_rs/" py-bindings = ["dep:pyo3"] [dependencies] -clvmr = "0.4.0" +clvmr = "0.5.0" hex = "0.4.3" pyo3 = { version = ">=0.19.0", optional = true } -clvm-utils = { version = "0.4.0", path = "clvm-utils" } +clvm-utils = { version = "0.5.0", path = "clvm-utils" } chia-traits = { version = "0.5.0", path = "chia-traits" } -clvm-traits = { version = "0.3.3", path = "clvm-traits" } +clvm-traits = { version = "0.5.0", path = "clvm-traits" } clvm-derive = { version = "0.2.14", path = "clvm-derive" } chia-protocol = { version = "0.5.0", path = "chia-protocol" } chia-wallet = { version = "0.5.0", path = "chia-wallet" } diff --git a/chia-bls/Cargo.toml b/chia-bls/Cargo.toml index 68c3ed6b3..56caac286 100644 --- a/chia-bls/Cargo.toml +++ b/chia-bls/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chia-bls" -version = "0.4.0" +version = "0.5.0" edition = "2021" license = "Apache-2.0" description = "BLS signature, verification and aggregation funcions for the Chia blockchain" diff --git a/chia-client/Cargo.toml b/chia-client/Cargo.toml index 8cd6e9240..ab3373421 100644 --- a/chia-client/Cargo.toml +++ b/chia-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chia-client" -version = "0.4.0" +version = "0.5.0" edition = "2021" license = "Apache-2.0" description = "Chia light client and async peer connections." diff --git a/chia-protocol/Cargo.toml b/chia-protocol/Cargo.toml index 7ebc59dd9..664d21421 100644 --- a/chia-protocol/Cargo.toml +++ b/chia-protocol/Cargo.toml @@ -17,11 +17,11 @@ sha2 = "0.10.8" hex = "0.4.3" chia_streamable_macro = { version = "0.3.0", path = "../chia_streamable_macro" } chia_py_streamable_macro = { version = "0.5.0", path = "../chia_py_streamable_macro", optional = true } -clvmr = "0.4.0" +clvmr = "0.5.0" chia-traits = { version = "0.5.0", path = "../chia-traits" } -clvm-traits = { version = "0.3.3", path = "../clvm-traits", features = ["derive"] } -clvm-utils = { version = "0.4.0", path = "../clvm-utils" } -chia-bls = { version = "0.4.0", path = "../chia-bls" } +clvm-traits = { version = "0.5.0", path = "../clvm-traits", features = ["derive"] } +clvm-utils = { version = "0.5.0", path = "../clvm-utils" } +chia-bls = { version = "0.5.0", path = "../chia-bls" } arbitrary = { version = "1.3.0", features = ["derive"] } [dev-dependencies] diff --git a/chia-protocol/fuzz/Cargo.toml b/chia-protocol/fuzz/Cargo.toml index 29a4ec74b..bf69c3602 100644 --- a/chia-protocol/fuzz/Cargo.toml +++ b/chia-protocol/fuzz/Cargo.toml @@ -10,7 +10,7 @@ cargo-fuzz = true [dependencies] libfuzzer-sys = "0.4" -clvmr = "0.4.0" +clvmr = "0.5.0" chia-traits = { path = "../../chia-traits" } clvm-traits = { path = "../../clvm-traits" } arbitrary = { version = "=1.3.0" } diff --git a/chia-protocol/src/program.rs b/chia-protocol/src/program.rs index 8fbf3fbec..0dd458e11 100644 --- a/chia-protocol/src/program.rs +++ b/chia-protocol/src/program.rs @@ -1,7 +1,7 @@ use crate::bytes::Bytes; use chia_traits::chia_error::{Error, Result}; use chia_traits::Streamable; -use clvm_traits::{FromClvmError, ToClvmError}; +use clvm_traits::{FromClvmError, FromNodePtr, ToClvmError, ToNodePtr}; use clvmr::allocator::NodePtr; use clvmr::cost::Cost; use clvmr::reduction::EvalErr; @@ -10,7 +10,7 @@ use clvmr::serde::{ node_from_bytes, node_from_bytes_backrefs, node_to_bytes, serialized_length_from_bytes, serialized_length_from_bytes_trusted, }; -use clvmr::{Allocator, ChiaDialect, FromNodePtr, ToNodePtr}; +use clvmr::{Allocator, ChiaDialect}; use sha2::{Digest, Sha256}; use std::io::Cursor; use std::ops::Deref; @@ -440,7 +440,7 @@ impl Program { <( clvm_traits::MatchByte<4>, (clvm_traits::match_quote!(NodePtr), (NodePtr, ())), - ) as clvmr::FromNodePtr>::from_node_ptr(&a, args) + ) as clvm_traits::FromNodePtr>::from_node_ptr(&a, args) .map_err(|error| PyErr::new::(error.to_string()))?; curried_args.push(arg); args = rest; diff --git a/chia-tools/Cargo.toml b/chia-tools/Cargo.toml index c1c0b3048..092db360e 100644 --- a/chia-tools/Cargo.toml +++ b/chia-tools/Cargo.toml @@ -9,14 +9,14 @@ homepage = "https://github.com/Chia-Network/chia_rs/chia-tools" repository = "https://github.com/Chia-Network/chia_rs/chia-tools" [dependencies] -chia-protocol = { version = "0.5.0", path = "../chia-protocol" } -chia-traits = { path = "../chia-traits" } -clvm-utils = { path = "../clvm-utils" } -clvm-traits = { version = "=0.3.3", path = "../clvm-traits" } +chia-protocol = { version = "=0.5.0", path = "../chia-protocol" } +chia-traits = { version = "=0.5.0", path = "../chia-traits" } +clvm-utils = { version = "=0.5.0", path = "../clvm-utils" } +clvm-traits = { version = "=0.5.0", path = "../clvm-traits" } chia-wallet = { version = "=0.5.0", path = "../chia-wallet" } -chia-bls = { version = "0.4.0", path = "../chia-bls" } -clvmr = { version = "0.4.0", features = ["counters"] } -chia = { version = "0.5.0", path = ".." } +chia-bls = { version = "=0.5.0", path = "../chia-bls" } +clvmr = { version = "0.5.0", features = ["counters"] } +chia = { version = "=0.5.0", path = ".." } rusqlite = { version = "=0.30.0", features = ["bundled"] } clap = { version = "=4.3.9", features = ["derive"] } zstd = "=0.12.3" diff --git a/chia-tools/src/bin/fast-forward-spend.rs b/chia-tools/src/bin/fast-forward-spend.rs index 23118263f..6faa5b964 100644 --- a/chia-tools/src/bin/fast-forward-spend.rs +++ b/chia-tools/src/bin/fast-forward-spend.rs @@ -5,9 +5,9 @@ use chia::fast_forward::fast_forward_singleton; use chia_protocol::bytes::Bytes32; use chia_protocol::{coin::Coin, coin_spend::CoinSpend, program::Program}; use chia_traits::streamable::Streamable; +use clvm_traits::{FromNodePtr, ToNodePtr}; use clvm_utils::tree_hash; use clvmr::allocator::Allocator; -use clvmr::{FromNodePtr, ToNodePtr}; #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] diff --git a/chia-tools/src/bin/gen-corpus.rs b/chia-tools/src/bin/gen-corpus.rs index b2f9cf5d5..a5709db88 100644 --- a/chia-tools/src/bin/gen-corpus.rs +++ b/chia-tools/src/bin/gen-corpus.rs @@ -10,10 +10,10 @@ use chia_traits::streamable::Streamable; use chia_protocol::{Bytes32, Coin, CoinSpend, Program, SpendBundle}; use chia_wallet::singleton::SINGLETON_TOP_LAYER_PUZZLE_HASH; -use clvm_traits::FromClvm; +use clvm_traits::{FromClvm, FromNodePtr}; use clvm_utils::{tree_hash, CurriedProgram}; use clvmr::allocator::NodePtr; -use clvmr::{Allocator, FromNodePtr}; +use clvmr::Allocator; use std::thread::available_parallelism; use threadpool::ThreadPool; diff --git a/chia-tools/src/bin/run-spend.rs b/chia-tools/src/bin/run-spend.rs index 62bfeffaa..4ec76a4e4 100644 --- a/chia-tools/src/bin/run-spend.rs +++ b/chia-tools/src/bin/run-spend.rs @@ -2,10 +2,9 @@ use chia::gen::conditions::Condition; use chia_protocol::Bytes32; use chia_traits::Streamable; use clap::Parser; -use clvm_traits::{FromClvm, ToClvm}; +use clvm_traits::{FromClvm, ToClvm, ToNodePtr}; use clvm_utils::tree_hash; use clvm_utils::CurriedProgram; -use clvmr::ToNodePtr; use clvmr::{allocator::NodePtr, Allocator}; use hex_literal::hex; diff --git a/chia-wallet/Cargo.toml b/chia-wallet/Cargo.toml index 473a03473..92723c992 100644 --- a/chia-wallet/Cargo.toml +++ b/chia-wallet/Cargo.toml @@ -9,13 +9,13 @@ homepage = "https://github.com/Chia-Network/chia_rs/chia-wallet/" repository = "https://github.com/Chia-Network/chia_rs/chia-wallet/" [dependencies] -clvmr = "0.4.0" +clvmr = "0.5.0" sha2 = "0.10.8" num-bigint = "0.4.3" hex-literal = "0.4.1" -clvm-utils = { version = "0.4.0", path = "../clvm-utils" } -clvm-traits = { version = "0.3.3", path = "../clvm-traits", features = ["chia-bls"] } -chia-bls = { version = "0.4.0", path = "../chia-bls" } +clvm-utils = { version = "0.5.0", path = "../clvm-utils" } +clvm-traits = { version = "0.5.0", path = "../clvm-traits", features = ["chia-bls"] } +chia-bls = { version = "0.5.0", path = "../chia-bls" } chia-protocol = { version = "0.5.0", path = "../chia-protocol" } arbitrary = "1.3.0" diff --git a/chia-wallet/fuzz/Cargo.toml b/chia-wallet/fuzz/Cargo.toml index de668856a..7efdca4b5 100644 --- a/chia-wallet/fuzz/Cargo.toml +++ b/chia-wallet/fuzz/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chia-wallet-fuzz" -version = "0.4.0" +version = "0.5.0" authors = ["Automatically generated"] publish = false edition = "2021" @@ -10,10 +10,10 @@ cargo-fuzz = true [dependencies] libfuzzer-sys = "0.4" -clvmr = "0.4.0" +clvmr = "0.5.0" pyo3 = { version = ">=0.19.0", features = ["auto-initialize"]} chia-wallet = { path = ".." } -clvm-traits = { version = "=0.3.3", path = "../../clvm-traits" } +clvm-traits = { version = "=0.5.0", path = "../../clvm-traits" } [[bin]] name = "roundtrip" diff --git a/chia-wallet/src/puzzles/cat.rs b/chia-wallet/src/puzzles/cat.rs index 7e527b035..d4d4f1c37 100644 --- a/chia-wallet/src/puzzles/cat.rs +++ b/chia-wallet/src/puzzles/cat.rs @@ -193,8 +193,9 @@ pub static CAT_PUZZLE_HASH_V1: [u8; 32] = hex!( #[cfg(test)] mod tests { + use clvm_traits::ToNodePtr; use clvm_utils::{tree_hash, CurriedProgram}; - use clvmr::{serde::node_from_bytes, Allocator, ToNodePtr}; + use clvmr::{serde::node_from_bytes, Allocator}; use super::*; diff --git a/chia-wallet/src/puzzles/standard.rs b/chia-wallet/src/puzzles/standard.rs index 257066185..d4749d450 100644 --- a/chia-wallet/src/puzzles/standard.rs +++ b/chia-wallet/src/puzzles/standard.rs @@ -55,8 +55,9 @@ pub static DEFAULT_HIDDEN_PUZZLE_HASH: [u8; 32] = hex!( #[cfg(test)] mod tests { + use clvm_traits::ToNodePtr; use clvm_utils::{tree_hash, CurriedProgram}; - use clvmr::{serde::node_from_bytes, Allocator, ToNodePtr}; + use clvmr::{serde::node_from_bytes, Allocator}; use super::*; diff --git a/clvm-traits/Cargo.toml b/clvm-traits/Cargo.toml index 6b36a9e4d..cb1e2a810 100644 --- a/clvm-traits/Cargo.toml +++ b/clvm-traits/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clvm-traits" -version = "0.3.3" +version = "0.5.0" edition = "2021" license = "Apache-2.0" description = "Traits for encoding and decoding CLVM objects." @@ -18,8 +18,9 @@ py-bindings = ["dep:pyo3"] [dependencies] pyo3 = { version = ">=0.19.0", optional = true } +clvmr = "0.5.0" clvm-derive = { version = "0.2.14", path = "../clvm-derive", optional = true } -chia-bls = { version = "0.4.0", path = "../chia-bls", optional = true } +chia-bls = { version = "0.5.0", path = "../chia-bls", optional = true } num-bigint = "0.4.3" thiserror = "1.0.44" diff --git a/clvm-traits/docs/derive_macros.md b/clvm-traits/docs/derive_macros.md index 12682087d..96f184366 100644 --- a/clvm-traits/docs/derive_macros.md +++ b/clvm-traits/docs/derive_macros.md @@ -24,7 +24,7 @@ For example: - `(A, B, C)` is encoded as `(A . (B . C))`, since every cons-pair must contain two values. - `(A, B, C, D)` is encoded as `(A . (B . (C . D)))` for the same reason as above. -```rust compile_fail +```rust use clvmr::Allocator; use clvm_traits::{ToClvm, FromClvm}; @@ -59,7 +59,7 @@ For example: Note that the following code is for example purposes only and is not indicative of how to create a secure program. Using a password like shown in this example is an insecure method of locking coins, but it's effective for learning. -```rust compile_fail +```rust use clvmr::Allocator; use clvm_traits::{ToClvm, FromClvm}; @@ -91,7 +91,7 @@ You can read more about currying on the [Chia blockchain documentation](https:// Note that the following code is for example purposes only and is not indicative of how to create a secure program. Using a password like shown in this example is an insecure method of locking coins, but it's effective for learning. -```rust compile_fail +```rust use clvmr::Allocator; use clvm_traits::{ToClvm, FromClvm}; @@ -121,7 +121,7 @@ For convenience, this is the behavior when deriving `ToClvm` and `FromClvm` for In this example, since the `tuple` representation is used and the only values are the discriminants, the variants will be encoded as an atom. Discriminants default to the `isize` type and the first value is `0`. Subsequent values are incremented by `1` by default. -```rust compile_fail +```rust use clvmr::Allocator; use clvm_traits::{ToClvm, FromClvm}; @@ -145,7 +145,7 @@ It's possible to override both the type of the discriminator, and the value. The `#[repr(...)]` attribute is used by the Rust compiler to allow overriding the discriminator type. As such, this attribute is also used to change the underlying type used to serialize and deserialize discriminator values. -```rust compile_fail +```rust use clvmr::Allocator; use clvm_traits::{ToClvm, FromClvm}; @@ -169,7 +169,7 @@ assert_eq!(Status::from_clvm(a, ptr).unwrap(), status); Of course, you can also include fields on enum variants, and they will be serialized after the discriminator accordingly. It's also possible to override the representation of an individual variant, as if it were a standalone struct. -```rust compile_fail +```rust use clvmr::Allocator; use clvm_traits::{ToClvm, FromClvm}; @@ -199,7 +199,7 @@ This is what `#[clvm(untagged)]` allows you to do. However, due to current limit Note that if there is any ambiguity, the first variant which matches a value will be the resulting value. For example, if both `A` and `B` are in that order and are the same type, if you serialize a value of `B`, it will be deserialized as `A`. -```rust compile_fail +```rust use clvmr::Allocator; use clvm_traits::{ToClvm, FromClvm}; diff --git a/clvm-traits/src/clvm_decoder.rs b/clvm-traits/src/clvm_decoder.rs index 57bd512c8..83ae96554 100644 --- a/clvm-traits/src/clvm_decoder.rs +++ b/clvm-traits/src/clvm_decoder.rs @@ -1,4 +1,6 @@ -use crate::FromClvmError; +use clvmr::{allocator::SExp, Allocator, NodePtr}; + +use crate::{FromClvm, FromClvmError}; pub trait ClvmDecoder { type Node: Clone; @@ -13,3 +15,50 @@ pub trait ClvmDecoder { node.clone() } } + +impl ClvmDecoder for Allocator { + type Node = NodePtr; + + fn decode_atom(&self, node: &Self::Node) -> Result<&[u8], FromClvmError> { + if let SExp::Atom = self.sexp(*node) { + Ok(self.atom(*node)) + } else { + Err(FromClvmError::ExpectedAtom) + } + } + + fn decode_pair(&self, node: &Self::Node) -> Result<(Self::Node, Self::Node), FromClvmError> { + if let SExp::Pair(first, rest) = self.sexp(*node) { + Ok((first, rest)) + } else { + Err(FromClvmError::ExpectedPair) + } + } +} + +pub trait FromNodePtr { + fn from_node_ptr(a: &Allocator, node: NodePtr) -> Result + where + Self: Sized; +} + +impl FromNodePtr for T +where + T: FromClvm, +{ + fn from_node_ptr(a: &Allocator, node: NodePtr) -> Result + where + Self: Sized, + { + T::from_clvm(a, node) + } +} + +impl FromClvm for NodePtr { + fn from_clvm( + _decoder: &impl ClvmDecoder, + node: NodePtr, + ) -> Result { + Ok(node) + } +} diff --git a/clvm-traits/src/clvm_encoder.rs b/clvm-traits/src/clvm_encoder.rs index dc3ebce9b..609b750a0 100644 --- a/clvm-traits/src/clvm_encoder.rs +++ b/clvm-traits/src/clvm_encoder.rs @@ -1,4 +1,6 @@ -use crate::ToClvmError; +use clvmr::{Allocator, NodePtr}; + +use crate::{ToClvm, ToClvmError}; pub trait ClvmEncoder { type Node: Clone; @@ -17,3 +19,41 @@ pub trait ClvmEncoder { node.clone() } } + +impl ClvmEncoder for Allocator { + type Node = NodePtr; + + fn encode_atom(&mut self, bytes: &[u8]) -> Result { + self.new_atom(bytes).or(Err(ToClvmError::OutOfMemory)) + } + + fn encode_pair( + &mut self, + first: Self::Node, + rest: Self::Node, + ) -> Result { + self.new_pair(first, rest).or(Err(ToClvmError::OutOfMemory)) + } +} + +pub trait ToNodePtr { + fn to_node_ptr(&self, a: &mut Allocator) -> Result; +} + +impl ToNodePtr for T +where + T: ToClvm, +{ + fn to_node_ptr(&self, a: &mut Allocator) -> Result { + self.to_clvm(a) + } +} + +impl ToClvm for NodePtr { + fn to_clvm( + &self, + _encoder: &mut impl ClvmEncoder, + ) -> Result { + Ok(*self) + } +} diff --git a/clvm-traits/src/from_clvm.rs b/clvm-traits/src/from_clvm.rs index d533744ad..33ebe0131 100644 --- a/clvm-traits/src/from_clvm.rs +++ b/clvm-traits/src/from_clvm.rs @@ -184,74 +184,79 @@ impl FromClvm for chia_bls::Signature { #[cfg(test)] mod tests { - use crate::tests::{str_to_node, TestAllocator, TestNode}; + use clvmr::{serde::node_from_bytes, Allocator, NodePtr}; - use super::FromClvm; use super::*; - fn decode(hex: &str) -> Result + fn decode(a: &mut Allocator, hex: &str) -> Result where - T: FromClvm, + T: FromClvm, { - let mut a = TestAllocator::new(); - let (rest, actual) = str_to_node(&mut a, hex); - assert_eq!(rest, ""); - T::from_clvm(&a, actual) + let bytes = hex::decode(hex).unwrap(); + let actual = node_from_bytes(a, &bytes).unwrap(); + T::from_clvm(a, actual) } #[test] fn test_primitives() { - assert_eq!(decode("NIL"), Ok(0u8)); - assert_eq!(decode("NIL"), Ok(0i8)); - assert_eq!(decode("05"), Ok(5u8)); - assert_eq!(decode("05"), Ok(5u32)); - assert_eq!(decode("05"), Ok(5i32)); - assert_eq!(decode("e5"), Ok(-27i32)); - assert_eq!(decode("NIL"), Ok(-0)); - assert_eq!(decode("80"), Ok(-128i8)); + let a = &mut Allocator::new(); + assert_eq!(decode(a, "80"), Ok(0u8)); + assert_eq!(decode(a, "80"), Ok(0i8)); + assert_eq!(decode(a, "05"), Ok(5u8)); + assert_eq!(decode(a, "05"), Ok(5u32)); + assert_eq!(decode(a, "05"), Ok(5i32)); + assert_eq!(decode(a, "81e5"), Ok(-27i32)); + assert_eq!(decode(a, "80"), Ok(-0)); + assert_eq!(decode(a, "8180"), Ok(-128i8)); } #[test] fn test_pair() { - assert_eq!(decode("( 05 02"), Ok((5, 2))); - assert_eq!(decode("( b8 ( 016009 NIL"), Ok((-72, (90121, ())))); + let a = &mut Allocator::new(); + assert_eq!(decode(a, "ff0502"), Ok((5, 2))); + assert_eq!(decode(a, "ff81b8ff8301600980"), Ok((-72, (90121, ())))); assert_eq!( - decode("( ( NIL ( NIL ( NIL ( ( NIL ( NIL ( NIL NIL NIL NIL"), + decode(a, "ffff80ff80ff80ffff80ff80ff80808080"), Ok((((), ((), ((), (((), ((), ((), ()))), ())))), ())) ); } #[test] fn test_nil() { - assert_eq!(decode("NIL"), Ok(())); + let a = &mut Allocator::new(); + assert_eq!(decode(a, "80"), Ok(())); } #[test] fn test_array() { - assert_eq!(decode("( 01 ( 02 ( 03 ( 04 NIL"), Ok([1, 2, 3, 4])); - assert_eq!(decode("NIL"), Ok([] as [i32; 0])); + let a = &mut Allocator::new(); + assert_eq!(decode(a, "ff01ff02ff03ff0480"), Ok([1, 2, 3, 4])); + assert_eq!(decode(a, "80"), Ok([] as [i32; 0])); } #[test] fn test_vec() { - assert_eq!(decode("( 01 ( 02 ( 03 ( 04 NIL"), Ok(vec![1, 2, 3, 4])); - assert_eq!(decode("NIL"), Ok(Vec::::new())); + let a = &mut Allocator::new(); + assert_eq!(decode(a, "ff01ff02ff03ff0480"), Ok(vec![1, 2, 3, 4])); + assert_eq!(decode(a, "80"), Ok(Vec::::new())); } #[test] fn test_option() { - assert_eq!(decode("68656c6c6f"), Ok(Some("hello".to_string()))); - assert_eq!(decode("NIL"), Ok(None::)); + let a = &mut Allocator::new(); + assert_eq!(decode(a, "8568656c6c6f"), Ok(Some("hello".to_string()))); + assert_eq!(decode(a, "80"), Ok(None::)); // Empty strings get decoded as None instead, since both values are represented by nil bytes. // This could be considered either intended behavior or not, depending on the way it's used. - assert_ne!(decode("NIL"), Ok(Some("".to_string()))); + assert_ne!(decode(a, "80"), Ok(Some("".to_string()))); } #[test] fn test_string() { - assert_eq!(decode("68656c6c6f"), Ok("hello".to_string())); - assert_eq!(decode("NIL"), Ok("".to_string())); + let a = &mut Allocator::new(); + assert_eq!(decode(a, "8568656c6c6f"), Ok("hello".to_string())); + assert_eq!(decode(a, "80"), Ok("".to_string())); } #[cfg(feature = "chia-bls")] @@ -260,13 +265,21 @@ mod tests { use chia_bls::PublicKey; use hex_literal::hex; - let valid_bytes = hex!("b8f7dd239557ff8c49d338f89ac1a258a863fa52cd0a502e3aaae4b6738ba39ac8d982215aa3fa16bc5f8cb7e44b954d"); + let a = &mut Allocator::new(); + + let bytes = hex!( + " + b8f7dd239557ff8c49d338f89ac1a258a863fa52cd0a502e + 3aaae4b6738ba39ac8d982215aa3fa16bc5f8cb7e44b954d + " + ); + assert_eq!( - decode(&hex::encode(valid_bytes)), - Ok(PublicKey::from_bytes(&valid_bytes).unwrap()) + decode(a, "b0b8f7dd239557ff8c49d338f89ac1a258a863fa52cd0a502e3aaae4b6738ba39ac8d982215aa3fa16bc5f8cb7e44b954d"), + Ok(PublicKey::from_bytes(&bytes).unwrap()) ); assert_eq!( - decode::("68656c6c6f"), + decode::(a, "8568656c6c6f"), Err(FromClvmError::WrongAtomLength { expected: 48, found: 5 @@ -280,13 +293,21 @@ mod tests { use chia_bls::Signature; use hex_literal::hex; - let valid_bytes = hex!("a3994dc9c0ef41a903d3335f0afe42ba16c88e7881706798492da4a1653cd10c69c841eeb56f44ae005e2bad27fb7ebb16ce8bbfbd708ea91dd4ff24f030497b50e694a8270eccd07dbc206b8ffe0c34a9ea81291785299fae8206a1e1bbc1d1"); + let a = &mut Allocator::new(); + + let bytes = hex!( + " + a3994dc9c0ef41a903d3335f0afe42ba16c88e7881706798492da4a1653cd10c + 69c841eeb56f44ae005e2bad27fb7ebb16ce8bbfbd708ea91dd4ff24f030497b + 50e694a8270eccd07dbc206b8ffe0c34a9ea81291785299fae8206a1e1bbc1d1 + " + ); assert_eq!( - decode(&hex::encode(valid_bytes)), - Ok(Signature::from_bytes(&valid_bytes).unwrap()) + decode(a, "c060a3994dc9c0ef41a903d3335f0afe42ba16c88e7881706798492da4a1653cd10c69c841eeb56f44ae005e2bad27fb7ebb16ce8bbfbd708ea91dd4ff24f030497b50e694a8270eccd07dbc206b8ffe0c34a9ea81291785299fae8206a1e1bbc1d1"), + Ok(Signature::from_bytes(&bytes).unwrap()) ); assert_eq!( - decode::("68656c6c6f"), + decode::(a, "8568656c6c6f"), Err(FromClvmError::WrongAtomLength { expected: 96, found: 5 diff --git a/clvm-traits/src/lib.rs b/clvm-traits/src/lib.rs index 6673d3484..2686c8ed6 100644 --- a/clvm-traits/src/lib.rs +++ b/clvm-traits/src/lib.rs @@ -26,146 +26,27 @@ pub use match_byte::*; pub use to_clvm::*; pub use wrappers::*; -#[cfg(test)] -pub mod tests { - extern crate self as clvm_traits; - - use super::*; - - #[derive(Clone)] - pub enum TestNode { - Atom(usize), - Pair(Box, Box), - } - - #[derive(Default)] - pub struct TestAllocator { - atoms: Vec>, - } - - impl TestAllocator { - pub fn new() -> Self { - TestAllocator::default() - } - - fn new_atom(&mut self, buf: &[u8]) -> TestNode { - let idx = self.atoms.len(); - self.atoms.push(buf.to_vec()); - TestNode::Atom(idx) - } - - fn atom(&self, idx: usize) -> &[u8] { - self.atoms[idx].as_slice() - } - } - - pub fn node_eq(a: &TestAllocator, left: &TestNode, right: &TestNode) -> bool { - match (left, right) { - (TestNode::Atom(l), TestNode::Atom(r)) => a.atom(*l) == a.atom(*r), - (TestNode::Pair(l1, r1), TestNode::Pair(l2, r2)) => { - node_eq(a, l1, l2) && node_eq(a, r1, r2) - } - _ => false, - } - } - - pub fn node_to_str(a: &TestAllocator, input: &TestNode) -> String { - match input { - TestNode::Atom(v) => { - let atom = a.atom(*v); - if atom.is_empty() { - "NIL".to_owned() - } else { - hex::encode(atom) - } - } - TestNode::Pair(l, r) => format!("( {} {}", node_to_str(a, l), node_to_str(a, r)), - } - } - - pub fn str_to_node<'a>(a: &mut TestAllocator, input: &'a str) -> (&'a str, TestNode) { - let (first, rest) = if let Some((f, r)) = input.split_once(' ') { - (f, r) - } else { - (input, "") - }; - - println!("\"{first}\" | \"{rest}\""); - if first == "(" { - let (rest, left) = str_to_node(a, rest); - let (rest, right) = str_to_node(a, rest); - (rest, TestNode::Pair(Box::new(left), Box::new(right))) - } else if first == "NIL" { - (rest, a.new_atom(&[])) - } else { - ( - rest, - a.new_atom(hex::decode(first).expect("invalid hex").as_slice()), - ) - } - } - - impl ClvmDecoder for TestAllocator { - type Node = TestNode; - - fn decode_atom(&self, node: &Self::Node) -> Result<&[u8], FromClvmError> { - match &node { - TestNode::Atom(v) => Ok(self.atom(*v)), - _ => Err(FromClvmError::ExpectedAtom), - } - } - - fn decode_pair( - &self, - node: &Self::Node, - ) -> Result<(Self::Node, Self::Node), FromClvmError> { - match &node { - TestNode::Pair(l, r) => Ok((*l.clone(), *r.clone())), - _ => Err(FromClvmError::ExpectedPair), - } - } - - fn clone_node(&self, node: &Self::Node) -> Self::Node { - node.clone() - } - } - - impl ClvmEncoder for TestAllocator { - type Node = TestNode; - - fn encode_atom(&mut self, bytes: &[u8]) -> Result { - Ok(self.new_atom(bytes)) - } - - fn encode_pair( - &mut self, - first: Self::Node, - rest: Self::Node, - ) -> Result { - Ok(TestNode::Pair(Box::new(first), Box::new(rest))) - } - } -} - #[cfg(test)] #[cfg(feature = "derive")] mod derive_tests { extern crate self as clvm_traits; use super::*; - use crate::tests::*; + use std::fmt::Debug; + use clvmr::{serde::node_to_bytes, Allocator, NodePtr}; + fn check(value: T, expected: &str) where - T: Debug + PartialEq + ToClvm + FromClvm, + T: Debug + PartialEq + ToClvm + FromClvm, { - let a = &mut TestAllocator::new(); + let a = &mut Allocator::new(); let ptr = value.to_clvm(a).unwrap(); - let actual = node_to_str(a, &ptr); - assert_eq!(expected, actual); + let actual = node_to_bytes(a, ptr).unwrap(); + assert_eq!(expected, hex::encode(actual)); let round_trip = T::from_clvm(a, ptr).unwrap(); assert_eq!(value, round_trip); @@ -173,10 +54,10 @@ mod derive_tests { fn coerce_into(value: A) -> B where - A: ToClvm, - B: FromClvm, + A: ToClvm, + B: FromClvm, { - let a = &mut TestAllocator::new(); + let a = &mut Allocator::new(); let ptr = value.to_clvm(a).unwrap(); B::from_clvm(a, ptr).unwrap() } @@ -190,7 +71,7 @@ mod derive_tests { b: i32, } - check(TupleStruct { a: 52, b: -32 }, "( 34 e0"); + check(TupleStruct { a: 52, b: -32 }, "ff3481e0"); } #[test] @@ -202,7 +83,7 @@ mod derive_tests { b: i32, } - check(ListStruct { a: 52, b: -32 }, "( 34 ( e0 NIL"); + check(ListStruct { a: 52, b: -32 }, "ff34ff81e080"); } #[test] @@ -216,7 +97,7 @@ mod derive_tests { check( CurryStruct { a: 52, b: -32 }, - "( 04 ( ( 01 34 ( ( 04 ( ( 01 e0 ( 01 NIL NIL", + "ff04ffff0134ffff04ffff0181e0ff018080", ); } @@ -226,7 +107,7 @@ mod derive_tests { #[clvm(tuple)] struct UnnamedStruct(String, String); - check(UnnamedStruct("A".to_string(), "B".to_string()), "( 41 42"); + check(UnnamedStruct("A".to_string(), "B".to_string()), "ff4142"); } #[test] @@ -235,7 +116,7 @@ mod derive_tests { #[clvm(tuple)] struct NewTypeStruct(String); - check(NewTypeStruct("XYZ".to_string()), "58595a"); + check(NewTypeStruct("XYZ".to_string()), "8358595a"); } #[test] @@ -248,9 +129,9 @@ mod derive_tests { C, } - check(Enum::A(32), "( NIL 20"); - check(Enum::B { x: -72 }, "( 01 b8"); - check(Enum::C, "( 02 NIL"); + check(Enum::A(32), "ff8020"); + check(Enum::B { x: -72 }, "ff0181b8"); + check(Enum::C, "ff0280"); } #[test] @@ -264,9 +145,9 @@ mod derive_tests { C = 11, } - check(Enum::A(32), "( 2a 20"); - check(Enum::B { x: -72 }, "( 22 b8"); - check(Enum::C, "( 0b NIL"); + check(Enum::A(32), "ff2a20"); + check(Enum::B { x: -72 }, "ff2281b8"); + check(Enum::C, "ff0b80"); } #[test] @@ -289,12 +170,12 @@ mod derive_tests { } check(Enum::A(32), "20"); - check(Enum::B { x: -72, y: 94 }, "( b8 ( 5e NIL"); + check(Enum::B { x: -72, y: 94 }, "ff81b8ff5e80"); check( Enum::C { curried_value: "Hello".to_string(), }, - "( 04 ( ( 01 48656c6c6f ( 01 NIL", + "ff04ffff018548656c6c6fff0180", ); } diff --git a/clvm-traits/src/to_clvm.rs b/clvm-traits/src/to_clvm.rs index e787b857f..8dfef8480 100644 --- a/clvm-traits/src/to_clvm.rs +++ b/clvm-traits/src/to_clvm.rs @@ -139,101 +139,119 @@ impl ToClvm for chia_bls::Signature { #[cfg(test)] mod tests { - use crate::tests::{node_to_str, TestAllocator, TestNode}; + use clvmr::{serde::node_to_bytes, Allocator, NodePtr}; + use hex::ToHex; use super::*; - fn encode(value: T) -> Result + fn encode(a: &mut Allocator, value: T) -> Result where - T: ToClvm, + T: ToClvm, { - let mut a = TestAllocator::new(); - let node = value.to_clvm(&mut a).unwrap(); - Ok(node_to_str(&a, &node)) + let actual = value.to_clvm(a).unwrap(); + let actual_bytes = node_to_bytes(a, actual).unwrap(); + Ok(actual_bytes.encode_hex()) + } + + #[test] + fn test_nodeptr() { + let a = &mut Allocator::new(); + let ptr = a.one(); + assert_eq!(ptr.to_clvm(a).unwrap(), ptr); } #[test] fn test_primitives() { - assert_eq!(encode(0u8), Ok("NIL".to_owned())); - assert_eq!(encode(0i8), Ok("NIL".to_owned())); - assert_eq!(encode(5u8), Ok("05".to_owned())); - assert_eq!(encode(5u32), Ok("05".to_owned())); - assert_eq!(encode(5i32), Ok("05".to_owned())); - assert_eq!(encode(-27i32), Ok("e5".to_owned())); - assert_eq!(encode(-0), Ok("NIL".to_owned())); - assert_eq!(encode(-128i8), Ok("80".to_owned())); + let a = &mut Allocator::new(); + assert_eq!(encode(a, 0u8), Ok("80".to_owned())); + assert_eq!(encode(a, 0i8), Ok("80".to_owned())); + assert_eq!(encode(a, 5u8), Ok("05".to_owned())); + assert_eq!(encode(a, 5u32), Ok("05".to_owned())); + assert_eq!(encode(a, 5i32), Ok("05".to_owned())); + assert_eq!(encode(a, -27i32), Ok("81e5".to_owned())); + assert_eq!(encode(a, -0), Ok("80".to_owned())); + assert_eq!(encode(a, -128i8), Ok("8180".to_owned())); } #[test] fn test_reference() { - assert_eq!(encode([1, 2, 3]), encode([1, 2, 3])); - assert_eq!(encode(Some(42)), encode(Some(42))); - assert_eq!(encode(Some(&42)), encode(Some(42))); - assert_eq!(encode(Some(&42)), encode(Some(42))); + let a = &mut Allocator::new(); + assert_eq!(encode(a, [1, 2, 3]), encode(a, [1, 2, 3])); + assert_eq!(encode(a, Some(42)), encode(a, Some(42))); + assert_eq!(encode(a, Some(&42)), encode(a, Some(42))); + assert_eq!(encode(a, Some(&42)), encode(a, Some(42))); } #[test] fn test_pair() { - assert_eq!(encode((5, 2)), Ok("( 05 02".to_owned())); + let a = &mut Allocator::new(); + assert_eq!(encode(a, (5, 2)), Ok("ff0502".to_owned())); assert_eq!( - encode((-72, (90121, ()))), - Ok("( b8 ( 016009 NIL".to_owned()) + encode(a, (-72, (90121, ()))), + Ok("ff81b8ff8301600980".to_owned()) ); assert_eq!( - encode((((), ((), ((), (((), ((), ((), ()))), ())))), ())), - Ok("( ( NIL ( NIL ( NIL ( ( NIL ( NIL ( NIL NIL NIL NIL".to_owned()) + encode(a, (((), ((), ((), (((), ((), ((), ()))), ())))), ())), + Ok("ffff80ff80ff80ffff80ff80ff80808080".to_owned()) ); } #[test] fn test_nil() { - assert_eq!(encode(()), Ok("NIL".to_owned())); + let a = &mut Allocator::new(); + assert_eq!(encode(a, ()), Ok("80".to_owned())); } #[test] fn test_slice() { + let a = &mut Allocator::new(); assert_eq!( - encode([1, 2, 3, 4].as_slice()), - Ok("( 01 ( 02 ( 03 ( 04 NIL".to_owned()) + encode(a, [1, 2, 3, 4].as_slice()), + Ok("ff01ff02ff03ff0480".to_owned()) ); - assert_eq!(encode([0; 0].as_slice()), Ok("NIL".to_owned())); + assert_eq!(encode(a, [0; 0].as_slice()), Ok("80".to_owned())); } #[test] fn test_array() { - assert_eq!( - encode([1, 2, 3, 4]), - Ok("( 01 ( 02 ( 03 ( 04 NIL".to_owned()) - ); - assert_eq!(encode([0; 0]), Ok("NIL".to_owned())); + let a = &mut Allocator::new(); + assert_eq!(encode(a, [1, 2, 3, 4]), Ok("ff01ff02ff03ff0480".to_owned())); + assert_eq!(encode(a, [0; 0]), Ok("80".to_owned())); } #[test] fn test_vec() { + let a = &mut Allocator::new(); assert_eq!( - encode(vec![1, 2, 3, 4]), - Ok("( 01 ( 02 ( 03 ( 04 NIL".to_owned()) + encode(a, vec![1, 2, 3, 4]), + Ok("ff01ff02ff03ff0480".to_owned()) ); - assert_eq!(encode(vec![0; 0]), Ok("NIL".to_owned())); + assert_eq!(encode(a, vec![0; 0]), Ok("80".to_owned())); } #[test] fn test_option() { - assert_eq!(encode(Some("hello")), Ok("68656c6c6f".to_owned())); - assert_eq!(encode(None::<&str>), Ok("NIL".to_owned())); - assert_eq!(encode(Some("")), Ok("NIL".to_owned())); + let a = &mut Allocator::new(); + assert_eq!(encode(a, Some("hello")), Ok("8568656c6c6f".to_owned())); + assert_eq!(encode(a, None::<&str>), Ok("80".to_owned())); + assert_eq!(encode(a, Some("")), Ok("80".to_owned())); } #[test] fn test_str() { - assert_eq!(encode("hello"), Ok("68656c6c6f".to_owned())); - assert_eq!(encode(""), Ok("NIL".to_owned())); + let a = &mut Allocator::new(); + assert_eq!(encode(a, "hello"), Ok("8568656c6c6f".to_owned())); + assert_eq!(encode(a, ""), Ok("80".to_owned())); } #[test] fn test_string() { - assert_eq!(encode("hello".to_string()), Ok("68656c6c6f".to_owned())); - assert_eq!(encode("".to_string()), Ok("NIL".to_owned())); + let a = &mut Allocator::new(); + assert_eq!( + encode(a, "hello".to_string()), + Ok("8568656c6c6f".to_owned()) + ); + assert_eq!(encode(a, "".to_string()), Ok("80".to_owned())); } #[cfg(feature = "chia-bls")] @@ -242,10 +260,17 @@ mod tests { use chia_bls::PublicKey; use hex_literal::hex; - let valid_bytes = hex!("b8f7dd239557ff8c49d338f89ac1a258a863fa52cd0a502e3aaae4b6738ba39ac8d982215aa3fa16bc5f8cb7e44b954d"); + let a = &mut Allocator::new(); + + let bytes = hex!( + " + b8f7dd239557ff8c49d338f89ac1a258a863fa52cd0a502e + 3aaae4b6738ba39ac8d982215aa3fa16bc5f8cb7e44b954d + " + ); assert_eq!( - encode(PublicKey::from_bytes(&valid_bytes).unwrap()), - Ok(hex::encode(valid_bytes)) + encode(a, PublicKey::from_bytes(&bytes).unwrap()), + Ok("b0b8f7dd239557ff8c49d338f89ac1a258a863fa52cd0a502e3aaae4b6738ba39ac8d982215aa3fa16bc5f8cb7e44b954d".to_string()) ); } @@ -255,10 +280,18 @@ mod tests { use chia_bls::Signature; use hex_literal::hex; - let valid_bytes = hex!("a3994dc9c0ef41a903d3335f0afe42ba16c88e7881706798492da4a1653cd10c69c841eeb56f44ae005e2bad27fb7ebb16ce8bbfbd708ea91dd4ff24f030497b50e694a8270eccd07dbc206b8ffe0c34a9ea81291785299fae8206a1e1bbc1d1"); + let a = &mut Allocator::new(); + + let bytes = hex!( + " + a3994dc9c0ef41a903d3335f0afe42ba16c88e7881706798492da4a1653cd10c + 69c841eeb56f44ae005e2bad27fb7ebb16ce8bbfbd708ea91dd4ff24f030497b + 50e694a8270eccd07dbc206b8ffe0c34a9ea81291785299fae8206a1e1bbc1d1 + " + ); assert_eq!( - encode(Signature::from_bytes(&valid_bytes).unwrap()), - Ok(hex::encode(valid_bytes)) + encode(a, Signature::from_bytes(&bytes).unwrap()), + Ok("c060a3994dc9c0ef41a903d3335f0afe42ba16c88e7881706798492da4a1653cd10c69c841eeb56f44ae005e2bad27fb7ebb16ce8bbfbd708ea91dd4ff24f030497b50e694a8270eccd07dbc206b8ffe0c34a9ea81291785299fae8206a1e1bbc1d1".to_string()) ); } } diff --git a/clvm-utils/Cargo.toml b/clvm-utils/Cargo.toml index 42b40b886..8a0dedb26 100644 --- a/clvm-utils/Cargo.toml +++ b/clvm-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clvm-utils" -version = "0.4.0" +version = "0.5.0" edition = "2021" license = "Apache-2.0" description = "Utility functions for processing clvm programs and structures" @@ -9,8 +9,8 @@ homepage = "https://github.com/Chia-Network/chia_rs/" repository = "https://github.com/Chia-Network/chia_rs/clvm-utils" [dependencies] -clvmr = "0.4.0" -clvm-traits = { version = "0.3.3", path = "../clvm-traits" } +clvmr = "0.5.0" +clvm-traits = { version = "0.5.0", path = "../clvm-traits" } [dev-dependencies] hex = "0.4.3" diff --git a/clvm-utils/fuzz/Cargo.toml b/clvm-utils/fuzz/Cargo.toml index 366dac717..90981dcec 100644 --- a/clvm-utils/fuzz/Cargo.toml +++ b/clvm-utils/fuzz/Cargo.toml @@ -10,7 +10,7 @@ cargo-fuzz = true [dependencies] libfuzzer-sys = "0.4" -clvmr = "=0.4.0" +clvmr = "=0.5.0" chia-fuzz = { path = "../../fuzz" } clvm-utils = { path = ".." } clvm-traits = { path = "../../clvm-traits" } diff --git a/clvm-utils/src/curried_program.rs b/clvm-utils/src/curried_program.rs index 44e52aefd..568fc88bb 100644 --- a/clvm-utils/src/curried_program.rs +++ b/clvm-utils/src/curried_program.rs @@ -36,7 +36,7 @@ mod tests { use std::fmt::Debug; use clvm_traits::clvm_curried_args; - use clvmr::{allocator::NodePtr, serde::node_to_bytes, Allocator}; + use clvmr::{serde::node_to_bytes, Allocator, NodePtr}; use super::*; @@ -48,7 +48,7 @@ mod tests { let a = &mut Allocator::new(); let curry = CurriedProgram { - program: program.to_clvm(a).unwrap(), + program: &program, args: &args, } .to_clvm(a) diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 916870b99..cc7083a76 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -10,7 +10,7 @@ cargo-fuzz = true [dependencies] libfuzzer-sys = "0.4" -clvmr = "0.4.0" +clvmr = "0.5.0" clvm-utils = { path = "../clvm-utils" } clvm-traits = { path = "../clvm-traits" } chia-protocol = { path = "../chia-protocol" } diff --git a/fuzz/fuzz_targets/fast-forward.rs b/fuzz/fuzz_targets/fast-forward.rs index 7bc42faa8..79587ffd3 100644 --- a/fuzz/fuzz_targets/fast-forward.rs +++ b/fuzz/fuzz_targets/fast-forward.rs @@ -7,9 +7,9 @@ use chia_protocol::Bytes32; use chia_protocol::Coin; use chia_protocol::CoinSpend; use chia_traits::streamable::Streamable; +use clvm_traits::ToNodePtr; use clvm_utils::tree_hash; use clvmr::serde::node_to_bytes; -use clvmr::ToNodePtr; use clvmr::{Allocator, NodePtr}; use hex_literal::hex; use libfuzzer_sys::fuzz_target; diff --git a/src/fast_forward.rs b/src/fast_forward.rs index 7b7f9dc8c..f1ff23cfa 100644 --- a/src/fast_forward.rs +++ b/src/fast_forward.rs @@ -180,8 +180,8 @@ mod tests { use crate::gen::run_puzzle::run_puzzle; use chia_protocol::CoinSpend; use chia_traits::streamable::Streamable; + use clvm_traits::ToNodePtr; use clvmr::serde::{node_from_bytes, node_to_bytes}; - use clvmr::ToNodePtr; use hex_literal::hex; use rstest::rstest; use std::fs; diff --git a/wheel/Cargo.toml b/wheel/Cargo.toml index 64ef7af92..4e7dc444f 100644 --- a/wheel/Cargo.toml +++ b/wheel/Cargo.toml @@ -15,15 +15,15 @@ crate-type = ["cdylib"] path = "src/lib.rs" [dependencies] -clvmr = "0.4.0" +clvmr = "0.5.0" hex = "0.4.3" sha2 = "0.10.8" pyo3 = { version = "=0.19.0", features = ["extension-module", "multiple-pymethods"] } chia = { version = "=0.5.0", path = "..", features = ["py-bindings"] } -chia-bls = { version = "=0.4.0", path = "../chia-bls", features = ["py-bindings"] } +chia-bls = { version = "=0.5.0", path = "../chia-bls", features = ["py-bindings"] } chia-protocol = { version = "=0.5.0", path = "../chia-protocol", features = ["py-bindings"] } chia-traits = { version = "=0.5.0", path = "../chia-traits", features = ["py-bindings"] } -clvm-traits = { version = "=0.3.3", path = "../clvm-traits", features = ["derive", "py-bindings"] } +clvm-traits = { version = "=0.5.0", path = "../clvm-traits", features = ["derive", "py-bindings"] } chia_py_streamable_macro = { version = "=0.5.0", path = "../chia_py_streamable_macro" } chia_streamable_macro = { version = "=0.3.0", path = "../chia_streamable_macro" }