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

chore(node): add workspace lints #1830

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/papyrus_network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ pretty_assertions.workspace = true
tokio = { workspace = true, features = ["full", "sync", "test-util"] }
tokio-stream.workspace = true
void.workspace = true

[lints]
workspace = true
5 changes: 3 additions & 2 deletions crates/papyrus_network/src/discovery/discovery_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ use crate::mixed_behaviour::BridgedBehaviour;
use crate::test_utils::next_on_mutex_stream;

const TIMEOUT: Duration = Duration::from_secs(1);
const BOOTSTRAP_DIAL_SLEEP: Duration = Duration::from_secs(1);
const BOOTSTRAP_DIAL_SLEEP_MILLIS: u64 = 1000; // 1 second
const BOOTSTRAP_DIAL_SLEEP: Duration = Duration::from_millis(BOOTSTRAP_DIAL_SLEEP_MILLIS);

const CONFIG: DiscoveryConfig = DiscoveryConfig {
bootstrap_dial_retry_config: RetryConfig {
base_delay_millis: BOOTSTRAP_DIAL_SLEEP.as_millis() as u64,
base_delay_millis: BOOTSTRAP_DIAL_SLEEP_MILLIS,
max_delay_seconds: BOOTSTRAP_DIAL_SLEEP,
factor: 1,
},
Expand Down
4 changes: 4 additions & 0 deletions crates/papyrus_network/src/network_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ impl<SwarmT: SwarmTrait> GenericNetworkManager<SwarmT> {
}

fn handle_swarm_event(&mut self, event: SwarmEvent<mixed_behaviour::Event>) {
#[allow(clippy::as_conversions)] // FIXME: use int metrics so `as f64` may be removed.
match event {
SwarmEvent::ConnectionEstablished { peer_id, .. } => {
debug!("Connected to peer id: {peer_id:?}");
Expand Down Expand Up @@ -375,6 +376,7 @@ impl<SwarmT: SwarmTrait> GenericNetworkManager<SwarmT> {
}
}

#[allow(clippy::as_conversions)] // FIXME: use int metrics so `as f64` may be removed.
fn handle_sqmr_event_new_inbound_session(
&mut self,
peer_id: PeerId,
Expand Down Expand Up @@ -537,6 +539,7 @@ impl<SwarmT: SwarmTrait> GenericNetworkManager<SwarmT> {
) {
let SqmrClientPayload { query, report_receiver, responses_sender } = client_payload;
match self.swarm.send_query(query, PeerId::random(), protocol.clone()) {
#[allow(clippy::as_conversions)] // FIXME: use int metrics so `as f64` may be removed.
Ok(outbound_session_id) => {
debug!(
"Network received new query. waiting for peer assignment. \
Expand Down Expand Up @@ -565,6 +568,7 @@ impl<SwarmT: SwarmTrait> GenericNetworkManager<SwarmT> {
}

fn report_session_removed_to_metrics(&mut self, session_id: SessionId) {
#[allow(clippy::as_conversions)] // FIXME: use int metrics so `as f64` may be removed.
match session_id {
SessionId::InboundSessionId(_) => {
self.num_active_inbound_sessions -= 1;
Expand Down
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 @@ -42,8 +42,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
Loading