From 562e895f2192621a37d34d92ecb45c6869e1aa6d Mon Sep 17 00:00:00 2001 From: Bjerg Date: Fri, 23 Dec 2022 13:19:50 +0100 Subject: [PATCH] ci: unused dependencies sanity check (#590) * ci: add unused deps sanity check * ci: fix unused deps issue template title * ci: rename udeps job * chore: formatting * chore: make `cargo-udeps` ignore `aquamarine` * deps: resolve unused deps * ci: check every feature and target in udeps job --- .github/SANITY_UNUSED_DEPS_ISSUE_TEMPLATE.md | 15 ++++++++++ .github/workflows/sanity.yml | 29 ++++++++++++++++++-- Cargo.lock | 20 -------------- bin/reth/Cargo.toml | 2 +- crates/common/rlp-derive/Cargo.toml | 3 +- crates/common/rlp/Cargo.toml | 1 - crates/consensus/Cargo.toml | 3 +- crates/executor/Cargo.toml | 2 -- crates/interfaces/Cargo.toml | 2 -- crates/net/network/Cargo.toml | 7 ++++- crates/primitives/Cargo.toml | 5 ++-- crates/stages/Cargo.toml | 10 +++++-- crates/storage/codecs/derive/Cargo.toml | 8 ++++++ crates/storage/db/Cargo.toml | 2 -- crates/transaction-pool/Cargo.toml | 7 ++++- 15 files changed, 74 insertions(+), 42 deletions(-) create mode 100644 .github/SANITY_UNUSED_DEPS_ISSUE_TEMPLATE.md diff --git a/.github/SANITY_UNUSED_DEPS_ISSUE_TEMPLATE.md b/.github/SANITY_UNUSED_DEPS_ISSUE_TEMPLATE.md new file mode 100644 index 000000000..76f6690e1 --- /dev/null +++ b/.github/SANITY_UNUSED_DEPS_ISSUE_TEMPLATE.md @@ -0,0 +1,15 @@ +--- +title: "chore: some installed deps are not needed" +labels: C-debt, A-dependencies +--- + +Some dependencies specified in `Cargo.toml` are not needed. + +Check the [unused dependencies sanity check]({{env.WORKFLOW_URL}}) workflow for details. + +This issue was raised by the workflow at `.github/workflows/sanity.yml`. + +> **Note** +> If this is a false positive, please refer to the [`cargo-udeps` docs][cargo-udeps-docs] on how to ignore the dependencies. + +[cargo-udeps-docs]: https://github.com/est31/cargo-udeps#ignoring-some-of-the-dependencies diff --git a/.github/workflows/sanity.yml b/.github/workflows/sanity.yml index 456db8e22..1b33133fd 100644 --- a/.github/workflows/sanity.yml +++ b/.github/workflows/sanity.yml @@ -43,8 +43,6 @@ jobs: - name: Install latest nextest release uses: taiki-e/install-action@nextest - - name: Install cargo-llvm-cov - uses: taiki-e/install-action@cargo-llvm-cov - name: Update packages run: cargo update @@ -60,3 +58,30 @@ jobs: with: update_existing: true filename: .github/SANITY_DEPS_ISSUE_TEMPLATE.md + + unused-deps: + # Pin to `20.04` instead of `ubuntu-latest`, until ubuntu-latest migration is complete + # See also + runs-on: ubuntu-20.04 + name: unused dependencies + steps: + - name: Checkout sources + uses: actions/checkout@v3 + - name: Install toolchain + uses: dtolnay/rust-toolchain@nightly + + - name: Install cargo-udeps + run: cargo install cargo-udeps --locked + + - name: Check for unused dependencies + run: cargo +nightly udeps --all-features --all-targets + + - uses: JasonEtco/create-an-issue@v2 + if: ${{ failure() }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + update_existing: true + filename: .github/SANITY_UNUSED_DEPS_ISSUE_TEMPLATE.md + diff --git a/Cargo.lock b/Cargo.lock index 1bc3fe971..a026e58e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2352,12 +2352,6 @@ dependencies = [ "libc", ] -[[package]] -name = "maplit" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" - [[package]] name = "matchers" version = "0.1.0" @@ -3305,7 +3299,6 @@ dependencies = [ "reth-primitives", "reth-provider", "reth-rlp", - "reth-rpc", "reth-stages", "reth-transaction-pool", "serde", @@ -3337,7 +3330,6 @@ version = "0.1.0" dependencies = [ "async-trait", "auto_impl", - "eyre", "futures", "reth-interfaces", "reth-primitives", @@ -3362,7 +3354,6 @@ dependencies = [ "async-trait", "bytes", "criterion", - "eyre", "futures", "heapless", "iai", @@ -3492,11 +3483,9 @@ version = "0.1.0" dependencies = [ "async-trait", "auto_impl", - "eyre", "hash-db", "hashbrown 0.13.1", "plain_hasher", - "reth-consensus", "reth-db", "reth-interfaces", "reth-primitives", @@ -3520,11 +3509,9 @@ dependencies = [ "auto_impl", "bytes", "futures", - "heapless", "hex-literal", "modular-bitfield", "parity-scale-codec", - "postcard", "rand 0.8.5", "reth-codecs", "reth-db", @@ -3599,7 +3586,6 @@ dependencies = [ "aquamarine", "async-trait", "bytes", - "either", "enr 0.7.0", "ethers-core", "ethers-providers", @@ -3644,7 +3630,6 @@ dependencies = [ "hash-db", "hex", "hex-literal", - "maplit", "modular-bitfield", "parity-scale-codec", "plain_hasher", @@ -3706,14 +3691,12 @@ dependencies = [ "rlp", "secp256k1", "smol_str", - "tracing", ] [[package]] name = "reth-rlp-derive" version = "0.1.1" dependencies = [ - "bytes", "proc-macro2", "quote", "syn", @@ -3777,7 +3760,6 @@ dependencies = [ "reth-eth-wire", "reth-executor", "reth-interfaces", - "reth-network", "reth-primitives", "reth-provider", "reth-rlp", @@ -3786,7 +3768,6 @@ dependencies = [ "tokio", "tokio-stream", "tracing", - "tracing-futures", ] [[package]] @@ -3816,7 +3797,6 @@ dependencies = [ "bitflags", "fnv", "futures-util", - "linked-hash-map", "parking_lot 0.12.1", "paste", "rand 0.8.5", diff --git a/bin/reth/Cargo.toml b/bin/reth/Cargo.toml index 9b12dc72b..181aaddcb 100644 --- a/bin/reth/Cargo.toml +++ b/bin/reth/Cargo.toml @@ -17,7 +17,7 @@ reth-interfaces = { path = "../../crates/interfaces", features = ["test-utils"] reth-transaction-pool = { path = "../../crates/transaction-pool" } reth-consensus = { path = "../../crates/consensus", features = ["serde"] } reth-executor = { path = "../../crates/executor" } -reth-rpc = {path = "../../crates/net/rpc"} +# reth-rpc = {path = "../../crates/net/rpc"} reth-rlp = { path = "../../crates/common/rlp" } reth-network = {path = "../../crates/net/network" } reth-downloaders = {path = "../../crates/net/downloaders" } diff --git a/crates/common/rlp-derive/Cargo.toml b/crates/common/rlp-derive/Cargo.toml index ff913a578..361521898 100644 --- a/crates/common/rlp-derive/Cargo.toml +++ b/crates/common/rlp-derive/Cargo.toml @@ -10,7 +10,6 @@ repository = "https://github.com/paradigmxyz/reth" proc-macro = true [dependencies] -bytes = { version = "1", default-features = false } syn = "1" quote = "1" -proc-macro2 = "1" \ No newline at end of file +proc-macro2 = "1" diff --git a/crates/common/rlp/Cargo.toml b/crates/common/rlp/Cargo.toml index c36bd5c33..b88818e84 100644 --- a/crates/common/rlp/Cargo.toml +++ b/crates/common/rlp/Cargo.toml @@ -16,7 +16,6 @@ enr = { version = "0.7", default-features = false, optional = true } rlp = { version = "0.5.2", default-features = false, optional = true } ethereum-types = { version = "0.14", features = ["codec"], optional = true } reth-rlp-derive = { version = "0.1", path = "../rlp-derive", optional = true } -tracing = "0.1.37" [dev-dependencies] reth-rlp = { path = ".", package = "reth-rlp", features = [ diff --git a/crates/consensus/Cargo.toml b/crates/consensus/Cargo.toml index 9397390d6..6c8b6fea6 100644 --- a/crates/consensus/Cargo.toml +++ b/crates/consensus/Cargo.toml @@ -22,11 +22,10 @@ tokio-stream = "0.1" # common thiserror = "1.0.37" -eyre = "0.6.8" auto_impl = "1.0" # io serde = { version = "1.0", optional = true } [features] -serde = ["dep:serde"] \ No newline at end of file +serde = ["dep:serde"] diff --git a/crates/executor/Cargo.toml b/crates/executor/Cargo.toml index 2d13e8524..ae88410b7 100644 --- a/crates/executor/Cargo.toml +++ b/crates/executor/Cargo.toml @@ -13,7 +13,6 @@ reth-interfaces = { path = "../interfaces" } reth-rlp = { path = "../common/rlp" } reth-db = { path = "../storage/db" } reth-provider = { path = "../storage/provider" } -reth-consensus = { path = "../consensus" } revm = "2.3" # remove from reth and reexport from revm @@ -22,7 +21,6 @@ hashbrown = "0.13" # common async-trait = "0.1.57" thiserror = "1.0.37" -eyre = "0.6.8" auto_impl = "1.0" tracing = "0.1.37" tokio = { version = "1.21.2", features = ["sync"] } diff --git a/crates/interfaces/Cargo.toml b/crates/interfaces/Cargo.toml index f875b8121..057df2919 100644 --- a/crates/interfaces/Cargo.toml +++ b/crates/interfaces/Cargo.toml @@ -21,8 +21,6 @@ reth-eth-wire = { path = "../net/eth-wire" } # codecs serde = { version = "1.0.*", default-features = false } -postcard = { version = "1.0.2", features = ["alloc"] } -heapless = "0.7.16" parity-scale-codec = { version = "3.2.1", features = ["bytes"] } futures = "0.3.25" tokio-stream = "0.1.11" diff --git a/crates/net/network/Cargo.toml b/crates/net/network/Cargo.toml index 7c85f557c..1022acc60 100644 --- a/crates/net/network/Cargo.toml +++ b/crates/net/network/Cargo.toml @@ -9,6 +9,12 @@ description = """ Ethereum network support """ +[package.metadata.cargo-udeps.ignore] +normal = [ + # Used for diagrams in docs + "aquamarine" +] + [dependencies] # reth reth-interfaces = { path = "../../interfaces" } @@ -37,7 +43,6 @@ thiserror = "1.0" parking_lot = "0.12" async-trait = "0.1" bytes = "1.2" -either = "1.8" linked_hash_set = "0.1" rand = "0.8" secp256k1 = { version = "0.24", features = [ diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 1d01fb1d3..f20d27953 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -28,9 +28,8 @@ secp256k1 = { version = "0.24.2", default-features = false, features = [ "recovery", ] } -#used for forkid +# used for forkid crc = "1" -maplit = "1" # misc bytes = "1.2" @@ -57,4 +56,4 @@ test-fuzz = "3.0.4" # necessary so we don't hit a "undeclared 'std'": # https://github.com/paradigmxyz/reth/pull/177#discussion_r1021172198 -secp256k1 = "0.24.2" \ No newline at end of file +secp256k1 = "0.24.2" diff --git a/crates/stages/Cargo.toml b/crates/stages/Cargo.toml index 574ec2afc..c6883029c 100644 --- a/crates/stages/Cargo.toml +++ b/crates/stages/Cargo.toml @@ -7,6 +7,12 @@ repository = "https://github.com/paradigmxyz/reth" readme = "README.md" description = "Staged syncing primitives used in reth." +[package.metadata.cargo-udeps.ignore] +normal = [ + # Used for diagrams in docs + "aquamarine" +] + [dependencies] # reth libs reth-primitives = { path = "../primitives" } @@ -15,15 +21,13 @@ reth-executor = { path = "../executor" } reth-rlp = { path = "../common/rlp" } reth-db = { path = "../storage/db" } reth-provider = { path = "../storage/provider" } -reth-network = { path = "../net/network" } -#async +# async tokio = { version = "1.21.2", features = ["sync"] } async-trait = "0.1.57" thiserror = "1.0.37" tracing = "0.1.36" -tracing-futures = "0.2.5" aquamarine = "0.1.12" metrics = "0.20.1" futures-util = "0.3.25" diff --git a/crates/storage/codecs/derive/Cargo.toml b/crates/storage/codecs/derive/Cargo.toml index a27ad69bf..98f73635b 100644 --- a/crates/storage/codecs/derive/Cargo.toml +++ b/crates/storage/codecs/derive/Cargo.toml @@ -6,6 +6,14 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/paradigmxyz/reth" readme = "../README.md" +[package.metadata.cargo-udeps.ignore] +normal = [ + # Used in proc macros + "serde", + # Used in proc macros + "parity-scale-codec" +] + [lib] proc-macro = true diff --git a/crates/storage/db/Cargo.toml b/crates/storage/db/Cargo.toml index aeb7e13b7..b52a9529a 100644 --- a/crates/storage/db/Cargo.toml +++ b/crates/storage/db/Cargo.toml @@ -31,8 +31,6 @@ bytes = "1.2.1" page_size = "0.4.2" thiserror = "1.0.37" tempfile = { version = "3.3.0", optional = true } -eyre = "0.6.8" - [dev-dependencies] tempfile = "3.3.0" diff --git a/crates/transaction-pool/Cargo.toml b/crates/transaction-pool/Cargo.toml index 729800462..1197ff8db 100644 --- a/crates/transaction-pool/Cargo.toml +++ b/crates/transaction-pool/Cargo.toml @@ -9,6 +9,12 @@ description = """ Transaction pool implementation """ +[package.metadata.cargo-udeps.ignore] +normal = [ + # Used for diagrams in docs + "aquamarine" +] + [dependencies] # eth @@ -25,7 +31,6 @@ aquamarine = "0.1" # docs thiserror = "1.0" tracing = "0.1" serde = { version = "1.0", features = ["derive", "rc"] } -linked-hash-map = "0.5" fnv = "1.0.7" bitflags = "1.3"