Skip to content

Commit

Permalink
drop clvm-trait's dependency on clvmr, and remove the ToNodePtr and F…
Browse files Browse the repository at this point in the history
…romNodePtr traits as well as FromClvm and ToClvm for Allocator and NodePtr (those are moved into clvmr)
  • Loading branch information
arvidn committed Dec 4, 2023
1 parent df9924f commit 5ab31e5
Show file tree
Hide file tree
Showing 17 changed files with 259 additions and 235 deletions.
47 changes: 36 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
4 changes: 2 additions & 2 deletions chia-bls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ py-bindings = ["dep:pyo3", "chia_py_streamable_macro", "chia-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
4 changes: 3 additions & 1 deletion chia-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ 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"] }
# TODO: ideally, "py-bindings" would only be requested here in case our own
# py-bindings feature is enabled
clvm-traits = { version = "=0.2.14", features = ["derive", "py-bindings"] }
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" }
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
5 changes: 3 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,10 @@ 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"
clvmr = "=0.3.0"
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

0 comments on commit 5ab31e5

Please sign in to comment.