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

drop clvm-trait's dependency on clvmr #332

Merged
merged 1 commit into from
Dec 5, 2023
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
46 changes: 35 additions & 11 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ hex = "0.4.3"
pyo3 = { version = ">=0.19.0", optional = true }
clvm-utils = { version = "=0.2.14", path = "clvm-utils" }
chia-traits = { version = "=0.2.14", path = "chia-traits" }
clvm-traits = { version = "=0.2.14", path = "clvm-traits" }
clvm-traits = { version = "=0.2.14" }
clvm-derive = { version = "=0.2.14", path = "clvm-derive" }
chia-protocol = { version = "=0.2.14", path = "chia-protocol" }
chia-wallet = { version = "=0.2.14", path = "chia-wallet" }
Expand Down
6 changes: 3 additions & 3 deletions chia-bls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ homepage = "https://github.com/Chia-Network/chia_rs/chia-bls/"
repository = "https://github.com/Chia-Network/chia_rs/chia-bls/"

[features]
py-bindings = ["dep:pyo3", "chia_py_streamable_macro", "chia-traits/py-bindings"]
py-bindings = ["dep:pyo3", "chia_py_streamable_macro", "chia-traits/py-bindings", "clvm-traits/py-bindings"]

[dependencies]
chia-traits = { version = "=0.2.14", path = "../chia-traits" }
clvm-traits = { version = "=0.2.14", path = "../clvm-traits", features = ["derive"] }
clvm-traits = { version = "=0.2.14", features = ["derive"] }
chia_py_streamable_macro = { version = "=0.2.14", path = "../chia_py_streamable_macro", optional = true }
tiny-bip39 = "1.0.0"
anyhow = "1.0.71"
sha2 = "0.10.8"
hkdf = "0.12.0"
blst = { version = "0.3.11", features = ["portable"] }
clvmr = "=0.3.0"
hex = "0.4.3"
thiserror = "1.0.44"
pyo3 = { version = "0.19.0", features = ["multiple-pymethods"], optional = true }
Expand All @@ -30,6 +29,7 @@ arbitrary = { version = "1.3.0" }
rand = "0.8.5"
criterion = "0.5.1"
rstest = "0.17.0"
clvmr = "=0.3.0"

[lib]
crate-type = ["rlib"]
Expand Down
2 changes: 1 addition & 1 deletion chia-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ chia_streamable_macro = { version = "=0.2.14", path = "../chia_streamable_macro"
chia_py_streamable_macro = { version = "=0.2.14", path = "../chia_py_streamable_macro", optional = true }
clvmr = "=0.3.0"
chia-traits = { version = "=0.2.14", path = "../chia-traits" }
clvm-traits = { version = "=0.2.14", path = "../clvm-traits", features = ["derive"] }
clvm-traits = { version = "=0.2.14", features = ["derive"] }
clvm-utils = { version = "=0.2.14", path = "../clvm-utils" }
chia-bls = { version = "=0.2.14", path = "../chia-bls" }
arbitrary = { version = "1.3.0", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion chia-tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repository = "https://github.com/Chia-Network/chia_rs/chia-tools"
chia-protocol = { version = "0.2.14", path = "../chia-protocol" }
chia-traits = { path = "../chia-traits" }
clvm-utils = { path = "../clvm-utils" }
clvm-traits = { path = "../clvm-traits" }
clvm-traits = { version = "=0.2.14" }
Rigidity marked this conversation as resolved.
Show resolved Hide resolved
chia-wallet = { version = "=0.2.14", path = "../chia-wallet" }
clvmr = { version = "=0.3.0", features = ["counters"] }
chia = { version = "0.2.14", path = ".." }
Expand Down
4 changes: 2 additions & 2 deletions chia-wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sha2 = "0.10.8"
num-bigint = "0.4.3"
hex-literal = "0.4.1"
clvm-utils = { version = "0.2.14", path = "../clvm-utils" }
clvm-traits = { version = "0.2.14", path = "../clvm-traits" }
clvm-traits = { version = "0.2.14" }
chia-bls = { version = "0.2.14", path = "../chia-bls" }
chia-protocol = { version = "0.2.14", path = "../chia-protocol" }
arbitrary = "=1.3.0"
Expand All @@ -23,4 +23,4 @@ arbitrary = "=1.3.0"
hex = "0.4.3"

[lib]
crate-type = ["rlib"]
crate-type = ["rlib"]
2 changes: 1 addition & 1 deletion chia-wallet/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ libfuzzer-sys = "0.4"
clvmr = "0.3.0"
pyo3 = { version = ">=0.19.0", features = ["auto-initialize"]}
chia-wallet = { path = ".." }
clvm-traits = { path = "../../clvm-traits" }
clvm-traits = { version = "0.2.14" }

[[bin]]
name = "roundtrip"
Expand Down
4 changes: 2 additions & 2 deletions clvm-traits/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clvm-traits"
version = "0.2.14"
version = "0.2.15"
edition = "2021"
license = "Apache-2.0"
description = "Traits for encoding and decoding CLVM objects."
Expand All @@ -18,9 +18,9 @@ py-bindings = ["dep:pyo3"]
[dependencies]
pyo3 = { version = ">=0.19.0", optional = true }
clvm-derive = { version = "0.2.14", path = "../clvm-derive", optional = true }
clvmr = "0.3.0"
num-bigint = "0.4.3"
thiserror = "1.0.44"

[dev-dependencies]
hex = "0.4.3"
hex-literal = "=0.4.1"
14 changes: 7 additions & 7 deletions clvm-traits/docs/derive_macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```rust compile_fail
Rigidity marked this conversation as resolved.
Show resolved Hide resolved
use clvmr::Allocator;
use clvm_traits::{ToClvm, FromClvm};

Expand Down Expand Up @@ -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
```rust compile_fail
use clvmr::Allocator;
use clvm_traits::{ToClvm, FromClvm};

Expand Down Expand Up @@ -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
```rust compile_fail
use clvmr::Allocator;
use clvm_traits::{ToClvm, FromClvm};

Expand Down Expand Up @@ -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
```rust compile_fail
use clvmr::Allocator;
use clvm_traits::{ToClvm, FromClvm};

Expand All @@ -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
```rust compile_fail
use clvmr::Allocator;
use clvm_traits::{ToClvm, FromClvm};

Expand All @@ -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
```rust compile_fail
use clvmr::Allocator;
use clvm_traits::{ToClvm, FromClvm};

Expand Down Expand Up @@ -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
```rust compile_fail
use clvmr::Allocator;
use clvm_traits::{ToClvm, FromClvm};

Expand Down
25 changes: 0 additions & 25 deletions clvm-traits/src/clvm_decoder.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
use clvmr::{
allocator::{NodePtr, SExp},
Allocator,
};

use crate::FromClvmError;

pub trait ClvmDecoder {
Expand All @@ -18,23 +13,3 @@ 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)
}
}
}
18 changes: 0 additions & 18 deletions clvm-traits/src/clvm_encoder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use clvmr::{allocator::NodePtr, Allocator};

use crate::ToClvmError;

pub trait ClvmEncoder {
Expand All @@ -19,19 +17,3 @@ pub trait ClvmEncoder {
node.clone()
}
}

impl ClvmEncoder for Allocator {
type Node = NodePtr;

fn encode_atom(&mut self, bytes: &[u8]) -> Result<Self::Node, ToClvmError> {
self.new_atom(bytes).or(Err(ToClvmError::OutOfMemory))
}

fn encode_pair(
&mut self,
first: Self::Node,
rest: Self::Node,
) -> Result<Self::Node, ToClvmError> {
self.new_pair(first, rest).or(Err(ToClvmError::OutOfMemory))
}
}
Loading
Loading