Skip to content

Commit

Permalink
chore: add cargo-deny (#603)
Browse files Browse the repository at this point in the history
* chore: add cargo-deny and ensure it passes

* ci: enforce cargo deny
  • Loading branch information
itegulov authored Feb 27, 2025
1 parent 18cdc30 commit 6bd3643
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 41 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/cargo-license.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: cargo-deny check
on: pull_request
jobs:
cargo-deny:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2
with:
manifest-path: "./Cargo.toml"
command: check
command-arguments: "--hide-inclusion-graph"
66 changes: 39 additions & 27 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ zksync_contracts = { git = "https://github.com/matter-labs/zksync-era", tag = "c
zksync_types = { git = "https://github.com/matter-labs/zksync-era", tag = "core-v26.4.0" }
zksync_vm_interface = { git = "https://github.com/matter-labs/zksync-era", tag = "core-v26.4.0" }
zksync_web3_decl = { git = "https://github.com/matter-labs/zksync-era", tag = "core-v26.4.0" }
zksync_telemetry = { git = "https://github.com/matter-labs/zksync-telemetry.git", rev = "ed600f46c74ccc15ae34ea38f27327d66458518a" }
zksync_telemetry = { git = "https://github.com/matter-labs/zksync-telemetry.git", rev = "d5c35951843263765079545c31c908dcbaab1f30" }
zksync-error-codegen = { git = "https://github.com/matter-labs/zksync-error", rev = "92d1b60d18686e0e261f04dc7efd74db60e112f1", default-features = false }
zksync-error-description = { git = "https://github.com/matter-labs/zksync-error", rev = "92d1b60d18686e0e261f04dc7efd74db60e112f1" }

Expand Down Expand Up @@ -72,7 +72,7 @@ serde_json = "1.0"
strum = "0.26.3"
strum_macros = "0.26.4"
serde_yaml = "0.9.33"
tempdir = "0.3.7"
tempfile = { version = "3.16.0", default-features = false }
thiserror = "1"
time = "0.3.36"
tokio = { version = "1", features = ["full", "tracing"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ flate2.workspace = true
url.workspace = true

[dev-dependencies]
tempdir.workspace = true
tempfile.workspace = true
11 changes: 8 additions & 3 deletions crates/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,6 @@ mod tests {
env,
net::{IpAddr, Ipv4Addr},
};
use tempdir::TempDir;
use zksync_types::{H160, U256};

#[test]
Expand Down Expand Up @@ -915,7 +914,10 @@ mod tests {

#[tokio::test]
async fn test_dump_state() -> anyhow::Result<()> {
let temp_dir = TempDir::new("state-test").expect("failed creating temporary dir");
let temp_dir = tempfile::Builder::new()
.prefix("state-test")
.tempdir()
.expect("failed creating temporary dir");
let dump_path = temp_dir.path().join("state.json");

let config = anvil_zksync_config::TestNodeConfig {
Expand Down Expand Up @@ -956,7 +958,10 @@ mod tests {

#[tokio::test]
async fn test_load_state() -> anyhow::Result<()> {
let temp_dir = TempDir::new("state-load-test").expect("failed creating temporary dir");
let temp_dir = tempfile::Builder::new()
.prefix("state-load-test")
.tempdir()
.expect("failed creating temporary dir");
let state_path = temp_dir.path().join("state.json");

let config = anvil_zksync_config::TestNodeConfig {
Expand Down
2 changes: 1 addition & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ url.workspace = true
[dev-dependencies]
maplit.workspace = true
httptest.workspace = true
tempdir.workspace = true
tempfile.workspace = true
test-case.workspace = true
backon.workspace = true

Expand Down
16 changes: 12 additions & 4 deletions crates/core/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ impl Cache {

#[cfg(test)]
mod tests {
use tempdir::TempDir;
use zksync_types::{Execute, ExecuteTransactionCommon};
use zksync_types::{H160, U64};

Expand Down Expand Up @@ -504,7 +503,10 @@ mod tests {
l2_legacy_shared_bridge: Some(H160::repeat_byte(0x6)),
};

let cache_dir = TempDir::new("cache-test").expect("failed creating temporary dir");
let cache_dir = tempfile::Builder::new()
.prefix("cache-test")
.tempdir()
.expect("failed creating temporary dir");
let cache_dir_path = cache_dir
.path()
.to_str()
Expand Down Expand Up @@ -605,7 +607,10 @@ mod tests {
l2_legacy_shared_bridge: Some(H160::repeat_byte(0x6)),
};

let cache_dir = TempDir::new("cache-test").expect("failed creating temporary dir");
let cache_dir = tempfile::Builder::new()
.prefix("cache-test")
.tempdir()
.expect("failed creating temporary dir");
let cache_dir_path = cache_dir
.path()
.to_str()
Expand Down Expand Up @@ -660,7 +665,10 @@ mod tests {

#[test]
fn test_cache_config_disk_only_resets_created_data_on_disk() {
let cache_dir = TempDir::new("cache-test").expect("failed creating temporary dir");
let cache_dir = tempfile::Builder::new()
.prefix("cache-test")
.tempdir()
.expect("failed creating temporary dir");
let cache_dir_path = cache_dir
.path()
.to_str()
Expand Down
2 changes: 1 addition & 1 deletion crates/l1_sidecar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ alloy = { workspace = true, default-features = false, features = ["sol-types", "
foundry-anvil.workspace = true
foundry-common.workspace = true
anyhow.workspace = true
tempdir.workspace = true
tempfile.workspace = true
serde.workspace = true
serde_yaml.workspace = true
serde_with.workspace = true
Expand Down
6 changes: 4 additions & 2 deletions crates/l1_sidecar/src/anvil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use anyhow::Context;
use foundry_anvil::{NodeConfig, NodeHandle};
use foundry_common::Shell;
use std::time::Duration;
use tempdir::TempDir;
use tempfile::TempDir;
use tokio::io::AsyncWriteExt;

/// Representation of an anvil process spawned onto an event loop.
Expand Down Expand Up @@ -34,7 +34,9 @@ pub async fn spawn_builtin(
port: u16,
zkstack_config: &ZkstackConfig,
) -> anyhow::Result<(AnvilHandle, Box<dyn Provider>)> {
let tmpdir = TempDir::new("anvil_zksync_l1")?;
let tmpdir = tempfile::Builder::new()
.prefix("anvil_zksync_l1")
.tempdir()?;
let anvil_state_path = tmpdir.path().join("l1-state.json");
let mut anvil_state_file = tokio::fs::File::create(&anvil_state_path).await?;
anvil_state_file
Expand Down
78 changes: 78 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
[graph]
targets = [
"x86_64-unknown-linux-gnu",
"aarch64-unknown-linux-gnu",
"x86_64-apple-darwin",
"aarch64-apple-darwin",
]
all-features = false
no-default-features = false

[output]
feature-depth = 1

[advisories]
ignore = [
{ id = "RUSTSEC-2024-0370", reason = "`proc-macro-error` is unmaintained, but foundry relies on it" },
{ id = "RUSTSEC-2024-0388", reason = '`derivative` is unmaintained, crypto dependenicies (boojum, circuit_encodings and others) rely on it' },
]

[licenses]
allow = [
"MIT",
"Apache-2.0",
"ISC",
"Unlicense",
"MPL-2.0",
"CC0-1.0",
"BSD-2-Clause",
"BSD-3-Clause",
"Zlib",
"OpenSSL",
"Apache-2.0 WITH LLVM-exception",
"0BSD",
"BSL-1.0",
"Unicode-3.0"
]
confidence-threshold = 0.8

[[licenses.clarify]]
crate = "ring"
# SPDX considers OpenSSL to encompass both the OpenSSL and SSLeay licenses
# https://spdx.org/licenses/OpenSSL.html
# ISC - Both BoringSSL and ring use this for their new files
# MIT - "Files in third_party/ have their own licenses, as described therein. The MIT
# license, for third_party/fiat, which, unlike other third_party directories, is
# compiled into non-test libraries, is included below."
# OpenSSL - Obviously
expression = "ISC AND MIT AND OpenSSL"
license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }]

[licenses.private]
ignore = false
registries = []

[bans]
multiple-versions = "allow"
wildcards = "allow"
highlight = "all"
workspace-default-features = "allow"
external-default-features = "allow"
allow = []
deny = [
{ crate = "openssl", use-instead = "rustls" },
{ crate = "openssl-sys", use-instead = "rustls" },
]
skip = []
skip-tree = []

[sources]
unknown-registry = "deny"
unknown-git = "allow"
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
allow-git = []

[sources.allow-org]
github = []
gitlab = []
bitbucket = []

0 comments on commit 6bd3643

Please sign in to comment.