cargo fix --edition

This commit is contained in:
Greg Fitzgerald 2018-12-07 20:16:27 -07:00
parent 92584bd323
commit ec5a8141eb
52 changed files with 435 additions and 429 deletions

View File

@ -3,21 +3,22 @@
//! on behalf of the caller, and a low-level API for when they have
//! already been signed and verified.
use crate::counter::Counter;
use crate::entry::Entry;
use crate::jsonrpc_macros::pubsub::Sink;
use crate::leader_scheduler::LeaderScheduler;
use crate::ledger::Block;
use crate::mint::Mint;
use crate::poh_recorder::PohRecorder;
use crate::poh_service::NUM_TICKS_PER_SECOND;
use crate::rpc::RpcSignatureStatus;
use crate::runtime::{self, RuntimeError};
use crate::storage_stage::StorageState;
use bincode::deserialize;
use bincode::serialize;
use counter::Counter;
use entry::Entry;
use itertools::Itertools;
use jsonrpc_macros::pubsub::Sink;
use leader_scheduler::LeaderScheduler;
use ledger::Block;
use log::Level;
use mint::Mint;
use poh_recorder::PohRecorder;
use poh_service::NUM_TICKS_PER_SECOND;
use rayon::prelude::*;
use rpc::RpcSignatureStatus;
use runtime::{self, RuntimeError};
use solana_native_loader;
use solana_sdk::account::Account;
use solana_sdk::bpf_loader;
@ -42,7 +43,6 @@ use std::result;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex, RwLock};
use std::time::Instant;
use storage_stage::StorageState;
use tokio::prelude::Future;
/// The number of most recent `last_id` values that the bank will track the signatures
@ -1433,12 +1433,12 @@ impl Bank {
#[cfg(test)]
mod tests {
use super::*;
use crate::entry::next_entry;
use crate::entry::Entry;
use crate::jsonrpc_macros::pubsub::{Subscriber, SubscriptionId};
use crate::ledger;
use crate::signature::GenKeys;
use bincode::serialize;
use entry::next_entry;
use entry::Entry;
use jsonrpc_macros::pubsub::{Subscriber, SubscriptionId};
use ledger;
use signature::GenKeys;
use solana_sdk::hash::hash;
use solana_sdk::signature::Keypair;
use solana_sdk::signature::KeypairUtil;

View File

@ -2,18 +2,18 @@
//! to contruct a software pipeline. The stage uses all available CPU cores and
//! can do its processing in parallel with signature verification on the GPU.
use bank::Bank;
use crate::bank::Bank;
use crate::compute_leader_finality_service::ComputeLeaderFinalityService;
use crate::counter::Counter;
use crate::entry::Entry;
use crate::packet::Packets;
use crate::poh_recorder::{PohRecorder, PohRecorderError};
use crate::poh_service::{Config, PohService};
use crate::result::{Error, Result};
use crate::service::Service;
use crate::sigverify_stage::VerifiedPackets;
use bincode::deserialize;
use compute_leader_finality_service::ComputeLeaderFinalityService;
use counter::Counter;
use entry::Entry;
use log::Level;
use packet::Packets;
use poh_recorder::{PohRecorder, PohRecorderError};
use poh_service::{Config, PohService};
use result::{Error, Result};
use service::Service;
use sigverify_stage::VerifiedPackets;
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::timing;
@ -260,11 +260,11 @@ impl Service for BankingStage {
#[cfg(test)]
mod tests {
use super::*;
use bank::Bank;
use banking_stage::BankingStageReturnType;
use ledger::Block;
use mint::Mint;
use packet::to_packets;
use crate::bank::Bank;
use crate::banking_stage::BankingStageReturnType;
use crate::ledger::Block;
use crate::mint::Mint;
use crate::packet::to_packets;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::transaction::Transaction;

View File

@ -1,12 +1,12 @@
//! The `blob_fetch_stage` pulls blobs from UDP sockets and sends it to a channel.
use service::Service;
use crate::service::Service;
use crate::streamer::{self, BlobReceiver};
use std::net::UdpSocket;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel;
use std::sync::Arc;
use std::thread::{self, JoinHandle};
use streamer::{self, BlobReceiver};
pub struct BlobFetchStage {
exit: Arc<AtomicBool>,

View File

@ -1,17 +1,18 @@
//! The `broadcast_service` broadcasts data from a leader node to validators
//!
use cluster_info::{ClusterInfo, ClusterInfoError, NodeInfo};
use counter::Counter;
use entry::Entry;
use crate::cluster_info::{ClusterInfo, ClusterInfoError, NodeInfo};
use crate::counter::Counter;
use crate::entry::Entry;
#[cfg(feature = "erasure")]
use erasure;
use ledger::Block;
use crate::ledger::Block;
use crate::packet::{index_blobs, SharedBlobs};
use crate::result::{Error, Result};
use crate::service::Service;
use crate::window::{SharedWindow, WindowIndex, WindowUtil};
use log::Level;
use packet::{index_blobs, SharedBlobs};
use rayon::prelude::*;
use result::{Error, Result};
use service::Service;
use solana_metrics::{influxdb, submit};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::timing::duration_as_ms;
@ -21,7 +22,6 @@ use std::sync::mpsc::{Receiver, RecvTimeoutError};
use std::sync::{Arc, RwLock};
use std::thread::{self, Builder, JoinHandle};
use std::time::{Duration, Instant};
use window::{SharedWindow, WindowIndex, WindowUtil};
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum BroadcastServiceReturnType {

View File

@ -1,6 +1,6 @@
use cluster_info::{NodeInfo, FULLNODE_PORT_RANGE};
use netutil::bind_in_range;
use thin_client::ThinClient;
use crate::cluster_info::{NodeInfo, FULLNODE_PORT_RANGE};
use crate::netutil::bind_in_range;
use crate::thin_client::ThinClient;
pub fn mk_client(r: &NodeInfo) -> ThinClient {
let (_, transactions_socket) = bind_in_range(FULLNODE_PORT_RANGE).unwrap();

View File

@ -12,22 +12,24 @@
//! * layer 2 - Everyone else, if layer 1 is `2^10`, layer 2 should be able to fit `2^20` number of nodes.
//!
//! Bank needs to provide an interface for us to query the stake weight
use crate::bloom::Bloom;
use crate::contact_info::ContactInfo;
use crate::counter::Counter;
use crate::crds_gossip::CrdsGossip;
use crate::crds_gossip_error::CrdsGossipError;
use crate::crds_gossip_pull::CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS;
use crate::crds_value::{CrdsValue, CrdsValueLabel, LeaderId};
use crate::ledger::LedgerWindow;
use crate::netutil::{bind_in_range, bind_to, find_available_port_in_range, multi_bind_in_range};
use crate::packet::{to_blob, Blob, SharedBlob, BLOB_SIZE};
use crate::result::Result;
use crate::rpc::RPC_PORT;
use crate::streamer::{BlobReceiver, BlobSender};
use crate::window::{SharedWindow, WindowIndex};
use bincode::{deserialize, serialize};
use bloom::Bloom;
use contact_info::ContactInfo;
use counter::Counter;
use crds_gossip::CrdsGossip;
use crds_gossip_error::CrdsGossipError;
use crds_gossip_pull::CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS;
use crds_value::{CrdsValue, CrdsValueLabel, LeaderId};
use ledger::LedgerWindow;
use log::Level;
use netutil::{bind_in_range, bind_to, find_available_port_in_range, multi_bind_in_range};
use packet::{to_blob, Blob, SharedBlob, BLOB_SIZE};
use rand::{thread_rng, Rng};
use rayon::prelude::*;
use result::Result;
use rpc::RPC_PORT;
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil, Signable, Signature};
@ -39,8 +41,6 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::{Arc, RwLock};
use std::thread::{sleep, Builder, JoinHandle};
use std::time::{Duration, Instant};
use streamer::{BlobReceiver, BlobSender};
use window::{SharedWindow, WindowIndex};
pub type NodeInfo = ContactInfo;
@ -1129,18 +1129,18 @@ fn report_time_spent(label: &str, time: &Duration, extra: &str) {
#[cfg(test)]
mod tests {
use super::*;
use crds_value::CrdsValueLabel;
use entry::Entry;
use ledger::{get_tmp_ledger_path, LedgerWindow, LedgerWriter};
use logger;
use packet::SharedBlob;
use result::Error;
use crate::crds_value::CrdsValueLabel;
use crate::entry::Entry;
use crate::ledger::{get_tmp_ledger_path, LedgerWindow, LedgerWriter};
use crate::logger;
use crate::packet::SharedBlob;
use crate::result::Error;
use crate::window::default_window;
use solana_sdk::hash::{hash, Hash};
use solana_sdk::signature::{Keypair, KeypairUtil};
use std::fs::remove_dir_all;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::sync::{Arc, RwLock};
use window::default_window;
#[test]
fn test_cluster_spy_gossip() {

View File

@ -2,9 +2,9 @@
//! to generate a thread which regularly calculates the last finality times
//! observed by the leader
use bank::Bank;
use crate::bank::Bank;
use service::Service;
use crate::service::Service;
use solana_metrics::{influxdb, submit};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::timing;
@ -148,12 +148,12 @@ impl Service for ComputeLeaderFinalityService {
#[cfg(test)]
pub mod tests {
use bank::Bank;
use crate::bank::Bank;
use crate::compute_leader_finality_service::ComputeLeaderFinalityService;
use crate::create_vote_account::*;
use crate::logger;
use crate::mint::Mint;
use bincode::serialize;
use compute_leader_finality_service::ComputeLeaderFinalityService;
use create_vote_account::*;
use logger;
use mint::Mint;
use solana_sdk::hash::hash;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::transaction::Transaction;

View File

@ -1,5 +1,5 @@
use crate::rpc::RPC_PORT;
use bincode::serialize;
use rpc::RPC_PORT;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil, Signable, Signature};
use solana_sdk::timing::timestamp;

View File

@ -96,7 +96,7 @@ impl Counter {
}
#[cfg(test)]
mod tests {
use counter::{Counter, DEFAULT_LOG_RATE};
use crate::counter::{Counter, DEFAULT_LOG_RATE};
use log::Level;
use std::env;
use std::sync::atomic::{AtomicUsize, Ordering};

View File

@ -24,8 +24,8 @@
//! A value is updated to a new version if the labels match, and the value
//! wallclock is later, or the value hash is greater.
use crate::crds_value::{CrdsValue, CrdsValueLabel};
use bincode::serialize;
use crds_value::{CrdsValue, CrdsValueLabel};
use indexmap::map::IndexMap;
use solana_sdk::hash::{hash, Hash};
use solana_sdk::pubkey::Pubkey;
@ -163,8 +163,8 @@ impl Crds {
#[cfg(test)]
mod test {
use super::*;
use contact_info::ContactInfo;
use crds_value::LeaderId;
use crate::contact_info::ContactInfo;
use crate::crds_value::LeaderId;
use solana_sdk::signature::{Keypair, KeypairUtil};
#[test]

View File

@ -3,12 +3,12 @@
//! designed to run with a simulator or over a UDP network connection with messages up to a
//! packet::BLOB_DATA_SIZE size.
use bloom::Bloom;
use crds::Crds;
use crds_gossip_error::CrdsGossipError;
use crds_gossip_pull::CrdsGossipPull;
use crds_gossip_push::{CrdsGossipPush, CRDS_GOSSIP_NUM_ACTIVE};
use crds_value::CrdsValue;
use crate::bloom::Bloom;
use crate::crds::Crds;
use crate::crds_gossip_error::CrdsGossipError;
use crate::crds_gossip_pull::CrdsGossipPull;
use crate::crds_gossip_push::{CrdsGossipPush, CRDS_GOSSIP_NUM_ACTIVE};
use crate::crds_value::CrdsValue;
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
@ -158,11 +158,11 @@ impl CrdsGossip {
#[cfg(test)]
mod test {
use super::*;
use crate::cluster_info::NodeInfo;
use crate::contact_info::ContactInfo;
use crate::crds_gossip_push::CRDS_GOSSIP_PUSH_MSG_TIMEOUT_MS;
use crate::crds_value::CrdsValueLabel;
use bincode::serialized_size;
use cluster_info::NodeInfo;
use contact_info::ContactInfo;
use crds_gossip_push::CRDS_GOSSIP_PUSH_MSG_TIMEOUT_MS;
use crds_value::CrdsValueLabel;
use rayon::prelude::*;
use solana_sdk::hash::hash;
use solana_sdk::signature::{Keypair, KeypairUtil};
@ -491,7 +491,7 @@ mod test {
#[test]
#[ignore]
fn test_star_network_large_pull() {
use logger;
use crate::logger;
logger::setup();
let mut network = star_network_create(2000);
network_simulator_pull_only(&mut network);
@ -499,7 +499,7 @@ mod test {
#[test]
#[ignore]
fn test_rstar_network_large_push() {
use logger;
use crate::logger;
logger::setup();
let mut network = rstar_network_create(4000);
network_simulator(&mut network);
@ -507,7 +507,7 @@ mod test {
#[test]
#[ignore]
fn test_ring_network_large_push() {
use logger;
use crate::logger;
logger::setup();
let mut network = ring_network_create(4001);
network_simulator(&mut network);
@ -515,7 +515,7 @@ mod test {
#[test]
#[ignore]
fn test_star_network_large_push() {
use logger;
use crate::logger;
logger::setup();
let mut network = star_network_create(4002);
network_simulator(&mut network);

View File

@ -9,13 +9,13 @@
//! with random hash functions. So each subsequent request will have a different distribution
//! of false positives.
use crate::bloom::Bloom;
use crate::crds::Crds;
use crate::crds_gossip::CRDS_GOSSIP_BLOOM_SIZE;
use crate::crds_gossip_error::CrdsGossipError;
use crate::crds_value::{CrdsValue, CrdsValueLabel};
use crate::packet::BLOB_DATA_SIZE;
use bincode::serialized_size;
use bloom::Bloom;
use crds::Crds;
use crds_gossip::CRDS_GOSSIP_BLOOM_SIZE;
use crds_gossip_error::CrdsGossipError;
use crds_value::{CrdsValue, CrdsValueLabel};
use packet::BLOB_DATA_SIZE;
use rand;
use rand::distributions::{Distribution, WeightedIndex};
use solana_sdk::hash::Hash;
@ -198,8 +198,8 @@ impl CrdsGossipPull {
#[cfg(test)]
mod test {
use super::*;
use contact_info::ContactInfo;
use crds_value::LeaderId;
use crate::contact_info::ContactInfo;
use crate::crds_value::LeaderId;
use solana_sdk::signature::{Keypair, KeypairUtil};
#[test]

View File

@ -8,15 +8,15 @@
//! the local nodes wallclock window they are drooped silently.
//! 2. The prune set is stored in a Bloom filter.
use crate::bloom::Bloom;
use crate::contact_info::ContactInfo;
use crate::crds::{Crds, VersionedCrdsValue};
use crate::crds_gossip::CRDS_GOSSIP_BLOOM_SIZE;
use crate::crds_gossip_error::CrdsGossipError;
use crate::crds_value::{CrdsValue, CrdsValueLabel};
use crate::packet::BLOB_DATA_SIZE;
use bincode::serialized_size;
use bloom::Bloom;
use contact_info::ContactInfo;
use crds::{Crds, VersionedCrdsValue};
use crds_gossip::CRDS_GOSSIP_BLOOM_SIZE;
use crds_gossip_error::CrdsGossipError;
use crds_value::{CrdsValue, CrdsValueLabel};
use indexmap::map::IndexMap;
use packet::BLOB_DATA_SIZE;
use rand;
use rand::seq::SliceRandom;
use solana_sdk::hash::Hash;
@ -245,7 +245,7 @@ impl CrdsGossipPush {
#[cfg(test)]
mod test {
use super::*;
use contact_info::ContactInfo;
use crate::contact_info::ContactInfo;
use solana_sdk::signature::{Keypair, KeypairUtil};
#[test]
fn test_process_push() {
@ -342,7 +342,7 @@ mod test {
}
#[test]
fn test_refresh_active_set() {
use logger;
use crate::logger;
logger::setup();
let mut crds = Crds::default();
let mut push = CrdsGossipPush::default();

View File

@ -1,4 +1,4 @@
use bloom::BloomHashIndex;
use crate::bloom::BloomHashIndex;
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;

View File

@ -1,5 +1,5 @@
use crate::contact_info::ContactInfo;
use bincode::serialize;
use contact_info::ContactInfo;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, Signable, Signature};
use solana_sdk::transaction::Transaction;
@ -230,10 +230,10 @@ impl Signable for CrdsValue {
#[cfg(test)]
mod test {
use super::*;
use contact_info::ContactInfo;
use crate::contact_info::ContactInfo;
use crate::test_tx::test_tx;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::timing::timestamp;
use test_tx::test_tx;
#[test]
fn test_labels() {

View File

@ -1,5 +1,5 @@
use bank::Bank;
use result::Result;
use crate::bank::Bank;
use crate::result::Result;
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::transaction::Transaction;

View File

@ -2,11 +2,11 @@
//! Proof of History ledger as well as iterative read, append write, and random
//! access read to a persistent file-based ledger.
use crate::entry::Entry;
use crate::packet::{Blob, SharedBlob, BLOB_HEADER_SIZE};
use crate::result::{Error, Result};
use bincode::{deserialize, serialize};
use byteorder::{BigEndian, ByteOrder, ReadBytesExt};
use entry::Entry;
use packet::{Blob, SharedBlob, BLOB_HEADER_SIZE};
use result::{Error, Result};
use rocksdb::{ColumnFamily, Options, WriteBatch, DB};
use serde::de::DeserializeOwned;
use serde::Serialize;
@ -474,7 +474,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use ledger::{get_tmp_ledger_path, make_tiny_test_entries, Block};
use crate::ledger::{get_tmp_ledger_path, make_tiny_test_entries, Block};
#[test]
fn test_put_get_simple() {

View File

@ -1,14 +1,15 @@
//! Set of functions for emulating windowing functions from a database ledger implementation
use cluster_info::ClusterInfo;
use counter::Counter;
use db_ledger::*;
use entry::Entry;
use crate::cluster_info::ClusterInfo;
use crate::counter::Counter;
use crate::db_ledger::*;
use crate::entry::Entry;
use crate::leader_scheduler::LeaderScheduler;
use crate::packet::{SharedBlob, BLOB_HEADER_SIZE};
use crate::result::Result;
use crate::streamer::BlobSender;
#[cfg(feature = "erasure")]
use erasure;
use leader_scheduler::LeaderScheduler;
use log::Level;
use packet::{SharedBlob, BLOB_HEADER_SIZE};
use result::Result;
use rocksdb::DBRawIterator;
use solana_metrics::{influxdb, submit};
use solana_sdk::pubkey::Pubkey;
@ -17,7 +18,6 @@ use std::net::SocketAddr;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, RwLock};
use streamer::BlobSender;
pub const MAX_REPAIR_LENGTH: usize = 128;
@ -400,14 +400,15 @@ fn try_erasure(db_ledger: &mut DbLedger, slot: u64, consume_queue: &mut Vec<Entr
#[cfg(test)]
mod test {
use super::*;
use crate::ledger::{get_tmp_ledger_path, make_tiny_test_entries, Block};
use crate::packet::{Blob, Packet, Packets, SharedBlob, PACKET_DATA_SIZE};
use crate::streamer::{receiver, responder, PacketReceiver};
#[cfg(all(feature = "erasure", test))]
use entry::reconstruct_entries_from_blobs;
#[cfg(all(feature = "erasure", test))]
use erasure::test::{generate_db_ledger_from_window, setup_window_ledger};
#[cfg(all(feature = "erasure", test))]
use erasure::{NUM_CODING, NUM_DATA};
use ledger::{get_tmp_ledger_path, make_tiny_test_entries, Block};
use packet::{Blob, Packet, Packets, SharedBlob, PACKET_DATA_SIZE};
use rocksdb::{Options, DB};
use solana_sdk::signature::{Keypair, KeypairUtil};
use std::io;
@ -417,7 +418,6 @@ mod test {
use std::sync::mpsc::channel;
use std::sync::Arc;
use std::time::Duration;
use streamer::{receiver, responder, PacketReceiver};
fn get_msgs(r: PacketReceiver, num: &mut usize) {
for _t in 0..5 {

View File

@ -2,10 +2,10 @@
//! unique ID that is the hash of the Entry before it, plus the hash of the
//! transactions within it. Entries cannot be reordered, and its field `num_hashes`
//! represents an approximate amount of time since the last Entry was created.
use crate::packet::{SharedBlob, BLOB_DATA_SIZE};
use crate::poh::Poh;
use crate::result::Result;
use bincode::{deserialize, serialize_into, serialized_size};
use packet::{SharedBlob, BLOB_DATA_SIZE};
use poh::Poh;
use result::Result;
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::transaction::Transaction;
@ -272,8 +272,8 @@ pub fn reconstruct_entries_from_blobs(blobs: Vec<SharedBlob>) -> Result<(Vec<Ent
#[cfg(test)]
mod tests {
use super::*;
use crate::entry::Entry;
use chrono::prelude::*;
use entry::Entry;
use solana_sdk::budget_transaction::BudgetTransaction;
use solana_sdk::hash::hash;
use solana_sdk::signature::{Keypair, KeypairUtil};

View File

@ -1,12 +1,12 @@
//! The `fetch_stage` batches input from a UDP socket and sends it to a channel.
use service::Service;
use crate::service::Service;
use crate::streamer::{self, PacketReceiver};
use std::net::UdpSocket;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel;
use std::sync::Arc;
use std::thread::{self, JoinHandle};
use streamer::{self, PacketReceiver};
pub struct FetchStage {
exit: Arc<AtomicBool>,

View File

@ -1,15 +1,19 @@
//! The `fullnode` module hosts all the fullnode microservices.
use bank::Bank;
use broadcast_service::BroadcastService;
use cluster_info::{ClusterInfo, Node, NodeInfo};
use db_ledger::{write_entries_to_ledger, DbLedger};
use gossip_service::GossipService;
use leader_scheduler::LeaderScheduler;
use ledger::read_ledger;
use rpc::JsonRpcService;
use rpc_pubsub::PubSubService;
use service::Service;
use crate::bank::Bank;
use crate::broadcast_service::BroadcastService;
use crate::cluster_info::{ClusterInfo, Node, NodeInfo};
use crate::db_ledger::{write_entries_to_ledger, DbLedger};
use crate::gossip_service::GossipService;
use crate::leader_scheduler::LeaderScheduler;
use crate::ledger::read_ledger;
use crate::rpc::JsonRpcService;
use crate::rpc_pubsub::PubSubService;
use crate::service::Service;
use crate::tpu::{Tpu, TpuReturnType};
use crate::tpu_forwarder::TpuForwarder;
use crate::tvu::{Tvu, TvuReturnType};
use crate::window::{new_window, SharedWindow};
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::timing::timestamp;
@ -18,11 +22,7 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, RwLock};
use std::thread::Result;
use tpu::{Tpu, TpuReturnType};
use tpu_forwarder::TpuForwarder;
use tvu::{Tvu, TvuReturnType};
use untrusted::Input;
use window::{new_window, SharedWindow};
pub enum NodeRole {
Leader(LeaderServices),
@ -650,21 +650,25 @@ impl Service for Fullnode {
#[cfg(test)]
mod tests {
use bank::Bank;
use cluster_info::Node;
use db_ledger::*;
use fullnode::{Fullnode, FullnodeReturnType, NodeRole, TvuReturnType};
use leader_scheduler::{make_active_set_entries, LeaderScheduler, LeaderSchedulerConfig};
use ledger::{create_tmp_genesis, create_tmp_sample_ledger, tmp_copy_ledger, LedgerWriter};
use packet::make_consecutive_blobs;
use service::Service;
use crate::bank::Bank;
use crate::cluster_info::Node;
use crate::db_ledger::*;
use crate::fullnode::{Fullnode, FullnodeReturnType, NodeRole, TvuReturnType};
use crate::leader_scheduler::{
make_active_set_entries, LeaderScheduler, LeaderSchedulerConfig,
};
use crate::ledger::{
create_tmp_genesis, create_tmp_sample_ledger, tmp_copy_ledger, LedgerWriter,
};
use crate::packet::make_consecutive_blobs;
use crate::service::Service;
use crate::streamer::responder;
use solana_sdk::signature::{Keypair, KeypairUtil};
use std::cmp;
use std::fs::remove_dir_all;
use std::net::UdpSocket;
use std::sync::mpsc::channel;
use std::sync::{Arc, RwLock};
use streamer::responder;
#[test]
fn validator_exit() {

View File

@ -1,14 +1,14 @@
//! The `gossip_service` module implements the network control plane.
use cluster_info::ClusterInfo;
use service::Service;
use crate::cluster_info::ClusterInfo;
use crate::service::Service;
use crate::streamer;
use crate::window::SharedWindow;
use std::net::UdpSocket;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel;
use std::sync::{Arc, RwLock};
use std::thread::{self, JoinHandle};
use streamer;
use window::SharedWindow;
pub struct GossipService {
exit: Arc<AtomicBool>,
@ -67,7 +67,7 @@ impl Service for GossipService {
#[cfg(test)]
mod tests {
use super::*;
use cluster_info::{ClusterInfo, Node};
use crate::cluster_info::{ClusterInfo, Node};
use std::sync::atomic::AtomicBool;
use std::sync::{Arc, RwLock};

View File

@ -1,12 +1,12 @@
//! The `leader_scheduler` module implements a structure and functions for tracking and
//! managing the schedule for leader rotation
use bank::Bank;
use crate::bank::Bank;
use crate::entry::Entry;
use crate::ledger::create_ticks;
use bincode::serialize;
use byteorder::{LittleEndian, ReadBytesExt};
use entry::Entry;
use ledger::create_ticks;
use solana_sdk::hash::{hash, Hash};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
@ -508,13 +508,13 @@ pub fn make_active_set_entries(
#[cfg(test)]
mod tests {
use bank::Bank;
use create_vote_account::*;
use leader_scheduler::{
use crate::bank::Bank;
use crate::create_vote_account::*;
use crate::leader_scheduler::{
LeaderScheduler, LeaderSchedulerConfig, DEFAULT_BOOTSTRAP_HEIGHT,
DEFAULT_LEADER_ROTATION_INTERVAL, DEFAULT_SEED_ROTATION_INTERVAL,
};
use mint::Mint;
use crate::mint::Mint;
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};

View File

@ -2,12 +2,12 @@
//! Proof of History ledger as well as iterative read, append write, and random
//! access read to a persistent file-based ledger.
use crate::entry::Entry;
use crate::mint::Mint;
use crate::packet::{SharedBlob, BLOB_DATA_SIZE};
use bincode::{self, deserialize_from, serialize_into, serialized_size};
use chrono::prelude::Utc;
use entry::Entry;
use log::Level::Trace;
use mint::Mint;
use packet::{SharedBlob, BLOB_DATA_SIZE};
use rayon::prelude::*;
use solana_sdk::budget_transaction::BudgetTransaction;
use solana_sdk::hash::{hash, Hash};
@ -702,9 +702,9 @@ pub fn make_large_test_entries(num_entries: usize) -> Vec<Entry> {
#[cfg(test)]
mod tests {
use super::*;
use crate::entry::{next_entry, reconstruct_entries_from_blobs, Entry};
use crate::packet::{to_blobs, BLOB_DATA_SIZE, PACKET_DATA_SIZE};
use bincode::{deserialize, serialized_size};
use entry::{next_entry, reconstruct_entries_from_blobs, Entry};
use packet::{to_blobs, BLOB_DATA_SIZE, PACKET_DATA_SIZE};
use solana_sdk::hash::hash;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::transaction::Transaction;
@ -714,7 +714,7 @@ mod tests {
#[test]
fn test_verify_slice() {
use logger;
use crate::logger;
logger::setup();
let zero = Hash::default();
let one = hash(&zero.as_ref());
@ -758,7 +758,7 @@ mod tests {
#[test]
fn test_entries_to_blobs() {
use logger;
use crate::logger;
logger::setup();
let entries = make_test_entries();
@ -769,7 +769,7 @@ mod tests {
#[test]
fn test_bad_blobs_attack() {
use logger;
use crate::logger;
logger::setup();
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 8000);
let blobs_q = to_blobs(vec![(0, addr)]).unwrap(); // <-- attack!
@ -778,7 +778,7 @@ mod tests {
#[test]
fn test_next_entries() {
use logger;
use crate::logger;
logger::setup();
let id = Hash::default();
let next_id = hash(&id.as_ref());
@ -827,7 +827,7 @@ mod tests {
#[test]
fn test_ledger_reader_writer() {
use logger;
use crate::logger;
logger::setup();
let ledger_path = get_tmp_ledger_path("test_ledger_reader_writer");
let entries = make_tiny_test_entries(10);
@ -905,7 +905,7 @@ mod tests {
#[test]
fn test_recover_ledger() {
use logger;
use crate::logger;
logger::setup();
let entries = make_tiny_test_entries(10);
@ -956,7 +956,7 @@ mod tests {
#[test]
fn test_verify_ledger() {
use logger;
use crate::logger;
logger::setup();
let entries = make_tiny_test_entries(10);
@ -974,7 +974,7 @@ mod tests {
#[test]
fn test_get_entries_bytes() {
use logger;
use crate::logger;
logger::setup();
let entries = make_tiny_test_entries(10);
let ledger_path = get_tmp_ledger_path("test_raw_entries");

View File

@ -1,12 +1,12 @@
//! The `ledger_write_stage` module implements the ledger write stage. It
//! writes entries to the given writer, which is typically a file
use counter::Counter;
use entry::{EntryReceiver, EntrySender};
use ledger::LedgerWriter;
use crate::counter::Counter;
use crate::entry::{EntryReceiver, EntrySender};
use crate::ledger::LedgerWriter;
use crate::result::{Error, Result};
use crate::service::Service;
use log::Level;
use result::{Error, Result};
use service::Service;
use solana_sdk::timing::duration_as_ms;
use std::sync::atomic::AtomicUsize;
use std::sync::mpsc::{channel, RecvTimeoutError};

View File

@ -1,6 +1,6 @@
//! The `mint` module is a library for generating the chain's genesis block.
use entry::Entry;
use crate::entry::Entry;
use ring::rand::SystemRandom;
use solana_sdk::hash::{hash, Hash};
use solana_sdk::pubkey::Pubkey;
@ -106,8 +106,8 @@ impl Mint {
#[cfg(test)]
mod tests {
use super::*;
use crate::ledger::Block;
use bincode::deserialize;
use ledger::Block;
use solana_sdk::system_instruction::SystemInstruction;
use solana_sdk::system_program;

View File

@ -203,9 +203,9 @@ pub fn find_available_port_in_range(range: (u16, u16)) -> io::Result<u16> {
#[cfg(test)]
mod tests {
use crate::logger;
use crate::netutil::*;
use ipnetwork::IpNetwork;
use logger;
use netutil::*;
use pnet_datalink as datalink;
#[test]

View File

@ -1,14 +1,14 @@
//! The `packet` module defines data structures and methods to pull data from the network.
use crate::counter::Counter;
#[cfg(test)]
use crate::entry::Entry;
#[cfg(test)]
use crate::ledger::Block;
use crate::recvmmsg::{recv_mmsg, NUM_RCVMMSGS};
use crate::result::{Error, Result};
use bincode::{deserialize, serialize};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use counter::Counter;
#[cfg(test)]
use entry::Entry;
#[cfg(test)]
use ledger::Block;
use log::Level;
use recvmmsg::{recv_mmsg, NUM_RCVMMSGS};
use result::{Error, Result};
use serde::Serialize;
#[cfg(test)]
use solana_sdk::hash::Hash;
@ -473,7 +473,7 @@ pub fn make_consecutive_blobs(
#[cfg(test)]
mod tests {
use packet::{
use crate::packet::{
to_packets, Blob, Meta, Packet, Packets, SharedBlob, SharedPackets, NUM_PACKETS,
PACKET_DATA_SIZE,
};

View File

@ -96,7 +96,7 @@ pub fn verify(initial: Hash, entries: &[PohEntry]) -> bool {
#[cfg(test)]
mod tests {
use poh::{self, PohEntry};
use crate::poh::{self, PohEntry};
use solana_sdk::hash::Hash;
#[test]

View File

@ -1,10 +1,10 @@
//! The `poh_recorder` module provides an object for synchronizing with Proof of History.
//! It synchronizes PoH, bank's register_tick and the ledger
//!
use bank::Bank;
use entry::Entry;
use poh::Poh;
use result::{Error, Result};
use crate::bank::Bank;
use crate::entry::Entry;
use crate::poh::Poh;
use crate::result::{Error, Result};
use solana_sdk::hash::Hash;
use solana_sdk::transaction::Transaction;
use std::sync::mpsc::Sender;
@ -118,11 +118,11 @@ impl PohRecorder {
#[cfg(test)]
mod tests {
use super::*;
use mint::Mint;
use crate::mint::Mint;
use crate::test_tx::test_tx;
use solana_sdk::hash::hash;
use std::sync::mpsc::channel;
use std::sync::Arc;
use test_tx::test_tx;
#[test]
fn test_poh() {

View File

@ -1,9 +1,9 @@
//! The `poh_service` module implements a service that records the passing of
//! "ticks", a measure of time in the PoH stream
use poh_recorder::PohRecorder;
use result::Result;
use service::Service;
use crate::poh_recorder::PohRecorder;
use crate::result::Result;
use crate::service::Service;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::thread::sleep;
@ -97,17 +97,17 @@ impl Service for PohService {
#[cfg(test)]
mod tests {
use super::{Config, PohService};
use bank::Bank;
use mint::Mint;
use poh_recorder::PohRecorder;
use result::Result;
use service::Service;
use crate::bank::Bank;
use crate::mint::Mint;
use crate::poh_recorder::PohRecorder;
use crate::result::Result;
use crate::service::Service;
use crate::test_tx::test_tx;
use solana_sdk::hash::hash;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel;
use std::sync::Arc;
use std::thread::{Builder, JoinHandle};
use test_tx::test_tx;
#[test]
fn test_poh_service() {

View File

@ -1,6 +1,6 @@
//! The `recvmmsg` module provides recvmmsg() API implementation
use packet::Packet;
use crate::packet::Packet;
use std::cmp;
use std::io;
use std::net::UdpSocket;
@ -85,8 +85,8 @@ pub fn recv_mmsg(sock: &UdpSocket, packets: &mut [Packet]) -> io::Result<usize>
#[cfg(test)]
mod tests {
use packet::PACKET_DATA_SIZE;
use recvmmsg::*;
use crate::packet::PACKET_DATA_SIZE;
use crate::recvmmsg::*;
#[test]
pub fn test_recv_mmsg_one_iter() {

View File

@ -1,16 +1,18 @@
//! The `replicate_stage` replicates transactions broadcast by the leader.
use bank::Bank;
use cluster_info::ClusterInfo;
use counter::Counter;
use entry::{EntryReceiver, EntrySender};
use crate::bank::Bank;
use crate::cluster_info::ClusterInfo;
use crate::counter::Counter;
use crate::entry::{EntryReceiver, EntrySender};
use solana_sdk::hash::Hash;
use ledger::Block;
use crate::ledger::Block;
use crate::packet::BlobError;
use crate::result::{Error, Result};
use crate::service::Service;
use crate::streamer::{responder, BlobSender};
use crate::vote_stage::send_validator_vote;
use log::Level;
use packet::BlobError;
use result::{Error, Result};
use service::Service;
use solana_metrics::{influxdb, submit};
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::timing::duration_as_ms;
@ -22,8 +24,6 @@ use std::sync::{Arc, RwLock};
use std::thread::{self, Builder, JoinHandle};
use std::time::Duration;
use std::time::Instant;
use streamer::{responder, BlobSender};
use vote_stage::send_validator_vote;
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum ReplicateStageReturnType {
@ -244,24 +244,26 @@ impl Service for ReplicateStage {
#[cfg(test)]
mod test {
use bank::Bank;
use cluster_info::{ClusterInfo, Node};
use entry::Entry;
use fullnode::Fullnode;
use leader_scheduler::{make_active_set_entries, LeaderScheduler, LeaderSchedulerConfig};
use ledger::{create_ticks, create_tmp_sample_ledger, LedgerWriter};
use logger;
use packet::BlobError;
use replicate_stage::{ReplicateStage, ReplicateStageReturnType};
use result::Error;
use service::Service;
use crate::bank::Bank;
use crate::cluster_info::{ClusterInfo, Node};
use crate::entry::Entry;
use crate::fullnode::Fullnode;
use crate::leader_scheduler::{
make_active_set_entries, LeaderScheduler, LeaderSchedulerConfig,
};
use crate::ledger::{create_ticks, create_tmp_sample_ledger, LedgerWriter};
use crate::logger;
use crate::packet::BlobError;
use crate::replicate_stage::{ReplicateStage, ReplicateStageReturnType};
use crate::result::Error;
use crate::service::Service;
use crate::vote_stage::{send_validator_vote, VoteError};
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil};
use std::fs::remove_dir_all;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel;
use std::sync::{Arc, RwLock};
use vote_stage::{send_validator_vote, VoteError};
#[test]
pub fn test_replicate_stage_leader_rotation_exit() {

View File

@ -1,17 +1,21 @@
use blob_fetch_stage::BlobFetchStage;
use crate::blob_fetch_stage::BlobFetchStage;
use crate::client::mk_client;
use crate::cluster_info::{ClusterInfo, Node, NodeInfo};
use crate::db_ledger::DbLedger;
use crate::gossip_service::GossipService;
use crate::leader_scheduler::LeaderScheduler;
use crate::ledger::LEDGER_DATA_FILE;
use crate::result::Result;
use crate::rpc_request::{RpcClient, RpcRequest};
use crate::service::Service;
use crate::store_ledger_stage::StoreLedgerStage;
use crate::streamer::BlobReceiver;
use crate::window;
use crate::window_service::window_service;
#[cfg(feature = "chacha")]
use chacha::{chacha_cbc_encrypt_file, CHACHA_BLOCK_SIZE};
use client::mk_client;
use cluster_info::{ClusterInfo, Node, NodeInfo};
use db_ledger::DbLedger;
use gossip_service::GossipService;
use leader_scheduler::LeaderScheduler;
use ledger::LEDGER_DATA_FILE;
use rand::thread_rng;
use rand::Rng;
use result::Result;
use rpc_request::{RpcClient, RpcRequest};
use service::Service;
use solana_drone::drone::{request_airdrop_transaction, DRONE_PORT};
use solana_sdk::hash::{Hash, Hasher};
use solana_sdk::signature::{Keypair, KeypairUtil};
@ -33,10 +37,6 @@ use std::sync::{Arc, RwLock};
use std::thread::sleep;
use std::thread::JoinHandle;
use std::time::Duration;
use store_ledger_stage::StoreLedgerStage;
use streamer::BlobReceiver;
use window;
use window_service::window_service;
pub struct Replicator {
gossip_service: GossipService,
@ -280,8 +280,8 @@ impl Replicator {
#[cfg(test)]
mod tests {
use logger;
use replicator::sample_file;
use crate::logger;
use crate::replicator::sample_file;
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil};
use std::fs::File;

View File

@ -1,18 +1,18 @@
//! The `result` module exposes a Result type that propagates one of many different Error types.
use bank;
use crate::bank;
use crate::cluster_info;
use crate::db_ledger;
use crate::packet;
use crate::poh_recorder;
use crate::vote_stage;
use bincode;
use cluster_info;
use db_ledger;
#[cfg(feature = "erasure")]
use erasure;
use packet;
use poh_recorder;
use rocksdb;
use serde_json;
use std;
use std::any::Any;
use vote_stage;
#[derive(Debug)]
pub enum Error {
@ -124,8 +124,8 @@ impl std::convert::From<db_ledger::DbLedgerError> for Error {
#[cfg(test)]
mod tests {
use result::Error;
use result::Result;
use crate::result::Error;
use crate::result::Result;
use serde_json;
use std::io;
use std::io::Write;

View File

@ -1,14 +1,16 @@
//! The `retransmit_stage` retransmits blobs between validators
use cluster_info::ClusterInfo;
use counter::Counter;
use db_ledger::DbLedger;
use entry::Entry;
use crate::cluster_info::ClusterInfo;
use crate::counter::Counter;
use crate::db_ledger::DbLedger;
use crate::entry::Entry;
use leader_scheduler::LeaderScheduler;
use crate::leader_scheduler::LeaderScheduler;
use crate::result::{Error, Result};
use crate::service::Service;
use crate::streamer::BlobReceiver;
use crate::window_service::window_service;
use log::Level;
use result::{Error, Result};
use service::Service;
use solana_metrics::{influxdb, submit};
use std::net::UdpSocket;
use std::sync::atomic::{AtomicBool, AtomicUsize};
@ -17,8 +19,6 @@ use std::sync::mpsc::{channel, Receiver};
use std::sync::{Arc, RwLock};
use std::thread::{self, Builder, JoinHandle};
use std::time::Duration;
use streamer::BlobReceiver;
use window_service::window_service;
fn retransmit(
cluster_info: &Arc<RwLock<ClusterInfo>>,

View File

@ -1,13 +1,13 @@
//! The `rpc` module implements the Solana RPC interface.
use bank::{Bank, BankError};
use crate::bank::{Bank, BankError};
use crate::cluster_info::ClusterInfo;
use crate::jsonrpc_core::*;
use crate::jsonrpc_http_server::*;
use crate::packet::PACKET_DATA_SIZE;
use crate::service::Service;
use bincode::{deserialize, serialize};
use bs58;
use cluster_info::ClusterInfo;
use jsonrpc_core::*;
use jsonrpc_http_server::*;
use packet::PACKET_DATA_SIZE;
use service::Service;
use solana_drone::drone::{request_airdrop_transaction, DRONE_PORT};
use solana_sdk::account::Account;
use solana_sdk::pubkey::Pubkey;
@ -371,17 +371,17 @@ fn verify_signature(input: &str) -> Result<Signature> {
#[cfg(test)]
mod tests {
use super::*;
use bank::Bank;
use crate::bank::Bank;
use crate::cluster_info::{Node, NodeInfo};
use crate::fullnode::Fullnode;
use crate::jsonrpc_core::Response;
use crate::leader_scheduler::LeaderScheduler;
use crate::ledger::create_tmp_ledger_with_mint;
use crate::mint::Mint;
use crate::rpc_request::get_rpc_request_str;
use bincode::serialize;
use cluster_info::{Node, NodeInfo};
use fullnode::Fullnode;
use jsonrpc_core::Response;
use leader_scheduler::LeaderScheduler;
use ledger::create_tmp_ledger_with_mint;
use mint::Mint;
use reqwest;
use reqwest::header::CONTENT_TYPE;
use rpc_request::get_rpc_request_str;
use solana_sdk::hash::{hash, Hash};
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;

View File

@ -1,14 +1,14 @@
//! The `pubsub` module implements a threaded subscription service on client RPC request
use bank::Bank;
use crate::bank::Bank;
use crate::jsonrpc_core::futures::Future;
use crate::jsonrpc_core::*;
use crate::jsonrpc_macros::pubsub;
use crate::jsonrpc_pubsub::{PubSubHandler, Session, SubscriptionId};
use crate::jsonrpc_ws_server::{RequestContext, Sender, ServerBuilder};
use crate::rpc::{JsonRpcRequestProcessor, RpcSignatureStatus};
use crate::service::Service;
use bs58;
use jsonrpc_core::futures::Future;
use jsonrpc_core::*;
use jsonrpc_macros::pubsub;
use jsonrpc_pubsub::{PubSubHandler, Session, SubscriptionId};
use jsonrpc_ws_server::{RequestContext, Sender, ServerBuilder};
use rpc::{JsonRpcRequestProcessor, RpcSignatureStatus};
use service::Service;
use solana_sdk::account::Account;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil, Signature};
@ -247,8 +247,8 @@ impl RpcSolPubSub for RpcSolPubSubImpl {
#[cfg(test)]
mod tests {
use super::*;
use jsonrpc_core::futures::sync::mpsc;
use mint::Mint;
use crate::jsonrpc_core::futures::sync::mpsc;
use crate::mint::Mint;
use solana_sdk::budget_program;
use solana_sdk::budget_transaction::BudgetTransaction;
use solana_sdk::signature::{Keypair, KeypairUtil};

View File

@ -135,8 +135,8 @@ impl error::Error for RpcError {
#[cfg(test)]
mod tests {
use super::*;
use jsonrpc_core::*;
use jsonrpc_http_server::*;
use crate::jsonrpc_core::*;
use crate::jsonrpc_http_server::*;
use serde_json::Number;
use std::net::{Ipv4Addr, SocketAddr};
use std::sync::mpsc::channel;

View File

@ -4,11 +4,11 @@
//! offloaded to the GPU.
//!
use crate::counter::Counter;
use crate::packet::{Packet, SharedPackets};
use crate::result::Result;
use byteorder::{LittleEndian, ReadBytesExt};
use counter::Counter;
use log::Level;
use packet::{Packet, SharedPackets};
use result::Result;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::Signature;
#[cfg(test)]
@ -325,16 +325,16 @@ pub fn make_packet_from_transaction(tx: Transaction) -> Packet {
#[cfg(test)]
mod tests {
use crate::packet::{Packet, SharedPackets};
use crate::sigverify;
use crate::test_tx::test_tx;
use bincode::{deserialize, serialize};
use packet::{Packet, SharedPackets};
use sigverify;
use solana_sdk::budget_program;
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_instruction::SystemInstruction;
use solana_sdk::system_program;
use solana_sdk::transaction::{Instruction, Transaction, SIG_OFFSET};
use test_tx::test_tx;
pub fn memfind<A: Eq>(a: &[A], b: &[A]) -> Option<usize> {
assert!(a.len() >= b.len());
@ -388,7 +388,7 @@ mod tests {
#[test]
fn test_system_transaction_userdata_layout() {
use packet::PACKET_DATA_SIZE;
use crate::packet::PACKET_DATA_SIZE;
let mut tx0 = test_tx();
tx0.instructions[0].userdata = vec![1, 2, 3];
let sign_data0a = tx0.get_sign_data();
@ -481,7 +481,7 @@ mod tests {
#[test]
fn test_verify_multi_sig() {
use logger;
use crate::logger;
logger::setup();
let keypair0 = Keypair::new();
let keypair1 = Keypair::new();

View File

@ -5,14 +5,15 @@
//! transaction. All processing is done on the CPU by default and on a GPU
//! if the `cuda` feature is enabled with `--features=cuda`.
use counter::Counter;
use crate::counter::Counter;
use crate::packet::SharedPackets;
use crate::result::{Error, Result};
use crate::service::Service;
use crate::sigverify;
use crate::streamer::{self, PacketReceiver};
use log::Level;
use packet::SharedPackets;
use rand::{thread_rng, Rng};
use result::{Error, Result};
use service::Service;
use sigverify;
use solana_metrics::{influxdb, submit};
use solana_sdk::timing;
use std::sync::atomic::AtomicUsize;
@ -20,7 +21,6 @@ use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender};
use std::sync::{Arc, Mutex};
use std::thread::{self, spawn, JoinHandle};
use std::time::Instant;
use streamer::{self, PacketReceiver};
pub type VerifiedPackets = Vec<(SharedPackets, Vec<u8>)>;

View File

@ -2,13 +2,13 @@
// for storage mining. Replicators submit storage proofs, validator then bundles them
// to submit its proof for mining to be rewarded.
use crate::entry::EntryReceiver;
use crate::result::{Error, Result};
use crate::service::Service;
#[cfg(all(feature = "chacha", feature = "cuda"))]
use chacha_cuda::chacha_cbc_encrypt_file_many_keys;
use entry::EntryReceiver;
use rand::{Rng, SeedableRng};
use rand_chacha::ChaChaRng;
use result::{Error, Result};
use service::Service;
use solana_sdk::hash::Hash;
use solana_sdk::signature::Keypair;
use solana_sdk::signature::Signature;
@ -266,12 +266,15 @@ impl Service for StorageStage {
#[cfg(test)]
mod tests {
use entry::Entry;
use ledger::make_tiny_test_entries;
use ledger::{create_tmp_sample_ledger, LedgerWriter};
use logger;
use crate::entry::Entry;
use crate::ledger::make_tiny_test_entries;
use crate::ledger::{create_tmp_sample_ledger, LedgerWriter};
use crate::logger;
use crate::service::Service;
use crate::storage_stage::StorageState;
use crate::storage_stage::NUM_IDENTITIES;
use crate::storage_stage::{get_identity_index_from_signature, StorageStage};
use rayon::prelude::*;
use service::Service;
use solana_sdk::hash::Hash;
use solana_sdk::hash::Hasher;
use solana_sdk::signature::{Keypair, KeypairUtil, Signature};
@ -285,9 +288,6 @@ mod tests {
use std::sync::Arc;
use std::thread::sleep;
use std::time::Duration;
use storage_stage::StorageState;
use storage_stage::NUM_IDENTITIES;
use storage_stage::{get_identity_index_from_signature, StorageStage};
#[test]
fn test_storage_stage_none_ledger() {

View File

@ -1,11 +1,11 @@
//! The `store_ledger` stores the ledger from received entries for storage nodes
use counter::Counter;
use entry::EntryReceiver;
use ledger::LedgerWriter;
use crate::counter::Counter;
use crate::entry::EntryReceiver;
use crate::ledger::LedgerWriter;
use crate::result::{Error, Result};
use crate::service::Service;
use log::Level;
use result::{Error, Result};
use service::Service;
use std::sync::atomic::AtomicUsize;
use std::sync::mpsc::RecvTimeoutError;
use std::thread::{self, Builder, JoinHandle};

View File

@ -1,8 +1,8 @@
//! The `streamer` module defines a set of services for efficiently pulling data from UDP sockets.
//!
use packet::{Blob, SharedBlobs, SharedPackets};
use result::{Error, Result};
use crate::packet::{Blob, SharedBlobs, SharedPackets};
use crate::result::{Error, Result};
use solana_metrics::{influxdb, submit};
use solana_sdk::timing::duration_as_ms;
use std::net::UdpSocket;
@ -135,7 +135,9 @@ pub fn blob_receiver(sock: Arc<UdpSocket>, exit: Arc<AtomicBool>, s: BlobSender)
#[cfg(test)]
mod test {
use packet::{Blob, Packet, Packets, SharedBlob, PACKET_DATA_SIZE};
use crate::packet::{Blob, Packet, Packets, SharedBlob, PACKET_DATA_SIZE};
use crate::streamer::PacketReceiver;
use crate::streamer::{receiver, responder};
use std::io;
use std::io::Write;
use std::net::UdpSocket;
@ -143,8 +145,6 @@ mod test {
use std::sync::mpsc::channel;
use std::sync::Arc;
use std::time::Duration;
use streamer::PacketReceiver;
use streamer::{receiver, responder};
fn get_msgs(r: PacketReceiver, num: &mut usize) {
for _t in 0..5 {

View File

@ -3,15 +3,15 @@
//! messages to the network directly. The binary encoding of its messages are
//! unstable and may change in future releases.
use bank::Bank;
use crate::bank::Bank;
use crate::cluster_info::{ClusterInfo, ClusterInfoError, NodeInfo};
use crate::gossip_service::GossipService;
use crate::packet::PACKET_DATA_SIZE;
use crate::result::{Error, Result};
use crate::rpc_request::{RpcClient, RpcRequest};
use bincode::serialize;
use bs58;
use cluster_info::{ClusterInfo, ClusterInfoError, NodeInfo};
use gossip_service::GossipService;
use log::Level;
use packet::PACKET_DATA_SIZE;
use result::{Error, Result};
use rpc_request::{RpcClient, RpcRequest};
use serde_json;
use solana_metrics;
use solana_metrics::influxdb;
@ -431,14 +431,14 @@ pub fn retry_get_balance(
#[cfg(test)]
mod tests {
use super::*;
use bank::Bank;
use crate::bank::Bank;
use crate::cluster_info::Node;
use crate::fullnode::Fullnode;
use crate::leader_scheduler::LeaderScheduler;
use crate::ledger::create_tmp_ledger_with_mint;
use crate::logger;
use crate::mint::Mint;
use bincode::deserialize;
use cluster_info::Node;
use fullnode::Fullnode;
use leader_scheduler::LeaderScheduler;
use ledger::create_tmp_ledger_with_mint;
use logger;
use mint::Mint;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_instruction::SystemInstruction;
use solana_sdk::vote_program::VoteProgram;

View File

@ -1,14 +1,14 @@
//! The `tpu` module implements the Transaction Processing Unit, a
//! 5-stage transaction processing pipeline in software.
use bank::Bank;
use banking_stage::{BankingStage, BankingStageReturnType};
use entry::Entry;
use fetch_stage::FetchStage;
use ledger_write_stage::LedgerWriteStage;
use poh_service::Config;
use service::Service;
use sigverify_stage::SigVerifyStage;
use crate::bank::Bank;
use crate::banking_stage::{BankingStage, BankingStageReturnType};
use crate::entry::Entry;
use crate::fetch_stage::FetchStage;
use crate::ledger_write_stage::LedgerWriteStage;
use crate::poh_service::Config;
use crate::service::Service;
use crate::sigverify_stage::SigVerifyStage;
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use std::net::UdpSocket;

View File

@ -2,18 +2,18 @@
//! transaction processing unit responsibility, which
//! forwards received packets to the current leader
use cluster_info::ClusterInfo;
use contact_info::ContactInfo;
use counter::Counter;
use crate::cluster_info::ClusterInfo;
use crate::contact_info::ContactInfo;
use crate::counter::Counter;
use crate::result::Result;
use crate::service::Service;
use crate::streamer::{self, PacketReceiver};
use log::Level;
use result::Result;
use service::Service;
use std::net::UdpSocket;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::mpsc::channel;
use std::sync::{Arc, RwLock};
use std::thread::{self, Builder, JoinHandle};
use streamer::{self, PacketReceiver};
pub struct TpuForwarder {
exit: Arc<AtomicBool>,
@ -105,9 +105,9 @@ impl Service for TpuForwarder {
#[cfg(test)]
mod tests {
use super::*;
use cluster_info::ClusterInfo;
use contact_info::ContactInfo;
use netutil::bind_in_range;
use crate::cluster_info::ClusterInfo;
use crate::contact_info::ContactInfo;
use crate::netutil::bind_in_range;
use solana_sdk::pubkey::Pubkey;
use std::net::UdpSocket;
use std::net::{Ipv4Addr, SocketAddr};

View File

@ -10,21 +10,21 @@
//! - Transactions in blobs are processed and applied to the bank.
//! - TODO We need to verify the signatures in the blobs.
use bank::Bank;
use blob_fetch_stage::BlobFetchStage;
use cluster_info::ClusterInfo;
use db_ledger::DbLedger;
use ledger_write_stage::LedgerWriteStage;
use replicate_stage::{ReplicateStage, ReplicateStageReturnType};
use retransmit_stage::RetransmitStage;
use service::Service;
use crate::bank::Bank;
use crate::blob_fetch_stage::BlobFetchStage;
use crate::cluster_info::ClusterInfo;
use crate::db_ledger::DbLedger;
use crate::ledger_write_stage::LedgerWriteStage;
use crate::replicate_stage::{ReplicateStage, ReplicateStageReturnType};
use crate::retransmit_stage::RetransmitStage;
use crate::service::Service;
use crate::storage_stage::StorageStage;
use solana_sdk::hash::Hash;
use solana_sdk::signature::Keypair;
use std::net::UdpSocket;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, RwLock};
use std::thread;
use storage_stage::StorageStage;
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum TvuReturnType {
@ -163,19 +163,22 @@ impl Service for Tvu {
#[cfg(test)]
pub mod tests {
use bank::Bank;
use crate::bank::Bank;
use crate::cluster_info::{ClusterInfo, Node};
use crate::db_ledger::DbLedger;
use crate::entry::Entry;
use crate::gossip_service::GossipService;
use crate::leader_scheduler::LeaderScheduler;
use crate::ledger::get_tmp_ledger_path;
use crate::logger;
use crate::mint::Mint;
use crate::packet::SharedBlob;
use crate::service::Service;
use crate::streamer;
use crate::tvu::Tvu;
use crate::window::{self, SharedWindow};
use bincode::serialize;
use cluster_info::{ClusterInfo, Node};
use db_ledger::DbLedger;
use entry::Entry;
use gossip_service::GossipService;
use leader_scheduler::LeaderScheduler;
use ledger::get_tmp_ledger_path;
use logger;
use mint::Mint;
use packet::SharedBlob;
use rocksdb::{Options, DB};
use service::Service;
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
@ -186,9 +189,6 @@ pub mod tests {
use std::sync::mpsc::channel;
use std::sync::{Arc, RwLock};
use std::time::Duration;
use streamer;
use tvu::Tvu;
use window::{self, SharedWindow};
fn new_ncp(
cluster_info: Arc<RwLock<ClusterInfo>>,

View File

@ -1,12 +1,13 @@
//! The `vote_stage` votes on the `last_id` of the bank at a regular cadence
use bank::Bank;
use crate::bank::Bank;
use crate::cluster_info::ClusterInfo;
use crate::counter::Counter;
use crate::packet::SharedBlob;
use crate::result::{Error, Result};
use crate::streamer::BlobSender;
use bincode::serialize;
use cluster_info::ClusterInfo;
use counter::Counter;
use log::Level;
use packet::SharedBlob;
use result::{Error, Result};
use solana_sdk::hash::Hash;
use solana_sdk::signature::Keypair;
use solana_sdk::transaction::Transaction;
@ -15,7 +16,6 @@ use solana_sdk::vote_transaction::VoteTransaction;
use std::net::SocketAddr;
use std::sync::atomic::AtomicUsize;
use std::sync::{Arc, RwLock};
use streamer::BlobSender;
#[derive(Debug, PartialEq, Eq)]
pub enum VoteError {

View File

@ -1,13 +1,14 @@
use crate::fullnode::Config;
use crate::rpc::RpcSignatureStatus;
use crate::rpc_request::{get_rpc_request_str, RpcClient, RpcRequest};
use crate::thin_client::poll_gossip_for_leader;
use bincode::serialize;
use bs58;
use chrono::prelude::*;
use clap::ArgMatches;
use elf;
use fullnode::Config;
use ring::rand::SystemRandom;
use ring::signature::Ed25519KeyPair;
use rpc::RpcSignatureStatus;
use rpc_request::{get_rpc_request_str, RpcClient, RpcRequest};
use serde_json;
use solana_drone::drone::{request_airdrop_transaction, DRONE_PORT};
use solana_sdk::bpf_loader;
@ -27,7 +28,6 @@ use std::str::FromStr;
use std::thread::sleep;
use std::time::Duration;
use std::{error, fmt, mem};
use thin_client::poll_gossip_for_leader;
const PLATFORM_SECTION_C: &str = ".text.entrypoint";
const USERDATA_CHUNK_SIZE: usize = 256;
@ -768,12 +768,12 @@ fn send_and_confirm_tx(rpc_client: &RpcClient, tx: &Transaction) -> Result<(), B
#[cfg(test)]
mod tests {
use super::*;
use bank::Bank;
use crate::bank::Bank;
use crate::cluster_info::Node;
use crate::fullnode::Fullnode;
use crate::leader_scheduler::LeaderScheduler;
use crate::ledger::create_tmp_genesis;
use clap::{App, Arg, SubCommand};
use cluster_info::Node;
use fullnode::Fullnode;
use leader_scheduler::LeaderScheduler;
use ledger::create_tmp_genesis;
use serde_json::Value;
use solana_drone::drone::run_local_drone;
use solana_sdk::signature::{read_keypair, read_pkcs8, Keypair, KeypairUtil};

View File

@ -1,12 +1,12 @@
//! The `window` module defines data structure for storing the tail of the ledger.
//!
use cluster_info::ClusterInfo;
use counter::Counter;
use entry::reconstruct_entries_from_blobs;
use entry::Entry;
use leader_scheduler::LeaderScheduler;
use crate::cluster_info::ClusterInfo;
use crate::counter::Counter;
use crate::entry::reconstruct_entries_from_blobs;
use crate::entry::Entry;
use crate::leader_scheduler::LeaderScheduler;
use crate::packet::SharedBlob;
use log::Level;
use packet::SharedBlob;
use solana_sdk::pubkey::Pubkey;
use std::cmp;
use std::mem;
@ -398,7 +398,9 @@ pub fn default_window() -> Window {
#[cfg(test)]
mod test {
use packet::{Blob, Packet, Packets, SharedBlob, PACKET_DATA_SIZE};
use crate::packet::{Blob, Packet, Packets, SharedBlob, PACKET_DATA_SIZE};
use crate::streamer::{receiver, responder, PacketReceiver};
use crate::window::{calculate_max_repair, new_window, Window, WindowUtil};
use solana_sdk::pubkey::Pubkey;
use std::io;
use std::io::Write;
@ -407,8 +409,6 @@ mod test {
use std::sync::mpsc::channel;
use std::sync::Arc;
use std::time::Duration;
use streamer::{receiver, responder, PacketReceiver};
use window::{calculate_max_repair, new_window, Window, WindowUtil};
fn get_msgs(r: PacketReceiver, num: &mut usize) {
for _t in 0..5 {

View File

@ -1,15 +1,16 @@
//! The `window_service` provides a thread for maintaining a window (tail of the ledger).
//!
use cluster_info::ClusterInfo;
use counter::Counter;
use db_ledger::{DbLedger, LedgerColumnFamily, MetaCf, DEFAULT_SLOT_HEIGHT};
use db_window::*;
use entry::EntrySender;
use crate::cluster_info::ClusterInfo;
use crate::counter::Counter;
use crate::db_ledger::{DbLedger, LedgerColumnFamily, MetaCf, DEFAULT_SLOT_HEIGHT};
use crate::db_window::*;
use crate::entry::EntrySender;
use leader_scheduler::LeaderScheduler;
use crate::leader_scheduler::LeaderScheduler;
use crate::result::{Error, Result};
use crate::streamer::{BlobReceiver, BlobSender};
use log::Level;
use rand::{thread_rng, Rng};
use result::{Error, Result};
use solana_metrics::{influxdb, submit};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::timing::duration_as_ms;
@ -20,7 +21,6 @@ use std::sync::mpsc::RecvTimeoutError;
use std::sync::{Arc, RwLock};
use std::thread::{Builder, JoinHandle};
use std::time::{Duration, Instant};
use streamer::{BlobReceiver, BlobSender};
pub const MAX_REPAIR_BACKOFF: usize = 128;
@ -227,13 +227,15 @@ pub fn window_service(
#[cfg(test)]
mod test {
use cluster_info::{ClusterInfo, Node};
use db_ledger::DbLedger;
use entry::Entry;
use leader_scheduler::LeaderScheduler;
use ledger::get_tmp_ledger_path;
use logger;
use packet::{make_consecutive_blobs, SharedBlob, PACKET_DATA_SIZE};
use crate::cluster_info::{ClusterInfo, Node};
use crate::db_ledger::DbLedger;
use crate::entry::Entry;
use crate::leader_scheduler::LeaderScheduler;
use crate::ledger::get_tmp_ledger_path;
use crate::logger;
use crate::packet::{make_consecutive_blobs, SharedBlob, PACKET_DATA_SIZE};
use crate::streamer::{blob_receiver, responder};
use crate::window_service::{repair_backoff, window_service};
use rocksdb::{Options, DB};
use solana_sdk::hash::Hash;
use std::fs::remove_dir_all;
@ -242,8 +244,6 @@ mod test {
use std::sync::mpsc::{channel, Receiver};
use std::sync::{Arc, RwLock};
use std::time::Duration;
use streamer::{blob_receiver, responder};
use window_service::{repair_backoff, window_service};
fn get_entries(r: Receiver<Vec<Entry>>, num: &mut usize) {
for _t in 0..5 {