From f8805adc82cb967c3e3e5f4c8f0a02698d11f571 Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu <23022326+d0cd@users.noreply.github.com> Date: Tue, 1 Oct 2024 15:19:19 -0700 Subject: [PATCH] Use style_edition instead of version in .rustfmt.toml and apply new changes from nightly --- .integration/src/lib.rs | 4 +-- .rustfmt.toml | 2 +- cli/src/commands/account.rs | 2 +- cli/src/commands/clean.rs | 2 +- cli/src/commands/developer/decrypt.rs | 2 +- cli/src/commands/developer/deploy.rs | 12 +++---- cli/src/commands/developer/execute.rs | 10 +++--- cli/src/commands/developer/mod.rs | 4 +-- cli/src/commands/developer/scan.rs | 6 ++-- .../commands/developer/transfer_private.rs | 8 ++--- cli/src/commands/mod.rs | 2 +- cli/src/commands/start.rs | 10 +++--- cli/src/helpers/dynamic_format.rs | 6 ++-- cli/src/helpers/logger.rs | 4 +-- cli/src/helpers/mod.rs | 2 +- cli/src/helpers/updater.rs | 2 +- display/src/lib.rs | 6 ++-- display/src/pages/logs.rs | 2 +- display/src/pages/overview.rs | 4 +-- node/bft/events/src/batch_certified.rs | 2 +- node/bft/events/src/batch_propose.rs | 4 +-- node/bft/events/src/batch_signature.rs | 2 +- node/bft/events/src/block_request.rs | 2 +- node/bft/events/src/block_response.rs | 6 ++-- node/bft/events/src/certificate_request.rs | 2 +- node/bft/events/src/certificate_response.rs | 4 +-- node/bft/events/src/challenge_request.rs | 2 +- node/bft/events/src/challenge_response.rs | 2 +- node/bft/events/src/lib.rs | 12 +++---- node/bft/events/src/primary_ping.rs | 6 ++-- node/bft/events/src/transmission_request.rs | 2 +- node/bft/events/src/transmission_response.rs | 4 +-- node/bft/events/src/validators_response.rs | 4 +-- node/bft/events/src/worker_ping.rs | 2 +- node/bft/examples/monitor.rs | 2 +- node/bft/examples/simple_node.rs | 18 +++++------ node/bft/ledger-service/src/ledger.rs | 8 ++--- node/bft/ledger-service/src/mock.rs | 4 +-- node/bft/ledger-service/src/prover.rs | 2 +- node/bft/ledger-service/src/translucent.rs | 6 ++-- node/bft/src/bft.rs | 20 ++++++------ node/bft/src/gateway.rs | 32 +++++++++---------- node/bft/src/helpers/dag.rs | 2 +- node/bft/src/helpers/partition.rs | 2 +- node/bft/src/helpers/pending.rs | 2 +- node/bft/src/helpers/proposal.rs | 6 ++-- node/bft/src/helpers/proposal_cache.rs | 4 +-- node/bft/src/helpers/signed_proposals.rs | 2 +- node/bft/src/helpers/storage.rs | 10 +++--- node/bft/src/helpers/timestamp.rs | 2 +- node/bft/src/primary.rs | 30 ++++++++--------- node/bft/src/sync/mod.rs | 14 ++++---- node/bft/src/worker.rs | 10 +++--- node/bft/storage-service/src/memory.rs | 4 +-- node/bft/storage-service/src/persistent.rs | 10 +++--- node/bft/tests/common/primary.rs | 12 +++---- node/bft/tests/common/test_peer.rs | 2 +- node/bft/tests/common/utils.rs | 10 +++--- node/bft/tests/components/pending.rs | 2 +- node/bft/tests/components/worker.rs | 2 +- node/bft/tests/gateway_e2e.rs | 4 +-- node/cdn/src/blocks.rs | 12 +++---- node/consensus/src/lib.rs | 10 +++--- node/metrics/src/lib.rs | 4 +-- node/rest/src/helpers/auth.rs | 8 ++--- node/rest/src/lib.rs | 10 +++--- node/rest/src/routes.rs | 4 +-- node/router/messages/src/block_request.rs | 2 +- node/router/messages/src/block_response.rs | 4 +-- node/router/messages/src/challenge_request.rs | 2 +- .../router/messages/src/challenge_response.rs | 4 +-- node/router/messages/src/helpers/codec.rs | 2 +- .../router/messages/src/helpers/disconnect.rs | 2 +- node/router/messages/src/helpers/node_type.rs | 2 +- node/router/messages/src/lib.rs | 6 ++-- node/router/messages/src/peer_response.rs | 2 +- node/router/messages/src/ping.rs | 6 ++-- node/router/messages/src/pong.rs | 2 +- node/router/messages/src/puzzle_response.rs | 4 +-- .../messages/src/unconfirmed_solution.rs | 2 +- .../messages/src/unconfirmed_transaction.rs | 2 +- node/router/src/handshake.rs | 10 +++--- node/router/src/heartbeat.rs | 2 +- node/router/src/helpers/cache.rs | 2 +- node/router/src/inbound.rs | 8 ++--- node/router/src/lib.rs | 4 +-- node/router/src/outbound.rs | 2 +- node/router/src/routing.rs | 2 +- node/router/tests/cleanups.rs | 2 +- node/router/tests/common/mod.rs | 4 +-- node/router/tests/common/router.rs | 18 +++++------ node/router/tests/connect.rs | 2 +- node/router/tests/disconnect.rs | 2 +- node/src/client/mod.rs | 8 ++--- node/src/client/router.rs | 4 +-- node/src/node.rs | 8 ++--- node/src/prover/mod.rs | 10 +++--- node/src/prover/router.rs | 2 +- node/src/traits.rs | 6 ++-- node/src/validator/mod.rs | 12 +++---- node/src/validator/router.rs | 2 +- node/sync/locators/src/block_locators.rs | 8 ++--- node/sync/src/block_sync.rs | 12 +++---- node/tcp/src/helpers/mod.rs | 2 +- node/tcp/src/protocols/disconnect.rs | 4 +-- node/tcp/src/protocols/handshake.rs | 4 +-- node/tcp/src/protocols/on_connect.rs | 4 +-- node/tcp/src/protocols/reading.rs | 6 ++-- node/tcp/src/protocols/writing.rs | 4 +-- node/tcp/src/tcp.rs | 6 ++-- node/tests/common/mod.rs | 2 +- node/tests/common/node.rs | 2 +- node/tests/common/test_peer.rs | 6 ++-- node/tests/handshake.rs | 2 +- node/tests/peering.rs | 4 +-- 115 files changed, 317 insertions(+), 317 deletions(-) diff --git a/.integration/src/lib.rs b/.integration/src/lib.rs index 841505ec0c..0788b20107 100644 --- a/.integration/src/lib.rs +++ b/.integration/src/lib.rs @@ -20,12 +20,12 @@ mod tests { use aleo_std::StorageMode; use snarkos_node_cdn::sync_ledger_with_cdn; use snarkvm::prelude::{ - block::Block, - store::helpers::memory::ConsensusMemory, FromBytes, Ledger, MainnetV0, Network, + block::Block, + store::helpers::memory::ConsensusMemory, }; use tracing_test::traced_test; diff --git a/.rustfmt.toml b/.rustfmt.toml index 30b32606ff..b5dd5e6730 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -13,4 +13,4 @@ imports_layout = "HorizontalVertical" imports_granularity = "Crate" overflow_delimited_expr = true reorder_impl_items = true -version = "Two" +style_edition = "2024" diff --git a/cli/src/commands/account.rs b/cli/src/commands/account.rs index e6aa040a64..b697d4e47b 100644 --- a/cli/src/commands/account.rs +++ b/cli/src/commands/account.rs @@ -21,7 +21,7 @@ use snarkvm::console::{ types::Field, }; -use anyhow::{anyhow, bail, Result}; +use anyhow::{Result, anyhow, bail}; use clap::Parser; use colored::Colorize; use core::str::FromStr; diff --git a/cli/src/commands/clean.rs b/cli/src/commands/clean.rs index 38c72065a3..e4aa9d62d7 100644 --- a/cli/src/commands/clean.rs +++ b/cli/src/commands/clean.rs @@ -16,7 +16,7 @@ use snarkos_node::bft::helpers::proposal_cache_path; use aleo_std::StorageMode; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use clap::Parser; use colored::Colorize; use std::path::PathBuf; diff --git a/cli/src/commands/developer/decrypt.rs b/cli/src/commands/developer/decrypt.rs index 052850131a..5bca740012 100644 --- a/cli/src/commands/developer/decrypt.rs +++ b/cli/src/commands/developer/decrypt.rs @@ -21,7 +21,7 @@ use snarkvm::{ prelude::{Record, ViewKey}, }; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use clap::Parser; use std::str::FromStr; use zeroize::Zeroize; diff --git a/cli/src/commands/developer/deploy.rs b/cli/src/commands/developer/deploy.rs index f438fc0c0b..26aef78241 100644 --- a/cli/src/commands/developer/deploy.rs +++ b/cli/src/commands/developer/deploy.rs @@ -21,18 +21,18 @@ use snarkvm::{ program::ProgramOwner, }, prelude::{ - block::Transaction, - deployment_cost, - query::Query, - store::{helpers::memory::ConsensusMemory, ConsensusStore}, PrivateKey, ProgramID, VM, + block::Transaction, + deployment_cost, + query::Query, + store::{ConsensusStore, helpers::memory::ConsensusMemory}, }, }; use aleo_std::StorageMode; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use clap::Parser; use colored::Colorize; use std::{path::PathBuf, str::FromStr}; @@ -178,7 +178,7 @@ impl Deploy { #[cfg(test)] mod tests { use super::*; - use crate::commands::{Command, CLI}; + use crate::commands::{CLI, Command}; #[test] fn clap_snarkos_deploy() { diff --git a/cli/src/commands/developer/execute.rs b/cli/src/commands/developer/execute.rs index 73e488e10d..91fe2cd1c7 100644 --- a/cli/src/commands/developer/execute.rs +++ b/cli/src/commands/developer/execute.rs @@ -17,21 +17,21 @@ use super::Developer; use snarkvm::{ console::network::{CanaryV0, MainnetV0, Network, TestnetV0}, prelude::{ - query::Query, - store::{helpers::memory::ConsensusMemory, ConsensusStore}, Address, Identifier, Locator, PrivateKey, Process, ProgramID, - Value, VM, + Value, + query::Query, + store::{ConsensusStore, helpers::memory::ConsensusMemory}, }, }; use aleo_std::StorageMode; -use anyhow::{anyhow, bail, Result}; +use anyhow::{Result, anyhow, bail}; use clap::Parser; use colored::Colorize; use std::{path::PathBuf, str::FromStr}; @@ -213,7 +213,7 @@ fn load_program(endpoint: &str, process: &mut Process, program_id #[cfg(test)] mod tests { use super::*; - use crate::commands::{Command, CLI}; + use crate::commands::{CLI, Command}; #[test] fn clap_snarkos_execute() { diff --git a/cli/src/commands/developer/mod.rs b/cli/src/commands/developer/mod.rs index 173a0b4629..f4f1aba369 100644 --- a/cli/src/commands/developer/mod.rs +++ b/cli/src/commands/developer/mod.rs @@ -32,7 +32,6 @@ use snarkvm::{ console::network::Network, package::Package, prelude::{ - block::Transaction, Address, Ciphertext, Identifier, @@ -45,10 +44,11 @@ use snarkvm::{ ToBytes, Value, ViewKey, + block::Transaction, }, }; -use anyhow::{bail, ensure, Result}; +use anyhow::{Result, bail, ensure}; use clap::Parser; use colored::Colorize; use std::{path::PathBuf, str::FromStr}; diff --git a/cli/src/commands/developer/scan.rs b/cli/src/commands/developer/scan.rs index 16d35a4f96..1b5ce0468a 100644 --- a/cli/src/commands/developer/scan.rs +++ b/cli/src/commands/developer/scan.rs @@ -17,14 +17,14 @@ use snarkvm::{ console::network::{CanaryV0, MainnetV0, Network, TestnetV0}, - prelude::{block::Block, Ciphertext, Field, FromBytes, Plaintext, PrivateKey, Record, ViewKey}, + prelude::{Ciphertext, Field, FromBytes, Plaintext, PrivateKey, Record, ViewKey, block::Block}, }; -use anyhow::{bail, ensure, Result}; +use anyhow::{Result, bail, ensure}; use clap::Parser; use parking_lot::RwLock; use std::{ - io::{stdout, Write}, + io::{Write, stdout}, str::FromStr, sync::Arc, }; diff --git a/cli/src/commands/developer/transfer_private.rs b/cli/src/commands/developer/transfer_private.rs index 89fa0f582f..b3ce8e43d8 100644 --- a/cli/src/commands/developer/transfer_private.rs +++ b/cli/src/commands/developer/transfer_private.rs @@ -17,18 +17,18 @@ use super::Developer; use snarkvm::{ console::network::{CanaryV0, MainnetV0, Network, TestnetV0}, prelude::{ - query::Query, - store::{helpers::memory::ConsensusMemory, ConsensusStore}, Address, Locator, PrivateKey, - Value, VM, + Value, + query::Query, + store::{ConsensusStore, helpers::memory::ConsensusMemory}, }, }; use aleo_std::StorageMode; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use clap::Parser; use std::{path::PathBuf, str::FromStr}; use zeroize::Zeroize; diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index 92a64d5eba..618f750850 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -30,7 +30,7 @@ pub use update::*; use anstyle::{AnsiColor, Color, Style}; use anyhow::Result; -use clap::{builder::Styles, Parser}; +use clap::{Parser, builder::Styles}; const HEADER_COLOR: Option = Some(Color::Ansi(AnsiColor::Yellow)); const LITERAL_COLOR: Option = Some(Color::Ansi(AnsiColor::Green)); diff --git a/cli/src/commands/start.rs b/cli/src/commands/start.rs index 8865cada5a..7fa3efb8e2 100644 --- a/cli/src/commands/start.rs +++ b/cli/src/commands/start.rs @@ -15,7 +15,7 @@ use snarkos_account::Account; use snarkos_display::Display; -use snarkos_node::{bft::MEMORY_POOL_PORT, router::messages::NodeType, Node}; +use snarkos_node::{Node, bft::MEMORY_POOL_PORT, router::messages::NodeType}; use snarkvm::{ console::{ account::{Address, PrivateKey}, @@ -25,7 +25,7 @@ use snarkvm::{ ledger::{ block::Block, committee::{Committee, MIN_DELEGATOR_STAKE, MIN_VALIDATOR_STAKE}, - store::{helpers::memory::ConsensusMemory, ConsensusStore}, + store::{ConsensusStore, helpers::memory::ConsensusMemory}, }, prelude::{FromBytes, ToBits, ToBytes}, synthesizer::VM, @@ -33,7 +33,7 @@ use snarkvm::{ }; use aleo_std::StorageMode; -use anyhow::{bail, ensure, Result}; +use anyhow::{Result, bail, ensure}; use clap::Parser; use colored::Colorize; use core::str::FromStr; @@ -44,7 +44,7 @@ use serde::{Deserialize, Serialize}; use std::{ net::SocketAddr, path::PathBuf, - sync::{atomic::AtomicBool, Arc}, + sync::{Arc, atomic::AtomicBool}, }; use tokio::runtime::{self, Runtime}; @@ -767,7 +767,7 @@ fn load_or_compute_genesis( #[cfg(test)] mod tests { use super::*; - use crate::commands::{Command, CLI}; + use crate::commands::{CLI, Command}; use snarkvm::prelude::MainnetV0; type CurrentNetwork = MainnetV0; diff --git a/cli/src/helpers/dynamic_format.rs b/cli/src/helpers/dynamic_format.rs index 91ee8e2cce..1537d74e5e 100644 --- a/cli/src/helpers/dynamic_format.rs +++ b/cli/src/helpers/dynamic_format.rs @@ -14,17 +14,17 @@ // limitations under the License. use std::sync::{ - atomic::{AtomicBool, Ordering}, Arc, + atomic::{AtomicBool, Ordering}, }; use time::{ - format_description::{self, OwnedFormatItem}, OffsetDateTime, + format_description::{self, OwnedFormatItem}, }; use tracing::{Event, Subscriber}; use tracing_subscriber::{ - fmt::{format::Writer, FmtContext, FormatEvent, FormatFields}, + fmt::{FmtContext, FormatEvent, FormatFields, format::Writer}, registry::LookupSpan, }; diff --git a/cli/src/helpers/logger.rs b/cli/src/helpers/logger.rs index 19e5d8cd9f..f7f954db95 100644 --- a/cli/src/helpers/logger.rs +++ b/cli/src/helpers/logger.rs @@ -20,13 +20,13 @@ use std::{ fs::File, io, path::Path, - sync::{atomic::AtomicBool, Arc}, + sync::{Arc, atomic::AtomicBool}, }; use tokio::sync::mpsc; use tracing_subscriber::{ + EnvFilter, layer::{Layer, SubscriberExt}, util::SubscriberInitExt, - EnvFilter, }; /// Initializes the logger. diff --git a/cli/src/helpers/mod.rs b/cli/src/helpers/mod.rs index 4b8ff51041..4f9dbbcd6d 100644 --- a/cli/src/helpers/mod.rs +++ b/cli/src/helpers/mod.rs @@ -32,7 +32,7 @@ use snarkos_node::router::messages::NodeType; use colored::*; #[cfg(target_family = "unix")] -use nix::sys::resource::{getrlimit, Resource}; +use nix::sys::resource::{Resource, getrlimit}; /// Check if process's open files limit is above minimum and warn if not. #[cfg(target_family = "unix")] diff --git a/cli/src/helpers/updater.rs b/cli/src/helpers/updater.rs index f97b34b083..8b4a0fa5b2 100644 --- a/cli/src/helpers/updater.rs +++ b/cli/src/helpers/updater.rs @@ -14,7 +14,7 @@ // limitations under the License. use colored::Colorize; -use self_update::{backends::github, version::bump_is_greater, Status}; +use self_update::{Status, backends::github, version::bump_is_greater}; use std::fmt::Write; pub struct Updater; diff --git a/display/src/lib.rs b/display/src/lib.rs index bb0c052ee8..f2e381a57f 100644 --- a/display/src/lib.rs +++ b/display/src/lib.rs @@ -28,16 +28,16 @@ use anyhow::Result; use crossterm::{ event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode}, execute, - terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, + terminal::{EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode, enable_raw_mode}, }; use ratatui::{ + Frame, + Terminal, backend::{Backend, CrosstermBackend}, layout::{Constraint, Direction, Layout}, style::{Color, Modifier, Style}, text::{Line, Span}, widgets::{Block, Borders, Tabs as TabsTui}, - Frame, - Terminal, }; use std::{ io, diff --git a/display/src/pages/logs.rs b/display/src/pages/logs.rs index 9a8921b353..626d609f3a 100644 --- a/display/src/pages/logs.rs +++ b/display/src/pages/logs.rs @@ -14,9 +14,9 @@ // limitations under the License. use ratatui::{ + Frame, layout::{Constraint, Direction, Layout, Rect}, widgets::{Block, Borders, Paragraph}, - Frame, }; use std::collections::VecDeque; use tokio::sync::mpsc; diff --git a/display/src/pages/overview.rs b/display/src/pages/overview.rs index 463892b7fc..f816121e37 100644 --- a/display/src/pages/overview.rs +++ b/display/src/pages/overview.rs @@ -17,11 +17,11 @@ use snarkos_node::Node; use snarkvm::prelude::Network; use ratatui::{ + Frame, layout::{Constraint, Direction, Layout, Rect}, style::{Color, Style}, text::Span, - widgets::{canvas::Canvas, Block, Borders}, - Frame, + widgets::{Block, Borders, canvas::Canvas}, }; pub(crate) struct Overview; diff --git a/node/bft/events/src/batch_certified.rs b/node/bft/events/src/batch_certified.rs index 702d8dc7de..eb3e21aff3 100644 --- a/node/bft/events/src/batch_certified.rs +++ b/node/bft/events/src/batch_certified.rs @@ -59,7 +59,7 @@ impl FromBytes for BatchCertified { #[cfg(test)] pub mod prop_tests { - use crate::{certificate_response::prop_tests::any_batch_certificate, BatchCertified}; + use crate::{BatchCertified, certificate_response::prop_tests::any_batch_certificate}; use snarkvm::console::prelude::{FromBytes, ToBytes}; use bytes::{Buf, BufMut, BytesMut}; diff --git a/node/bft/events/src/batch_propose.rs b/node/bft/events/src/batch_propose.rs index 6dec6ad359..3b41b9f5ae 100644 --- a/node/bft/events/src/batch_propose.rs +++ b/node/bft/events/src/batch_propose.rs @@ -62,7 +62,7 @@ impl FromBytes for BatchPropose { #[cfg(test)] pub mod prop_tests { - use crate::{certificate_response::prop_tests::any_batch_header, BatchPropose}; + use crate::{BatchPropose, certificate_response::prop_tests::any_batch_header}; use snarkvm::{ console::prelude::{FromBytes, ToBytes}, ledger::committee::prop_tests::CommitteeContext, @@ -70,7 +70,7 @@ pub mod prop_tests { }; use bytes::{Buf, BufMut, BytesMut}; - use proptest::prelude::{any, BoxedStrategy, Strategy}; + use proptest::prelude::{BoxedStrategy, Strategy, any}; use test_strategy::proptest; type CurrentNetwork = snarkvm::prelude::MainnetV0; diff --git a/node/bft/events/src/batch_signature.rs b/node/bft/events/src/batch_signature.rs index 132063236e..a9a2dcc385 100644 --- a/node/bft/events/src/batch_signature.rs +++ b/node/bft/events/src/batch_signature.rs @@ -56,9 +56,9 @@ impl FromBytes for BatchSignature { #[cfg(test)] pub mod prop_tests { use crate::{ + BatchSignature, certificate_request::prop_tests::any_field, challenge_response::prop_tests::any_signature, - BatchSignature, }; use snarkvm::console::prelude::{FromBytes, ToBytes}; diff --git a/node/bft/events/src/block_request.rs b/node/bft/events/src/block_request.rs index ff66579cfc..c476f5ff13 100644 --- a/node/bft/events/src/block_request.rs +++ b/node/bft/events/src/block_request.rs @@ -65,7 +65,7 @@ pub mod prop_tests { use crate::BlockRequest; use bytes::{Buf, BufMut, BytesMut}; - use proptest::prelude::{any, BoxedStrategy, Strategy}; + use proptest::prelude::{BoxedStrategy, Strategy, any}; use snarkvm::utilities::{FromBytes, ToBytes}; use test_strategy::proptest; diff --git a/node/bft/events/src/block_response.rs b/node/bft/events/src/block_response.rs index 73b98a81f6..340c73da04 100644 --- a/node/bft/events/src/block_response.rs +++ b/node/bft/events/src/block_response.rs @@ -136,16 +136,16 @@ impl FromBytes for DataBlocks { #[cfg(test)] pub mod prop_tests { - use crate::{block_request::prop_tests::any_block_request, BlockResponse, DataBlocks}; + use crate::{BlockResponse, DataBlocks, block_request::prop_tests::any_block_request}; use snarkvm::{ ledger::ledger_test_helpers::sample_genesis_block, - prelude::{block::Block, narwhal::Data, FromBytes, TestRng, ToBytes}, + prelude::{FromBytes, TestRng, ToBytes, block::Block, narwhal::Data}, }; use bytes::{Buf, BufMut, BytesMut}; use proptest::{ collection::vec, - prelude::{any, BoxedStrategy, Strategy}, + prelude::{BoxedStrategy, Strategy, any}, }; use test_strategy::proptest; diff --git a/node/bft/events/src/certificate_request.rs b/node/bft/events/src/certificate_request.rs index 8a7c0afb07..166651bbf4 100644 --- a/node/bft/events/src/certificate_request.rs +++ b/node/bft/events/src/certificate_request.rs @@ -66,7 +66,7 @@ pub mod prop_tests { }; use bytes::{Buf, BufMut, BytesMut}; - use proptest::prelude::{any, BoxedStrategy, Strategy}; + use proptest::prelude::{BoxedStrategy, Strategy, any}; use test_strategy::proptest; type CurrentNetwork = snarkvm::prelude::MainnetV0; diff --git a/node/bft/events/src/certificate_response.rs b/node/bft/events/src/certificate_response.rs index 2c284742fb..8daac79ed6 100644 --- a/node/bft/events/src/certificate_response.rs +++ b/node/bft/events/src/certificate_response.rs @@ -59,7 +59,7 @@ impl FromBytes for CertificateResponse { #[cfg(test)] pub mod prop_tests { - use crate::{prop_tests::now, transmission_response::prop_tests::any_transmission, CertificateResponse}; + use crate::{CertificateResponse, prop_tests::now, transmission_response::prop_tests::any_transmission}; use snarkvm::{ console::{ account::Signature, @@ -76,7 +76,7 @@ pub mod prop_tests { use indexmap::IndexSet; use proptest::{ collection::vec, - prelude::{any, BoxedStrategy, Just, Strategy}, + prelude::{BoxedStrategy, Just, Strategy, any}, sample::Selector, }; use test_strategy::proptest; diff --git a/node/bft/events/src/challenge_request.rs b/node/bft/events/src/challenge_request.rs index d0d5c02dc5..2f23fb3f2b 100644 --- a/node/bft/events/src/challenge_request.rs +++ b/node/bft/events/src/challenge_request.rs @@ -68,7 +68,7 @@ pub mod prop_tests { }; use bytes::{Buf, BufMut, BytesMut}; - use proptest::prelude::{any, BoxedStrategy, Strategy}; + use proptest::prelude::{BoxedStrategy, Strategy, any}; use test_strategy::proptest; type CurrentNetwork = snarkvm::prelude::MainnetV0; diff --git a/node/bft/events/src/challenge_response.rs b/node/bft/events/src/challenge_response.rs index 20445eb266..c32ba0e379 100644 --- a/node/bft/events/src/challenge_response.rs +++ b/node/bft/events/src/challenge_response.rs @@ -60,7 +60,7 @@ pub mod prop_tests { }; use bytes::{Buf, BufMut, BytesMut}; - use proptest::prelude::{any, BoxedStrategy, Strategy}; + use proptest::prelude::{BoxedStrategy, Strategy, any}; use test_strategy::proptest; type CurrentNetwork = snarkvm::prelude::MainnetV0; diff --git a/node/bft/events/src/lib.rs b/node/bft/events/src/lib.rs index aa3cb0a384..4ebc2d8d68 100644 --- a/node/bft/events/src/lib.rs +++ b/node/bft/events/src/lib.rs @@ -68,7 +68,7 @@ pub use worker_ping::WorkerPing; use snarkos_node_sync_locators::BlockLocators; use snarkvm::{ - console::prelude::{error, FromBytes, Network, Read, ToBytes, Write}, + console::prelude::{FromBytes, Network, Read, ToBytes, Write, error}, ledger::{ block::Block, narwhal::{BatchCertificate, BatchHeader, Data, Transmission, TransmissionID}, @@ -76,7 +76,7 @@ use snarkvm::{ prelude::{Address, Field, Signature}, }; -use anyhow::{bail, ensure, Result}; +use anyhow::{Result, bail, ensure}; use indexmap::{IndexMap, IndexSet}; use serde::{Deserialize, Serialize}; pub use std::io::{self, Result as IoResult}; @@ -249,6 +249,9 @@ mod tests { #[cfg(test)] pub mod prop_tests { use crate::{ + Disconnect, + DisconnectReason, + Event, batch_certified::prop_tests::any_batch_certified, batch_propose::prop_tests::any_batch_propose, batch_signature::prop_tests::any_batch_signature, @@ -259,9 +262,6 @@ pub mod prop_tests { transmission_request::prop_tests::any_transmission_request, transmission_response::prop_tests::any_transmission_response, worker_ping::prop_tests::any_worker_ping, - Disconnect, - DisconnectReason, - Event, }; use snarkvm::{ console::{network::Network, types::Field}, @@ -270,7 +270,7 @@ pub mod prop_tests { }; use proptest::{ - prelude::{any, BoxedStrategy, Just, Strategy}, + prelude::{BoxedStrategy, Just, Strategy, any}, prop_oneof, sample::Selector, }; diff --git a/node/bft/events/src/primary_ping.rs b/node/bft/events/src/primary_ping.rs index b3806557a4..977580f9be 100644 --- a/node/bft/events/src/primary_ping.rs +++ b/node/bft/events/src/primary_ping.rs @@ -77,12 +77,12 @@ impl FromBytes for PrimaryPing { #[cfg(test)] pub mod prop_tests { - use crate::{certificate_response::prop_tests::any_batch_certificate, PrimaryPing}; - use snarkos_node_sync_locators::{test_helpers::sample_block_locators, BlockLocators}; + use crate::{PrimaryPing, certificate_response::prop_tests::any_batch_certificate}; + use snarkos_node_sync_locators::{BlockLocators, test_helpers::sample_block_locators}; use snarkvm::utilities::{FromBytes, ToBytes}; use bytes::{Buf, BufMut, BytesMut}; - use proptest::prelude::{any, BoxedStrategy, Strategy}; + use proptest::prelude::{BoxedStrategy, Strategy, any}; use test_strategy::proptest; type CurrentNetwork = snarkvm::prelude::MainnetV0; diff --git a/node/bft/events/src/transmission_request.rs b/node/bft/events/src/transmission_request.rs index bca488fa0d..a93735bc4c 100644 --- a/node/bft/events/src/transmission_request.rs +++ b/node/bft/events/src/transmission_request.rs @@ -59,7 +59,7 @@ impl FromBytes for TransmissionRequest { #[cfg(test)] pub mod prop_tests { - use crate::{prop_tests::any_transmission_id, TransmissionRequest}; + use crate::{TransmissionRequest, prop_tests::any_transmission_id}; use snarkvm::console::prelude::{FromBytes, ToBytes}; use bytes::{Buf, BufMut, BytesMut}; diff --git a/node/bft/events/src/transmission_response.rs b/node/bft/events/src/transmission_response.rs index 9aa3224514..18d3e1a591 100644 --- a/node/bft/events/src/transmission_response.rs +++ b/node/bft/events/src/transmission_response.rs @@ -63,8 +63,8 @@ impl FromBytes for TransmissionResponse { #[cfg(test)] pub mod prop_tests { use crate::{ - prop_tests::{any_solution_id, any_transaction_id, any_transmission_checksum}, TransmissionResponse, + prop_tests::{any_solution_id, any_transaction_id, any_transmission_checksum}, }; use snarkvm::{ console::prelude::{FromBytes, ToBytes}, @@ -74,7 +74,7 @@ pub mod prop_tests { use bytes::{Buf, BufMut, Bytes, BytesMut}; use proptest::{ collection, - prelude::{any, BoxedStrategy, Strategy}, + prelude::{BoxedStrategy, Strategy, any}, prop_oneof, }; use test_strategy::proptest; diff --git a/node/bft/events/src/validators_response.rs b/node/bft/events/src/validators_response.rs index 9959828bd9..d64239bd1c 100644 --- a/node/bft/events/src/validators_response.rs +++ b/node/bft/events/src/validators_response.rs @@ -58,13 +58,13 @@ impl FromBytes for ValidatorsResponse { #[cfg(test)] pub mod prop_tests { - use crate::{challenge_request::prop_tests::any_valid_address, ValidatorsResponse}; + use crate::{ValidatorsResponse, challenge_request::prop_tests::any_valid_address}; use bytes::{Buf, BufMut, BytesMut}; use indexmap::IndexMap; use proptest::{ collection::hash_map, - prelude::{any, BoxedStrategy, Strategy}, + prelude::{BoxedStrategy, Strategy, any}, }; use snarkvm::{ prelude::Address, diff --git a/node/bft/events/src/worker_ping.rs b/node/bft/events/src/worker_ping.rs index e8ac98b2f5..92bb905bd1 100644 --- a/node/bft/events/src/worker_ping.rs +++ b/node/bft/events/src/worker_ping.rs @@ -65,7 +65,7 @@ impl FromBytes for WorkerPing { #[cfg(test)] pub mod prop_tests { - use crate::{prop_tests::any_transmission_id, WorkerPing}; + use crate::{WorkerPing, prop_tests::any_transmission_id}; use snarkvm::console::prelude::{FromBytes, ToBytes}; use bytes::{Buf, BufMut, BytesMut}; diff --git a/node/bft/examples/monitor.rs b/node/bft/examples/monitor.rs index 19bdd23070..a81f3d0707 100644 --- a/node/bft/examples/monitor.rs +++ b/node/bft/examples/monitor.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use axum::{routing::get, Router}; +use axum::{Router, routing::get}; use std::net::SocketAddr; use tokio::net::TcpListener; use tower_http::services::{ServeDir, ServeFile}; diff --git a/node/bft/examples/simple_node.rs b/node/bft/examples/simple_node.rs index 654a1a287b..6e667904cc 100644 --- a/node/bft/examples/simple_node.rs +++ b/node/bft/examples/simple_node.rs @@ -18,36 +18,36 @@ extern crate tracing; use snarkos_account::Account; use snarkos_node_bft::{ - helpers::{init_consensus_channels, init_primary_channels, ConsensusReceiver, PrimarySender, Storage}, - Primary, BFT, MEMORY_POOL_PORT, + Primary, + helpers::{ConsensusReceiver, PrimarySender, Storage, init_consensus_channels, init_primary_channels}, }; use snarkos_node_bft_ledger_service::TranslucentLedgerService; use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ console::{account::PrivateKey, algorithms::BHP256, types::Address}, ledger::{ + Block, + Ledger, block::Transaction, committee::{Committee, MIN_VALIDATOR_STAKE}, narwhal::{BatchHeader, Data}, puzzle::{Solution, SolutionID}, - store::{helpers::memory::ConsensusMemory, ConsensusStore}, - Block, - Ledger, + store::{ConsensusStore, helpers::memory::ConsensusMemory}, }, prelude::{Field, Hash, Network, Uniform, VM}, - utilities::{to_bytes_le, FromBytes, TestRng, ToBits, ToBytes}, + utilities::{FromBytes, TestRng, ToBits, ToBytes, to_bytes_le}, }; use ::bytes::Bytes; -use anyhow::{anyhow, ensure, Error, Result}; +use anyhow::{Error, Result, anyhow, ensure}; use axum::{ + Router, extract::{Path, State}, http::StatusCode, response::{IntoResponse, Response}, routing::get, - Router, }; use axum_extra::response::ErasedJson; use clap::{Parser, ValueEnum}; @@ -58,7 +58,7 @@ use std::{ net::SocketAddr, path::PathBuf, str::FromStr, - sync::{atomic::AtomicBool, Arc, Mutex, OnceLock}, + sync::{Arc, Mutex, OnceLock, atomic::AtomicBool}, }; use tokio::{net::TcpListener, sync::oneshot}; use tracing_subscriber::{ diff --git a/node/bft/ledger-service/src/ledger.rs b/node/bft/ledger-service/src/ledger.rs index a93206a2e1..35efe8695f 100644 --- a/node/bft/ledger-service/src/ledger.rs +++ b/node/bft/ledger-service/src/ledger.rs @@ -13,17 +13,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{fmt_id, spawn_blocking, LedgerService}; +use crate::{LedgerService, fmt_id, spawn_blocking}; use snarkvm::{ ledger::{ + Ledger, block::{Block, Transaction}, committee::Committee, narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, puzzle::{Solution, SolutionID}, store::ConsensusStorage, - Ledger, }, - prelude::{bail, Address, Field, FromBytes, Network, Result}, + prelude::{Address, Field, FromBytes, Network, Result, bail}, }; use indexmap::IndexMap; @@ -34,8 +34,8 @@ use std::{ io::Read, ops::Range, sync::{ - atomic::{AtomicBool, Ordering}, Arc, + atomic::{AtomicBool, Ordering}, }, }; diff --git a/node/bft/ledger-service/src/mock.rs b/node/bft/ledger-service/src/mock.rs index 17eb583187..2833878bfb 100644 --- a/node/bft/ledger-service/src/mock.rs +++ b/node/bft/ledger-service/src/mock.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{fmt_id, LedgerService}; +use crate::{LedgerService, fmt_id}; use snarkvm::{ ledger::{ block::{Block, Transaction}, @@ -21,7 +21,7 @@ use snarkvm::{ narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, puzzle::{Solution, SolutionID}, }, - prelude::{bail, ensure, Address, Field, Network, Result, Zero}, + prelude::{Address, Field, Network, Result, Zero, bail, ensure}, }; use indexmap::IndexMap; diff --git a/node/bft/ledger-service/src/prover.rs b/node/bft/ledger-service/src/prover.rs index 82df46b2a7..9ff464a3d1 100644 --- a/node/bft/ledger-service/src/prover.rs +++ b/node/bft/ledger-service/src/prover.rs @@ -21,7 +21,7 @@ use snarkvm::{ narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, puzzle::{Solution, SolutionID}, }, - prelude::{bail, Address, Field, Network, Result, Zero}, + prelude::{Address, Field, Network, Result, Zero, bail}, }; use indexmap::IndexMap; diff --git a/node/bft/ledger-service/src/translucent.rs b/node/bft/ledger-service/src/translucent.rs index f057a23857..a3869738f1 100644 --- a/node/bft/ledger-service/src/translucent.rs +++ b/node/bft/ledger-service/src/translucent.rs @@ -18,19 +18,19 @@ use async_trait::async_trait; use indexmap::IndexMap; use snarkvm::{ ledger::{ + Ledger, block::{Block, Transaction}, committee::Committee, narwhal::{Data, Subdag, Transmission, TransmissionID}, puzzle::{Solution, SolutionID}, store::ConsensusStorage, - Ledger, }, - prelude::{narwhal::BatchCertificate, Address, Field, Network, Result}, + prelude::{Address, Field, Network, Result, narwhal::BatchCertificate}, }; use std::{ fmt, ops::Range, - sync::{atomic::AtomicBool, Arc}, + sync::{Arc, atomic::AtomicBool}, }; pub struct TranslucentLedgerService> { diff --git a/node/bft/src/bft.rs b/node/bft/src/bft.rs index 87af078893..1cfcc775c3 100644 --- a/node/bft/src/bft.rs +++ b/node/bft/src/bft.rs @@ -14,19 +14,19 @@ // limitations under the License. use crate::{ + MAX_LEADER_CERTIFICATE_DELAY_IN_SECS, + Primary, helpers::{ - fmt_id, - init_bft_channels, - now, BFTReceiver, ConsensusSender, + DAG, PrimaryReceiver, PrimarySender, Storage, - DAG, + fmt_id, + init_bft_channels, + now, }, - Primary, - MAX_LEADER_CERTIFICATE_DELAY_IN_SECS, }; use snarkos_account::Account; use snarkos_node_bft_ledger_service::LedgerService; @@ -38,7 +38,7 @@ use snarkvm::{ narwhal::{BatchCertificate, Data, Subdag, Transmission, TransmissionID}, puzzle::{Solution, SolutionID}, }, - prelude::{bail, ensure, Field, Network, Result}, + prelude::{Field, Network, Result, bail, ensure}, }; use colored::Colorize; @@ -49,12 +49,12 @@ use std::{ future::Future, net::SocketAddr, sync::{ - atomic::{AtomicI64, Ordering}, Arc, + atomic::{AtomicI64, Ordering}, }, }; use tokio::{ - sync::{oneshot, Mutex as TMutex, OnceCell}, + sync::{Mutex as TMutex, OnceCell, oneshot}, task::JoinHandle, }; @@ -892,7 +892,7 @@ impl BFT { #[cfg(test)] mod tests { - use crate::{helpers::Storage, BFT, MAX_LEADER_CERTIFICATE_DELAY_IN_SECS}; + use crate::{BFT, MAX_LEADER_CERTIFICATE_DELAY_IN_SECS, helpers::Storage}; use snarkos_account::Account; use snarkos_node_bft_ledger_service::MockLedgerService; use snarkos_node_bft_storage_service::BFTMemoryService; diff --git a/node/bft/src/gateway.rs b/node/bft/src/gateway.rs index ac0d678f5b..5efa73f55c 100644 --- a/node/bft/src/gateway.rs +++ b/node/bft/src/gateway.rs @@ -14,13 +14,13 @@ // limitations under the License. use crate::{ - events::{EventCodec, PrimaryPing}, - helpers::{assign_to_worker, Cache, PrimarySender, Resolver, Storage, SyncSender, WorkerSender}, - spawn_blocking, - Worker, CONTEXT, MAX_BATCH_DELAY_IN_MS, MEMORY_POOL_PORT, + Worker, + events::{EventCodec, PrimaryPing}, + helpers::{Cache, PrimarySender, Resolver, Storage, SyncSender, WorkerSender, assign_to_worker}, + spawn_blocking, }; use snarkos_account::Account; use snarkos_node_bft_events::{ @@ -40,16 +40,16 @@ use snarkos_node_bft_events::{ ValidatorsResponse, }; use snarkos_node_bft_ledger_service::LedgerService; -use snarkos_node_sync::{communication_service::CommunicationService, MAX_BLOCKS_BEHIND}; +use snarkos_node_sync::{MAX_BLOCKS_BEHIND, communication_service::CommunicationService}; use snarkos_node_tcp::{ - is_bogon_ip, - is_unspecified_or_broadcast_ip, - protocols::{Disconnect, Handshake, OnConnect, Reading, Writing}, Config, Connection, ConnectionSide, - Tcp, P2P, + Tcp, + is_bogon_ip, + is_unspecified_or_broadcast_ip, + protocols::{Disconnect, Handshake, OnConnect, Reading, Writing}, }; use snarkvm::{ console::prelude::*, @@ -68,7 +68,7 @@ use rand::seq::{IteratorRandom, SliceRandom}; use std::{collections::HashSet, future::Future, io, net::SocketAddr, sync::Arc, time::Duration}; use tokio::{ net::TcpStream, - sync::{oneshot, OnceCell}, + sync::{OnceCell, oneshot}, task::{self, JoinHandle}, }; use tokio_stream::StreamExt; @@ -1383,12 +1383,12 @@ impl Gateway { #[cfg(test)] mod prop_tests { use crate::{ - gateway::prop_tests::GatewayAddress::{Dev, Prod}, - helpers::{init_primary_channels, init_worker_channels, Storage}, Gateway, - Worker, MAX_WORKERS, MEMORY_POOL_PORT, + Worker, + gateway::prop_tests::GatewayAddress::{Dev, Prod}, + helpers::{Storage, init_primary_channels, init_worker_channels}, }; use snarkos_account::Account; use snarkos_node_bft_ledger_service::MockLedgerService; @@ -1397,11 +1397,11 @@ mod prop_tests { use snarkvm::{ ledger::{ committee::{ + Committee, prop_tests::{CommitteeContext, ValidatorSet}, test_helpers::sample_committee_for_round_and_members, - Committee, }, - narwhal::{batch_certificate::test_helpers::sample_batch_certificate_for_round, BatchHeader}, + narwhal::{BatchHeader, batch_certificate::test_helpers::sample_batch_certificate_for_round}, }, prelude::{MainnetV0, PrivateKey}, utilities::TestRng, @@ -1409,7 +1409,7 @@ mod prop_tests { use indexmap::{IndexMap, IndexSet}; use proptest::{ - prelude::{any, any_with, Arbitrary, BoxedStrategy, Just, Strategy}, + prelude::{Arbitrary, BoxedStrategy, Just, Strategy, any, any_with}, sample::Selector, }; use std::{ diff --git a/node/bft/src/helpers/dag.rs b/node/bft/src/helpers/dag.rs index a95fa70c4f..dd99f6e209 100644 --- a/node/bft/src/helpers/dag.rs +++ b/node/bft/src/helpers/dag.rs @@ -153,7 +153,7 @@ pub(crate) mod test_helpers { mod tests { use super::*; use snarkvm::{ - prelude::{narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round, MainnetV0}, + prelude::{MainnetV0, narwhal::batch_certificate::test_helpers::sample_batch_certificate_for_round}, utilities::TestRng, }; diff --git a/node/bft/src/helpers/partition.rs b/node/bft/src/helpers/partition.rs index abd8f87cdc..a65b46466b 100644 --- a/node/bft/src/helpers/partition.rs +++ b/node/bft/src/helpers/partition.rs @@ -19,7 +19,7 @@ use snarkvm::{ prelude::{Network, ToBytes}, }; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use sha2::{Digest, Sha256}; fn double_sha256(data: &[u8]) -> [u8; 32] { diff --git a/node/bft/src/helpers/pending.rs b/node/bft/src/helpers/pending.rs index baca6d9bff..4d6699eb27 100644 --- a/node/bft/src/helpers/pending.rs +++ b/node/bft/src/helpers/pending.rs @@ -484,7 +484,7 @@ mod tests { mod prop_tests { use super::*; - use test_strategy::{proptest, Arbitrary}; + use test_strategy::{Arbitrary, proptest}; #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] pub struct Item { diff --git a/node/bft/src/helpers/proposal.rs b/node/bft/src/helpers/proposal.rs index 28ece680a8..4029722461 100644 --- a/node/bft/src/helpers/proposal.rs +++ b/node/bft/src/helpers/proposal.rs @@ -23,7 +23,7 @@ use snarkvm::{ committee::Committee, narwhal::{BatchCertificate, BatchHeader, Transmission, TransmissionID}, }, - prelude::{bail, ensure, error, FromBytes, IoResult, Itertools, Read, Result, ToBytes, Write}, + prelude::{FromBytes, IoResult, Itertools, Read, Result, ToBytes, Write, bail, ensure, error}, }; use indexmap::{IndexMap, IndexSet}; @@ -260,9 +260,9 @@ pub(crate) mod tests { #[cfg(test)] mod prop_tests { use crate::helpers::{ + Proposal, now, storage::prop_tests::{AnyTransmission, AnyTransmissionID, CryptoTestRng}, - Proposal, }; use snarkvm::ledger::{ committee::prop_tests::{CommitteeContext, ValidatorSet}, @@ -270,7 +270,7 @@ mod prop_tests { }; use indexmap::IndexMap; - use proptest::sample::{size_range, Selector}; + use proptest::sample::{Selector, size_range}; use test_strategy::proptest; #[proptest] diff --git a/node/bft/src/helpers/proposal_cache.rs b/node/bft/src/helpers/proposal_cache.rs index 2e79430702..074fe97291 100644 --- a/node/bft/src/helpers/proposal_cache.rs +++ b/node/bft/src/helpers/proposal_cache.rs @@ -18,10 +18,10 @@ use crate::helpers::{Proposal, SignedProposals}; use snarkvm::{ console::{account::Address, network::Network, program::SUBDAG_CERTIFICATES_DEPTH}, ledger::narwhal::BatchCertificate, - prelude::{anyhow, bail, error, FromBytes, IoResult, Read, Result, ToBytes, Write}, + prelude::{FromBytes, IoResult, Read, Result, ToBytes, Write, anyhow, bail, error}, }; -use aleo_std::{aleo_ledger_dir, StorageMode}; +use aleo_std::{StorageMode, aleo_ledger_dir}; use indexmap::IndexSet; use std::{fs, path::PathBuf}; diff --git a/node/bft/src/helpers/signed_proposals.rs b/node/bft/src/helpers/signed_proposals.rs index 9cee036163..38bd4e8431 100644 --- a/node/bft/src/helpers/signed_proposals.rs +++ b/node/bft/src/helpers/signed_proposals.rs @@ -19,7 +19,7 @@ use snarkvm::{ network::Network, types::Field, }, - prelude::{error, FromBytes, IoResult, Read, ToBytes, Write}, + prelude::{FromBytes, IoResult, Read, ToBytes, Write, error}, }; use std::{collections::HashMap, ops::Deref}; diff --git a/node/bft/src/helpers/storage.rs b/node/bft/src/helpers/storage.rs index 578d75b350..0bb3fdbbcd 100644 --- a/node/bft/src/helpers/storage.rs +++ b/node/bft/src/helpers/storage.rs @@ -21,16 +21,16 @@ use snarkvm::{ block::{Block, Transaction}, narwhal::{BatchCertificate, BatchHeader, Transmission, TransmissionID}, }, - prelude::{anyhow, bail, ensure, Address, Field, Network, Result}, + prelude::{Address, Field, Network, Result, anyhow, bail, ensure}, }; -use indexmap::{map::Entry, IndexMap, IndexSet}; +use indexmap::{IndexMap, IndexSet, map::Entry}; use parking_lot::RwLock; use std::{ collections::{HashMap, HashSet}, sync::{ - atomic::{AtomicU32, AtomicU64, Ordering}, Arc, + atomic::{AtomicU32, AtomicU64, Ordering}, }, }; @@ -1043,9 +1043,9 @@ pub mod prop_tests { use indexmap::indexset; use proptest::{ collection, - prelude::{any, Arbitrary, BoxedStrategy, Just, Strategy}, + prelude::{Arbitrary, BoxedStrategy, Just, Strategy, any}, prop_oneof, - sample::{size_range, Selector}, + sample::{Selector, size_range}, test_runner::TestRng, }; use rand::{CryptoRng, Error, Rng, RngCore}; diff --git a/node/bft/src/helpers/timestamp.rs b/node/bft/src/helpers/timestamp.rs index a3290f95a2..2612dfbfeb 100644 --- a/node/bft/src/helpers/timestamp.rs +++ b/node/bft/src/helpers/timestamp.rs @@ -14,7 +14,7 @@ // limitations under the License. use crate::MAX_TIMESTAMP_DELTA_IN_SECS; -use snarkvm::prelude::{bail, Result}; +use snarkvm::prelude::{Result, bail}; use time::OffsetDateTime; diff --git a/node/bft/src/primary.rs b/node/bft/src/primary.rs index 0d874d7ef1..fbd75b2908 100644 --- a/node/bft/src/primary.rs +++ b/node/bft/src/primary.rs @@ -14,14 +14,17 @@ // limitations under the License. use crate::{ + Gateway, + MAX_BATCH_DELAY_IN_MS, + MAX_WORKERS, + MIN_BATCH_DELAY_IN_SECS, + PRIMARY_PING_IN_MS, + Sync, + Transport, + WORKER_PING_IN_MS, + Worker, events::{BatchPropose, BatchSignature, Event}, helpers::{ - assign_to_worker, - assign_to_workers, - fmt_id, - init_sync_channels, - init_worker_channels, - now, BFTSender, PrimaryReceiver, PrimarySender, @@ -29,17 +32,14 @@ use crate::{ ProposalCache, SignedProposals, Storage, + assign_to_worker, + assign_to_workers, + fmt_id, + init_sync_channels, + init_worker_channels, + now, }, spawn_blocking, - Gateway, - Sync, - Transport, - Worker, - MAX_BATCH_DELAY_IN_MS, - MAX_WORKERS, - MIN_BATCH_DELAY_IN_SECS, - PRIMARY_PING_IN_MS, - WORKER_PING_IN_MS, }; use snarkos_account::Account; use snarkos_node_bft_events::PrimaryPing; diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 46cb269a54..51d3edafcd 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -14,28 +14,28 @@ // limitations under the License. use crate::{ - helpers::{fmt_id, max_redundant_requests, BFTSender, Pending, Storage, SyncReceiver}, - spawn_blocking, Gateway, - Transport, MAX_FETCH_TIMEOUT_IN_MS, PRIMARY_PING_IN_MS, + Transport, + helpers::{BFTSender, Pending, Storage, SyncReceiver, fmt_id, max_redundant_requests}, + spawn_blocking, }; use snarkos_node_bft_events::{CertificateRequest, CertificateResponse, Event}; use snarkos_node_bft_ledger_service::LedgerService; -use snarkos_node_sync::{locators::BlockLocators, BlockSync, BlockSyncMode}; +use snarkos_node_sync::{BlockSync, BlockSyncMode, locators::BlockLocators}; use snarkvm::{ console::{network::Network, types::Field}, ledger::{authority::Authority, block::Block, narwhal::BatchCertificate}, prelude::{cfg_into_iter, cfg_iter}, }; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use parking_lot::Mutex; use rayon::prelude::*; use std::{collections::HashMap, future::Future, net::SocketAddr, sync::Arc, time::Duration}; use tokio::{ - sync::{oneshot, Mutex as TMutex, OnceCell}, + sync::{Mutex as TMutex, OnceCell, oneshot}, task::JoinHandle, }; @@ -668,7 +668,7 @@ mod tests { }, ledger::{ narwhal::{BatchCertificate, BatchHeader, Subdag}, - store::{helpers::memory::ConsensusMemory, ConsensusStore}, + store::{ConsensusStore, helpers::memory::ConsensusMemory}, }, prelude::{Ledger, VM}, utilities::TestRng, diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index 92cb7bb65f..2200877d25 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -14,13 +14,13 @@ // limitations under the License. use crate::{ - events::{Event, TransmissionRequest, TransmissionResponse}, - helpers::{fmt_id, max_redundant_requests, Pending, Ready, Storage, WorkerReceiver}, - spawn_blocking, - ProposedBatch, - Transport, MAX_FETCH_TIMEOUT_IN_MS, MAX_WORKERS, + ProposedBatch, + Transport, + events::{Event, TransmissionRequest, TransmissionResponse}, + helpers::{Pending, Ready, Storage, WorkerReceiver, fmt_id, max_redundant_requests}, + spawn_blocking, }; use snarkos_node_bft_ledger_service::LedgerService; use snarkvm::{ diff --git a/node/bft/storage-service/src/memory.rs b/node/bft/storage-service/src/memory.rs index 550daaefcf..372041cb36 100644 --- a/node/bft/storage-service/src/memory.rs +++ b/node/bft/storage-service/src/memory.rs @@ -16,10 +16,10 @@ use crate::StorageService; use snarkvm::{ ledger::narwhal::{BatchHeader, Transmission, TransmissionID}, - prelude::{bail, Field, Network, Result}, + prelude::{Field, Network, Result, bail}, }; -use indexmap::{indexset, map::Entry, IndexMap, IndexSet}; +use indexmap::{IndexMap, IndexSet, indexset, map::Entry}; use parking_lot::RwLock; use std::collections::{HashMap, HashSet}; use tracing::error; diff --git a/node/bft/storage-service/src/persistent.rs b/node/bft/storage-service/src/persistent.rs index 8d7e31bca2..2721b2cc73 100644 --- a/node/bft/storage-service/src/persistent.rs +++ b/node/bft/storage-service/src/persistent.rs @@ -20,20 +20,20 @@ use snarkvm::{ store::{ cow_to_cloned, helpers::{ + Map, + MapRead, rocksdb::{ - internal::{self, BFTMap, Database, MapID}, DataMap, + internal::{self, BFTMap, Database, MapID}, }, - Map, - MapRead, }, }, }, - prelude::{bail, Field, Network, Result}, + prelude::{Field, Network, Result, bail}, }; use aleo_std::StorageMode; -use indexmap::{indexset, IndexSet}; +use indexmap::{IndexSet, indexset}; use std::{ borrow::Cow, collections::{HashMap, HashSet}, diff --git a/node/bft/tests/common/primary.rs b/node/bft/tests/common/primary.rs index 5c0752aea0..110572138b 100644 --- a/node/bft/tests/common/primary.rs +++ b/node/bft/tests/common/primary.rs @@ -14,30 +14,30 @@ // limitations under the License. use crate::common::{ - utils::{fire_unconfirmed_solutions, fire_unconfirmed_transactions, initialize_logger}, CurrentNetwork, TranslucentLedgerService, + utils::{fire_unconfirmed_solutions, fire_unconfirmed_transactions, initialize_logger}, }; use snarkos_account::Account; use snarkos_node_bft::{ - helpers::{init_primary_channels, PrimarySender, Storage}, - Primary, BFT, MAX_BATCH_DELAY_IN_MS, + Primary, + helpers::{PrimarySender, Storage, init_primary_channels}, }; use snarkos_node_bft_storage_service::BFTMemoryService; use snarkvm::{ console::{ account::{Address, PrivateKey}, - algorithms::{Hash, BHP256}, + algorithms::{BHP256, Hash}, network::Network, }, ledger::{ + Ledger, block::Block, committee::{Committee, MIN_VALIDATOR_STAKE}, narwhal::BatchHeader, - store::{helpers::memory::ConsensusMemory, ConsensusStore}, - Ledger, + store::{ConsensusStore, helpers::memory::ConsensusMemory}, }, prelude::{CryptoRng, FromBytes, Rng, TestRng, ToBits, ToBytes, VM}, utilities::to_bytes_le, diff --git a/node/bft/tests/common/test_peer.rs b/node/bft/tests/common/test_peer.rs index 752a3e1731..ef7a95c36f 100644 --- a/node/bft/tests/common/test_peer.rs +++ b/node/bft/tests/common/test_peer.rs @@ -23,12 +23,12 @@ use std::{ }; use pea2pea::{ - protocols::{Handshake, OnDisconnect, Reading, Writing}, Config, Connection, ConnectionSide, Node, Pea2Pea, + protocols::{Handshake, OnDisconnect, Reading, Writing}, }; use tokio::{ diff --git a/node/bft/tests/common/utils.rs b/node/bft/tests/common/utils.rs index ad86e6dbde..6c9b79e079 100644 --- a/node/bft/tests/common/utils.rs +++ b/node/bft/tests/common/utils.rs @@ -13,12 +13,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::common::{primary, CurrentNetwork, TranslucentLedgerService}; +use crate::common::{CurrentNetwork, TranslucentLedgerService, primary}; use snarkos_account::Account; use snarkos_node_bft::{ - helpers::{PrimarySender, Storage}, Gateway, Worker, + helpers::{PrimarySender, Storage}, }; use snarkos_node_bft_storage_service::BFTMemoryService; @@ -30,13 +30,13 @@ use snarkvm::{ store::helpers::memory::ConsensusMemory, }, prelude::{ - block::Transaction, - committee::MIN_VALIDATOR_STAKE, - puzzle::{Solution, SolutionID}, Field, Network, TestRng, Uniform, + block::Transaction, + committee::MIN_VALIDATOR_STAKE, + puzzle::{Solution, SolutionID}, }, }; diff --git a/node/bft/tests/components/pending.rs b/node/bft/tests/components/pending.rs index 2435b3d6ca..ee622a54fe 100644 --- a/node/bft/tests/components/pending.rs +++ b/node/bft/tests/components/pending.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::common::{primary::new_test_committee, utils::sample_ledger, CurrentNetwork}; +use crate::common::{CurrentNetwork, primary::new_test_committee, utils::sample_ledger}; use snarkos_node_bft::helpers::max_redundant_requests; use snarkvm::{ledger::committee::Committee, prelude::TestRng}; diff --git a/node/bft/tests/components/worker.rs b/node/bft/tests/components/worker.rs index 40950b571f..0e70eb7840 100644 --- a/node/bft/tests/components/worker.rs +++ b/node/bft/tests/components/worker.rs @@ -14,9 +14,9 @@ // limitations under the License. use crate::common::{ + CurrentNetwork, primary::new_test_committee, utils::{sample_ledger, sample_worker}, - CurrentNetwork, }; use snarkos_node_bft::helpers::max_redundant_requests; use snarkvm::{ diff --git a/node/bft/tests/gateway_e2e.rs b/node/bft/tests/gateway_e2e.rs index 047dc21f7e..af160f33f7 100644 --- a/node/bft/tests/gateway_e2e.rs +++ b/node/bft/tests/gateway_e2e.rs @@ -17,13 +17,13 @@ mod common; use crate::common::{ + CurrentNetwork, primary::new_test_committee, test_peer::TestPeer, utils::{sample_gateway, sample_ledger, sample_storage}, - CurrentNetwork, }; use snarkos_account::Account; -use snarkos_node_bft::{helpers::init_primary_channels, Gateway}; +use snarkos_node_bft::{Gateway, helpers::init_primary_channels}; use snarkos_node_bft_events::{ChallengeRequest, ChallengeResponse, Disconnect, DisconnectReason, Event, WorkerPing}; use snarkos_node_tcp::P2P; use snarkvm::{ledger::narwhal::Data, prelude::TestRng}; diff --git a/node/cdn/src/blocks.rs b/node/cdn/src/blocks.rs index 3114c022a0..581a281dea 100644 --- a/node/cdn/src/blocks.rs +++ b/node/cdn/src/blocks.rs @@ -18,24 +18,24 @@ #![allow(clippy::await_holding_lock)] use snarkvm::prelude::{ - block::Block, - store::{cow_to_copied, ConsensusStorage}, Deserialize, DeserializeOwned, Ledger, Network, Serialize, + block::Block, + store::{ConsensusStorage, cow_to_copied}, }; -use anyhow::{anyhow, bail, Result}; +use anyhow::{Result, anyhow, bail}; use colored::Colorize; use parking_lot::Mutex; use reqwest::Client; use std::{ cmp, sync::{ - atomic::{AtomicBool, AtomicU32, Ordering}, Arc, + atomic::{AtomicBool, AtomicU32, Ordering}, }, time::{Duration, Instant}, }; @@ -429,10 +429,10 @@ fn log_progress( #[cfg(test)] mod tests { use crate::{ - blocks::{cdn_get, cdn_height, log_progress, BLOCKS_PER_FILE}, + blocks::{BLOCKS_PER_FILE, cdn_get, cdn_height, log_progress}, load_blocks, }; - use snarkvm::prelude::{block::Block, MainnetV0}; + use snarkvm::prelude::{MainnetV0, block::Block}; use parking_lot::RwLock; use std::{sync::Arc, time::Instant}; diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs index 30cef14098..f47fdc8b4f 100644 --- a/node/consensus/src/lib.rs +++ b/node/consensus/src/lib.rs @@ -20,17 +20,17 @@ extern crate tracing; use snarkos_account::Account; use snarkos_node_bft::{ + BFT, + Primary, helpers::{ - fmt_id, - init_consensus_channels, ConsensusReceiver, PrimaryReceiver, PrimarySender, Storage as NarwhalStorage, + fmt_id, + init_consensus_channels, }, spawn_blocking, - Primary, - BFT, }; use snarkos_node_bft_ledger_service::LedgerService; use snarkos_node_bft_storage_service::BFTPersistentStorage; @@ -51,7 +51,7 @@ use lru::LruCache; use parking_lot::Mutex; use std::{future::Future, net::SocketAddr, num::NonZeroUsize, sync::Arc}; use tokio::{ - sync::{oneshot, OnceCell}, + sync::{OnceCell, oneshot}, task::JoinHandle, }; diff --git a/node/metrics/src/lib.rs b/node/metrics/src/lib.rs index cfa06a90f4..a8cfa4e4ed 100644 --- a/node/metrics/src/lib.rs +++ b/node/metrics/src/lib.rs @@ -27,13 +27,13 @@ use rayon::prelude::*; use parking_lot::Mutex; use snarkvm::{ ledger::narwhal::TransmissionID, - prelude::{cfg_iter, Block, Network}, + prelude::{Block, Network, cfg_iter}, }; use std::{ collections::HashMap, sync::{ - atomic::{AtomicUsize, Ordering}, Arc, + atomic::{AtomicUsize, Ordering}, }, }; use time::OffsetDateTime; diff --git a/node/rest/src/helpers/auth.rs b/node/rest/src/helpers/auth.rs index 7317de7075..3284732a9d 100644 --- a/node/rest/src/helpers/auth.rs +++ b/node/rest/src/helpers/auth.rs @@ -16,19 +16,19 @@ use snarkvm::prelude::*; use ::time::OffsetDateTime; -use anyhow::{anyhow, Result}; +use anyhow::{Result, anyhow}; use axum::{ + RequestPartsExt, body::Body, http::{Request, StatusCode}, middleware::Next, response::{IntoResponse, Response}, - RequestPartsExt, }; use axum_extra::{ - headers::authorization::{Authorization, Bearer}, TypedHeader, + headers::authorization::{Authorization, Bearer}, }; -use jsonwebtoken::{decode, encode, Algorithm, DecodingKey, EncodingKey, Header, Validation}; +use jsonwebtoken::{Algorithm, DecodingKey, EncodingKey, Header, Validation, decode, encode}; use once_cell::sync::OnceCell; use serde::{Deserialize, Serialize}; diff --git a/node/rest/src/lib.rs b/node/rest/src/lib.rs index eba9129c82..a6235f4ee6 100644 --- a/node/rest/src/lib.rs +++ b/node/rest/src/lib.rs @@ -25,31 +25,31 @@ mod routes; use snarkos_node_consensus::Consensus; use snarkos_node_router::{ - messages::{Message, UnconfirmedTransaction}, Routing, + messages::{Message, UnconfirmedTransaction}, }; use snarkvm::{ console::{program::ProgramID, types::Field}, ledger::narwhal::Data, - prelude::{cfg_into_iter, store::ConsensusStorage, Ledger, Network}, + prelude::{Ledger, Network, cfg_into_iter, store::ConsensusStorage}, }; use anyhow::Result; use axum::{ + Json, body::Body, extract::{ConnectInfo, DefaultBodyLimit, Path, Query, State}, - http::{header::CONTENT_TYPE, Method, Request, StatusCode}, + http::{Method, Request, StatusCode, header::CONTENT_TYPE}, middleware, middleware::Next, response::Response, routing::{get, post}, - Json, }; use axum_extra::response::ErasedJson; use parking_lot::Mutex; use std::{net::SocketAddr, sync::Arc}; use tokio::{net::TcpListener, task::JoinHandle}; -use tower_governor::{governor::GovernorConfigBuilder, GovernorLayer}; +use tower_governor::{GovernorLayer, governor::GovernorConfigBuilder}; use tower_http::{ cors::{Any, CorsLayer}, trace::TraceLayer, diff --git a/node/rest/src/routes.rs b/node/rest/src/routes.rs index a646ef2047..bff0337f00 100644 --- a/node/rest/src/routes.rs +++ b/node/rest/src/routes.rs @@ -14,10 +14,10 @@ // limitations under the License. use super::*; -use snarkos_node_router::{messages::UnconfirmedSolution, SYNC_LENIENCY}; +use snarkos_node_router::{SYNC_LENIENCY, messages::UnconfirmedSolution}; use snarkvm::{ ledger::puzzle::Solution, - prelude::{block::Transaction, Address, Identifier, LimitedWriter, Plaintext, ToBytes}, + prelude::{Address, Identifier, LimitedWriter, Plaintext, ToBytes, block::Transaction}, }; use indexmap::IndexMap; diff --git a/node/router/messages/src/block_request.rs b/node/router/messages/src/block_request.rs index ff04c14ecb..0e417b1b80 100644 --- a/node/router/messages/src/block_request.rs +++ b/node/router/messages/src/block_request.rs @@ -69,7 +69,7 @@ pub mod prop_tests { use snarkvm::utilities::{FromBytes, ToBytes}; use bytes::{Buf, BufMut, BytesMut}; - use proptest::prelude::{any, BoxedStrategy, Strategy}; + use proptest::prelude::{BoxedStrategy, Strategy, any}; use test_strategy::proptest; pub fn any_block_request() -> BoxedStrategy { diff --git a/node/router/messages/src/block_response.rs b/node/router/messages/src/block_response.rs index b4e8f857a1..649e1b8c15 100644 --- a/node/router/messages/src/block_response.rs +++ b/node/router/messages/src/block_response.rs @@ -61,7 +61,7 @@ impl FromBytes for BlockResponse { #[cfg(test)] pub mod prop_tests { - use crate::{block_request::prop_tests::any_block_request, BlockResponse, DataBlocks}; + use crate::{BlockResponse, DataBlocks, block_request::prop_tests::any_block_request}; use snarkvm::{ ledger::ledger_test_helpers::sample_genesis_block, prelude::{block::Block, narwhal::Data}, @@ -71,7 +71,7 @@ pub mod prop_tests { use bytes::{Buf, BufMut, BytesMut}; use proptest::{ collection::vec, - prelude::{any, BoxedStrategy, Strategy}, + prelude::{BoxedStrategy, Strategy, any}, }; use test_strategy::proptest; diff --git a/node/router/messages/src/challenge_request.rs b/node/router/messages/src/challenge_request.rs index 633079d05c..5f4a62991e 100644 --- a/node/router/messages/src/challenge_request.rs +++ b/node/router/messages/src/challenge_request.rs @@ -74,7 +74,7 @@ pub mod prop_tests { }; use bytes::{Buf, BufMut, BytesMut}; - use proptest::prelude::{any, BoxedStrategy, Strategy}; + use proptest::prelude::{BoxedStrategy, Strategy, any}; use test_strategy::proptest; type CurrentNetwork = snarkvm::prelude::MainnetV0; diff --git a/node/router/messages/src/challenge_response.rs b/node/router/messages/src/challenge_response.rs index 6b74e12b2b..2e95cfe559 100644 --- a/node/router/messages/src/challenge_response.rs +++ b/node/router/messages/src/challenge_response.rs @@ -64,12 +64,12 @@ pub mod prop_tests { use snarkvm::{ console::prelude::{FromBytes, ToBytes}, ledger::{ledger_test_helpers::sample_genesis_block, narwhal::Data}, - prelude::{block::Header, Field, PrivateKey, Signature}, + prelude::{Field, PrivateKey, Signature, block::Header}, utilities::rand::{TestRng, Uniform}, }; use bytes::{Buf, BufMut, BytesMut}; - use proptest::prelude::{any, BoxedStrategy, Strategy}; + use proptest::prelude::{BoxedStrategy, Strategy, any}; use test_strategy::proptest; type CurrentNetwork = snarkvm::prelude::MainnetV0; diff --git a/node/router/messages/src/helpers/codec.rs b/node/router/messages/src/helpers/codec.rs index c151e6fe12..c2fbd8009e 100644 --- a/node/router/messages/src/helpers/codec.rs +++ b/node/router/messages/src/helpers/codec.rs @@ -95,8 +95,8 @@ mod tests { use super::*; use crate::{ - unconfirmed_transaction::prop_tests::{any_large_unconfirmed_transaction, any_unconfirmed_transaction}, UnconfirmedTransaction, + unconfirmed_transaction::prop_tests::{any_large_unconfirmed_transaction, any_unconfirmed_transaction}, }; use proptest::prelude::ProptestConfig; diff --git a/node/router/messages/src/helpers/disconnect.rs b/node/router/messages/src/helpers/disconnect.rs index b4e97d49fc..53a38a1782 100644 --- a/node/router/messages/src/helpers/disconnect.rs +++ b/node/router/messages/src/helpers/disconnect.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use snarkvm::prelude::{error, FromBytes, ToBytes}; +use snarkvm::prelude::{FromBytes, ToBytes, error}; use std::io; diff --git a/node/router/messages/src/helpers/node_type.rs b/node/router/messages/src/helpers/node_type.rs index cb9cdf40db..42fbf9bf1e 100644 --- a/node/router/messages/src/helpers/node_type.rs +++ b/node/router/messages/src/helpers/node_type.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use snarkvm::prelude::{error, FromBytes, ToBytes}; +use snarkvm::prelude::{FromBytes, ToBytes, error}; use serde::{Deserialize, Serialize}; use std::io; diff --git a/node/router/messages/src/lib.rs b/node/router/messages/src/lib.rs index 5cd9773c23..ba177cd9de 100644 --- a/node/router/messages/src/lib.rs +++ b/node/router/messages/src/lib.rs @@ -64,14 +64,14 @@ pub use snarkos_node_bft_events::DataBlocks; use snarkos_node_sync_locators::BlockLocators; use snarkvm::prelude::{ - block::{Header, Transaction}, - error, - puzzle::{Solution, SolutionID}, Address, FromBytes, Network, Signature, ToBytes, + block::{Header, Transaction}, + error, + puzzle::{Solution, SolutionID}, }; use std::{ diff --git a/node/router/messages/src/peer_response.rs b/node/router/messages/src/peer_response.rs index dace842ed4..71a4998241 100644 --- a/node/router/messages/src/peer_response.rs +++ b/node/router/messages/src/peer_response.rs @@ -67,7 +67,7 @@ pub mod prop_tests { use bytes::{Buf, BufMut, BytesMut}; use proptest::{ collection::vec, - prelude::{any, BoxedStrategy, Strategy}, + prelude::{BoxedStrategy, Strategy, any}, }; use std::net::{IpAddr, SocketAddr}; use test_strategy::proptest; diff --git a/node/router/messages/src/ping.rs b/node/router/messages/src/ping.rs index b6ca9194fe..80297fc3fa 100644 --- a/node/router/messages/src/ping.rs +++ b/node/router/messages/src/ping.rs @@ -73,12 +73,12 @@ impl Ping { #[cfg(test)] pub mod prop_tests { - use crate::{challenge_request::prop_tests::any_node_type, Ping}; - use snarkos_node_sync_locators::{test_helpers::sample_block_locators, BlockLocators}; + use crate::{Ping, challenge_request::prop_tests::any_node_type}; + use snarkos_node_sync_locators::{BlockLocators, test_helpers::sample_block_locators}; use snarkvm::utilities::{FromBytes, ToBytes}; use bytes::{Buf, BufMut, BytesMut}; - use proptest::prelude::{any, BoxedStrategy, Strategy}; + use proptest::prelude::{BoxedStrategy, Strategy, any}; use test_strategy::proptest; type CurrentNetwork = snarkvm::prelude::MainnetV0; diff --git a/node/router/messages/src/pong.rs b/node/router/messages/src/pong.rs index 71ae1444cb..e3d80d79cd 100644 --- a/node/router/messages/src/pong.rs +++ b/node/router/messages/src/pong.rs @@ -65,7 +65,7 @@ pub mod tests { use bytes::{Buf, BufMut, BytesMut}; use proptest::{ option::of, - prelude::{any, BoxedStrategy, Strategy}, + prelude::{BoxedStrategy, Strategy, any}, }; use test_strategy::proptest; diff --git a/node/router/messages/src/puzzle_response.rs b/node/router/messages/src/puzzle_response.rs index ecec70c699..2c9488a3e2 100644 --- a/node/router/messages/src/puzzle_response.rs +++ b/node/router/messages/src/puzzle_response.rs @@ -51,7 +51,7 @@ impl FromBytes for PuzzleResponse { #[cfg(test)] pub mod prop_tests { - use crate::{challenge_response::prop_tests::any_genesis_header, PuzzleResponse}; + use crate::{PuzzleResponse, challenge_response::prop_tests::any_genesis_header}; use snarkvm::{ console::prelude::{FromBytes, ToBytes}, ledger::narwhal::Data, @@ -59,7 +59,7 @@ pub mod prop_tests { }; use bytes::{Buf, BufMut, BytesMut}; - use proptest::prelude::{any, BoxedStrategy, Strategy}; + use proptest::prelude::{BoxedStrategy, Strategy, any}; use test_strategy::proptest; type CurrentNetwork = snarkvm::prelude::MainnetV0; diff --git a/node/router/messages/src/unconfirmed_solution.rs b/node/router/messages/src/unconfirmed_solution.rs index 1c3cdad085..fd76aa7fc6 100644 --- a/node/router/messages/src/unconfirmed_solution.rs +++ b/node/router/messages/src/unconfirmed_solution.rs @@ -58,7 +58,7 @@ pub mod prop_tests { }; use bytes::{Buf, BufMut, BytesMut}; - use proptest::prelude::{any, BoxedStrategy, Strategy}; + use proptest::prelude::{BoxedStrategy, Strategy, any}; use test_strategy::proptest; type CurrentNetwork = snarkvm::prelude::MainnetV0; diff --git a/node/router/messages/src/unconfirmed_transaction.rs b/node/router/messages/src/unconfirmed_transaction.rs index 23b5d91cfa..bbe595d6b4 100644 --- a/node/router/messages/src/unconfirmed_transaction.rs +++ b/node/router/messages/src/unconfirmed_transaction.rs @@ -69,7 +69,7 @@ pub mod prop_tests { }; use bytes::{Buf, BufMut, BytesMut}; - use proptest::prelude::{any, BoxedStrategy, Strategy}; + use proptest::prelude::{BoxedStrategy, Strategy, any}; use test_strategy::proptest; type CurrentNetwork = snarkvm::prelude::MainnetV0; diff --git a/node/router/src/handshake.rs b/node/router/src/handshake.rs index 3b8d083c23..ab888d2193 100644 --- a/node/router/src/handshake.rs +++ b/node/router/src/handshake.rs @@ -14,20 +14,20 @@ // limitations under the License. use crate::{ - messages::{ChallengeRequest, ChallengeResponse, DisconnectReason, Message, MessageCodec, MessageTrait}, NodeType, Peer, Router, + messages::{ChallengeRequest, ChallengeResponse, DisconnectReason, Message, MessageCodec, MessageTrait}, }; -use snarkos_node_tcp::{ConnectionSide, Tcp, P2P}; +use snarkos_node_tcp::{ConnectionSide, P2P, Tcp}; use snarkvm::{ ledger::narwhal::Data, - prelude::{block::Header, error, Address, Field, Network}, + prelude::{Address, Field, Network, block::Header, error}, }; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use futures::SinkExt; -use rand::{rngs::OsRng, Rng}; +use rand::{Rng, rngs::OsRng}; use std::{io, net::SocketAddr}; use tokio::net::TcpStream; use tokio_stream::StreamExt; diff --git a/node/router/src/heartbeat.rs b/node/router/src/heartbeat.rs index baef5afdfc..8b4139d7f2 100644 --- a/node/router/src/heartbeat.rs +++ b/node/router/src/heartbeat.rs @@ -14,9 +14,9 @@ // limitations under the License. use crate::{ - messages::{DisconnectReason, Message, PeerRequest}, Outbound, Router, + messages::{DisconnectReason, Message, PeerRequest}, }; use snarkvm::prelude::Network; diff --git a/node/router/src/helpers/cache.rs b/node/router/src/helpers/cache.rs index c87c2a1038..fe03f7a0b4 100644 --- a/node/router/src/helpers/cache.rs +++ b/node/router/src/helpers/cache.rs @@ -14,7 +14,7 @@ // limitations under the License. use crate::messages::BlockRequest; -use snarkvm::prelude::{puzzle::SolutionID, Network}; +use snarkvm::prelude::{Network, puzzle::SolutionID}; use core::hash::Hash; use linked_hash_map::LinkedHashMap; diff --git a/node/router/src/inbound.rs b/node/router/src/inbound.rs index d1e1d604b7..770a6c6790 100644 --- a/node/router/src/inbound.rs +++ b/node/router/src/inbound.rs @@ -14,6 +14,8 @@ // limitations under the License. use crate::{ + Outbound, + Peer, messages::{ BlockRequest, BlockResponse, @@ -25,17 +27,15 @@ use crate::{ UnconfirmedSolution, UnconfirmedTransaction, }, - Outbound, - Peer, }; use snarkos_node_tcp::protocols::Reading; use snarkvm::prelude::{ + Network, block::{Block, Header, Transaction}, puzzle::Solution, - Network, }; -use anyhow::{anyhow, bail, Result}; +use anyhow::{Result, anyhow, bail}; use snarkos_node_tcp::is_bogon_ip; use std::net::SocketAddr; use tokio::task::spawn_blocking; diff --git a/node/router/src/lib.rs b/node/router/src/lib.rs index 8d9152c744..20d780b9de 100644 --- a/node/router/src/lib.rs +++ b/node/router/src/lib.rs @@ -41,10 +41,10 @@ pub use routing::*; use crate::messages::NodeType; use snarkos_account::Account; -use snarkos_node_tcp::{is_bogon_ip, is_unspecified_or_broadcast_ip, Config, Tcp}; +use snarkos_node_tcp::{Config, Tcp, is_bogon_ip, is_unspecified_or_broadcast_ip}; use snarkvm::prelude::{Address, Network, PrivateKey, ViewKey}; -use anyhow::{bail, Result}; +use anyhow::{Result, bail}; use parking_lot::{Mutex, RwLock}; use std::{ collections::{HashMap, HashSet}, diff --git a/node/router/src/outbound.rs b/node/router/src/outbound.rs index c145525f5c..83218eebe5 100644 --- a/node/router/src/outbound.rs +++ b/node/router/src/outbound.rs @@ -14,8 +14,8 @@ // limitations under the License. use crate::{ - messages::{Message, Ping}, Router, + messages::{Message, Ping}, }; use snarkos_node_sync_locators::BlockLocators; use snarkos_node_tcp::protocols::Writing; diff --git a/node/router/src/routing.rs b/node/router/src/routing.rs index 7792fe54df..d3c865e8b2 100644 --- a/node/router/src/routing.rs +++ b/node/router/src/routing.rs @@ -15,8 +15,8 @@ use crate::{Heartbeat, Inbound, Outbound}; use snarkos_node_tcp::{ - protocols::{Disconnect, Handshake, OnConnect}, P2P, + protocols::{Disconnect, Handshake, OnConnect}, }; use snarkvm::prelude::Network; diff --git a/node/router/tests/cleanups.rs b/node/router/tests/cleanups.rs index c0412f9f01..2d8e90a8b4 100644 --- a/node/router/tests/cleanups.rs +++ b/node/router/tests/cleanups.rs @@ -20,8 +20,8 @@ use deadline::deadline; use peak_alloc::PeakAlloc; use snarkos_node_router::Routing; use snarkos_node_tcp::{ - protocols::{Disconnect, Handshake}, P2P, + protocols::{Disconnect, Handshake}, }; use snarkvm::{prelude::Rng, utilities::TestRng}; diff --git a/node/router/tests/common/mod.rs b/node/router/tests/common/mod.rs index 53331193e9..5fc0866ced 100644 --- a/node/router/tests/common/mod.rs +++ b/node/router/tests/common/mod.rs @@ -24,8 +24,8 @@ use std::{ }; use snarkos_account::Account; -use snarkos_node_router::{messages::NodeType, Router}; -use snarkvm::prelude::{block::Block, FromBytes, MainnetV0 as CurrentNetwork, Network}; +use snarkos_node_router::{Router, messages::NodeType}; +use snarkvm::prelude::{FromBytes, MainnetV0 as CurrentNetwork, Network, block::Block}; /// A helper macro to print the TCP listening address, along with the connected and connecting peers. #[macro_export] diff --git a/node/router/tests/common/router.rs b/node/router/tests/common/router.rs index 095d2db599..d1b4f7669e 100644 --- a/node/router/tests/common/router.rs +++ b/node/router/tests/common/router.rs @@ -15,6 +15,11 @@ use crate::common::sample_genesis_block; use snarkos_node_router::{ + Heartbeat, + Inbound, + Outbound, + Router, + Routing, messages::{ BlockRequest, DisconnectReason, @@ -25,24 +30,19 @@ use snarkos_node_router::{ UnconfirmedSolution, UnconfirmedTransaction, }, - Heartbeat, - Inbound, - Outbound, - Router, - Routing, }; use snarkos_node_tcp::{ - protocols::{Disconnect, Handshake, OnConnect, Reading, Writing}, Connection, ConnectionSide, - Tcp, P2P, + Tcp, + protocols::{Disconnect, Handshake, OnConnect, Reading, Writing}, }; use snarkvm::prelude::{ - block::{Block, Header, Transaction}, - puzzle::Solution, Field, Network, + block::{Block, Header, Transaction}, + puzzle::Solution, }; use async_trait::async_trait; diff --git a/node/router/tests/connect.rs b/node/router/tests/connect.rs index 8bc0f2c66a..584dcb3d4d 100644 --- a/node/router/tests/connect.rs +++ b/node/router/tests/connect.rs @@ -16,7 +16,7 @@ mod common; use common::*; -use snarkos_node_tcp::{protocols::Handshake, P2P}; +use snarkos_node_tcp::{P2P, protocols::Handshake}; use core::time::Duration; use deadline::deadline; diff --git a/node/router/tests/disconnect.rs b/node/router/tests/disconnect.rs index 4250ea5048..66a4b671d6 100644 --- a/node/router/tests/disconnect.rs +++ b/node/router/tests/disconnect.rs @@ -16,7 +16,7 @@ mod common; use common::*; -use snarkos_node_tcp::{protocols::Handshake, P2P}; +use snarkos_node_tcp::{P2P, protocols::Handshake}; use core::time::Duration; diff --git a/node/src/client/mod.rs b/node/src/client/mod.rs index 0858547df6..92ceafe9d3 100644 --- a/node/src/client/mod.rs +++ b/node/src/client/mod.rs @@ -20,25 +20,25 @@ use snarkos_account::Account; use snarkos_node_bft::ledger_service::CoreLedgerService; use snarkos_node_rest::Rest; use snarkos_node_router::{ - messages::{Message, NodeType, UnconfirmedSolution}, Heartbeat, Inbound, Outbound, Router, Routing, + messages::{Message, NodeType, UnconfirmedSolution}, }; use snarkos_node_sync::{BlockSync, BlockSyncMode}; use snarkos_node_tcp::{ - protocols::{Disconnect, Handshake, OnConnect, Reading, Writing}, P2P, + protocols::{Disconnect, Handshake, OnConnect, Reading, Writing}, }; use snarkvm::{ console::network::Network, ledger::{ + Ledger, block::{Block, Header}, puzzle::{Puzzle, Solution}, store::ConsensusStorage, - Ledger, }, }; @@ -48,7 +48,7 @@ use core::future::Future; use parking_lot::Mutex; use std::{ net::SocketAddr, - sync::{atomic::AtomicBool, Arc}, + sync::{Arc, atomic::AtomicBool}, }; use tokio::task::JoinHandle; diff --git a/node/src/client/router.rs b/node/src/client/router.rs index f92d333dad..ec5602b9c0 100644 --- a/node/src/client/router.rs +++ b/node/src/client/router.rs @@ -15,6 +15,7 @@ use super::*; use snarkos_node_router::{ + Routing, messages::{ BlockRequest, BlockResponse, @@ -26,13 +27,12 @@ use snarkos_node_router::{ PuzzleResponse, UnconfirmedTransaction, }, - Routing, }; use snarkos_node_sync::communication_service::CommunicationService; use snarkos_node_tcp::{Connection, ConnectionSide, Tcp}; use snarkvm::{ ledger::narwhal::Data, - prelude::{block::Transaction, Network}, + prelude::{Network, block::Transaction}, }; use std::{io, net::SocketAddr, time::Duration}; diff --git a/node/src/node.rs b/node/src/node.rs index 7a11a826ad..9e457f9aa0 100644 --- a/node/src/node.rs +++ b/node/src/node.rs @@ -13,23 +13,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::{traits::NodeInterface, Client, Prover, Validator}; +use crate::{Client, Prover, Validator, traits::NodeInterface}; use snarkos_account::Account; use snarkos_node_router::messages::NodeType; use snarkvm::prelude::{ - block::Block, - store::helpers::{memory::ConsensusMemory, rocksdb::ConsensusDB}, Address, Network, PrivateKey, ViewKey, + block::Block, + store::helpers::{memory::ConsensusMemory, rocksdb::ConsensusDB}, }; use aleo_std::StorageMode; use anyhow::Result; use std::{ net::SocketAddr, - sync::{atomic::AtomicBool, Arc}, + sync::{Arc, atomic::AtomicBool}, }; pub enum Node { diff --git a/node/src/prover/mod.rs b/node/src/prover/mod.rs index efb261146a..fd39d62c39 100644 --- a/node/src/prover/mod.rs +++ b/node/src/prover/mod.rs @@ -19,25 +19,25 @@ use crate::traits::NodeInterface; use snarkos_account::Account; use snarkos_node_bft::ledger_service::ProverLedgerService; use snarkos_node_router::{ - messages::{Message, NodeType, UnconfirmedSolution}, Heartbeat, Inbound, Outbound, Router, Routing, + messages::{Message, NodeType, UnconfirmedSolution}, }; use snarkos_node_sync::{BlockSync, BlockSyncMode}; use snarkos_node_tcp::{ - protocols::{Disconnect, Handshake, OnConnect, Reading, Writing}, P2P, + protocols::{Disconnect, Handshake, OnConnect, Reading, Writing}, }; use snarkvm::{ ledger::narwhal::Data, prelude::{ + Network, block::{Block, Header}, puzzle::{Puzzle, Solution}, store::ConsensusStorage, - Network, }, synthesizer::VM, }; @@ -47,13 +47,13 @@ use anyhow::Result; use colored::Colorize; use core::{marker::PhantomData, time::Duration}; use parking_lot::{Mutex, RwLock}; -use rand::{rngs::OsRng, CryptoRng, Rng}; +use rand::{CryptoRng, Rng, rngs::OsRng}; use snarkos_node_bft::helpers::fmt_id; use std::{ net::SocketAddr, sync::{ - atomic::{AtomicBool, AtomicU8, Ordering}, Arc, + atomic::{AtomicBool, AtomicU8, Ordering}, }, }; use tokio::task::JoinHandle; diff --git a/node/src/prover/router.rs b/node/src/prover/router.rs index bc146d860b..d7c8344505 100644 --- a/node/src/prover/router.rs +++ b/node/src/prover/router.rs @@ -26,7 +26,7 @@ use snarkos_node_router::messages::{ UnconfirmedTransaction, }; use snarkos_node_tcp::{Connection, ConnectionSide, Tcp}; -use snarkvm::prelude::{block::Transaction, Field, Network, Zero}; +use snarkvm::prelude::{Field, Network, Zero, block::Transaction}; use std::{io, net::SocketAddr}; diff --git a/node/src/traits.rs b/node/src/traits.rs index a8569ada24..d22c938d07 100644 --- a/node/src/traits.rs +++ b/node/src/traits.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use snarkos_node_router::{messages::NodeType, Routing}; +use snarkos_node_router::{Routing, messages::NodeType}; use snarkvm::prelude::{Address, Network, PrivateKey, ViewKey}; use once_cell::sync::OnceCell; @@ -21,8 +21,8 @@ use std::{ future::Future, io, sync::{ - atomic::{AtomicBool, Ordering}, Arc, + atomic::{AtomicBool, Ordering}, }, time::Duration, }; @@ -63,7 +63,7 @@ pub trait NodeInterface: Routing { #[cfg(target_family = "unix")] fn signal_listener() -> impl Future> { - use tokio::signal::unix::{signal, SignalKind}; + use tokio::signal::unix::{SignalKind, signal}; // Handle SIGINT, SIGTERM, SIGQUIT, and SIGHUP. let mut s_int = signal(SignalKind::interrupt()).unwrap(); diff --git a/node/src/validator/mod.rs b/node/src/validator/mod.rs index fd9a8721fe..c97dbb6587 100644 --- a/node/src/validator/mod.rs +++ b/node/src/validator/mod.rs @@ -21,24 +21,24 @@ use snarkos_node_bft::{helpers::init_primary_channels, ledger_service::CoreLedge use snarkos_node_consensus::Consensus; use snarkos_node_rest::Rest; use snarkos_node_router::{ - messages::{NodeType, PuzzleResponse, UnconfirmedSolution, UnconfirmedTransaction}, Heartbeat, Inbound, Outbound, Router, Routing, + messages::{NodeType, PuzzleResponse, UnconfirmedSolution, UnconfirmedTransaction}, }; use snarkos_node_sync::{BlockSync, BlockSyncMode}; use snarkos_node_tcp::{ - protocols::{Disconnect, Handshake, OnConnect, Reading, Writing}, P2P, + protocols::{Disconnect, Handshake, OnConnect, Reading, Writing}, }; use snarkvm::prelude::{ + Ledger, + Network, block::{Block, Header}, puzzle::Solution, store::ConsensusStorage, - Ledger, - Network, }; use aleo_std::StorageMode; @@ -47,7 +47,7 @@ use core::future::Future; use parking_lot::Mutex; use std::{ net::SocketAddr, - sync::{atomic::AtomicBool, Arc}, + sync::{Arc, atomic::AtomicBool}, time::Duration, }; use tokio::task::JoinHandle; @@ -443,9 +443,9 @@ impl> NodeInterface for Validator { mod tests { use super::*; use snarkvm::prelude::{ - store::{helpers::memory::ConsensusMemory, ConsensusStore}, MainnetV0, VM, + store::{ConsensusStore, helpers::memory::ConsensusMemory}, }; use anyhow::bail; diff --git a/node/src/validator/router.rs b/node/src/validator/router.rs index d9b5c0abb8..f22e1000c8 100644 --- a/node/src/validator/router.rs +++ b/node/src/validator/router.rs @@ -28,7 +28,7 @@ use snarkos_node_router::messages::{ use snarkos_node_tcp::{Connection, ConnectionSide, Tcp}; use snarkvm::{ ledger::narwhal::Data, - prelude::{block::Transaction, error, Network}, + prelude::{Network, block::Transaction, error}, }; use std::{io, net::SocketAddr, time::Duration}; diff --git a/node/sync/locators/src/block_locators.rs b/node/sync/locators/src/block_locators.rs index 82b8df0b2e..ba8981cd66 100644 --- a/node/sync/locators/src/block_locators.rs +++ b/node/sync/locators/src/block_locators.rs @@ -13,12 +13,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -use snarkvm::prelude::{error, has_duplicates, FromBytes, IoResult, Network, Read, ToBytes, Write}; +use snarkvm::prelude::{FromBytes, IoResult, Network, Read, ToBytes, Write, error, has_duplicates}; -use anyhow::{bail, ensure, Result}; -use indexmap::{indexmap, IndexMap}; +use anyhow::{Result, bail, ensure}; +use indexmap::{IndexMap, indexmap}; use serde::{Deserialize, Serialize}; -use std::collections::{btree_map::IntoIter, BTreeMap}; +use std::collections::{BTreeMap, btree_map::IntoIter}; /// The number of recent blocks (near tip). pub const NUM_RECENT_BLOCKS: usize = 100; // 100 blocks diff --git a/node/sync/src/block_sync.rs b/node/sync/src/block_sync.rs index d512e7478c..50908d2dfc 100644 --- a/node/sync/src/block_sync.rs +++ b/node/sync/src/block_sync.rs @@ -21,19 +21,19 @@ use snarkos_node_bft_ledger_service::LedgerService; use snarkos_node_router::messages::DataBlocks; use snarkos_node_sync_communication_service::CommunicationService; use snarkos_node_sync_locators::{CHECKPOINT_INTERVAL, NUM_RECENT_BLOCKS}; -use snarkvm::prelude::{block::Block, Network}; +use snarkvm::prelude::{Network, block::Block}; -use anyhow::{bail, ensure, Result}; +use anyhow::{Result, bail, ensure}; use indexmap::{IndexMap, IndexSet}; use itertools::Itertools; use parking_lot::{Mutex, RwLock}; -use rand::{prelude::IteratorRandom, CryptoRng, Rng}; +use rand::{CryptoRng, Rng, prelude::IteratorRandom}; use std::{ collections::BTreeMap, net::{IpAddr, Ipv4Addr, SocketAddr}, sync::{ - atomic::{AtomicBool, AtomicU32, Ordering}, Arc, + atomic::{AtomicBool, AtomicU32, Ordering}, }, time::Instant, }; @@ -944,14 +944,14 @@ where mod tests { use super::*; use crate::locators::{ - test_helpers::{sample_block_locators, sample_block_locators_with_fork}, CHECKPOINT_INTERVAL, NUM_RECENT_BLOCKS, + test_helpers::{sample_block_locators, sample_block_locators_with_fork}, }; use snarkos_node_bft_ledger_service::MockLedgerService; use snarkvm::prelude::{Field, TestRng}; - use indexmap::{indexset, IndexSet}; + use indexmap::{IndexSet, indexset}; use snarkvm::ledger::committee::Committee; use std::net::{IpAddr, Ipv4Addr}; diff --git a/node/tcp/src/helpers/mod.rs b/node/tcp/src/helpers/mod.rs index 55cf62818b..8077ae2ca4 100644 --- a/node/tcp/src/helpers/mod.rs +++ b/node/tcp/src/helpers/mod.rs @@ -25,7 +25,7 @@ pub use known_peers::KnownPeers; mod stats; pub use stats::Stats; -use tracing::{debug_span, error_span, info_span, trace_span, warn_span, Span}; +use tracing::{Span, debug_span, error_span, info_span, trace_span, warn_span}; /// Creates the Tcp's tracing span based on its name. pub fn create_span(tcp_name: &str) -> Span { diff --git a/node/tcp/src/protocols/disconnect.rs b/node/tcp/src/protocols/disconnect.rs index f2c0c8931a..325cef6a20 100644 --- a/node/tcp/src/protocols/disconnect.rs +++ b/node/tcp/src/protocols/disconnect.rs @@ -18,9 +18,9 @@ use std::net::SocketAddr; use tokio::sync::{mpsc, oneshot}; use tracing::*; -use crate::{protocols::ProtocolHandler, P2P}; #[cfg(doc)] -use crate::{protocols::Writing, Connection}; +use crate::{Connection, protocols::Writing}; +use crate::{P2P, protocols::ProtocolHandler}; /// Can be used to automatically perform some extra actions when the node disconnects from its /// peer, which is especially practical if the disconnect is triggered automatically, e.g. due diff --git a/node/tcp/src/protocols/handshake.rs b/node/tcp/src/protocols/handshake.rs index d280ba5c33..45ee06a1d3 100644 --- a/node/tcp/src/protocols/handshake.rs +++ b/node/tcp/src/protocols/handshake.rs @@ -16,7 +16,7 @@ use std::{io, time::Duration}; use tokio::{ - io::{split, AsyncRead, AsyncWrite}, + io::{AsyncRead, AsyncWrite, split}, net::TcpStream, sync::{mpsc, oneshot}, time::timeout, @@ -24,9 +24,9 @@ use tokio::{ use tracing::*; use crate::{ - protocols::{ProtocolHandler, ReturnableConnection}, Connection, P2P, + protocols::{ProtocolHandler, ReturnableConnection}, }; /// Can be used to specify and enable network handshakes. Upon establishing a connection, both sides will diff --git a/node/tcp/src/protocols/on_connect.rs b/node/tcp/src/protocols/on_connect.rs index 87d3837e13..09aff9efae 100644 --- a/node/tcp/src/protocols/on_connect.rs +++ b/node/tcp/src/protocols/on_connect.rs @@ -18,12 +18,12 @@ use std::net::SocketAddr; use tokio::sync::{mpsc, oneshot}; use tracing::*; -use crate::{protocols::ProtocolHandler, P2P}; #[cfg(doc)] use crate::{ - protocols::{Reading, Writing}, Connection, + protocols::{Reading, Writing}, }; +use crate::{P2P, protocols::ProtocolHandler}; /// Can be used to automatically perform some initial actions once the connection with a peer is /// fully established. diff --git a/node/tcp/src/protocols/reading.rs b/node/tcp/src/protocols/reading.rs index a11f88fd89..1081b30cc4 100644 --- a/node/tcp/src/protocols/reading.rs +++ b/node/tcp/src/protocols/reading.rs @@ -14,12 +14,12 @@ // limitations under the License. #[cfg(doc)] -use crate::{protocols::Handshake, Config}; +use crate::{Config, protocols::Handshake}; use crate::{ - protocols::{ProtocolHandler, ReturnableConnection}, ConnectionSide, - Tcp, P2P, + Tcp, + protocols::{ProtocolHandler, ReturnableConnection}, }; use async_trait::async_trait; diff --git a/node/tcp/src/protocols/writing.rs b/node/tcp/src/protocols/writing.rs index d5cdad8682..9c77c6738e 100644 --- a/node/tcp/src/protocols/writing.rs +++ b/node/tcp/src/protocols/writing.rs @@ -26,12 +26,12 @@ use tokio_util::codec::{Encoder, FramedWrite}; use tracing::*; #[cfg(doc)] -use crate::{protocols::Handshake, Config, Tcp}; +use crate::{Config, Tcp, protocols::Handshake}; use crate::{ - protocols::{Protocol, ProtocolHandler, ReturnableConnection}, Connection, ConnectionSide, P2P, + protocols::{Protocol, ProtocolHandler, ReturnableConnection}, }; type WritingSenders = Arc>>>; diff --git a/node/tcp/src/tcp.rs b/node/tcp/src/tcp.rs index 364dd770ff..f58d6db38f 100644 --- a/node/tcp/src/tcp.rs +++ b/node/tcp/src/tcp.rs @@ -20,8 +20,8 @@ use std::{ net::{IpAddr, SocketAddr}, ops::Deref, sync::{ - atomic::{AtomicUsize, Ordering::*}, Arc, + atomic::{AtomicUsize, Ordering::*}, }, time::Duration, }; @@ -38,11 +38,11 @@ use tokio::{ use tracing::*; use crate::{ - connections::{Connection, ConnectionSide, Connections}, - protocols::{Protocol, Protocols}, Config, KnownPeers, Stats, + connections::{Connection, ConnectionSide, Connections}, + protocols::{Protocol, Protocols}, }; // A sequential numeric identifier assigned to `Tcp`s that were not provided with a name. diff --git a/node/tests/common/mod.rs b/node/tests/common/mod.rs index 6119e91528..669fcc99c1 100644 --- a/node/tests/common/mod.rs +++ b/node/tests/common/mod.rs @@ -19,7 +19,7 @@ pub mod test_peer; use std::{env, str::FromStr}; use snarkos_account::Account; -use snarkvm::prelude::{block::Block, FromBytes, MainnetV0 as CurrentNetwork, Network}; +use snarkvm::prelude::{FromBytes, MainnetV0 as CurrentNetwork, Network, block::Block}; /// Returns a fixed account. pub fn sample_account() -> Account { diff --git a/node/tests/common/node.rs b/node/tests/common/node.rs index e38bdf753f..24289a3b12 100644 --- a/node/tests/common/node.rs +++ b/node/tests/common/node.rs @@ -16,7 +16,7 @@ use crate::common::test_peer::sample_genesis_block; use snarkos_account::Account; use snarkos_node::{Client, Prover, Validator}; -use snarkvm::prelude::{store::helpers::memory::ConsensusMemory, MainnetV0 as CurrentNetwork}; +use snarkvm::prelude::{MainnetV0 as CurrentNetwork, store::helpers::memory::ConsensusMemory}; use aleo_std::StorageMode; use std::str::FromStr; diff --git a/node/tests/common/test_peer.rs b/node/tests/common/test_peer.rs index ebb31e8e0d..50b8d969b4 100644 --- a/node/tests/common/test_peer.rs +++ b/node/tests/common/test_peer.rs @@ -20,7 +20,7 @@ use snarkos_node_router::{ }; use snarkvm::{ ledger::narwhal::Data, - prelude::{block::Block, error, Address, Field, FromBytes, MainnetV0 as CurrentNetwork, Network, TestRng}, + prelude::{Address, Field, FromBytes, MainnetV0 as CurrentNetwork, Network, TestRng, block::Block, error}, }; use std::{ @@ -29,14 +29,14 @@ use std::{ str::FromStr, }; -use futures_util::{sink::SinkExt, TryStreamExt}; +use futures_util::{TryStreamExt, sink::SinkExt}; use pea2pea::{ - protocols::{Handshake, OnDisconnect, Reading, Writing}, Config, Connection, ConnectionSide, Node, Pea2Pea, + protocols::{Handshake, OnDisconnect, Reading, Writing}, }; use rand::Rng; use tokio_util::codec::Framed; diff --git a/node/tests/handshake.rs b/node/tests/handshake.rs index c1ece5ad87..07bd8f8d90 100644 --- a/node/tests/handshake.rs +++ b/node/tests/handshake.rs @@ -22,7 +22,7 @@ use common::{node::*, test_peer::TestPeer}; use snarkos_node::{Client, Prover, Validator}; use snarkos_node_router::Outbound; use snarkos_node_tcp::P2P; -use snarkvm::prelude::{store::helpers::memory::ConsensusMemory, MainnetV0 as CurrentNetwork}; +use snarkvm::prelude::{MainnetV0 as CurrentNetwork, store::helpers::memory::ConsensusMemory}; use pea2pea::Pea2Pea; diff --git a/node/tests/peering.rs b/node/tests/peering.rs index 163846b803..f6e6fac3d0 100644 --- a/node/tests/peering.rs +++ b/node/tests/peering.rs @@ -18,14 +18,14 @@ mod common; use common::test_peer::TestPeer; use snarkos_node_router::{ - messages::{Message, PeerResponse}, Outbound, + messages::{Message, PeerResponse}, }; use snarkos_node_tcp::P2P; use deadline::deadline; use paste::paste; -use pea2pea::{protocols::Writing, Pea2Pea}; +use pea2pea::{Pea2Pea, protocols::Writing}; use std::time::Duration; macro_rules! test_reject_unsolicited_peer_response {