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 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
4 changes: 2 additions & 2 deletions Cargo.lock

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

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 All @@ -28,7 +28,6 @@ use topos_sequencer_subnet_runtime::{SubnetRuntimeProxyConfig, SubnetRuntimeProx
use topos_test_sdk::constants::*;

// Local test network with default 2 seconds block
const STANDALONE_SUBNET: &str = "standalone-test";
const STANDALONE_SUBNET_BLOCK_TIME: u64 = 2;
// Local test network with 12 seconds block, usefull for multiple transactions in one block tests
const STANDALONE_SUBNET_WITH_LONG_BLOCKS_BLOCK_TIME: u64 = 12;
Expand All @@ -38,7 +37,6 @@ const SUBNET_RPC_PORT: u32 = 8545;
const TEST_SECRET_ETHEREUM_KEY: &str =
"ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
const TEST_ETHEREUM_ACCOUNT: &str = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266";
const SUBNET_STARTUP_DELAY: u64 = 5; // seconds left for subnet startup
const TEST_SUBNET_ID: &str = "6464646464646464646464646464646464646464646464646464646464646464";
const TOKEN_SYMBOL: &str = "TKX";

Expand Down
1 change: 1 addition & 0 deletions crates/topos-tce-api/src/runtime/sync_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub(crate) enum SyncTaskStatus {
/// The sync task is active and started running
Running,
/// The sync task failed and reported an error
#[allow(dead_code)]
Error(Box<SyncTaskError>),
/// The sync task exited gracefully and is done pushing certificates to the stream
Done,
Expand Down
20 changes: 4 additions & 16 deletions crates/topos-tce-api/tests/grpc/certificate_precedence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ 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};
use topos_tce_storage::validator::ValidatorStore;

#[rstest]
#[test(tokio::test)]
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
1 change: 1 addition & 0 deletions crates/topos-tce-storage/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub struct CheckpointSummary {
sequence_number: usize,
checkpoint_data: Vec<SourceStreamPosition>,
}
#[allow(unused)]
pub struct VerifiedCheckpointSummary(CheckpointSummary, ValidatorQuorumSignatureInfo);

#[allow(unused)]
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
Loading
Loading