Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

fix: clippy unused #434

Merged
merged 10 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ members = [
[workspace.lints.rust]
# Deny
missing_docs = "allow"
unused = "allow"

# Warn
deprecated-in-future = "warn"
Expand Down
6 changes: 2 additions & 4 deletions crates/topos-p2p/src/runtime/handle_command.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use std::collections::hash_map::Entry;

use crate::{
error::{CommandExecutionError, P2PError},
protocol_name, Command, Runtime,
};
use libp2p::{kad::record::Key, PeerId};
use rand::{seq::SliceRandom, thread_rng, Rng};
use rand::{thread_rng, Rng};
use topos_metrics::P2P_MESSAGE_SENT_ON_GOSSIPSUB_TOTAL;
use tracing::{debug, error, info, warn};

Expand Down Expand Up @@ -41,7 +39,7 @@ impl Runtime {
}
Command::RandomKnownPeer { sender } => {
if self.peer_set.is_empty() {
sender.send(Err(P2PError::CommandError(
let _ = sender.send(Err(P2PError::CommandError(
CommandExecutionError::NoKnownPeer,
)));

Expand Down
2 changes: 1 addition & 1 deletion crates/topos-p2p/src/tests/command/random_peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn no_random_peer() {
.await
.expect("Unable to create p2p network");

let mut runtime = runtime.bootstrap().await.unwrap();
let runtime = runtime.bootstrap().await.unwrap();

spawn(runtime.run());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::collections::HashSet;
use std::process::{Child, Command};
use std::sync::Arc;
use test_log::test;
use tokio::sync::{oneshot, Mutex};
use tokio::sync::Mutex;
use topos_core::uci::{Certificate, CertificateId, SubnetId, SUBNET_ID_LENGTH};
use topos_sequencer_subnet_runtime::proxy::{SubnetRuntimeProxyCommand, SubnetRuntimeProxyEvent};
use tracing::{error, info, warn, Span};
Expand Down
18 changes: 3 additions & 15 deletions crates/topos-tce-api/tests/grpc/certificate_precedence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ use base64ct::{Base64, Encoding};
use rstest::rstest;
use std::sync::Arc;
use test_log::test;
use tokio_stream::Stream;
use topos_api::grpc::tce::v1::{GetLastPendingCertificatesRequest, LastPendingCertificate};
use topos_core::uci::Certificate;
use topos_tce_api::RuntimeEvent;
use topos_test_sdk::{
certificates::create_certificate_chain,
constants::{SOURCE_SUBNET_ID_1, TARGET_SUBNET_ID_1},
storage::{create_fullnode_store, create_validator_store, storage_client},
tce::public_api::{broadcast_stream, create_public_api, PublicApiContext},
tce::public_api::{broadcast_stream, create_public_api},
};

use topos_tce_storage::{types::CertificateDeliveredWithPositions, validator::ValidatorStore};
Expand All @@ -22,12 +20,7 @@ async fn fetch_latest_pending_certificates() {
let validator_store: Arc<ValidatorStore> =
create_validator_store(vec![], futures::future::ready(fullnode_store.clone())).await;

let (tx, rx): (
_,
tokio::sync::broadcast::Receiver<CertificateDeliveredWithPositions>,
) = tokio::sync::broadcast::channel(10);

let (mut api_context, _) = create_public_api(
let (api_context, _) = create_public_api(
storage_client(vec![]),
broadcast_stream(),
futures::future::ready(validator_store.clone()),
Expand Down Expand Up @@ -73,12 +66,7 @@ async fn fetch_latest_pending_certificates_with_conflicts() {
let validator_store: Arc<ValidatorStore> =
create_validator_store(vec![], futures::future::ready(fullnode_store.clone())).await;

let (tx, rx): (
_,
tokio::sync::broadcast::Receiver<CertificateDeliveredWithPositions>,
) = tokio::sync::broadcast::channel(10);

let (mut api_context, _) = create_public_api(
let (api_context, _) = create_public_api(
storage_client(vec![]),
broadcast_stream(),
futures::future::ready(validator_store.clone()),
Expand Down
1 change: 0 additions & 1 deletion crates/topos-tce-broadcast/src/double_echo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//! be ignored by others. `fullnode` still consumes Echo and Ready coming from
//! validators and use those messages to build their state.

use crate::TaskStatus;
use crate::{DoubleEchoCommand, SubscriptionsView};
use std::collections::HashSet;
use std::sync::Arc;
Expand Down
2 changes: 1 addition & 1 deletion crates/topos-tce-broadcast/src/task_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl TaskManager {
}
}

pub async fn run(mut self, mut shutdown_receiver: CancellationToken) {
pub async fn run(mut self, shutdown_receiver: CancellationToken) {
let mut interval = tokio::time::interval(Duration::from_secs(1));

loop {
Expand Down
8 changes: 4 additions & 4 deletions crates/topos-tce-broadcast/src/tests/task_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async fn can_start(#[future] create_validator_store: Arc<ValidatorStore>) {
.unwrap(),
);

let mut manager = TaskManager::new(
let manager = TaskManager::new(
message_receiver,
SubscriptionsView::default(),
event_sender,
Expand All @@ -60,21 +60,21 @@ async fn can_start(#[future] create_validator_store: Arc<ValidatorStore>) {
.take()
.expect("Failed to create certificate");

message_sender
let _ = message_sender
.send(crate::DoubleEchoCommand::Broadcast {
need_gossip: false,
cert: child.certificate.clone(),
})
.await;

message_sender
let _ = message_sender
.send(crate::DoubleEchoCommand::Broadcast {
need_gossip: false,
cert: parent.certificate.clone(),
})
.await;

message_sender
let _ = message_sender
.send(crate::DoubleEchoCommand::Broadcast {
need_gossip: false,
cert: parent.certificate.clone(),
Expand Down
5 changes: 0 additions & 5 deletions crates/topos-tce-gatekeeper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::{future::IntoFuture, time::Duration};

use builder::GatekeeperBuilder;
use futures::{future::BoxFuture, FutureExt};
use rand::seq::SliceRandom;
use thiserror::Error;
use tokio::{
sync::{mpsc, oneshot},
Expand All @@ -16,14 +15,11 @@ mod client;
mod tests;

pub use client::GatekeeperClient;
use topos_core::uci::SubnetId;
use tracing::{info, warn};

pub struct Gatekeeper {
pub(crate) shutdown: mpsc::Receiver<oneshot::Sender<()>>,
pub(crate) tick_duration: Duration,

subnet_list: Vec<SubnetId>,
}

impl Default for Gatekeeper {
Expand All @@ -34,7 +30,6 @@ impl Default for Gatekeeper {
Self {
shutdown,
tick_duration,
subnet_list: Vec::default(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/topos-tce-gatekeeper/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::future::IntoFuture;

use rstest::{fixture, rstest};
use rstest::fixture;
use test_log::test;
use tokio::spawn;
use topos_p2p::PeerId;
Expand Down
2 changes: 1 addition & 1 deletion crates/topos-tce-storage/src/fullnode/locking.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
collections::{hash_map::RandomState, HashMap},
hash::{BuildHasher, Hash, Hasher},
hash::{BuildHasher, Hash},
sync::Arc,
};

Expand Down
2 changes: 1 addition & 1 deletion crates/topos-tce-storage/src/rocks/db_column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rocksdb::{
};

use bincode::Options;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde::{de::DeserializeOwned, Serialize};

use crate::errors::InternalStorageError;

Expand Down
2 changes: 1 addition & 1 deletion crates/topos-tce-storage/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub struct CheckpointSummary {
sequence_number: usize,
checkpoint_data: Vec<SourceStreamPosition>,
}
pub struct VerifiedCheckpointSummary(CheckpointSummary, ValidatorQuorumSignatureInfo);
pub struct VerifiedCheckpointSummary((), ());
gruberb marked this conversation as resolved.
Show resolved Hide resolved

#[allow(unused)]
pub struct ValidatorQuorumSignatureInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ enum SyncError {
#[allow(unused)]
UnableToParseSubnetId,

#[error("Gatekeeper returned no peer")]
NoPeerAvailable,

#[error(transparent)]
GrpcParsingError(#[from] GrpcParsingError),

Expand Down
5 changes: 2 additions & 3 deletions crates/topos-tce/src/app_context/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use tokio::spawn;
use topos_metrics::CERTIFICATE_DELIVERY_LATENCY;
use topos_p2p::Event as NetEvent;
use topos_tce_broadcast::DoubleEchoCommand;
use tracing::{debug, error, info, trace};
use tracing::{debug, error, trace};

use topos_core::api::grpc::tce::v1::{double_echo_request, DoubleEchoRequest, Echo, Gossip, Ready};
use topos_core::uci;
Expand All @@ -32,7 +32,6 @@ impl AppContext {
certificate: Some(certificate),
}) => match uci::Certificate::try_from(certificate) {
Ok(cert) => {
let channel = self.tce_cli.get_double_echo_channel();
if let hash_map::Entry::Vacant(entry) = self.delivery_latency.entry(cert.id)
{
entry.insert(CERTIFICATE_DELIVERY_LATENCY.start_timer());
Expand All @@ -43,7 +42,7 @@ impl AppContext {
);

match self.validator_store.insert_pending_certificate(&cert) {
Ok(Some(pending_id)) => {
Ok(Some(_)) => {
debug!(
"Certificate {} has been inserted into pending pool",
cert.id
Expand Down
2 changes: 1 addition & 1 deletion crates/topos-tce/src/app_context/protocol.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use tce_transport::ProtocolEvents;
use topos_core::api::grpc::tce::v1::{double_echo_request, DoubleEchoRequest, Echo, Gossip, Ready};
use tracing::{debug, error, info, warn};
use tracing::{error, info, warn};

use crate::events::Events;
use crate::AppContext;
Expand Down
8 changes: 2 additions & 6 deletions crates/topos-tce/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ use config::TceConfiguration;
use futures::StreamExt;
use opentelemetry::global;
use std::process::ExitStatus;
use std::{
future::IntoFuture,
panic::UnwindSafe,
sync::{atomic::AtomicBool, Arc},
};
use std::{future::IntoFuture, sync::Arc};
use tokio::{
spawn,
sync::{broadcast, mpsc},
Expand All @@ -17,7 +13,7 @@ use topos_core::api::grpc::tce::v1::synchronizer_service_server::SynchronizerSer
use topos_crypto::{messages::MessageSigner, validator_id::ValidatorId};
use topos_p2p::{
utils::{local_key_pair, local_key_pair_from_slice},
GrpcContext, GrpcRouter, Multiaddr,
GrpcContext, GrpcRouter,
};
use topos_tce_broadcast::{ReliableBroadcastClient, ReliableBroadcastConfig};
use topos_tce_storage::{
Expand Down
11 changes: 4 additions & 7 deletions crates/topos-tce/src/tests/api.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use std::sync::Arc;

use libp2p::PeerId;
use prost::Message;
use rstest::rstest;
use test_log::test;
use tokio::sync::{mpsc, oneshot};
use topos_core::api::grpc::tce::v1::{double_echo_request, DoubleEchoRequest, Echo, Gossip, Ready};
use topos_crypto::{messages::MessageSigner, validator_id::ValidatorId};
use topos_crypto::messages::MessageSigner;
use topos_tce_storage::{store::WriteStore, types::PendingResult};
use topos_test_sdk::{
certificates::create_certificate_chain,
Expand All @@ -26,7 +23,7 @@ async fn handle_new_certificate(
Arc<MessageSigner>,
),
) {
let (mut context, mut p2p_receiver, message_signer) = setup_test.await;
let (mut context, _, _) = setup_test.await;
let mut certificates = create_certificate_chain(SOURCE_SUBNET_ID_1, &[TARGET_SUBNET_ID_1], 1);
let certificate = certificates.pop().unwrap().certificate;

Expand All @@ -53,7 +50,7 @@ async fn handle_certificate_in_precedence_pool(
Arc<MessageSigner>,
),
) {
let (mut context, mut p2p_receiver, message_signer) = setup_test.await;
let (mut context, _, _) = setup_test.await;
let mut certificates = create_certificate_chain(SOURCE_SUBNET_ID_1, &[TARGET_SUBNET_ID_1], 2);
let certificate = certificates.pop().unwrap().certificate;

Expand All @@ -80,7 +77,7 @@ async fn handle_certificate_already_delivered(
Arc<MessageSigner>,
),
) {
let (mut context, mut p2p_receiver, message_signer) = setup_test.await;
let (mut context, _, _) = setup_test.await;
let mut certificates = create_certificate_chain(SOURCE_SUBNET_ID_1, &[TARGET_SUBNET_ID_1], 1);
let certificate_delivered = certificates.pop().unwrap();

Expand Down
21 changes: 8 additions & 13 deletions crates/topos-tce/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
use libp2p::PeerId;
use rstest::{fixture, rstest};
use std::{
collections::{HashMap, HashSet},
future::IntoFuture,
net::SocketAddr,
sync::Arc,
};
use std::{collections::HashSet, future::IntoFuture, sync::Arc};
use tce_transport::ProtocolEvents;
use tokio_stream::Stream;
use topos_tce_api::RuntimeEvent;
use topos_tce_gatekeeper::{Gatekeeper, GatekeeperClient};
use topos_tce_gatekeeper::Gatekeeper;

use tokio::sync::{broadcast, mpsc};
use topos_crypto::messages::MessageSigner;
Expand Down Expand Up @@ -104,12 +99,12 @@ pub async fn setup_test(
) {
let validator_store = create_validator_store.await;
let is_validator = false;
let mut message_signer = Arc::new(MessageSigner::new(&[5u8; 32]).unwrap());
let message_signer = Arc::new(MessageSigner::new(&[5u8; 32]).unwrap());
let validator_id = message_signer.public_address.into();

let (broadcast_sender, broadcast_receiver) = broadcast::channel(1);
let (broadcast_sender, _) = broadcast::channel(1);

let (tce_cli, tce_stream) = ReliableBroadcastClient::new(
let (tce_cli, _) = ReliableBroadcastClient::new(
ReliableBroadcastConfig {
tce_params: tce_transport::ReliableBroadcastParams::default(),
validator_id,
Expand All @@ -122,7 +117,7 @@ pub async fn setup_test(
.await;

let (shutdown_p2p, _) = mpsc::channel(1);
let (p2p_sender, mut p2p_receiver) = mpsc::channel(1);
let (p2p_sender, p2p_receiver) = mpsc::channel(1);
let grpc_over_p2p = GrpcOverP2P::new(p2p_sender.clone());
let network_client = NetworkClient {
retry_ttl: 10,
Expand All @@ -135,9 +130,9 @@ pub async fn setup_test(
let (api_context, _api_stream) = create_public_api.await;
let api_client = api_context.client;

let (gatekeeper_client, gatekeeper) = Gatekeeper::builder().into_future().await.unwrap();
let (gatekeeper_client, _) = Gatekeeper::builder().into_future().await.unwrap();

let (mut context, _) = AppContext::new(
let (context, _) = AppContext::new(
is_validator,
StorageClient::new(validator_store.clone()),
tce_cli,
Expand Down
Loading
Loading