diff --git a/node/src/chain.rs b/node/src/chain.rs index e443916936..1a99ef6ddf 100644 --- a/node/src/chain.rs +++ b/node/src/chain.rs @@ -10,37 +10,24 @@ mod fallback; mod fsm; mod genesis; -use crate::database::{Candidate, Ledger, Mempool}; +use crate::database::Ledger; use crate::{database, vm, Network}; use crate::{LongLivedService, Message}; -use anyhow::{anyhow, bail, Result}; +use anyhow::Result; -use dusk_consensus::user::committee::CommitteeSet; -use std::rc::Rc; use std::sync::Arc; -use tracing::{debug, error, info, warn}; +use tracing::{error, info, warn}; use async_trait::async_trait; -use dusk_consensus::commons::{ConsensusError, Database, RoundUpdate}; -use dusk_consensus::consensus::Consensus; -use dusk_consensus::contract_state::{ - CallParams, Error, Operations, Output, StateRoot, -}; -use dusk_consensus::user::provisioners::Provisioners; -use node_data::ledger::{self, to_str, Block, Hash, Header}; +use node_data::ledger::{to_str, Block}; use node_data::message::AsyncQueue; use node_data::message::{Payload, Topics}; -use node_data::Serializable; -use tokio::sync::{oneshot, Mutex, RwLock}; -use tokio::task::JoinHandle; +use tokio::sync::RwLock; use tokio::time::{sleep_until, Instant}; -use node_data::message::payload::GetBlocks; -use std::any; use std::time::Duration; use self::acceptor::{Acceptor, RevertTarget}; -use self::consensus::Task; use self::fsm::SimpleFSM; pub use acceptor::verify_block_cert; diff --git a/node/src/chain/acceptor.rs b/node/src/chain/acceptor.rs index a5b24dcce2..89a232591d 100644 --- a/node/src/chain/acceptor.rs +++ b/node/src/chain/acceptor.rs @@ -4,43 +4,26 @@ // // Copyright (c) DUSK NETWORK. All rights reserved. -use crate::database::{Candidate, Ledger, Mempool}; -use crate::{database, vm, Network}; -use crate::{LongLivedService, Message}; -use anyhow::{anyhow, bail, Result}; -use async_trait::async_trait; -use dusk_bls12_381_sign::PublicKey; -use dusk_consensus::commons::{ - ConsensusError, Database, IterCounter, RoundUpdate, StepName, -}; -use dusk_consensus::consensus::{self, Consensus}; -use dusk_consensus::contract_state::{ - CallParams, Error, Operations, Output, StateRoot, -}; +use crate::database::{self, Ledger, Mempool}; +use crate::{vm, Message, Network}; +use anyhow::{anyhow, Result}; +use dusk_consensus::commons::{ConsensusError, IterCounter, StepName}; use dusk_consensus::user::committee::{Committee, CommitteeSet}; use dusk_consensus::user::provisioners::Provisioners; use dusk_consensus::user::sortition; -use hex::ToHex; use node_data::ledger::{ - self, to_str, Block, Hash, Header, Seed, Signature, SpentTransaction, + self, to_str, Block, Seed, Signature, SpentTransaction, }; use node_data::message::AsyncQueue; -use node_data::message::{Payload, Topics}; -use node_data::Serializable; -use std::cell::RefCell; -use std::rc::Rc; +use node_data::message::Payload; use std::sync::Arc; -use tokio::sync::{oneshot, Mutex, RwLock}; -use tokio::task::JoinHandle; +use tokio::sync::{Mutex, RwLock}; use tracing::{error, info, warn}; use dusk_consensus::agreement::verifiers; use dusk_consensus::config::{self, SELECTION_COMMITTEE_SIZE}; -use std::any; -use std::collections::HashMap; use super::consensus::Task; -use super::genesis; pub(crate) enum RevertTarget { LastFinalizedState = 0, diff --git a/node/src/chain/consensus.rs b/node/src/chain/consensus.rs index 3af7504fac..1b2b041738 100644 --- a/node/src/chain/consensus.rs +++ b/node/src/chain/consensus.rs @@ -4,28 +4,24 @@ // // Copyright (c) DUSK NETWORK. All rights reserved. -use crate::database::{Candidate, Ledger, Mempool}; -use crate::{database, vm, Network}; -use crate::{LongLivedService, Message}; -use anyhow::bail; +use crate::database::{self, Candidate, Mempool}; +use crate::{vm, Message, Network}; use async_trait::async_trait; -use dusk_consensus::commons::{ConsensusError, Database, RoundUpdate}; +use dusk_consensus::commons::{ConsensusError, RoundUpdate}; use dusk_consensus::consensus::Consensus; use dusk_consensus::contract_state::{ - CallParams, Error, Operations, Output, StateRoot, VerificationOutput, + CallParams, Error, Operations, Output, VerificationOutput, }; use dusk_consensus::user::provisioners::Provisioners; use node_data::ledger::{Block, Hash, Transaction}; -use node_data::message::payload::{self, GetCandidate}; +use node_data::message::payload::GetCandidate; use node_data::message::AsyncQueue; use node_data::message::{Payload, Topics}; -use node_data::Serializable; use tokio::sync::{oneshot, Mutex, RwLock}; use tokio::task::JoinHandle; -use tracing::{error, info, trace}; +use tracing::{error, info, trace, warn}; use std::sync::Arc; -use std::{any, vec}; /// Consensus Service Task is responsible for running the consensus layer. /// diff --git a/node/src/chain/fallback.rs b/node/src/chain/fallback.rs index 77823edcaa..17c5c33cff 100644 --- a/node/src/chain/fallback.rs +++ b/node/src/chain/fallback.rs @@ -4,19 +4,13 @@ // // Copyright (c) DUSK NETWORK. All rights reserved. -use std::sync::Arc; - -use anyhow::{anyhow, bail, Result}; -use node_data::{ - bls::PublicKey, - ledger::{self, Block, Hash, Header}, -}; -use tokio::sync::RwLock; -use tracing::{info, warn}; +use anyhow::{anyhow, Result}; +use node_data::ledger::Block; +use tracing::info; use crate::{ chain::acceptor, - database::{self, Ledger, Mempool}, + database::{self, Ledger}, vm, Network, }; diff --git a/node/src/chain/fsm.rs b/node/src/chain/fsm.rs index e41e78c2e9..29e8bbae89 100644 --- a/node/src/chain/fsm.rs +++ b/node/src/chain/fsm.rs @@ -4,22 +4,20 @@ // // Copyright (c) DUSK NETWORK. All rights reserved. -use super::{acceptor::Acceptor, consensus, genesis}; +use super::acceptor::Acceptor; use crate::chain::fallback; -use crate::database::{self, Ledger}; +use crate::database; use crate::{vm, Network}; -use dusk_consensus::user::provisioners::{self, Provisioners}; -use node_data::ledger::{self, to_str, Block, Hash, Transaction}; +use node_data::ledger::{to_str, Block}; use node_data::message::payload::GetBlocks; use node_data::message::Message; -use std::cell::RefCell; use std::collections::{HashMap, HashSet}; use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4}; use std::ops::Deref; use std::time::Duration; use std::{sync::Arc, time::SystemTime}; use tokio::sync::RwLock; -use tracing::{debug, error, info}; +use tracing::{error, info, warn}; const MAX_BLOCKS_TO_REQUEST: i16 = 50; const EXPIRY_TIMEOUT_MILLIS: i16 = 5000; diff --git a/node/src/chain/genesis.rs b/node/src/chain/genesis.rs index 91d26e2860..62654cc4f7 100644 --- a/node/src/chain/genesis.rs +++ b/node/src/chain/genesis.rs @@ -4,7 +4,6 @@ // // Copyright (c) DUSK NETWORK. All rights reserved. -use dusk_consensus::user::provisioners::Provisioners; use node_data::ledger::{Block, Header}; /// Generates the genesis state for the chain per specified network type diff --git a/node/src/database/rocksdb.rs b/node/src/database/rocksdb.rs index 4faa2b2c17..95f68d5c58 100644 --- a/node/src/database/rocksdb.rs +++ b/node/src/database/rocksdb.rs @@ -5,33 +5,26 @@ // Copyright (c) DUSK NETWORK. All rights reserved. use super::{Candidate, Ledger, Persist, Register, DB}; -use anyhow::{Context, Result}; +use anyhow::Result; -use node_data::encoding::*; use node_data::ledger::{self, SpentTransaction}; use node_data::Serializable; use crate::database::Mempool; -use dusk_bytes::Serializable as DuskBytesSerializable; - use rocksdb_lib::{ - ColumnFamily, ColumnFamilyDescriptor, DBAccess, DBCommon, - DBRawIteratorWithThreadMode, DBWithThreadMode, IteratorMode, MultiThreaded, - OptimisticTransactionDB, OptimisticTransactionOptions, Options, - ReadOptions, SnapshotWithThreadMode, Transaction, TransactionDB, + ColumnFamily, ColumnFamilyDescriptor, DBAccess, + DBRawIteratorWithThreadMode, IteratorMode, OptimisticTransactionDB, + OptimisticTransactionOptions, Options, SnapshotWithThreadMode, Transaction, WriteOptions, }; use std::io; use std::io::Read; use std::io::Write; -use std::marker::PhantomData; use std::path::Path; -use std::path::PathBuf; use std::sync::Arc; use std::vec; -use tokio::io::AsyncWriteExt; use tracing::info; diff --git a/node/src/databroker.rs b/node/src/databroker.rs index feb2c39085..4f0b868416 100644 --- a/node/src/databroker.rs +++ b/node/src/databroker.rs @@ -9,30 +9,18 @@ pub mod conf; use crate::database::{Candidate, Ledger, Mempool}; use crate::{database, vm, Network}; use crate::{LongLivedService, Message}; -use anyhow::{anyhow, bail, Result}; +use anyhow::{anyhow, Result}; -use dusk_consensus::user::committee::CommitteeSet; use node_data::message::payload::InvType; use smallvec::SmallVec; use std::net::SocketAddr; use std::sync::Arc; use async_trait::async_trait; -use dusk_consensus::commons::{ConsensusError, Database, RoundUpdate}; -use dusk_consensus::consensus::Consensus; -use dusk_consensus::contract_state::{ - CallParams, Error, Operations, Output, StateRoot, -}; -use dusk_consensus::user::provisioners::Provisioners; -use node_data::ledger::{self, Block, Hash, Header}; -use node_data::message::{self, Payload, Topics}; -use node_data::message::{payload, AsyncQueue, Metadata}; -use node_data::Serializable; -use tokio::sync::{oneshot, Mutex, RwLock, Semaphore}; -use tokio::task::JoinHandle; -use tracing::{debug, info, trace, warn}; - -use std::any; +use node_data::message::{payload, AsyncQueue}; +use node_data::message::{Payload, Topics}; +use tokio::sync::{RwLock, Semaphore}; +use tracing::{info, warn}; const TOPICS: &[u8] = &[ Topics::GetBlocks as u8, diff --git a/node/src/mempool.rs b/node/src/mempool.rs index d3741f8e7d..fc6bc5e887 100644 --- a/node/src/mempool.rs +++ b/node/src/mempool.rs @@ -6,15 +6,13 @@ use crate::database::{Ledger, Mempool}; use crate::{database, vm, LongLivedService, Message, Network}; -use anyhow::{anyhow, bail}; +use anyhow::anyhow; use async_trait::async_trait; -use dusk_bytes::Serializable; use node_data::ledger::Transaction; -use node_data::message::AsyncQueue; -use node_data::message::Payload; -use node_data::message::Topics; +use node_data::message::{AsyncQueue, Payload, Topics}; use std::sync::Arc; use tokio::sync::RwLock; +use tracing::warn; const TOPICS: &[u8] = &[Topics::Tx as u8]; diff --git a/node/src/network.rs b/node/src/network.rs index e80d791c2c..2717b7f3e7 100644 --- a/node/src/network.rs +++ b/node/src/network.rs @@ -4,10 +4,9 @@ // // Copyright (c) DUSK NETWORK. All rights reserved. -use std::net::{IpAddr, SocketAddr}; +use std::net::SocketAddr; use std::sync::Arc; use std::time::Duration; -use std::{any, default}; use crate::{BoxedFilter, Message}; use async_trait::async_trait; @@ -18,7 +17,7 @@ use node_data::message::{AsyncQueue, Topics}; use std::sync::atomic::{AtomicU64, Ordering}; use tokio::sync::RwLock; use tokio::time::{self, Instant}; -use tracing::{debug, error, info, trace}; +use tracing::{error, info, trace}; mod frame; diff --git a/node/src/vm.rs b/node/src/vm.rs index 9052972c8f..c39a1d2dcb 100644 --- a/node/src/vm.rs +++ b/node/src/vm.rs @@ -4,8 +4,6 @@ // // Copyright (c) DUSK NETWORK. All rights reserved. -use async_trait::async_trait; -use dusk_bls12_381_sign::PublicKey as BlsPublicKey; use dusk_consensus::{ contract_state::CallParams, contract_state::VerificationOutput, user::provisioners::Provisioners,