From 4eba00236d6f536b42a5724adc55fc61aaace9da Mon Sep 17 00:00:00 2001 From: foo Date: Mon, 3 Jun 2024 09:56:09 -0400 Subject: [PATCH] clippy: add suggested clippy lints to top-level Cargo.toml and enable clippy linting at the workspace level for all crates Configure all workspaces to use lints from the top-level Cargo.toml file Add example lints that the project could configure to improve security and reliability. Configure lints to warn level. Using deny level makes other binaries fail to compile if even one of them has a failure. No lints are added in this commit. Future changes can enable and fix lints --- Cargo.toml | 17 +++++++++++++++++ bin/darkfi-mmproxy/Cargo.toml | 4 ++++ bin/darkfid/Cargo.toml | 4 ++++ bin/darkirc/Cargo.toml | 4 ++++ bin/darkwallet/Cargo.toml | 4 ++++ bin/dhtd/dhtd/Cargo.toml | 4 ++++ bin/drk/Cargo.toml | 4 ++++ bin/fud/fu/Cargo.toml | 4 ++++ bin/fud/fud/Cargo.toml | 4 ++++ bin/genev/genev-cli/Cargo.toml | 4 ++++ bin/genev/genevd/Cargo.toml | 4 ++++ bin/lilith/Cargo.toml | 4 ++++ bin/minerd/Cargo.toml | 4 ++++ bin/tau/tau-cli/Cargo.toml | 4 ++++ bin/tau/taud/Cargo.toml | 4 ++++ bin/vanityaddr/Cargo.toml | 4 ++++ bin/zkas/Cargo.toml | 4 ++++ example/dchat/dchatd/Cargo.toml | 4 ++++ example/p2pdebug/Cargo.toml | 4 ++++ example/wasm-hello-world/Cargo.toml | 4 ++++ fuzz/Cargo.toml | 7 +++++++ fuzz/honggfuzz/Cargo.toml | 4 ++++ script/research/blockchain-explorer/Cargo.toml | 4 ++++ script/research/dhtd/Cargo.toml | 4 ++++ script/research/gg/Cargo.toml | 4 ++++ script/research/last_man_standing/Cargo.toml | 4 ++++ script/research/pallas_constants/Cargo.toml | 4 ++++ script/research/pow/Cargo.toml | 4 ++++ script/research/pqxdh/Cargo.toml | 4 ++++ script/research/rln/rlnv1/Cargo.toml | 4 ++++ script/research/rln/rlnv2/Cargo.toml | 4 ++++ script/research/snowball/Cargo.toml | 4 ++++ script/research/sss/Cargo.toml | 4 ++++ script/research/tfhe/Cargo.toml | 4 ++++ script/research/zk/ecip-bench/Cargo.toml | 4 ++++ src/contract/dao/Cargo.toml | 4 ++++ src/contract/deployooor/Cargo.toml | 4 ++++ src/contract/money/Cargo.toml | 4 ++++ src/contract/test-harness/Cargo.toml | 4 ++++ src/sdk/Cargo.toml | 4 ++++ src/sdk/python/Cargo.toml | 4 ++++ src/serial/Cargo.toml | 4 ++++ src/serial/derive-internal/Cargo.toml | 4 ++++ src/serial/derive/Cargo.toml | 4 ++++ 44 files changed, 192 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index f0654ea13..48838b82a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -345,3 +345,20 @@ path = "bench/zk_from_json.rs" name = "sled" harness = false path = "bench/sled.rs" + +# Top-level lints. Enabled optionally on a crate-level in their respective Cargo.toml files. +[workspace.lints.clippy] +#arithmetic_side_effects = "warn" +#eq_op = "warn" +#float_cmp = "warn" +# integer_division = "warn" +#large_futures = "warn" +#large_stack_arrays = "warn" +#large_stack_frames = "warn" +#lossy_float_literal = "warn" +#manual_slice_size_calculation = "warn" +#modulo_one = "warn" +#out_of_bounds_indexing = "warn" +#overflow_check_conditional = "warn" +#recursive_format_impl = "warn" +#unchecked_duration_subtraction = "warn" diff --git a/bin/darkfi-mmproxy/Cargo.toml b/bin/darkfi-mmproxy/Cargo.toml index 5b1ae393f..0e99ccd95 100644 --- a/bin/darkfi-mmproxy/Cargo.toml +++ b/bin/darkfi-mmproxy/Cargo.toml @@ -37,3 +37,7 @@ smol = "2.0.0" serde = {version = "1.0.203", features = ["derive"]} structopt = "0.3.26" structopt-toml = "0.5.1" + +[lints] +workspace = true + diff --git a/bin/darkfid/Cargo.toml b/bin/darkfid/Cargo.toml index 68625c597..1e67149ae 100644 --- a/bin/darkfid/Cargo.toml +++ b/bin/darkfid/Cargo.toml @@ -40,3 +40,7 @@ smol = "2.0.0" serde = {version = "1.0.203", features = ["derive"]} structopt = "0.3.26" structopt-toml = "0.5.1" + +[lints] +workspace = true + diff --git a/bin/darkirc/Cargo.toml b/bin/darkirc/Cargo.toml index acb71af4f..bb9c9dd83 100644 --- a/bin/darkirc/Cargo.toml +++ b/bin/darkirc/Cargo.toml @@ -62,3 +62,7 @@ structopt-toml = "0.5.1" # See https://github.com/rust-mobile/android-rs-glue/issues/193 [target.aarch64-linux-android.dependencies] openssl = { version = "*", features = ["vendored"] } + +[lints] +workspace = true + diff --git a/bin/darkwallet/Cargo.toml b/bin/darkwallet/Cargo.toml index 39c1dfdb5..e5fcfd065 100644 --- a/bin/darkwallet/Cargo.toml +++ b/bin/darkwallet/Cargo.toml @@ -46,3 +46,7 @@ simplelog = "0.12.1" [package.metadata.android.activity_attributes] "android:exported" = "true" "android:windowSoftInputMode" = "adjustResize" + +[lints] +workspace = true + diff --git a/bin/dhtd/dhtd/Cargo.toml b/bin/dhtd/dhtd/Cargo.toml index 2694d1ace..6a7b674bd 100644 --- a/bin/dhtd/dhtd/Cargo.toml +++ b/bin/dhtd/dhtd/Cargo.toml @@ -19,3 +19,7 @@ rand = "0.8.5" simplelog = "0.12.2" smol = "2.0.0" url = "2.5.0" + +[lints] +workspace = true + diff --git a/bin/drk/Cargo.toml b/bin/drk/Cargo.toml index 6242b5f52..447409b21 100644 --- a/bin/drk/Cargo.toml +++ b/bin/drk/Cargo.toml @@ -40,3 +40,7 @@ smol = "2.0.0" serde = {version = "1.0.203", features = ["derive"]} structopt = "0.3.26" structopt-toml = "0.5.1" + +[lints] +workspace = true + diff --git a/bin/fud/fu/Cargo.toml b/bin/fud/fu/Cargo.toml index 367c7a0a1..a122c294e 100644 --- a/bin/fud/fu/Cargo.toml +++ b/bin/fud/fu/Cargo.toml @@ -20,3 +20,7 @@ log = "0.4.21" serde_json = "1.0.117" simplelog = "0.12.2" url = "2.5.0" + +[lints] +workspace = true + diff --git a/bin/fud/fud/Cargo.toml b/bin/fud/fud/Cargo.toml index 5cb682c6d..caa239abe 100644 --- a/bin/fud/fud/Cargo.toml +++ b/bin/fud/fud/Cargo.toml @@ -30,3 +30,7 @@ smol = "2.0.0" serde = {version = "1.0.203", features = ["derive"]} structopt = "0.3.26" structopt-toml = "0.5.1" + +[lints] +workspace = true + diff --git a/bin/genev/genev-cli/Cargo.toml b/bin/genev/genev-cli/Cargo.toml index d92e99c5d..a96a36613 100644 --- a/bin/genev/genev-cli/Cargo.toml +++ b/bin/genev/genev-cli/Cargo.toml @@ -20,3 +20,7 @@ log = "0.4.21" simplelog = "0.12.2" tinyjson = "2.5.1" url = "2.5.0" + +[lints] +workspace = true + diff --git a/bin/genev/genevd/Cargo.toml b/bin/genev/genevd/Cargo.toml index 26d9d30bb..80a359901 100644 --- a/bin/genev/genevd/Cargo.toml +++ b/bin/genev/genevd/Cargo.toml @@ -47,3 +47,7 @@ smol = "2.0.0" serde = { version = "1.0.203", features = ["derive"] } structopt = "0.3.26" structopt-toml = "0.5.1" + +[lints] +workspace = true + diff --git a/bin/lilith/Cargo.toml b/bin/lilith/Cargo.toml index fd63d9c63..117071f53 100644 --- a/bin/lilith/Cargo.toml +++ b/bin/lilith/Cargo.toml @@ -31,3 +31,7 @@ smol = "2.0.0" serde = {version = "1.0.203", features = ["derive"]} structopt = "0.3.26" structopt-toml = "0.5.1" + +[lints] +workspace = true + diff --git a/bin/minerd/Cargo.toml b/bin/minerd/Cargo.toml index c2662b613..29144a098 100644 --- a/bin/minerd/Cargo.toml +++ b/bin/minerd/Cargo.toml @@ -33,3 +33,7 @@ smol = "2.0.0" serde = {version = "1.0.203", features = ["derive"]} structopt = "0.3.26" structopt-toml = "0.5.1" + +[lints] +workspace = true + diff --git a/bin/tau/tau-cli/Cargo.toml b/bin/tau/tau-cli/Cargo.toml index b4219db51..349f2dbbb 100644 --- a/bin/tau/tau-cli/Cargo.toml +++ b/bin/tau/tau-cli/Cargo.toml @@ -28,3 +28,7 @@ url = "2.5.0" clap = {version = "4.4.11", features = ["derive"]} serde = {version = "1.0.203", features = ["derive"]} tinyjson = "2.5.1" + +[lints] +workspace = true + diff --git a/bin/tau/taud/Cargo.toml b/bin/tau/taud/Cargo.toml index 4b3f11b33..45d9dac27 100644 --- a/bin/tau/taud/Cargo.toml +++ b/bin/tau/taud/Cargo.toml @@ -59,3 +59,7 @@ smol = "2.0.0" serde = { version = "1.0.203", features = ["derive"] } structopt = "0.3.26" structopt-toml = "0.5.1" + +[lints] +workspace = true + diff --git a/bin/vanityaddr/Cargo.toml b/bin/vanityaddr/Cargo.toml index 1eeca202c..a7de765f1 100644 --- a/bin/vanityaddr/Cargo.toml +++ b/bin/vanityaddr/Cargo.toml @@ -17,3 +17,7 @@ darkfi-sdk = {path = "../../src/sdk"} darkfi_money_contract = {path = "../../src/contract/money", features = ["no-entrypoint", "client"]} rand = "0.8.5" rayon = "1.10.0" + +[lints] +workspace = true + diff --git a/bin/zkas/Cargo.toml b/bin/zkas/Cargo.toml index d43132218..d4a1c4328 100644 --- a/bin/zkas/Cargo.toml +++ b/bin/zkas/Cargo.toml @@ -11,3 +11,7 @@ edition = "2021" [dependencies] arg = {git = "https://github.com/parazyd/arg"} darkfi = {path = "../../", features = ["zkas"]} + +[lints] +workspace = true + diff --git a/example/dchat/dchatd/Cargo.toml b/example/dchat/dchatd/Cargo.toml index 68f8834a2..2c7543649 100644 --- a/example/dchat/dchatd/Cargo.toml +++ b/example/dchat/dchatd/Cargo.toml @@ -32,3 +32,7 @@ async-trait = "0.1.80" log = "0.4.21" url = "2.5.0" # ANCHOR_END: dependencies + +[lints] +workspace = true + diff --git a/example/p2pdebug/Cargo.toml b/example/p2pdebug/Cargo.toml index 6b5058bc2..9ca6cb5f5 100644 --- a/example/p2pdebug/Cargo.toml +++ b/example/p2pdebug/Cargo.toml @@ -32,3 +32,7 @@ url = "2.5.0" # Encoding and parsing serde_json = "1.0.117" + +[lints] +workspace = true + diff --git a/example/wasm-hello-world/Cargo.toml b/example/wasm-hello-world/Cargo.toml index 064e71280..0b1c8f5f9 100644 --- a/example/wasm-hello-world/Cargo.toml +++ b/example/wasm-hello-world/Cargo.toml @@ -22,3 +22,7 @@ getrandom = { version = "0.2.8", features = ["custom"] } [features] default = [] no-entrypoint = [] + +[lints] +workspace = true + diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 41aad15d4..7aa483386 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" [package.metadata] cargo-fuzz = true +[lints] +workspace = true + [dependencies] libfuzzer-sys = "0.4.7" @@ -57,3 +60,7 @@ name = "zkas-compile" path = "fuzz_targets/zkas_compile.rs" test = false doc = false + +[lints] +workspace = true + diff --git a/fuzz/honggfuzz/Cargo.toml b/fuzz/honggfuzz/Cargo.toml index b51391ef7..330175322 100644 --- a/fuzz/honggfuzz/Cargo.toml +++ b/fuzz/honggfuzz/Cargo.toml @@ -52,3 +52,7 @@ name = "zkas-compile" path = "src/zkas_compile.rs" test = false doc = false + +[lints] +workspace = true + diff --git a/script/research/blockchain-explorer/Cargo.toml b/script/research/blockchain-explorer/Cargo.toml index a8d025ed8..f0a6ecf4a 100644 --- a/script/research/blockchain-explorer/Cargo.toml +++ b/script/research/blockchain-explorer/Cargo.toml @@ -20,3 +20,7 @@ sled = "0.34.7" [patch.crates-io] halo2_proofs = {git="https://github.com/parazyd/halo2", branch="v4"} halo2_gadgets = {git="https://github.com/parazyd/halo2", branch="v4"} + +[lints] +workspace = true + diff --git a/script/research/dhtd/Cargo.toml b/script/research/dhtd/Cargo.toml index e4ac90e6f..e9dad26f5 100644 --- a/script/research/dhtd/Cargo.toml +++ b/script/research/dhtd/Cargo.toml @@ -30,3 +30,7 @@ structopt = "0.3.26" structopt-toml = "0.5.1" [workspace] + +[lints] +workspace = true + diff --git a/script/research/gg/Cargo.toml b/script/research/gg/Cargo.toml index 1d23de204..b8f5dbf6e 100644 --- a/script/research/gg/Cargo.toml +++ b/script/research/gg/Cargo.toml @@ -30,3 +30,7 @@ sled = "0.34.7" halo2_proofs = {git="https://github.com/parazyd/halo2", branch="v4"} halo2_gadgets = {git="https://github.com/parazyd/halo2", branch="v4"} blake2b_simd = {git="https://github.com/parazyd/blake2_simd", branch="impl-common"} + +[lints] +workspace = true + diff --git a/script/research/last_man_standing/Cargo.toml b/script/research/last_man_standing/Cargo.toml index 51ef9ea9c..9b7521a68 100644 --- a/script/research/last_man_standing/Cargo.toml +++ b/script/research/last_man_standing/Cargo.toml @@ -14,3 +14,7 @@ darkfi = {path = "../../../", features = ["blockchain"]} darkfi-sdk = {path = "../../../src/sdk"} rand = "0.8.5" sled = "0.34.7" + +[lints] +workspace = true + diff --git a/script/research/pallas_constants/Cargo.toml b/script/research/pallas_constants/Cargo.toml index bf4d97faa..23c220f36 100644 --- a/script/research/pallas_constants/Cargo.toml +++ b/script/research/pallas_constants/Cargo.toml @@ -16,3 +16,7 @@ darkfi-sdk = {path = "../../../src/sdk"} [patch.crates-io] halo2_proofs = {git="https://github.com/parazyd/halo2", branch="v3"} + +[lints] +workspace = true + diff --git a/script/research/pow/Cargo.toml b/script/research/pow/Cargo.toml index e1224eabc..ec2d93690 100644 --- a/script/research/pow/Cargo.toml +++ b/script/research/pow/Cargo.toml @@ -18,3 +18,7 @@ lazy_static = "1.4.0" [patch.crates-io] blake2b_simd = {git = "https://github.com/parazyd/blake2_simd", branch = "impl-common"} + +[lints] +workspace = true + diff --git a/script/research/pqxdh/Cargo.toml b/script/research/pqxdh/Cargo.toml index 028f556f4..cfa8d99c5 100644 --- a/script/research/pqxdh/Cargo.toml +++ b/script/research/pqxdh/Cargo.toml @@ -16,3 +16,7 @@ kyber-kem = "0.1.3" rand = "0.8.5" sha2 = "0.10.8" x25519-dalek = {version = "2.0.1", features = ["static_secrets"]} + +[lints] +workspace = true + diff --git a/script/research/rln/rlnv1/Cargo.toml b/script/research/rln/rlnv1/Cargo.toml index bd1c4de5e..a1889ab82 100644 --- a/script/research/rln/rlnv1/Cargo.toml +++ b/script/research/rln/rlnv1/Cargo.toml @@ -16,3 +16,7 @@ rand = "0.8.5" [patch.crates-io] halo2_proofs = {git="https://github.com/parazyd/halo2", branch="v4"} halo2_gadgets = {git="https://github.com/parazyd/halo2", branch="v4"} + +[lints] +workspace = true + diff --git a/script/research/rln/rlnv2/Cargo.toml b/script/research/rln/rlnv2/Cargo.toml index 11dc9dce9..5fd7255b6 100644 --- a/script/research/rln/rlnv2/Cargo.toml +++ b/script/research/rln/rlnv2/Cargo.toml @@ -17,3 +17,7 @@ blake3 = "1.5.1" [patch.crates-io] halo2_proofs = {git="https://github.com/parazyd/halo2", branch="v4"} halo2_gadgets = {git="https://github.com/parazyd/halo2", branch="v4"} + +[lints] +workspace = true + diff --git a/script/research/snowball/Cargo.toml b/script/research/snowball/Cargo.toml index 81c10faa7..daddbdd31 100644 --- a/script/research/snowball/Cargo.toml +++ b/script/research/snowball/Cargo.toml @@ -14,3 +14,7 @@ darkfi-serial = {path = "../../../src/serial"} blake3 = "1.5.1" num-bigint = "0.4.5" rand = "0.8.5" + +[lints] +workspace = true + diff --git a/script/research/sss/Cargo.toml b/script/research/sss/Cargo.toml index 0a445fdf0..54a32a181 100644 --- a/script/research/sss/Cargo.toml +++ b/script/research/sss/Cargo.toml @@ -10,3 +10,7 @@ edition = "2021" [dependencies] pasta_curves = "0.5.1" rand = "0.8.5" + +[lints] +workspace = true + diff --git a/script/research/tfhe/Cargo.toml b/script/research/tfhe/Cargo.toml index 782c7b78b..982c50d77 100644 --- a/script/research/tfhe/Cargo.toml +++ b/script/research/tfhe/Cargo.toml @@ -10,3 +10,7 @@ edition = "2021" [dependencies] tfhe = {version = "0.5.4", features = ["boolean", "shortint", "integer", "x86_64-unix", "internal-keycache"]} rayon = "1.10.0" + +[lints] +workspace = true + diff --git a/script/research/zk/ecip-bench/Cargo.toml b/script/research/zk/ecip-bench/Cargo.toml index 7c5e5422b..06077189b 100644 --- a/script/research/zk/ecip-bench/Cargo.toml +++ b/script/research/zk/ecip-bench/Cargo.toml @@ -17,3 +17,7 @@ hex = "0.4.3" [patch.crates-io] halo2_proofs = {git="https://github.com/parazyd/halo2", branch="v3"} + +[lints] +workspace = true + diff --git a/src/contract/dao/Cargo.toml b/src/contract/dao/Cargo.toml index fbfc7f709..f727ec279 100644 --- a/src/contract/dao/Cargo.toml +++ b/src/contract/dao/Cargo.toml @@ -52,3 +52,7 @@ client = [ "log", "halo2_proofs", ] + +[lints] +workspace = true + diff --git a/src/contract/deployooor/Cargo.toml b/src/contract/deployooor/Cargo.toml index 659ef4d26..c5f18ffd0 100644 --- a/src/contract/deployooor/Cargo.toml +++ b/src/contract/deployooor/Cargo.toml @@ -41,3 +41,7 @@ client = [ "log", "rand", ] + +[lints] +workspace = true + diff --git a/src/contract/money/Cargo.toml b/src/contract/money/Cargo.toml index 2ed922a80..d46ecb151 100644 --- a/src/contract/money/Cargo.toml +++ b/src/contract/money/Cargo.toml @@ -51,3 +51,7 @@ client = [ "log", "halo2_proofs", ] + +[lints] +workspace = true + diff --git a/src/contract/test-harness/Cargo.toml b/src/contract/test-harness/Cargo.toml index 8f9536a6e..7829fcb2f 100644 --- a/src/contract/test-harness/Cargo.toml +++ b/src/contract/test-harness/Cargo.toml @@ -20,3 +20,7 @@ log = "0.4.21" rand = "0.8.5" simplelog = "0.12.2" sled = "0.34.7" + +[lints] +workspace = true + diff --git a/src/sdk/Cargo.toml b/src/sdk/Cargo.toml index 8ff83e1eb..fc2cfe57a 100644 --- a/src/sdk/Cargo.toml +++ b/src/sdk/Cargo.toml @@ -45,3 +45,7 @@ subtle = "2.5.0" halo2_proofs = {version = "0.3.0", features = ["dev-graph", "sanity-checks"]} halo2_gadgets = {version = "0.3.0", features = ["test-dependencies"]} rand = "0.8.5" + +[lints] +workspace = true + diff --git a/src/sdk/python/Cargo.toml b/src/sdk/python/Cargo.toml index c4d2d9e14..cb8cc2e91 100644 --- a/src/sdk/python/Cargo.toml +++ b/src/sdk/python/Cargo.toml @@ -21,3 +21,7 @@ halo2_gadgets = "0.3.0" plotters = "0.3.6" pyo3 = {version = "0.21.2", features = ["gil-refs"]} rand = "0.8.5" + +[lints] +workspace = true + diff --git a/src/serial/Cargo.toml b/src/serial/Cargo.toml index c2f7e5964..3a04259e1 100644 --- a/src/serial/Cargo.toml +++ b/src/serial/Cargo.toml @@ -30,3 +30,7 @@ async = ["futures-lite", "async-trait", "darkfi-derive/async"] collections = [] crypto = ["collections", "hash", "bridgetree", "pasta_curves"] hash = ["blake3"] + +[lints] +workspace = true + diff --git a/src/serial/derive-internal/Cargo.toml b/src/serial/derive-internal/Cargo.toml index cb80a57c1..56793edea 100644 --- a/src/serial/derive-internal/Cargo.toml +++ b/src/serial/derive-internal/Cargo.toml @@ -16,3 +16,7 @@ syn = {version = "2.0.66", features = ["full", "fold"]} [features] default = [] async = [] + +[lints] +workspace = true + diff --git a/src/serial/derive/Cargo.toml b/src/serial/derive/Cargo.toml index 3606ba65d..25642c14e 100644 --- a/src/serial/derive/Cargo.toml +++ b/src/serial/derive/Cargo.toml @@ -22,3 +22,7 @@ darkfi-derive-internal = {version = "0.4.1", path = "../derive-internal"} [features] default = [] async = ["darkfi-derive-internal/async"] + +[lints] +workspace = true +