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

Removed Cranky and started using Cargo's lints table #37

Merged
merged 11 commits into from
Dec 6, 2023
12 changes: 4 additions & 8 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ jobs:
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-nextest
- name: install cranky
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-cranky
- name: install deny
uses: baptiste0928/cargo-install@v2
with:
Expand All @@ -46,10 +42,10 @@ jobs:
run: cargo deny check
- name: fmt
run: cargo fmt --all --check
- name: cranky (all features)
run: cargo cranky --workspace --all-targets --all-features
- name: cranky (default features)
run: cargo cranky --workspace --exclude tools --all-targets
- name: clippy (all features)
run: cargo clippy --workspace --all-targets --all-features
- name: clippy (default features)
run: cargo clippy --workspace --exclude zksync_consensus_tools --all-targets
- name: build
run: cargo build --all-targets --locked
- name: test
Expand Down
18 changes: 0 additions & 18 deletions docs/style.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,6 @@ And then run tests with:
cargo nextest run
```

### Linting

We use a particular tool called `cargo cranky` in order to be able to apply a set of lints to an entire workspace. You
just need to install it with:

```
cargo install cargo-cranky
```

and then you can run it just like you would run clippy:

```
cargo cranky --all-targets --all-features
```

Note: There's a [RFC](https://github.com/rust-lang/rfcs/pull/3389) underway to add lints to `Cargo.toml``. But until that
happens, we are stuck with cranky.

## Codebase Layout

We want the files to be relatively small in general (lets say, <500 LoC), so feel free to split the module into multiple files
Expand Down
6 changes: 3 additions & 3 deletions node/Cargo.lock

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

82 changes: 64 additions & 18 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[workspace]
members = [
"libs/concurrency",
"libs/protobuf_build",
"libs/protobuf",
"actors/bft",
"libs/crypto",
"actors/executor",
"actors/network",
"actors/sync_blocks",
"libs/concurrency",
"libs/crypto",
"libs/protobuf",
"libs/protobuf_build",
"libs/roles",
"libs/storage",
"tools",
"libs/utils",
"tools",
]
resolver = "2"

Expand All @@ -22,40 +22,49 @@ homepage = "https://matter-labs.io/"
license = "MIT"

[workspace.dependencies]
zksync_protobuf_build = { path = "libs/protobuf_build" }
zksync_protobuf = { path = "libs/protobuf" }
zksync_concurrency = { path = "libs/concurrency" }
# Crates from this repo.
zksync_consensus_bft = { path = "actors/bft" }
zksync_consensus_crypto = { path = "libs/crypto" }
zksync_consensus_executor = { path = "actors/executor" }
zksync_consensus_network = { path = "actors/network" }
zksync_consensus_sync_blocks = { path = "actors/sync_blocks" }
zksync_consensus_roles = { path = "libs/roles" }
zksync_consensus_storage = { path = "libs/storage" }
zksync_consensus_sync_blocks = { path = "actors/sync_blocks" }
zksync_consensus_tools = { path = "tools" }
zksync_consensus_utils = { path = "libs/utils" }

# Crates from this repo that might become independent in the future.
zksync_concurrency = { path = "libs/concurrency" }
zksync_protobuf = { path = "libs/protobuf" }
zksync_protobuf_build = { path = "libs/protobuf_build" }

# Crates from Matter Labs.
pairing = { package = "pairing_ce", git = "https://github.com/matter-labs/pairing.git", rev = "f55393f" }
vise = { version = "0.1.0", git = "https://github.com/matter-labs/vise.git", rev = "dd0513" }
vise-exporter = { version = "0.1.0", git = "https://github.com/matter-labs/vise.git", rev = "dd0513" }

# Crates from third-parties.
anyhow = "1"
assert_matches = "1.5.0"
async-trait = "0.1.71"
bit-vec = "0.6"
blst = "0.3.10"
pairing = { package = "pairing_ce", git = "https://github.com/matter-labs/pairing.git", rev = "f55393f" }
ff_ce = "0.14.3"
clap = { version = "4.3.3", features = ["derive"] }
heck = "0.4.1"
criterion = "0.5.1"
ed25519-dalek = { version = "2.0.0", features = ["rand_core"] }
ff_ce = "0.14.3"
heck = "0.4.1"
hex = "0.4.3"
im = "15.1.0"
once_cell = "1.17.1"
pin-project = "1.1.0"
pretty_assertions = "1.4.0"
prettyplease = "0.2.6"
proc-macro2 = "1.0.66"
prost = "0.12.0"
prost-build = "0.12.0"
prost-reflect = { version = "0.12.0", features = ["serde"] }
protox = "0.5.0"
prettyplease = "0.2.6"
pretty_assertions = "1.4.0"
quick-protobuf = "0.8.1"
quote = "1.0.33"
rand = "0.8.0"
Expand All @@ -70,13 +79,9 @@ tempfile = "3"
test-casing = "0.1.0"
thiserror = "1.0.40"
time = "0.3.23"
# TODO(gprusak): only concurrency crate should depend on tokio.
# All the other crates should depend on concurrency.
tokio = { version = "1.34.0", features = ["full"] }
tracing = { version = "0.1.37", features = ["attributes"] }
tracing-subscriber = { version = "0.3.16", features = ["env-filter", "fmt"] }
vise = { version = "0.1.0", git = "https://github.com/matter-labs/vise.git", rev = "dd05139b76ab0843443ab3ff730174942c825dae" }
vise-exporter = { version = "0.1.0", git = "https://github.com/matter-labs/vise.git", rev = "dd05139b76ab0843443ab3ff730174942c825dae" }

# Note that "bench" profile inherits from "release" profile and
# "test" profile inherits from "dev" profile.
Expand Down Expand Up @@ -104,3 +109,44 @@ opt-level = 3
# is currently considered too slow for development.
[profile.dev.package."*"]
opt-level = 3

[workspace.lints.rust]
unsafe_code = "deny"
noop_method_call = "warn"
missing_docs = "warn"
unreachable_pub = "warn"
unused_qualifications = "warn"
unused_tuple_struct_fields = "warn"

[workspace.lints.clippy]
# restriction group
create_dir = "warn"
empty_structs_with_brackets = "warn"
float_arithmetic = "warn"
missing_docs_in_private_items = "warn"
non_ascii_literal = "warn"
partial_pub_fields = "warn"
print_stdout = "warn"
string_to_string = "warn"
suspicious_xor_used_as_pow = "warn"
try_err = "warn"
separated_literal_suffix = "warn"

# pedantic group
bool_to_int_with_if = "warn"
default_trait_access = "warn"
if_not_else = "warn"
manual_assert = "warn"
manual_instant_elapsed = "warn"
manual_let_else = "warn"
manual_ok_or = "warn"
manual_string_new = "warn"
match_bool = "warn"
wildcard_imports = "warn"

# cargo group
wildcard_dependencies = "warn"

# Produces too many false positives.
redundant_locals = "allow"
needless_pass_by_ref_mut = "allow"
brunoffranca marked this conversation as resolved.
Show resolved Hide resolved
45 changes: 0 additions & 45 deletions node/Cranky.toml

This file was deleted.

3 changes: 3 additions & 0 deletions node/actors/bft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ vise.workspace = true
[dev-dependencies]
tokio.workspace = true
assert_matches.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions node/actors/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ tokio.workspace = true

[build-dependencies]
zksync_protobuf_build.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions node/actors/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ tokio.workspace = true

[build-dependencies]
zksync_protobuf_build.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions node/actors/sync_blocks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ async-trait.workspace = true
rand.workspace = true
test-casing.workspace = true
tokio.workspace = true

[lints]
workspace = true
6 changes: 2 additions & 4 deletions node/deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ targets = [
unmaintained = "deny"
# The lint level for crates that have been yanked from their source registry
yanked = "deny"
# The lint level for crates with security notices. Note that as of
# 2019-12-17 there are no security notice advisories in
# https://github.com/rustsec/advisory-db
# The lint level for crates with security notices.
notice = "deny"
# Threshold for security vulnerabilities, any vulnerability with a CVSS score
# lower than the range specified will be ignored. Note that ignored advisories
Expand Down Expand Up @@ -54,7 +52,7 @@ skip = [
{ name = "regex-automata", version = "0.1.10" },
{ name = "regex-syntax", version = "0.6.29" },

# Old versions required by hyper.
# Old versions required by vise-exporter.
{ name = "socket2", version = "0.4.10" },

# Old versions required by pairing_ce & ff_ce.
Expand Down
3 changes: 3 additions & 0 deletions node/libs/concurrency/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ tokio.workspace = true
tracing.workspace = true
tracing-subscriber.workspace = true
vise.workspace = true

[lints]
workspace = true
1 change: 1 addition & 0 deletions node/libs/concurrency/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Concurrency primitives.
#![allow(unsafe_code)]

pub mod ctx;
pub mod error;
Expand Down
1 change: 0 additions & 1 deletion node/libs/concurrency/src/scope/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
// TODO(gprusak): add more tests
// TODO(gprusak): add simple useful real-life examples
// TODO(gprusak): add a style guide on how to use scopes.
#![allow(unsafe_code)]
use crate::{ctx, time};
use std::{
future::Future,
Expand Down
7 changes: 5 additions & 2 deletions node/libs/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ tracing.workspace = true
ff_ce.workspace = true

[dev-dependencies]
criterion = "0.5.1"
criterion.workspace = true

[lints]
workspace = true

[[bench]]
name = "bench"
harness = false
harness = false
4 changes: 3 additions & 1 deletion node/libs/protobuf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ edition.workspace = true
authors.workspace = true
homepage.workspace = true
license.workspace = true

links = "zksync_protobuf_proto"

[dependencies]
Expand All @@ -28,3 +27,6 @@ tracing-subscriber.workspace = true

[build-dependencies]
zksync_protobuf_build.workspace = true

[lints]
workspace = true
3 changes: 3 additions & 0 deletions node/libs/protobuf_build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ prost-reflect.workspace = true
protox.workspace = true
quote.workspace = true
syn.workspace = true

[lints]
workspace = true
4 changes: 3 additions & 1 deletion node/libs/roles/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ edition.workspace = true
authors.workspace = true
homepage.workspace = true
license.workspace = true

links = "zksync_consensus_roles_proto"

[dependencies]
Expand All @@ -25,3 +24,6 @@ tracing.workspace = true

[build-dependencies]
zksync_protobuf_build.workspace = true

[lints]
workspace = true
Loading
Loading