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

Add machete to check unused dependencies #693

Merged
merged 6 commits into from
Sep 17, 2024
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
6 changes: 6 additions & 0 deletions .github/workflows/build-crate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ 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
entry: cargo machete
language: system
pass_filenames: false
- id: tests
name: run tests
description: run cargo test on the workspace
Expand Down
8 changes: 0 additions & 8 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion crates/chia-bls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
1 change: 0 additions & 1 deletion crates/chia-consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 0 additions & 4 deletions crates/chia-consensus/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-consensus/fuzz/fuzz_targets/parse-cond-args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion crates/chia-consensus/fuzz/fuzz_targets/parse-spend-id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-consensus/fuzz/fuzz_targets/parse-spend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-consensus/fuzz/fuzz_targets/parse-spends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion crates/chia-consensus/fuzz/fuzz_targets/process-spend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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] = [
Expand Down
1 change: 0 additions & 1 deletion crates/chia-puzzles/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
1 change: 0 additions & 1 deletion crates/chia-tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion crates/clvm-utils/fuzz/fuzz_targets/curry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion crates/clvm-utils/fuzz/fuzz_targets/tree-hash.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
5 changes: 0 additions & 5 deletions wheel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Loading