From 9296f0d6a9c430672bfbc70055ef4383ed2dd114 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Thu, 29 Aug 2024 12:22:51 -0400 Subject: [PATCH 1/6] Add cargo machete to CI --- .github/workflows/build-crate.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build-crate.yml b/.github/workflows/build-crate.yml index e14a647ca..7e7ee4a8c 100644 --- a/.github/workflows/build-crate.yml +++ b/.github/workflows/build-crate.yml @@ -28,6 +28,12 @@ jobs: - name: Clippy run: cargo clippy --workspace --all-features --all-targets + - name: Install cargo-machete + run: cargo install cargo-machete + + - name: Unused dependencies + run: cargo machete + - name: Tests (debug) run: cargo test --workspace --all-features From 33242d18765de4ba46e67ae0f4f462308c8d75ec Mon Sep 17 00:00:00 2001 From: Rigidity Date: Thu, 29 Aug 2024 12:23:37 -0400 Subject: [PATCH 2/6] Add machete to pre-commit --- .pre-commit-config.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f59794fe3..19756e870 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,6 +28,13 @@ repos: entry: cargo clippy --workspace --all-features --all-targets language: system pass_filenames: false + - id: machete + name: machete + description: run cargo machete on the workspace + stages: [pre-push] + entry: cargo machete + language: system + pass_filenames: false - id: tests name: run tests description: run cargo test on the workspace From e46374ae474443a4207e62872328fc2adf4a97e0 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Thu, 29 Aug 2024 12:25:12 -0400 Subject: [PATCH 3/6] Add machete to all stages --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 19756e870..dcaf8c314 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,7 +31,6 @@ repos: - id: machete name: machete description: run cargo machete on the workspace - stages: [pre-push] entry: cargo machete language: system pass_filenames: false From 384945458ad7dd06d55ccf43cd3742c6c1e1a71f Mon Sep 17 00:00:00 2001 From: Rigidity Date: Thu, 29 Aug 2024 12:27:01 -0400 Subject: [PATCH 4/6] chia-fuzz --- crates/chia-consensus/fuzz/Cargo.toml | 4 ---- crates/chia-consensus/fuzz/fuzz_targets/parse-cond-args.rs | 2 +- crates/chia-consensus/fuzz/fuzz_targets/parse-conditions.rs | 2 +- crates/chia-consensus/fuzz/fuzz_targets/parse-spend-id.rs | 2 +- crates/chia-consensus/fuzz/fuzz_targets/parse-spend.rs | 2 +- crates/chia-consensus/fuzz/fuzz_targets/parse-spends.rs | 2 +- crates/chia-consensus/fuzz/fuzz_targets/process-spend.rs | 2 +- .../chia-consensus/fuzz/fuzz_targets/puzzle-coin-solution.rs | 2 +- crates/clvm-utils/fuzz/fuzz_targets/curry.rs | 2 +- crates/clvm-utils/fuzz/fuzz_targets/tree-hash.rs | 2 +- 10 files changed, 9 insertions(+), 13 deletions(-) diff --git a/crates/chia-consensus/fuzz/Cargo.toml b/crates/chia-consensus/fuzz/Cargo.toml index 6022d3a49..bff787e22 100644 --- a/crates/chia-consensus/fuzz/Cargo.toml +++ b/crates/chia-consensus/fuzz/Cargo.toml @@ -21,10 +21,6 @@ chia-traits = { workspace = true } chia-consensus = { workspace = true } hex-literal = { workspace = true } -[lib] -name = "fuzzing_utils" -crate-type = ["rlib"] - [[bin]] name = "puzzle-coin-solution" path = "fuzz_targets/puzzle-coin-solution.rs" diff --git a/crates/chia-consensus/fuzz/fuzz_targets/parse-cond-args.rs b/crates/chia-consensus/fuzz/fuzz_targets/parse-cond-args.rs index 5a30b8e8d..e08f41860 100644 --- a/crates/chia-consensus/fuzz/fuzz_targets/parse-cond-args.rs +++ b/crates/chia-consensus/fuzz/fuzz_targets/parse-cond-args.rs @@ -2,8 +2,8 @@ use libfuzzer_sys::fuzz_target; use chia_consensus::gen::conditions::parse_args; +use chia_fuzz::{make_list, BitCursor}; use clvmr::allocator::Allocator; -use fuzzing_utils::{make_list, BitCursor}; use chia_consensus::gen::flags::STRICT_ARGS_COUNT; diff --git a/crates/chia-consensus/fuzz/fuzz_targets/parse-conditions.rs b/crates/chia-consensus/fuzz/fuzz_targets/parse-conditions.rs index 16999caa0..03b80f95a 100644 --- a/crates/chia-consensus/fuzz/fuzz_targets/parse-conditions.rs +++ b/crates/chia-consensus/fuzz/fuzz_targets/parse-conditions.rs @@ -6,11 +6,11 @@ use chia_consensus::gen::conditions::{ parse_conditions, MempoolVisitor, ParseState, SpendBundleConditions, SpendConditions, }; use chia_consensus::gen::spend_visitor::SpendVisitor; +use chia_fuzz::{make_list, BitCursor}; use chia_protocol::Bytes32; use chia_protocol::Coin; use clvm_utils::tree_hash; use clvmr::{Allocator, NodePtr}; -use fuzzing_utils::{make_list, BitCursor}; use std::collections::HashSet; use std::sync::Arc; diff --git a/crates/chia-consensus/fuzz/fuzz_targets/parse-spend-id.rs b/crates/chia-consensus/fuzz/fuzz_targets/parse-spend-id.rs index 3567d4134..fbfb8e324 100644 --- a/crates/chia-consensus/fuzz/fuzz_targets/parse-spend-id.rs +++ b/crates/chia-consensus/fuzz/fuzz_targets/parse-spend-id.rs @@ -2,8 +2,8 @@ use libfuzzer_sys::fuzz_target; use chia_consensus::gen::messages::SpendId; +use chia_fuzz::{make_list, BitCursor}; use clvmr::allocator::Allocator; -use fuzzing_utils::{make_list, BitCursor}; fuzz_target!(|data: &[u8]| { let mut a = Allocator::new(); diff --git a/crates/chia-consensus/fuzz/fuzz_targets/parse-spend.rs b/crates/chia-consensus/fuzz/fuzz_targets/parse-spend.rs index 62e255fb9..f055c5740 100644 --- a/crates/chia-consensus/fuzz/fuzz_targets/parse-spend.rs +++ b/crates/chia-consensus/fuzz/fuzz_targets/parse-spend.rs @@ -2,8 +2,8 @@ use libfuzzer_sys::fuzz_target; use chia_consensus::gen::get_puzzle_and_solution::parse_coin_spend; +use chia_fuzz::{make_list, BitCursor}; use clvmr::allocator::Allocator; -use fuzzing_utils::{make_list, BitCursor}; fuzz_target!(|data: &[u8]| { let mut a = Allocator::new(); diff --git a/crates/chia-consensus/fuzz/fuzz_targets/parse-spends.rs b/crates/chia-consensus/fuzz/fuzz_targets/parse-spends.rs index 8b510918a..84257c734 100644 --- a/crates/chia-consensus/fuzz/fuzz_targets/parse-spends.rs +++ b/crates/chia-consensus/fuzz/fuzz_targets/parse-spends.rs @@ -2,8 +2,8 @@ use libfuzzer_sys::fuzz_target; use chia_consensus::gen::conditions::{parse_spends, MempoolVisitor}; +use chia_fuzz::{make_list, BitCursor}; use clvmr::{Allocator, NodePtr}; -use fuzzing_utils::{make_list, BitCursor}; use chia_consensus::consensus_constants::TEST_CONSTANTS; use chia_consensus::gen::flags::{NO_UNKNOWN_CONDS, STRICT_ARGS_COUNT}; diff --git a/crates/chia-consensus/fuzz/fuzz_targets/process-spend.rs b/crates/chia-consensus/fuzz/fuzz_targets/process-spend.rs index 134ac76e7..8be826dde 100644 --- a/crates/chia-consensus/fuzz/fuzz_targets/process-spend.rs +++ b/crates/chia-consensus/fuzz/fuzz_targets/process-spend.rs @@ -4,8 +4,8 @@ use chia_consensus::gen::conditions::{ process_single_spend, MempoolVisitor, ParseState, SpendBundleConditions, }; use chia_consensus::gen::flags::{NO_UNKNOWN_CONDS, STRICT_ARGS_COUNT}; +use chia_fuzz::{make_tree, BitCursor}; use clvmr::allocator::Allocator; -use fuzzing_utils::{make_tree, BitCursor}; use libfuzzer_sys::fuzz_target; fuzz_target!(|data: &[u8]| { diff --git a/crates/chia-consensus/fuzz/fuzz_targets/puzzle-coin-solution.rs b/crates/chia-consensus/fuzz/fuzz_targets/puzzle-coin-solution.rs index 8f871497a..9dcb5e79f 100644 --- a/crates/chia-consensus/fuzz/fuzz_targets/puzzle-coin-solution.rs +++ b/crates/chia-consensus/fuzz/fuzz_targets/puzzle-coin-solution.rs @@ -2,9 +2,9 @@ use libfuzzer_sys::fuzz_target; use chia_consensus::gen::get_puzzle_and_solution::get_puzzle_and_solution_for_coin; +use chia_fuzz::{make_tree, BitCursor}; use chia_protocol::Coin; use clvmr::allocator::Allocator; -use fuzzing_utils::{make_tree, BitCursor}; use std::collections::HashSet; const HASH: [u8; 32] = [ diff --git a/crates/clvm-utils/fuzz/fuzz_targets/curry.rs b/crates/clvm-utils/fuzz/fuzz_targets/curry.rs index d8b198830..877a660dd 100644 --- a/crates/clvm-utils/fuzz/fuzz_targets/curry.rs +++ b/crates/clvm-utils/fuzz/fuzz_targets/curry.rs @@ -2,9 +2,9 @@ use clvm_traits::{FromClvm, ToClvm}; use libfuzzer_sys::fuzz_target; +use chia_fuzz::{make_tree, BitCursor}; use clvm_utils::CurriedProgram; use clvmr::allocator::{Allocator, NodePtr}; -use fuzzing_utils::{make_tree, BitCursor}; fuzz_target!(|data: &[u8]| { let mut a = Allocator::new(); diff --git a/crates/clvm-utils/fuzz/fuzz_targets/tree-hash.rs b/crates/clvm-utils/fuzz/fuzz_targets/tree-hash.rs index 74f8e20cd..724957e06 100644 --- a/crates/clvm-utils/fuzz/fuzz_targets/tree-hash.rs +++ b/crates/clvm-utils/fuzz/fuzz_targets/tree-hash.rs @@ -1,9 +1,9 @@ #![no_main] use libfuzzer_sys::fuzz_target; +use chia_fuzz::{make_tree, BitCursor}; use clvm_utils::{tree_hash, tree_hash_cached, TreeHash}; use clvmr::{Allocator, NodePtr}; -use fuzzing_utils::{make_tree, BitCursor}; use std::collections::{HashMap, HashSet}; use clvmr::serde::{node_from_bytes_backrefs_record, node_to_bytes_backrefs}; From b4966a696e4fa76324ff762fdef2087625d61b17 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Thu, 29 Aug 2024 12:28:24 -0400 Subject: [PATCH 5/6] Add workaround for clvmr --- Cargo.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 631c3a8ef..cba3307d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,6 +62,11 @@ clvm-traits = { workspace = true, optional = true } clvm-utils = { workspace = true, optional = true } clvmr = { workspace = true } +# This is required since clvmr is only added here to provide the openssl feature conditionally. +# In the future we could pass the openssl feature to each of the relevant workspace crates instead. +[package.metadata.cargo-machete] +ignored = ["clvmr"] + [features] default = [ "bls", From fcc43196441316ba910e39dc626805a0dbcc2253 Mon Sep 17 00:00:00 2001 From: Rigidity Date: Thu, 29 Aug 2024 12:29:30 -0400 Subject: [PATCH 6/6] Remove unused deps --- Cargo.lock | 8 -------- crates/chia-bls/Cargo.toml | 1 - crates/chia-consensus/Cargo.toml | 1 - crates/chia-puzzles/fuzz/Cargo.toml | 1 - crates/chia-tools/Cargo.toml | 1 - wheel/Cargo.toml | 5 ----- 6 files changed, 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ddef533e0..76e45bce6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -305,7 +305,6 @@ dependencies = [ name = "chia-bls" version = "0.11.0" dependencies = [ - "anyhow", "arbitrary", "blst", "chia-traits 0.11.0", @@ -354,7 +353,6 @@ dependencies = [ "chia-traits 0.11.0", "chia_py_streamable_macro", "chia_streamable_macro 0.11.0", - "clvm-derive", "clvm-traits", "clvm-utils", "clvmr", @@ -436,7 +434,6 @@ dependencies = [ "clvm-traits", "clvmr", "libfuzzer-sys", - "pyo3", ] [[package]] @@ -466,7 +463,6 @@ dependencies = [ "clvm-utils", "clvmr", "hex", - "hex-literal", "rusqlite", "zstd", ] @@ -509,10 +505,6 @@ dependencies = [ "chia-bls 0.11.0", "chia-consensus", "chia-protocol", - "chia-traits 0.11.0", - "chia_py_streamable_macro", - "chia_streamable_macro 0.11.0", - "clvm-traits", "clvm-utils", "clvmr", "hex", diff --git a/crates/chia-bls/Cargo.toml b/crates/chia-bls/Cargo.toml index 851830e2e..a421d7047 100644 --- a/crates/chia-bls/Cargo.toml +++ b/crates/chia-bls/Cargo.toml @@ -18,7 +18,6 @@ arbitrary = ["dep:arbitrary"] [dependencies] chia-traits = { workspace = true } chia_py_streamable_macro = { workspace = true, optional = true } -anyhow = { workspace = true } sha2 = { workspace = true } clvmr = { workspace = true } hkdf = { workspace = true } diff --git a/crates/chia-consensus/Cargo.toml b/crates/chia-consensus/Cargo.toml index c58c66e25..7d5553e6f 100644 --- a/crates/chia-consensus/Cargo.toml +++ b/crates/chia-consensus/Cargo.toml @@ -23,7 +23,6 @@ chia_py_streamable_macro = { workspace = true, optional = true } clvm-utils = { workspace = true } chia-traits = { workspace = true } clvm-traits = { workspace = true } -clvm-derive = { workspace = true } chia-protocol = { workspace = true } chia-puzzles = { workspace = true } chia-bls = { workspace = true } diff --git a/crates/chia-puzzles/fuzz/Cargo.toml b/crates/chia-puzzles/fuzz/Cargo.toml index a9d81b326..df2700289 100644 --- a/crates/chia-puzzles/fuzz/Cargo.toml +++ b/crates/chia-puzzles/fuzz/Cargo.toml @@ -14,7 +14,6 @@ workspace = true [dependencies] libfuzzer-sys = { workspace = true } clvmr = { workspace = true } -pyo3 = { workspace = true, features = ["auto-initialize"]} chia-puzzles = { workspace = true, features = ["arbitrary"] } clvm-traits = { workspace = true } diff --git a/crates/chia-tools/Cargo.toml b/crates/chia-tools/Cargo.toml index 950e80ee4..3d48a3b21 100644 --- a/crates/chia-tools/Cargo.toml +++ b/crates/chia-tools/Cargo.toml @@ -25,7 +25,6 @@ clap = { workspace = true, features = ["derive"] } zstd = { workspace = true } blocking-threadpool = { workspace = true } hex = { workspace = true } -hex-literal = { workspace = true } [lib] name = "chia_tools" diff --git a/wheel/Cargo.toml b/wheel/Cargo.toml index f3d602ddd..ba2bbc64f 100644 --- a/wheel/Cargo.toml +++ b/wheel/Cargo.toml @@ -23,13 +23,8 @@ python-source = "python" [dependencies] clvmr = { workspace = true } hex = { workspace = true } - pyo3 = { workspace = true, features = ["multiple-pymethods"] } chia-consensus = { workspace = true, features = ["py-bindings"] } chia-bls = { workspace = true, features = ["py-bindings"] } chia-protocol = { workspace = true, features = ["py-bindings"] } -chia-traits = { workspace = true, features = ["py-bindings"] } -clvm-traits = { workspace = true, features = ["derive", "py-bindings"] } clvm-utils = { workspace = true } -chia_py_streamable_macro = { workspace = true } -chia_streamable_macro = { workspace = true }