Skip to content

Commit

Permalink
chore(node): add workspace lints (#1830)
Browse files Browse the repository at this point in the history
* chore(network): add workspace lints to network

Lior banned `as` repo-wide, unless absolutely necessary.

Nearly all as uses can be replaced with [Try]From which doesn't have
implicit coercions like as (we encountered several bugs due to these coercions).

Motivation: we are standardizing lints across the repo and CI,
instead of each crate having separate sets of lints.

Note: i left the `as f64` since `gauge!` expects f64, even though the
metrics themselves are integers. This is probably fixable by using
`counter!` instead of `gauge!`, but i haven't found anyone who knows how
to test these metrics so i'm leaving it for now.
I left them at the statement level intentionaly, instead of the module level,
so that it won't be forgotten.

* chore(node): add workspace lints

Lior banned `as` repo-wide, unless absolutely necessary.

Nearly all as uses can be replaced with [Try]From which doesn't
have implicit coercions like as (we encountered several bugs due to these coercions).

Motivation: we are standardizing lints across the repo and CI,
instead of each crate having separate sets of lints.

Note: the change in pointers.rs is due to cargo doc being triggered due
to changes in the crate, and cargo doc thought it was a busted HTML tag
:sweat_smile:

Co-Authored-By: Gilad Chase <gilad@starkware.com>
  • Loading branch information
giladchase and Gilad Chase authored Nov 7, 2024
1 parent e8a59dc commit 880df26
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 2 additions & 4 deletions crates/papyrus_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,5 @@ papyrus_test_utils.workspace = true
pretty_assertions.workspace = true
tempfile.workspace = true

[lints.rust]
# See [here](https://github.com/taiki-e/cargo-llvm-cov/issues/370) for a discussion on why this is
# needed (from rust 1.80).
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage_nightly)'] }
[lints]
workspace = true
6 changes: 3 additions & 3 deletions crates/papyrus_node/examples/get_transaction_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct CliParams {
iteration_increments: u64,
file_path: String,
deprecated: bool,
concurrent_requests: u64,
concurrent_requests: usize,
}

/// The start_block and end_block arguments are mandatory and define the block range to dump,
Expand Down Expand Up @@ -79,7 +79,7 @@ fn get_cli_params() -> CliParams {
let concurrent_requests = matches
.get_one::<String>("concurrent_requests")
.expect("Failed parsing concurrent_requests")
.parse::<u64>()
.parse::<usize>()
.expect("Failed parsing concurrent_requests");
let deprecated = matches
.get_one::<String>("deprecated")
Expand Down Expand Up @@ -156,7 +156,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.lock()
.expect("Couldn't lock transaction types")
.is_empty()
&& handles.len() < concurrent_requests as usize
&& handles.len() < concurrent_requests
{
let client_ref = client.clone();
let node_url_ref = node_url.clone();
Expand Down
4 changes: 2 additions & 2 deletions crates/papyrus_node/src/config/pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ use validator::Validate;

use crate::version::VERSION_FULL;

/// Returns vector of (pointer target name, pointer target serialized param, vec<pointer param
/// path>) to be applied on the dumped node config.
/// Returns vector of `(pointer target name, pointer target serialized param, vec<pointer param
/// path>)` to be applied on the dumped node config.
/// The config updates will be performed on the shared pointer targets, and finally, the values
/// will be propagated to the pointer params.
pub static CONFIG_POINTERS: LazyLock<ConfigPointers> = LazyLock::new(|| {
Expand Down

0 comments on commit 880df26

Please sign in to comment.