Reformat imports to a consistent style for imports

rustfmt.toml configuration:
  imports_granularity = "One"
  group_imports = "One"
This commit is contained in:
Michael Vines
2021-12-03 09:00:31 -08:00
parent 0ef1b25e4b
commit b8837c04ec
397 changed files with 5990 additions and 5175 deletions

View File

@ -3,41 +3,44 @@
extern crate test;
use crossbeam_channel::unbounded;
use log::*;
use rand::{thread_rng, Rng};
use rayon::prelude::*;
use solana_core::banking_stage::{BankingStage, BankingStageStats};
use solana_core::qos_service::QosService;
use solana_entry::entry::{next_hash, Entry};
use solana_gossip::cluster_info::ClusterInfo;
use solana_gossip::cluster_info::Node;
use solana_ledger::blockstore_processor::process_entries_for_tests;
use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};
use solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path};
use solana_perf::packet::to_packets_chunked;
use solana_perf::test_tx::test_tx;
use solana_poh::poh_recorder::{create_test_recorder, WorkingBankEntry};
use solana_runtime::bank::Bank;
use solana_runtime::cost_model::CostModel;
use solana_sdk::genesis_config::GenesisConfig;
use solana_sdk::hash::Hash;
use solana_sdk::message::Message;
use solana_sdk::pubkey;
use solana_sdk::signature::Keypair;
use solana_sdk::signature::Signature;
use solana_sdk::signature::Signer;
use solana_sdk::system_instruction;
use solana_sdk::system_transaction;
use solana_sdk::timing::{duration_as_us, timestamp};
use solana_sdk::transaction::{Transaction, VersionedTransaction};
use solana_streamer::socket::SocketAddrSpace;
use std::collections::VecDeque;
use std::sync::atomic::Ordering;
use std::sync::mpsc::Receiver;
use std::sync::{Arc, RwLock};
use std::time::{Duration, Instant};
use test::Bencher;
use {
crossbeam_channel::unbounded,
log::*,
rand::{thread_rng, Rng},
rayon::prelude::*,
solana_core::{
banking_stage::{BankingStage, BankingStageStats},
qos_service::QosService,
},
solana_entry::entry::{next_hash, Entry},
solana_gossip::cluster_info::{ClusterInfo, Node},
solana_ledger::{
blockstore::Blockstore,
blockstore_processor::process_entries_for_tests,
genesis_utils::{create_genesis_config, GenesisConfigInfo},
get_tmp_ledger_path,
},
solana_perf::{packet::to_packets_chunked, test_tx::test_tx},
solana_poh::poh_recorder::{create_test_recorder, WorkingBankEntry},
solana_runtime::{bank::Bank, cost_model::CostModel},
solana_sdk::{
genesis_config::GenesisConfig,
hash::Hash,
message::Message,
pubkey,
signature::{Keypair, Signature, Signer},
system_instruction, system_transaction,
timing::{duration_as_us, timestamp},
transaction::{Transaction, VersionedTransaction},
},
solana_streamer::socket::SocketAddrSpace,
std::{
collections::VecDeque,
sync::{atomic::Ordering, mpsc::Receiver, Arc, RwLock},
time::{Duration, Instant},
},
test::Bencher,
};
fn check_txs(receiver: &Arc<Receiver<WorkingBankEntry>>, ref_tx_count: usize) {
let mut total = 0;

View File

@ -7,8 +7,7 @@ use {
solana_core::{
consensus::Tower, tower_storage::FileTowerStorage, vote_simulator::VoteSimulator,
},
solana_runtime::bank::Bank,
solana_runtime::bank_forks::BankForks,
solana_runtime::{bank::Bank, bank_forks::BankForks},
solana_sdk::{
pubkey::Pubkey,
signature::{Keypair, Signer},

View File

@ -2,8 +2,7 @@
extern crate test;
use solana_core::gen_keys::GenKeys;
use test::Bencher;
use {solana_core::gen_keys::GenKeys, test::Bencher};
#[bench]
fn bench_gen_keys(b: &mut Bencher) {

View File

@ -3,18 +3,19 @@
extern crate test;
use rand::seq::SliceRandom;
use raptorq::{Decoder, Encoder};
use solana_entry::entry::{create_ticks, Entry};
use solana_ledger::shred::{
max_entries_per_n_shred, max_ticks_per_n_shreds, ProcessShredsStats, Shred, Shredder,
MAX_DATA_SHREDS_PER_FEC_BLOCK, SHRED_PAYLOAD_SIZE, SIZE_OF_CODING_SHRED_HEADERS,
SIZE_OF_DATA_SHRED_PAYLOAD,
use {
rand::seq::SliceRandom,
raptorq::{Decoder, Encoder},
solana_entry::entry::{create_ticks, Entry},
solana_ledger::shred::{
max_entries_per_n_shred, max_ticks_per_n_shreds, ProcessShredsStats, Shred, Shredder,
MAX_DATA_SHREDS_PER_FEC_BLOCK, SHRED_PAYLOAD_SIZE, SIZE_OF_CODING_SHRED_HEADERS,
SIZE_OF_DATA_SHRED_PAYLOAD,
},
solana_perf::test_tx,
solana_sdk::{hash::Hash, signature::Keypair},
test::Bencher,
};
use solana_perf::test_tx;
use solana_sdk::hash::Hash;
use solana_sdk::signature::Keypair;
use test::Bencher;
fn make_test_entry(txs_per_entry: u64) -> Entry {
Entry {

View File

@ -3,20 +3,24 @@
extern crate solana_core;
extern crate test;
use crossbeam_channel::unbounded;
use log::*;
use rand::{thread_rng, Rng};
use solana_core::sigverify::TransactionSigVerifier;
use solana_core::sigverify_stage::SigVerifyStage;
use solana_perf::packet::to_packets_chunked;
use solana_perf::test_tx::test_tx;
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, Signer};
use solana_sdk::system_transaction;
use solana_sdk::timing::duration_as_ms;
use std::sync::mpsc::channel;
use std::time::{Duration, Instant};
use test::Bencher;
use {
crossbeam_channel::unbounded,
log::*,
rand::{thread_rng, Rng},
solana_core::{sigverify::TransactionSigVerifier, sigverify_stage::SigVerifyStage},
solana_perf::{packet::to_packets_chunked, test_tx::test_tx},
solana_sdk::{
hash::Hash,
signature::{Keypair, Signer},
system_transaction,
timing::duration_as_ms,
},
std::{
sync::mpsc::channel,
time::{Duration, Instant},
},
test::Bencher,
};
#[bench]
fn bench_packet_discard(bencher: &mut Bencher) {

View File

@ -4,30 +4,32 @@
// hash on gossip. Monitor gossip for messages from validators in the `--known-validator`s
// set and halt the node if a mismatch is detected.
use rayon::ThreadPool;
use solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES};
use solana_measure::measure::Measure;
use solana_runtime::{
accounts_db::{self, AccountsDb},
accounts_hash::HashStats,
snapshot_config::SnapshotConfig,
snapshot_package::{
AccountsPackage, AccountsPackageReceiver, PendingSnapshotPackage, SnapshotPackage,
SnapshotType,
use {
rayon::ThreadPool,
solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES},
solana_measure::measure::Measure,
solana_runtime::{
accounts_db::{self, AccountsDb},
accounts_hash::HashStats,
snapshot_config::SnapshotConfig,
snapshot_package::{
AccountsPackage, AccountsPackageReceiver, PendingSnapshotPackage, SnapshotPackage,
SnapshotType,
},
sorted_storages::SortedStorages,
},
sorted_storages::SortedStorages,
};
use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey};
use std::collections::{HashMap, HashSet};
use std::{
path::{Path, PathBuf},
sync::{
atomic::{AtomicBool, Ordering},
mpsc::RecvTimeoutError,
Arc,
solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey},
std::{
collections::{HashMap, HashSet},
path::{Path, PathBuf},
sync::{
atomic::{AtomicBool, Ordering},
mpsc::RecvTimeoutError,
Arc,
},
thread::{self, Builder, JoinHandle},
time::Duration,
},
thread::{self, Builder, JoinHandle},
time::Duration,
};
pub struct AccountsHashVerifier {
@ -163,8 +165,10 @@ impl AccountsHashVerifier {
&& accounts_package.slot % fault_injection_rate_slots == 0
{
// For testing, publish an invalid hash to gossip.
use rand::{thread_rng, Rng};
use solana_sdk::hash::extend_and_hash;
use {
rand::{thread_rng, Rng},
solana_sdk::hash::extend_and_hash,
};
warn!("inserting fault at slot: {}", accounts_package.slot);
let rand = thread_rng().gen_range(0, 10);
let hash = extend_and_hash(&hash, &[rand]);
@ -277,15 +281,17 @@ impl AccountsHashVerifier {
#[cfg(test)]
mod tests {
use super::*;
use solana_gossip::{cluster_info::make_accounts_hashes_message, contact_info::ContactInfo};
use solana_runtime::snapshot_utils::{ArchiveFormat, SnapshotVersion};
use solana_sdk::{
genesis_config::ClusterType,
hash::hash,
signature::{Keypair, Signer},
use {
super::*,
solana_gossip::{cluster_info::make_accounts_hashes_message, contact_info::ContactInfo},
solana_runtime::snapshot_utils::{ArchiveFormat, SnapshotVersion},
solana_sdk::{
genesis_config::ClusterType,
hash::hash,
signature::{Keypair, Signer},
},
solana_streamer::socket::SocketAddrSpace,
};
use solana_streamer::socket::SocketAddrSpace;
fn new_test_cluster_info(contact_info: ContactInfo) -> ClusterInfo {
ClusterInfo::new(
@ -331,8 +337,7 @@ mod tests {
#[test]
fn test_max_hashes() {
solana_logger::setup();
use std::path::PathBuf;
use tempfile::TempDir;
use {std::path::PathBuf, tempfile::TempDir};
let keypair = Keypair::new();
let contact_info = ContactInfo::new_localhost(&keypair.pubkey(), 0);

View File

@ -1,38 +1,40 @@
use crate::{
cluster_slots::ClusterSlots,
duplicate_repair_status::{DeadSlotAncestorRequestStatus, DuplicateAncestorDecision},
outstanding_requests::OutstandingRequests,
repair_response::{self},
repair_service::{DuplicateSlotsResetSender, RepairInfo, RepairStatsGroup},
replay_stage::DUPLICATE_THRESHOLD,
result::{Error, Result},
serve_repair::{AncestorHashesRepairType, ServeRepair},
};
use crossbeam_channel::{unbounded, Receiver, Sender};
use dashmap::{mapref::entry::Entry::Occupied, DashMap};
use solana_ledger::{blockstore::Blockstore, shred::SIZE_OF_NONCE};
use solana_measure::measure::Measure;
use solana_perf::{
packet::{limited_deserialize, Packet, Packets},
recycler::Recycler,
};
use solana_runtime::bank::Bank;
use solana_sdk::{
clock::{Slot, SLOT_MS},
pubkey::Pubkey,
timing::timestamp,
};
use solana_streamer::streamer::{self, PacketReceiver};
use std::{
collections::HashSet,
net::UdpSocket,
sync::{
atomic::{AtomicBool, Ordering},
mpsc::channel,
{Arc, RwLock},
use {
crate::{
cluster_slots::ClusterSlots,
duplicate_repair_status::{DeadSlotAncestorRequestStatus, DuplicateAncestorDecision},
outstanding_requests::OutstandingRequests,
repair_response::{self},
repair_service::{DuplicateSlotsResetSender, RepairInfo, RepairStatsGroup},
replay_stage::DUPLICATE_THRESHOLD,
result::{Error, Result},
serve_repair::{AncestorHashesRepairType, ServeRepair},
},
crossbeam_channel::{unbounded, Receiver, Sender},
dashmap::{mapref::entry::Entry::Occupied, DashMap},
solana_ledger::{blockstore::Blockstore, shred::SIZE_OF_NONCE},
solana_measure::measure::Measure,
solana_perf::{
packet::{limited_deserialize, Packet, Packets},
recycler::Recycler,
},
solana_runtime::bank::Bank,
solana_sdk::{
clock::{Slot, SLOT_MS},
pubkey::Pubkey,
timing::timestamp,
},
solana_streamer::streamer::{self, PacketReceiver},
std::{
collections::HashSet,
net::UdpSocket,
sync::{
atomic::{AtomicBool, Ordering},
mpsc::channel,
Arc, RwLock,
},
thread::{self, sleep, Builder, JoinHandle},
time::{Duration, Instant},
},
thread::{self, sleep, Builder, JoinHandle},
time::{Duration, Instant},
};
#[derive(Debug, PartialEq)]
@ -681,27 +683,29 @@ impl AncestorHashesService {
#[cfg(test)]
mod test {
use super::*;
use crate::{
cluster_slot_state_verifier::DuplicateSlotsToRepair,
repair_service::DuplicateSlotsResetReceiver,
replay_stage::{
tests::{replay_blockstore_components, ReplayBlockstoreComponents},
ReplayStage,
use {
super::*,
crate::{
cluster_slot_state_verifier::DuplicateSlotsToRepair,
repair_service::DuplicateSlotsResetReceiver,
replay_stage::{
tests::{replay_blockstore_components, ReplayBlockstoreComponents},
ReplayStage,
},
serve_repair::MAX_ANCESTOR_RESPONSES,
vote_simulator::VoteSimulator,
},
serve_repair::MAX_ANCESTOR_RESPONSES,
vote_simulator::VoteSimulator,
solana_gossip::{
cluster_info::{ClusterInfo, Node},
contact_info::ContactInfo,
},
solana_ledger::{blockstore::make_many_slot_entries, get_tmp_ledger_path},
solana_runtime::{accounts_background_service::AbsRequestSender, bank_forks::BankForks},
solana_sdk::{hash::Hash, signature::Keypair},
solana_streamer::socket::SocketAddrSpace,
std::{collections::HashMap, sync::mpsc::channel},
trees::tr,
};
use solana_gossip::{
cluster_info::{ClusterInfo, Node},
contact_info::ContactInfo,
};
use solana_ledger::{blockstore::make_many_slot_entries, get_tmp_ledger_path};
use solana_runtime::{accounts_background_service::AbsRequestSender, bank_forks::BankForks};
use solana_sdk::{hash::Hash, signature::Keypair};
use solana_streamer::socket::SocketAddrSpace;
use std::{collections::HashMap, sync::mpsc::channel};
use trees::tr;
#[test]
pub fn test_ancestor_hashes_service_process_replay_updates() {

View File

@ -1,63 +1,66 @@
//! The `banking_stage` processes Transaction messages. It is intended to be used
//! 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 crate::{packet_hasher::PacketHasher, qos_service::QosService};
use crossbeam_channel::{Receiver as CrossbeamReceiver, RecvTimeoutError};
use itertools::Itertools;
use lru::LruCache;
use retain_mut::RetainMut;
use solana_entry::entry::hash_transactions;
use solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo};
use solana_ledger::blockstore_processor::TransactionStatusSender;
use solana_measure::measure::Measure;
use solana_metrics::{inc_new_counter_debug, inc_new_counter_info};
use solana_perf::{
cuda_runtime::PinnedVec,
data_budget::DataBudget,
packet::{limited_deserialize, Packet, Packets, PACKETS_PER_BATCH},
perf_libs,
};
use solana_poh::poh_recorder::{BankStart, PohRecorder, PohRecorderError, TransactionRecorder};
use solana_runtime::{
accounts_db::ErrorCounters,
bank::{
Bank, ExecuteTimings, TransactionBalancesSet, TransactionCheckResult,
TransactionExecutionResult,
use {
crate::{packet_hasher::PacketHasher, qos_service::QosService},
crossbeam_channel::{Receiver as CrossbeamReceiver, RecvTimeoutError},
itertools::Itertools,
lru::LruCache,
retain_mut::RetainMut,
solana_entry::entry::hash_transactions,
solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo},
solana_ledger::blockstore_processor::TransactionStatusSender,
solana_measure::measure::Measure,
solana_metrics::{inc_new_counter_debug, inc_new_counter_info},
solana_perf::{
cuda_runtime::PinnedVec,
data_budget::DataBudget,
packet::{limited_deserialize, Packet, Packets, PACKETS_PER_BATCH},
perf_libs,
},
bank_utils,
cost_model::CostModel,
transaction_batch::TransactionBatch,
vote_sender_types::ReplayVoteSender,
};
use solana_sdk::{
clock::{
Slot, DEFAULT_TICKS_PER_SLOT, MAX_PROCESSING_AGE, MAX_TRANSACTION_FORWARDING_DELAY,
MAX_TRANSACTION_FORWARDING_DELAY_GPU,
solana_poh::poh_recorder::{BankStart, PohRecorder, PohRecorderError, TransactionRecorder},
solana_runtime::{
accounts_db::ErrorCounters,
bank::{
Bank, ExecuteTimings, TransactionBalancesSet, TransactionCheckResult,
TransactionExecutionResult,
},
bank_utils,
cost_model::CostModel,
transaction_batch::TransactionBatch,
vote_sender_types::ReplayVoteSender,
},
solana_sdk::{
clock::{
Slot, DEFAULT_TICKS_PER_SLOT, MAX_PROCESSING_AGE, MAX_TRANSACTION_FORWARDING_DELAY,
MAX_TRANSACTION_FORWARDING_DELAY_GPU,
},
feature_set,
message::Message,
pubkey::Pubkey,
short_vec::decode_shortu16_len,
signature::Signature,
timing::{duration_as_ms, timestamp, AtomicInterval},
transaction::{self, SanitizedTransaction, TransactionError, VersionedTransaction},
},
solana_streamer::sendmmsg::{batch_send, SendPktsError},
solana_transaction_status::token_balances::{
collect_token_balances, TransactionTokenBalancesSet,
},
std::{
cmp,
collections::{HashMap, VecDeque},
env,
mem::size_of,
net::{SocketAddr, UdpSocket},
ops::DerefMut,
sync::{
atomic::{AtomicU64, AtomicUsize, Ordering},
Arc, Mutex, RwLock,
},
thread::{self, Builder, JoinHandle},
time::{Duration, Instant},
},
feature_set,
message::Message,
pubkey::Pubkey,
short_vec::decode_shortu16_len,
signature::Signature,
timing::{duration_as_ms, timestamp, AtomicInterval},
transaction::{self, SanitizedTransaction, TransactionError, VersionedTransaction},
};
use solana_streamer::sendmmsg::{batch_send, SendPktsError};
use solana_transaction_status::token_balances::{
collect_token_balances, TransactionTokenBalancesSet,
};
use std::{
cmp,
collections::{HashMap, VecDeque},
env,
mem::size_of,
net::{SocketAddr, UdpSocket},
ops::DerefMut,
sync::atomic::{AtomicU64, AtomicUsize, Ordering},
sync::{Arc, Mutex, RwLock},
thread::{self, Builder, JoinHandle},
time::Duration,
time::Instant,
};
/// (packets, valid_indexes, forwarded)
@ -1545,43 +1548,45 @@ where
#[cfg(test)]
mod tests {
use super::*;
use crossbeam_channel::unbounded;
use itertools::Itertools;
use solana_entry::entry::{next_entry, Entry, EntrySlice};
use solana_gossip::{cluster_info::Node, contact_info::ContactInfo};
use solana_ledger::{
blockstore::{entries_to_test_shreds, Blockstore},
genesis_utils::{create_genesis_config, GenesisConfigInfo},
get_tmp_ledger_path,
leader_schedule_cache::LeaderScheduleCache,
};
use solana_perf::packet::to_packets_chunked;
use solana_poh::{
poh_recorder::{create_test_recorder, Record, WorkingBankEntry},
poh_service::PohService,
};
use solana_rpc::transaction_status_service::TransactionStatusService;
use solana_sdk::{
hash::Hash,
instruction::InstructionError,
poh_config::PohConfig,
signature::{Keypair, Signer},
system_instruction::SystemError,
system_transaction,
transaction::{Transaction, TransactionError},
};
use solana_streamer::socket::SocketAddrSpace;
use solana_transaction_status::TransactionWithStatusMeta;
use solana_vote_program::vote_transaction;
use std::{
net::SocketAddr,
path::Path,
sync::{
atomic::{AtomicBool, Ordering},
mpsc::Receiver,
use {
super::*,
crossbeam_channel::unbounded,
itertools::Itertools,
solana_entry::entry::{next_entry, Entry, EntrySlice},
solana_gossip::{cluster_info::Node, contact_info::ContactInfo},
solana_ledger::{
blockstore::{entries_to_test_shreds, Blockstore},
genesis_utils::{create_genesis_config, GenesisConfigInfo},
get_tmp_ledger_path,
leader_schedule_cache::LeaderScheduleCache,
},
solana_perf::packet::to_packets_chunked,
solana_poh::{
poh_recorder::{create_test_recorder, Record, WorkingBankEntry},
poh_service::PohService,
},
solana_rpc::transaction_status_service::TransactionStatusService,
solana_sdk::{
hash::Hash,
instruction::InstructionError,
poh_config::PohConfig,
signature::{Keypair, Signer},
system_instruction::SystemError,
system_transaction,
transaction::{Transaction, TransactionError},
},
solana_streamer::socket::SocketAddrSpace,
solana_transaction_status::TransactionWithStatusMeta,
solana_vote_program::vote_transaction,
std::{
net::SocketAddr,
path::Path,
sync::{
atomic::{AtomicBool, Ordering},
mpsc::Receiver,
},
thread::sleep,
},
thread::sleep,
};
fn new_test_cluster_info(contact_info: ContactInfo) -> ClusterInfo {

View File

@ -24,8 +24,10 @@ use {
solana_poh::poh_recorder::WorkingBankEntry,
solana_runtime::{bank::Bank, bank_forks::BankForks},
solana_sdk::{
clock::Slot,
pubkey::Pubkey,
signature::Keypair,
timing::{timestamp, AtomicInterval},
{clock::Slot, pubkey::Pubkey, signature::Keypair},
},
solana_streamer::{
sendmmsg::{batch_send, SendPktsError},
@ -452,24 +454,28 @@ pub fn broadcast_shreds(
#[cfg(test)]
pub mod test {
use super::*;
use crossbeam_channel::unbounded;
use solana_entry::entry::create_ticks;
use solana_gossip::cluster_info::{ClusterInfo, Node};
use solana_ledger::{
blockstore::{make_slot_entries, Blockstore},
genesis_utils::{create_genesis_config, GenesisConfigInfo},
get_tmp_ledger_path,
shred::{max_ticks_per_n_shreds, ProcessShredsStats, Shredder},
};
use solana_runtime::bank::Bank;
use solana_sdk::{
hash::Hash,
pubkey::Pubkey,
signature::{Keypair, Signer},
};
use std::{
path::Path, sync::atomic::AtomicBool, sync::mpsc::channel, sync::Arc, thread::sleep,
use {
super::*,
crossbeam_channel::unbounded,
solana_entry::entry::create_ticks,
solana_gossip::cluster_info::{ClusterInfo, Node},
solana_ledger::{
blockstore::{make_slot_entries, Blockstore},
genesis_utils::{create_genesis_config, GenesisConfigInfo},
get_tmp_ledger_path,
shred::{max_ticks_per_n_shreds, ProcessShredsStats, Shredder},
},
solana_runtime::bank::Bank,
solana_sdk::{
hash::Hash,
pubkey::Pubkey,
signature::{Keypair, Signer},
},
std::{
path::Path,
sync::{atomic::AtomicBool, mpsc::channel, Arc},
thread::sleep,
},
};
#[allow(clippy::implicit_hasher)]

View File

@ -1,8 +1,9 @@
use super::*;
use solana_entry::entry::Entry;
use solana_ledger::shred::Shredder;
use solana_sdk::hash::Hash;
use solana_sdk::signature::Keypair;
use {
super::*,
solana_entry::entry::Entry,
solana_ledger::shred::Shredder,
solana_sdk::{hash::Hash, signature::Keypair},
};
#[derive(Clone)]
pub(super) struct BroadcastFakeShredsRun {
@ -139,10 +140,12 @@ impl BroadcastRun for BroadcastFakeShredsRun {
#[cfg(test)]
mod tests {
use super::*;
use solana_gossip::contact_info::ContactInfo;
use solana_streamer::socket::SocketAddrSpace;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use {
super::*,
solana_gossip::contact_info::ContactInfo,
solana_streamer::socket::SocketAddrSpace,
std::net::{IpAddr, Ipv4Addr, SocketAddr},
};
#[test]
fn test_tvu_peers_ordering() {

View File

@ -1,13 +1,14 @@
use crate::result::Result;
use solana_entry::entry::Entry;
use solana_ledger::shred::Shred;
use solana_poh::poh_recorder::WorkingBankEntry;
use solana_runtime::bank::Bank;
use solana_sdk::clock::Slot;
use std::{
sync::mpsc::Receiver,
sync::Arc,
time::{Duration, Instant},
use {
crate::result::Result,
solana_entry::entry::Entry,
solana_ledger::shred::Shred,
solana_poh::poh_recorder::WorkingBankEntry,
solana_runtime::bank::Bank,
solana_sdk::clock::Slot,
std::{
sync::{mpsc::Receiver, Arc},
time::{Duration, Instant},
},
};
pub(super) struct ReceiveResults {
@ -80,13 +81,15 @@ pub(super) fn recv_slot_entries(receiver: &Receiver<WorkingBankEntry>) -> Result
#[cfg(test)]
mod tests {
use super::*;
use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};
use solana_sdk::genesis_config::GenesisConfig;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::system_transaction;
use solana_sdk::transaction::Transaction;
use std::sync::mpsc::channel;
use {
super::*,
solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo},
solana_sdk::{
genesis_config::GenesisConfig, pubkey::Pubkey, system_transaction,
transaction::Transaction,
},
std::sync::mpsc::channel,
};
fn setup_test() -> (GenesisConfig, Arc<Bank>, Transaction) {
let GenesisConfigInfo {

View File

@ -508,22 +508,22 @@ impl BroadcastRun for StandardBroadcastRun {
#[cfg(test)]
mod test {
use super::*;
use solana_entry::entry::create_ticks;
use solana_gossip::cluster_info::{ClusterInfo, Node};
use solana_ledger::genesis_utils::create_genesis_config;
use solana_ledger::{
blockstore::Blockstore, get_tmp_ledger_path, shred::max_ticks_per_n_shreds,
use {
super::*,
solana_entry::entry::create_ticks,
solana_gossip::cluster_info::{ClusterInfo, Node},
solana_ledger::{
blockstore::Blockstore, genesis_utils::create_genesis_config, get_tmp_ledger_path,
shred::max_ticks_per_n_shreds,
},
solana_runtime::bank::Bank,
solana_sdk::{
genesis_config::GenesisConfig,
signature::{Keypair, Signer},
},
solana_streamer::socket::SocketAddrSpace,
std::{ops::Deref, sync::Arc, time::Duration},
};
use solana_runtime::bank::Bank;
use solana_sdk::{
genesis_config::GenesisConfig,
signature::{Keypair, Signer},
};
use solana_streamer::socket::SocketAddrSpace;
use std::ops::Deref;
use std::sync::Arc;
use std::time::Duration;
#[allow(clippy::type_complexity)]
fn setup(

View File

@ -1,56 +1,59 @@
use crate::{
optimistic_confirmation_verifier::OptimisticConfirmationVerifier,
replay_stage::DUPLICATE_THRESHOLD,
result::{Error, Result},
sigverify,
verified_vote_packets::{
ValidatorGossipVotesIterator, VerifiedVoteMetadata, VerifiedVotePackets,
use {
crate::{
optimistic_confirmation_verifier::OptimisticConfirmationVerifier,
replay_stage::DUPLICATE_THRESHOLD,
result::{Error, Result},
sigverify,
verified_vote_packets::{
ValidatorGossipVotesIterator, VerifiedVoteMetadata, VerifiedVotePackets,
},
vote_stake_tracker::VoteStakeTracker,
},
vote_stake_tracker::VoteStakeTracker,
};
use crossbeam_channel::{
unbounded, Receiver as CrossbeamReceiver, RecvTimeoutError, Select, Sender as CrossbeamSender,
};
use itertools::izip;
use log::*;
use solana_gossip::{
cluster_info::{ClusterInfo, GOSSIP_SLEEP_MILLIS},
crds::Cursor,
};
use solana_ledger::blockstore::Blockstore;
use solana_measure::measure::Measure;
use solana_metrics::inc_new_counter_debug;
use solana_perf::packet::{self, Packets};
use solana_poh::poh_recorder::PohRecorder;
use solana_rpc::{
optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender},
rpc_subscriptions::RpcSubscriptions,
};
use solana_runtime::{
bank::Bank,
bank_forks::BankForks,
commitment::VOTE_THRESHOLD_SIZE,
epoch_stakes::{EpochAuthorizedVoters, EpochStakes},
vote_sender_types::{ReplayVoteReceiver, ReplayedVote},
};
use solana_sdk::{
clock::{Epoch, Slot, DEFAULT_MS_PER_SLOT, DEFAULT_TICKS_PER_SLOT},
epoch_schedule::EpochSchedule,
hash::Hash,
pubkey::Pubkey,
signature::Signature,
slot_hashes,
transaction::Transaction,
};
use solana_vote_program::{self, vote_state::Vote, vote_transaction};
use std::{
collections::{HashMap, HashSet},
sync::{
atomic::{AtomicBool, Ordering},
{Arc, Mutex, RwLock},
crossbeam_channel::{
unbounded, Receiver as CrossbeamReceiver, RecvTimeoutError, Select,
Sender as CrossbeamSender,
},
itertools::izip,
log::*,
solana_gossip::{
cluster_info::{ClusterInfo, GOSSIP_SLEEP_MILLIS},
crds::Cursor,
},
solana_ledger::blockstore::Blockstore,
solana_measure::measure::Measure,
solana_metrics::inc_new_counter_debug,
solana_perf::packet::{self, Packets},
solana_poh::poh_recorder::PohRecorder,
solana_rpc::{
optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender},
rpc_subscriptions::RpcSubscriptions,
},
solana_runtime::{
bank::Bank,
bank_forks::BankForks,
commitment::VOTE_THRESHOLD_SIZE,
epoch_stakes::{EpochAuthorizedVoters, EpochStakes},
vote_sender_types::{ReplayVoteReceiver, ReplayedVote},
},
solana_sdk::{
clock::{Epoch, Slot, DEFAULT_MS_PER_SLOT, DEFAULT_TICKS_PER_SLOT},
epoch_schedule::EpochSchedule,
hash::Hash,
pubkey::Pubkey,
signature::Signature,
slot_hashes,
transaction::Transaction,
},
solana_vote_program::{self, vote_state::Vote, vote_transaction},
std::{
collections::{HashMap, HashSet},
sync::{
atomic::{AtomicBool, Ordering},
Arc, Mutex, RwLock,
},
thread::{self, sleep, Builder, JoinHandle},
time::{Duration, Instant},
},
thread::{self, sleep, Builder, JoinHandle},
time::{Duration, Instant},
};
// Map from a vote account to the authorized voter for an epoch
@ -939,23 +942,26 @@ impl ClusterInfoVoteListener {
#[cfg(test)]
mod tests {
use super::*;
use solana_perf::packet;
use solana_rpc::optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank;
use solana_runtime::{
bank::Bank,
commitment::BlockCommitmentCache,
genesis_utils::{self, create_genesis_config, GenesisConfigInfo, ValidatorVoteKeypairs},
vote_sender_types::ReplayVoteSender,
use {
super::*,
solana_perf::packet,
solana_rpc::optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank,
solana_runtime::{
bank::Bank,
commitment::BlockCommitmentCache,
genesis_utils::{
self, create_genesis_config, GenesisConfigInfo, ValidatorVoteKeypairs,
},
vote_sender_types::ReplayVoteSender,
},
solana_sdk::{
hash::Hash,
pubkey::Pubkey,
signature::{Keypair, Signature, Signer},
},
solana_vote_program::vote_state::Vote,
std::{collections::BTreeSet, sync::Arc},
};
use solana_sdk::{
hash::Hash,
pubkey::Pubkey,
signature::{Keypair, Signature, Signer},
};
use solana_vote_program::vote_state::Vote;
use std::collections::BTreeSet;
use std::sync::Arc;
#[test]
fn test_max_vote_tx_fits() {

View File

@ -1,11 +1,13 @@
use crate::{
ancestor_hashes_service::{AncestorHashesReplayUpdate, AncestorHashesReplayUpdateSender},
fork_choice::ForkChoice,
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
use {
crate::{
ancestor_hashes_service::{AncestorHashesReplayUpdate, AncestorHashesReplayUpdateSender},
fork_choice::ForkChoice,
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
},
solana_ledger::blockstore::Blockstore,
solana_sdk::{clock::Slot, hash::Hash},
std::collections::{BTreeMap, BTreeSet, HashMap},
};
use solana_ledger::blockstore::Blockstore;
use solana_sdk::{clock::Slot, hash::Hash};
use std::collections::{BTreeMap, BTreeSet, HashMap};
pub(crate) type DuplicateSlotsTracker = BTreeSet<Slot>;
pub(crate) type DuplicateSlotsToRepair = HashMap<Slot, Hash>;
@ -805,15 +807,17 @@ pub(crate) fn check_slot_agrees_with_cluster(
#[cfg(test)]
mod test {
use super::*;
use crate::{progress_map::ProgressMap, replay_stage::tests::setup_forks_from_tree};
use crossbeam_channel::unbounded;
use solana_runtime::bank_forks::BankForks;
use std::{
collections::{HashMap, HashSet},
sync::{Arc, RwLock},
use {
super::*,
crate::{progress_map::ProgressMap, replay_stage::tests::setup_forks_from_tree},
crossbeam_channel::unbounded,
solana_runtime::bank_forks::BankForks,
std::{
collections::{HashMap, HashSet},
sync::{Arc, RwLock},
},
trees::tr,
};
use trees::tr;
macro_rules! state_update_tests {
($($name:ident: $value:expr,)*) => {

View File

@ -218,8 +218,7 @@ impl ClusterSlots {
#[cfg(test)]
mod tests {
use super::*;
use solana_runtime::epoch_stakes::NodeVoteAccounts;
use {super::*, solana_runtime::epoch_stakes::NodeVoteAccounts};
#[test]
fn test_default() {

View File

@ -1,17 +1,19 @@
use crate::cluster_slots::ClusterSlots;
use crossbeam_channel::{Receiver, RecvTimeoutError, Sender};
use solana_gossip::cluster_info::ClusterInfo;
use solana_ledger::blockstore::Blockstore;
use solana_measure::measure::Measure;
use solana_runtime::bank_forks::BankForks;
use solana_sdk::clock::Slot;
use std::{
sync::{
atomic::{AtomicBool, Ordering},
{Arc, RwLock},
use {
crate::cluster_slots::ClusterSlots,
crossbeam_channel::{Receiver, RecvTimeoutError, Sender},
solana_gossip::cluster_info::ClusterInfo,
solana_ledger::blockstore::Blockstore,
solana_measure::measure::Measure,
solana_runtime::bank_forks::BankForks,
solana_sdk::clock::Slot,
std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc, RwLock,
},
thread::{self, Builder, JoinHandle},
time::{Duration, Instant},
},
thread::{self, Builder, JoinHandle},
time::{Duration, Instant},
};
pub type ClusterSlotsUpdateReceiver = Receiver<Vec<Slot>>;

View File

@ -1,21 +1,25 @@
use crate::consensus::Stake;
use solana_measure::measure::Measure;
use solana_metrics::datapoint_info;
use solana_rpc::rpc_subscriptions::RpcSubscriptions;
use solana_runtime::{
bank::Bank,
commitment::{BlockCommitment, BlockCommitmentCache, CommitmentSlots, VOTE_THRESHOLD_SIZE},
};
use solana_sdk::clock::Slot;
use solana_vote_program::vote_state::VoteState;
use std::{
cmp::max,
collections::HashMap,
sync::atomic::{AtomicBool, Ordering},
sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender},
sync::{Arc, RwLock},
thread::{self, Builder, JoinHandle},
time::Duration,
use {
crate::consensus::Stake,
solana_measure::measure::Measure,
solana_metrics::datapoint_info,
solana_rpc::rpc_subscriptions::RpcSubscriptions,
solana_runtime::{
bank::Bank,
commitment::{BlockCommitment, BlockCommitmentCache, CommitmentSlots, VOTE_THRESHOLD_SIZE},
},
solana_sdk::clock::Slot,
solana_vote_program::vote_state::VoteState,
std::{
cmp::max,
collections::HashMap,
sync::{
atomic::{AtomicBool, Ordering},
mpsc::{channel, Receiver, RecvTimeoutError, Sender},
Arc, RwLock,
},
thread::{self, Builder, JoinHandle},
time::Duration,
},
};
pub struct CommitmentAggregationData {
@ -247,18 +251,20 @@ impl AggregateCommitmentService {
#[cfg(test)]
mod tests {
use super::*;
use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};
use solana_runtime::{
accounts_background_service::AbsRequestSender,
bank_forks::BankForks,
genesis_utils::{create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs},
};
use solana_sdk::{account::Account, pubkey::Pubkey, signature::Signer};
use solana_stake_program::stake_state;
use solana_vote_program::{
vote_state::{self, VoteStateVersions},
vote_transaction,
use {
super::*,
solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo},
solana_runtime::{
accounts_background_service::AbsRequestSender,
bank_forks::BankForks,
genesis_utils::{create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs},
},
solana_sdk::{account::Account, pubkey::Pubkey, signature::Signer},
solana_stake_program::stake_state,
solana_vote_program::{
vote_state::{self, VoteStateVersions},
vote_transaction,
},
};
#[test]

View File

@ -1,15 +1,17 @@
use crossbeam_channel::{Receiver, RecvTimeoutError, Sender};
use solana_entry::entry::Entry;
use solana_ledger::blockstore::{Blockstore, CompletedDataSetInfo};
use solana_rpc::{max_slots::MaxSlots, rpc_subscriptions::RpcSubscriptions};
use solana_sdk::signature::Signature;
use std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc,
use {
crossbeam_channel::{Receiver, RecvTimeoutError, Sender},
solana_entry::entry::Entry,
solana_ledger::blockstore::{Blockstore, CompletedDataSetInfo},
solana_rpc::{max_slots::MaxSlots, rpc_subscriptions::RpcSubscriptions},
solana_sdk::signature::Signature,
std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
thread::{self, Builder, JoinHandle},
time::Duration,
},
thread::{self, Builder, JoinHandle},
time::Duration,
};
pub type CompletedDataSetsReceiver = Receiver<Vec<CompletedDataSetInfo>>;
@ -100,10 +102,14 @@ impl CompletedDataSetsService {
#[cfg(test)]
pub mod test {
use super::*;
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, Signer};
use solana_sdk::transaction::Transaction;
use {
super::*,
solana_sdk::{
hash::Hash,
signature::{Keypair, Signer},
transaction::Transaction,
},
};
#[test]
fn test_zero_signatures() {

View File

@ -3,18 +3,23 @@
//! packing transactions into block; it also triggers persisting cost
//! table to blockstore.
use solana_ledger::blockstore::Blockstore;
use solana_measure::measure::Measure;
use solana_runtime::{bank::Bank, bank::ExecuteTimings, cost_model::CostModel};
use solana_sdk::timing::timestamp;
use std::{
sync::{
atomic::{AtomicBool, Ordering},
mpsc::Receiver,
Arc, RwLock,
use {
solana_ledger::blockstore::Blockstore,
solana_measure::measure::Measure,
solana_runtime::{
bank::{Bank, ExecuteTimings},
cost_model::CostModel,
},
solana_sdk::timing::timestamp,
std::{
sync::{
atomic::{AtomicBool, Ordering},
mpsc::Receiver,
Arc, RwLock,
},
thread::{self, Builder, JoinHandle},
time::Duration,
},
thread::{self, Builder, JoinHandle},
time::Duration,
};
#[derive(Default)]
@ -203,9 +208,7 @@ impl CostUpdateService {
#[cfg(test)]
mod tests {
use super::*;
use solana_program_runtime::timings::ProgramTiming;
use solana_sdk::pubkey::Pubkey;
use {super::*, solana_program_runtime::timings::ProgramTiming, solana_sdk::pubkey::Pubkey};
#[test]
fn test_update_cost_model_with_empty_execute_timings() {

View File

@ -1,8 +1,10 @@
use solana_measure::measure::Measure;
use solana_runtime::bank::Bank;
use std::{
sync::{mpsc::Receiver, Arc},
thread::{self, Builder, JoinHandle},
use {
solana_measure::measure::Measure,
solana_runtime::bank::Bank,
std::{
sync::{mpsc::Receiver, Arc},
thread::{self, Builder, JoinHandle},
},
};
pub struct DropBankService {

View File

@ -1,6 +1,8 @@
use solana_ledger::blockstore::Blockstore;
use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey, timing::timestamp};
use std::{collections::HashMap, net::SocketAddr};
use {
solana_ledger::blockstore::Blockstore,
solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey, timing::timestamp},
std::{collections::HashMap, net::SocketAddr},
};
// Number of validators to sample for the ancestor repair
pub const ANCESTOR_HASH_REPAIR_SAMPLE_SIZE: usize = 21;
@ -350,11 +352,13 @@ impl DeadSlotAncestorRequestStatus {
#[cfg(test)]
pub mod tests {
use super::*;
use rand::{self, seq::SliceRandom, thread_rng};
use solana_ledger::get_tmp_ledger_path_auto_delete;
use std::{collections::BTreeMap, net::IpAddr};
use tempfile::TempDir;
use {
super::*,
rand::{self, seq::SliceRandom, thread_rng},
solana_ledger::get_tmp_ledger_path_auto_delete,
std::{collections::BTreeMap, net::IpAddr},
tempfile::TempDir,
};
struct TestSetup {
sampled_addresses: Vec<SocketAddr>,

View File

@ -1,18 +1,25 @@
//! The `fetch_stage` batches input from a UDP socket and sends it to a channel.
use crate::banking_stage::HOLD_TRANSACTIONS_SLOT_OFFSET;
use crate::result::{Error, Result};
use solana_metrics::{inc_new_counter_debug, inc_new_counter_info};
use solana_perf::packet::PacketsRecycler;
use solana_perf::recycler::Recycler;
use solana_poh::poh_recorder::PohRecorder;
use solana_sdk::clock::DEFAULT_TICKS_PER_SLOT;
use solana_streamer::streamer::{self, PacketReceiver, PacketSender};
use std::net::UdpSocket;
use std::sync::atomic::AtomicBool;
use std::sync::mpsc::{channel, RecvTimeoutError};
use std::sync::{Arc, Mutex};
use std::thread::{self, Builder, JoinHandle};
use {
crate::{
banking_stage::HOLD_TRANSACTIONS_SLOT_OFFSET,
result::{Error, Result},
},
solana_metrics::{inc_new_counter_debug, inc_new_counter_info},
solana_perf::{packet::PacketsRecycler, recycler::Recycler},
solana_poh::poh_recorder::PohRecorder,
solana_sdk::clock::DEFAULT_TICKS_PER_SLOT,
solana_streamer::streamer::{self, PacketReceiver, PacketSender},
std::{
net::UdpSocket,
sync::{
atomic::AtomicBool,
mpsc::{channel, RecvTimeoutError},
Arc, Mutex,
},
thread::{self, Builder, JoinHandle},
},
};
pub struct FetchStage {
thread_hdls: Vec<JoinHandle<()>>,

View File

@ -1,13 +1,15 @@
use crate::{
consensus::{SwitchForkDecision, Tower},
latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
progress_map::ProgressMap,
replay_stage::HeaviestForkFailures,
};
use solana_runtime::{bank::Bank, bank_forks::BankForks};
use std::{
collections::{HashMap, HashSet},
sync::{Arc, RwLock},
use {
crate::{
consensus::{SwitchForkDecision, Tower},
latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
progress_map::ProgressMap,
replay_stage::HeaviestForkFailures,
},
solana_runtime::{bank::Bank, bank_forks::BankForks},
std::{
collections::{HashMap, HashSet},
sync::{Arc, RwLock},
},
};
pub struct SelectVoteAndResetForkResult {

View File

@ -1,9 +1,11 @@
//! The `gen_keys` module makes lots of keypairs
use rand::{Rng, SeedableRng};
use rand_chacha::ChaChaRng;
use rayon::prelude::*;
use solana_sdk::signature::Keypair;
use {
rand::{Rng, SeedableRng},
rand_chacha::ChaChaRng,
rayon::prelude::*,
solana_sdk::signature::Keypair,
};
pub struct GenKeys {
generator: ChaChaRng,
@ -39,10 +41,8 @@ impl GenKeys {
#[cfg(test)]
mod tests {
use super::*;
pub use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::Signer;
use std::collections::HashSet;
use {super::*, solana_sdk::signature::Signer, std::collections::HashSet};
#[test]
fn test_new_key_is_deterministic() {

View File

@ -1,24 +1,26 @@
use crate::{
consensus::Tower, fork_choice::ForkChoice,
latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
progress_map::ProgressMap, tree_diff::TreeDiff,
};
use solana_measure::measure::Measure;
use solana_runtime::{bank::Bank, bank_forks::BankForks, epoch_stakes::EpochStakes};
use solana_sdk::{
clock::{Epoch, Slot},
epoch_schedule::EpochSchedule,
hash::Hash,
pubkey::Pubkey,
};
use std::{
borrow::Borrow,
collections::{hash_map::Entry, BTreeMap, HashMap, HashSet, VecDeque},
sync::{Arc, RwLock},
time::Instant,
};
#[cfg(test)]
use trees::{Tree, TreeWalk};
use {
crate::{
consensus::Tower, fork_choice::ForkChoice,
latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
progress_map::ProgressMap, tree_diff::TreeDiff,
},
solana_measure::measure::Measure,
solana_runtime::{bank::Bank, bank_forks::BankForks, epoch_stakes::EpochStakes},
solana_sdk::{
clock::{Epoch, Slot},
epoch_schedule::EpochSchedule,
hash::Hash,
pubkey::Pubkey,
},
std::{
borrow::Borrow,
collections::{hash_map::Entry, BTreeMap, HashMap, HashSet, VecDeque},
sync::{Arc, RwLock},
time::Instant,
},
};
pub type ForkWeight = u64;
pub type SlotHashKey = (Slot, Hash);
@ -1076,12 +1078,14 @@ impl<'a> Iterator for AncestorIterator<'a> {
#[cfg(test)]
mod test {
use super::*;
use crate::vote_simulator::VoteSimulator;
use solana_runtime::{bank::Bank, bank_utils};
use solana_sdk::{hash::Hash, slot_history::SlotHistory};
use std::{collections::HashSet, ops::Range};
use trees::tr;
use {
super::*,
crate::vote_simulator::VoteSimulator,
solana_runtime::{bank::Bank, bank_utils},
solana_sdk::{hash::Hash, slot_history::SlotHistory},
std::{collections::HashSet, ops::Range},
trees::tr,
};
#[test]
fn test_max_by_weight() {

View File

@ -1,6 +1,8 @@
use crate::heaviest_subtree_fork_choice::SlotHashKey;
use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey};
use std::collections::{hash_map::Entry, HashMap};
use {
crate::heaviest_subtree_fork_choice::SlotHashKey,
solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey},
std::collections::{hash_map::Entry, HashMap},
};
#[derive(Default)]
pub struct LatestValidatorVotesForFrozenBanks {

View File

@ -1,17 +1,24 @@
//! The `ledger_cleanup_service` drops older ledger data to limit disk space usage
use rand::{thread_rng, Rng};
use solana_ledger::blockstore::{Blockstore, PurgeType};
use solana_ledger::blockstore_db::Result as BlockstoreResult;
use solana_measure::measure::Measure;
use solana_sdk::clock::{Slot, DEFAULT_TICKS_PER_SLOT, TICKS_PER_DAY};
use std::string::ToString;
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use std::sync::mpsc::{Receiver, RecvTimeoutError};
use std::sync::Arc;
use std::thread;
use std::thread::{sleep, Builder, JoinHandle};
use std::time::Duration;
use {
rand::{thread_rng, Rng},
solana_ledger::{
blockstore::{Blockstore, PurgeType},
blockstore_db::Result as BlockstoreResult,
},
solana_measure::measure::Measure,
solana_sdk::clock::{Slot, DEFAULT_TICKS_PER_SLOT, TICKS_PER_DAY},
std::{
string::ToString,
sync::{
atomic::{AtomicBool, AtomicU64, Ordering},
mpsc::{Receiver, RecvTimeoutError},
Arc,
},
thread::{self, sleep, Builder, JoinHandle},
time::Duration,
},
};
// - To try and keep the RocksDB size under 400GB:
// Seeing about 1600b/shred, using 2000b/shred for margin, so 200m shreds can be stored in 400gb.
@ -306,10 +313,11 @@ impl LedgerCleanupService {
}
#[cfg(test)]
mod tests {
use super::*;
use solana_ledger::blockstore::make_many_slot_entries;
use solana_ledger::get_tmp_ledger_path;
use std::sync::mpsc::channel;
use {
super::*,
solana_ledger::{blockstore::make_many_slot_entries, get_tmp_ledger_path},
std::sync::mpsc::channel,
};
#[test]
fn test_cleanup1() {

View File

@ -1,8 +1,10 @@
use crate::cluster_info_vote_listener::VoteTracker;
use solana_ledger::blockstore::Blockstore;
use solana_runtime::bank::Bank;
use solana_sdk::{clock::Slot, hash::Hash};
use std::{collections::BTreeSet, time::Instant};
use {
crate::cluster_info_vote_listener::VoteTracker,
solana_ledger::blockstore::Blockstore,
solana_runtime::bank::Bank,
solana_sdk::{clock::Slot, hash::Hash},
std::{collections::BTreeSet, time::Instant},
};
pub struct OptimisticConfirmationVerifier {
snapshot_start_slot: Slot,
@ -139,13 +141,11 @@ impl OptimisticConfirmationVerifier {
#[cfg(test)]
mod test {
use super::*;
use crate::vote_simulator::VoteSimulator;
use solana_ledger::get_tmp_ledger_path;
use solana_runtime::bank::Bank;
use solana_sdk::pubkey::Pubkey;
use std::collections::HashMap;
use trees::tr;
use {
super::*, crate::vote_simulator::VoteSimulator, solana_ledger::get_tmp_ledger_path,
solana_runtime::bank::Bank, solana_sdk::pubkey::Pubkey, std::collections::HashMap,
trees::tr,
};
#[test]
fn test_add_new_optimistic_confirmed_slots() {

View File

@ -1,7 +1,9 @@
use crate::request_response::RequestResponse;
use lru::LruCache;
use rand::{thread_rng, Rng};
use solana_ledger::shred::Nonce;
use {
crate::request_response::RequestResponse,
lru::LruCache,
rand::{thread_rng, Rng},
solana_ledger::shred::Nonce,
};
pub const DEFAULT_REQUEST_EXPIRATION_MS: u64 = 60_000;
@ -82,10 +84,10 @@ pub struct RequestStatus<T> {
#[cfg(test)]
pub(crate) mod tests {
use super::*;
use crate::serve_repair::ShredRepairType;
use solana_ledger::shred::Shred;
use solana_sdk::timing::timestamp;
use {
super::*, crate::serve_repair::ShredRepairType, solana_ledger::shred::Shred,
solana_sdk::timing::timestamp,
};
#[test]
fn test_add_request() {

View File

@ -2,8 +2,8 @@ use {
crate::{
cluster_info_vote_listener::SlotVoteTracker,
cluster_slots::SlotPubkeys,
consensus::{Stake, VotedStakes},
replay_stage::SUPERMINORITY_THRESHOLD,
{consensus::Stake, consensus::VotedStakes},
},
solana_ledger::blockstore_processor::{ConfirmationProgress, ConfirmationTiming},
solana_runtime::{bank::Bank, bank_forks::BankForks, vote_account::VoteAccount},

View File

@ -1,10 +1,12 @@
use crate::{
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, repair_service::RepairService,
serve_repair::ShredRepairType, tree_diff::TreeDiff,
use {
crate::{
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, repair_service::RepairService,
serve_repair::ShredRepairType, tree_diff::TreeDiff,
},
solana_ledger::{blockstore::Blockstore, blockstore_meta::SlotMeta},
solana_sdk::{clock::Slot, hash::Hash},
std::collections::{HashMap, HashSet},
};
use solana_ledger::{blockstore::Blockstore, blockstore_meta::SlotMeta};
use solana_sdk::{clock::Slot, hash::Hash};
use std::collections::{HashMap, HashSet};
struct GenericTraversal<'a> {
tree: &'a HeaviestSubtreeForkChoice,
@ -164,14 +166,16 @@ pub fn get_closest_completion(
#[cfg(test)]
pub mod test {
use super::*;
use solana_ledger::{
blockstore::{Blockstore, MAX_TURBINE_PROPAGATION_IN_MS},
get_tmp_ledger_path,
use {
super::*,
solana_ledger::{
blockstore::{Blockstore, MAX_TURBINE_PROPAGATION_IN_MS},
get_tmp_ledger_path,
},
solana_sdk::hash::Hash,
std::{thread::sleep, time::Duration},
trees::{tr, Tree, TreeWalk},
};
use solana_sdk::hash::Hash;
use std::{thread::sleep, time::Duration};
use trees::{tr, Tree, TreeWalk};
#[test]
fn test_get_unknown_last_index() {

View File

@ -1,10 +1,12 @@
use solana_ledger::{
blockstore::Blockstore,
shred::{Nonce, SIZE_OF_NONCE},
use {
solana_ledger::{
blockstore::Blockstore,
shred::{Nonce, SIZE_OF_NONCE},
},
solana_perf::packet::limited_deserialize,
solana_sdk::{clock::Slot, packet::Packet},
std::{io, net::SocketAddr},
};
use solana_perf::packet::limited_deserialize;
use solana_sdk::{clock::Slot, packet::Packet};
use std::{io, net::SocketAddr};
pub fn repair_response_packet(
blockstore: &Blockstore,
@ -48,15 +50,17 @@ pub fn nonce(buf: &[u8]) -> Option<Nonce> {
#[cfg(test)]
mod test {
use super::*;
use solana_ledger::{
shred::{Shred, Shredder},
sigverify_shreds::verify_shred_cpu,
};
use solana_sdk::signature::{Keypair, Signer};
use std::{
collections::HashMap,
net::{IpAddr, Ipv4Addr},
use {
super::*,
solana_ledger::{
shred::{Shred, Shredder},
sigverify_shreds::verify_shred_cpu,
},
solana_sdk::signature::{Keypair, Signer},
std::{
collections::HashMap,
net::{IpAddr, Ipv4Addr},
},
};
fn run_test_sigverify_shred_cpu_repair(slot: Slot) {

View File

@ -1,38 +1,40 @@
//! The `repair_service` module implements the tools necessary to generate a thread which
//! regularly finds missing shreds in the ledger and sends repair requests for those shreds
use crate::{
ancestor_hashes_service::{AncestorHashesReplayUpdateReceiver, AncestorHashesService},
cluster_info_vote_listener::VerifiedVoteReceiver,
cluster_slots::ClusterSlots,
duplicate_repair_status::DuplicateSlotRepairStatus,
outstanding_requests::OutstandingRequests,
repair_weight::RepairWeight,
result::Result,
serve_repair::{ServeRepair, ShredRepairType, REPAIR_PEERS_CACHE_CAPACITY},
};
use crossbeam_channel::{Receiver as CrossbeamReceiver, Sender as CrossbeamSender};
use lru::LruCache;
use solana_gossip::cluster_info::ClusterInfo;
use solana_ledger::{
blockstore::{Blockstore, SlotMeta},
shred::Nonce,
};
use solana_measure::measure::Measure;
use solana_runtime::{bank_forks::BankForks, contains::Contains};
use solana_sdk::{
clock::Slot, epoch_schedule::EpochSchedule, hash::Hash, pubkey::Pubkey, timing::timestamp,
};
use solana_streamer::sendmmsg::{batch_send, SendPktsError};
use std::{
collections::{HashMap, HashSet},
iter::Iterator,
net::SocketAddr,
net::UdpSocket,
sync::atomic::{AtomicBool, Ordering},
sync::{Arc, RwLock},
thread::sleep,
thread::{self, Builder, JoinHandle},
time::{Duration, Instant},
use {
crate::{
ancestor_hashes_service::{AncestorHashesReplayUpdateReceiver, AncestorHashesService},
cluster_info_vote_listener::VerifiedVoteReceiver,
cluster_slots::ClusterSlots,
duplicate_repair_status::DuplicateSlotRepairStatus,
outstanding_requests::OutstandingRequests,
repair_weight::RepairWeight,
result::Result,
serve_repair::{ServeRepair, ShredRepairType, REPAIR_PEERS_CACHE_CAPACITY},
},
crossbeam_channel::{Receiver as CrossbeamReceiver, Sender as CrossbeamSender},
lru::LruCache,
solana_gossip::cluster_info::ClusterInfo,
solana_ledger::{
blockstore::{Blockstore, SlotMeta},
shred::Nonce,
},
solana_measure::measure::Measure,
solana_runtime::{bank_forks::BankForks, contains::Contains},
solana_sdk::{
clock::Slot, epoch_schedule::EpochSchedule, hash::Hash, pubkey::Pubkey, timing::timestamp,
},
solana_streamer::sendmmsg::{batch_send, SendPktsError},
std::{
collections::{HashMap, HashSet},
iter::Iterator,
net::{SocketAddr, UdpSocket},
sync::{
atomic::{AtomicBool, Ordering},
Arc, RwLock,
},
thread::{self, sleep, Builder, JoinHandle},
time::{Duration, Instant},
},
};
pub type DuplicateSlotsResetSender = CrossbeamSender<Vec<(Slot, Hash)>>;
@ -715,16 +717,20 @@ impl RepairService {
#[cfg(test)]
mod test {
use super::*;
use solana_gossip::{cluster_info::Node, contact_info::ContactInfo};
use solana_ledger::blockstore::{
make_chaining_slot_entries, make_many_slot_entries, make_slot_entries,
use {
super::*,
solana_gossip::{cluster_info::Node, contact_info::ContactInfo},
solana_ledger::{
blockstore::{
make_chaining_slot_entries, make_many_slot_entries, make_slot_entries, Blockstore,
},
get_tmp_ledger_path,
shred::max_ticks_per_n_shreds,
},
solana_sdk::signature::Keypair,
solana_streamer::socket::SocketAddrSpace,
std::collections::HashSet,
};
use solana_ledger::shred::max_ticks_per_n_shreds;
use solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path};
use solana_sdk::signature::Keypair;
use solana_streamer::socket::SocketAddrSpace;
use std::collections::HashSet;
fn new_test_cluster_info(contact_info: ContactInfo) -> ClusterInfo {
ClusterInfo::new(

View File

@ -1,23 +1,25 @@
use crate::{
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
repair_generic_traversal::{get_closest_completion, get_unknown_last_index},
repair_service::{BestRepairsStats, RepairTiming},
repair_weighted_traversal,
serve_repair::ShredRepairType,
tree_diff::TreeDiff,
use {
crate::{
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
repair_generic_traversal::{get_closest_completion, get_unknown_last_index},
repair_service::{BestRepairsStats, RepairTiming},
repair_weighted_traversal,
serve_repair::ShredRepairType,
tree_diff::TreeDiff,
},
solana_ledger::{
ancestor_iterator::AncestorIterator, blockstore::Blockstore, blockstore_meta::SlotMeta,
},
solana_measure::measure::Measure,
solana_runtime::{contains::Contains, epoch_stakes::EpochStakes},
solana_sdk::{
clock::Slot,
epoch_schedule::{Epoch, EpochSchedule},
hash::Hash,
pubkey::Pubkey,
},
std::collections::{BTreeSet, HashMap, HashSet, VecDeque},
};
use solana_ledger::{
ancestor_iterator::AncestorIterator, blockstore::Blockstore, blockstore_meta::SlotMeta,
};
use solana_measure::measure::Measure;
use solana_runtime::{contains::Contains, epoch_stakes::EpochStakes};
use solana_sdk::{
clock::Slot,
epoch_schedule::{Epoch, EpochSchedule},
hash::Hash,
pubkey::Pubkey,
};
use std::collections::{BTreeSet, HashMap, HashSet, VecDeque};
pub struct RepairWeight {
// Map from root -> a subtree rooted at that `root`
@ -653,11 +655,13 @@ impl RepairWeight {
#[cfg(test)]
mod test {
use super::*;
use solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path};
use solana_runtime::{bank::Bank, bank_utils};
use solana_sdk::hash::Hash;
use trees::tr;
use {
super::*,
solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path},
solana_runtime::{bank::Bank, bank_utils},
solana_sdk::hash::Hash,
trees::tr,
};
#[test]
fn test_sort_by_stake_weight_slot() {

View File

@ -1,11 +1,13 @@
use crate::{
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, repair_service::RepairService,
serve_repair::ShredRepairType, tree_diff::TreeDiff,
use {
crate::{
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, repair_service::RepairService,
serve_repair::ShredRepairType, tree_diff::TreeDiff,
},
solana_ledger::{blockstore::Blockstore, blockstore_meta::SlotMeta},
solana_runtime::contains::Contains,
solana_sdk::{clock::Slot, hash::Hash},
std::collections::{HashMap, HashSet},
};
use solana_ledger::{blockstore::Blockstore, blockstore_meta::SlotMeta};
use solana_runtime::contains::Contains;
use solana_sdk::{clock::Slot, hash::Hash};
use std::collections::{HashMap, HashSet};
#[derive(Debug, PartialEq)]
enum Visit {
@ -136,11 +138,13 @@ pub fn get_best_repair_shreds<'a>(
#[cfg(test)]
pub mod test {
use super::*;
use solana_ledger::{get_tmp_ledger_path, shred::Shred};
use solana_runtime::bank_utils;
use solana_sdk::hash::Hash;
use trees::tr;
use {
super::*,
solana_ledger::{get_tmp_ledger_path, shred::Shred},
solana_runtime::bank_utils,
solana_sdk::hash::Hash,
trees::tr,
};
#[test]
fn test_weighted_repair_traversal_single() {

View File

@ -43,8 +43,10 @@ use {
rpc_subscriptions::RpcSubscriptions,
},
solana_runtime::{
accounts_background_service::AbsRequestSender, bank::Bank, bank::ExecuteTimings,
bank::NewBankOptions, bank_forks::BankForks, commitment::BlockCommitmentCache,
accounts_background_service::AbsRequestSender,
bank::{Bank, ExecuteTimings, NewBankOptions},
bank_forks::BankForks,
commitment::BlockCommitmentCache,
vote_sender_types::ReplayVoteSender,
},
solana_sdk::{
@ -52,8 +54,7 @@ use {
genesis_config::ClusterType,
hash::Hash,
pubkey::Pubkey,
signature::Signature,
signature::{Keypair, Signer},
signature::{Keypair, Signature, Signer},
timing::timestamp,
transaction::Transaction,
},
@ -2882,61 +2883,61 @@ impl ReplayStage {
#[cfg(test)]
pub mod tests {
use super::*;
use crate::{
consensus::Tower,
progress_map::ValidatorStakeInfo,
replay_stage::ReplayStage,
tree_diff::TreeDiff,
vote_simulator::{self, VoteSimulator},
};
use crossbeam_channel::unbounded;
use solana_entry::entry::{self, Entry};
use solana_gossip::{cluster_info::Node, crds::Cursor};
use solana_ledger::{
blockstore::make_slot_entries,
blockstore::{entries_to_test_shreds, BlockstoreError},
create_new_tmp_ledger,
genesis_utils::{create_genesis_config, create_genesis_config_with_leader},
get_tmp_ledger_path,
shred::{
CodingShredHeader, DataShredHeader, Shred, ShredCommonHeader, DATA_COMPLETE_SHRED,
SIZE_OF_COMMON_SHRED_HEADER, SIZE_OF_DATA_SHRED_HEADER, SIZE_OF_DATA_SHRED_PAYLOAD,
use {
super::*,
crate::{
consensus::Tower,
progress_map::ValidatorStakeInfo,
replay_stage::ReplayStage,
tree_diff::TreeDiff,
vote_simulator::{self, VoteSimulator},
},
crossbeam_channel::unbounded,
solana_entry::entry::{self, Entry},
solana_gossip::{cluster_info::Node, crds::Cursor},
solana_ledger::{
blockstore::{entries_to_test_shreds, make_slot_entries, BlockstoreError},
create_new_tmp_ledger,
genesis_utils::{create_genesis_config, create_genesis_config_with_leader},
get_tmp_ledger_path,
shred::{
CodingShredHeader, DataShredHeader, Shred, ShredCommonHeader, DATA_COMPLETE_SHRED,
SIZE_OF_COMMON_SHRED_HEADER, SIZE_OF_DATA_SHRED_HEADER, SIZE_OF_DATA_SHRED_PAYLOAD,
},
},
solana_rpc::{
optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank,
rpc::create_test_transactions_and_populate_blockstore,
},
solana_runtime::{
accounts_background_service::AbsRequestSender,
commitment::BlockCommitment,
genesis_utils::{GenesisConfigInfo, ValidatorVoteKeypairs},
},
solana_sdk::{
clock::NUM_CONSECUTIVE_LEADER_SLOTS,
genesis_config,
hash::{hash, Hash},
instruction::InstructionError,
packet::PACKET_DATA_SIZE,
poh_config::PohConfig,
signature::{Keypair, Signer},
system_transaction,
transaction::TransactionError,
},
solana_streamer::socket::SocketAddrSpace,
solana_transaction_status::TransactionWithStatusMeta,
solana_vote_program::{
vote_state::{VoteState, VoteStateVersions},
vote_transaction,
},
std::{
fs::remove_dir_all,
iter,
sync::{atomic::AtomicU64, mpsc::channel, Arc, RwLock},
},
trees::{tr, Tree},
};
use solana_rpc::{
optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank,
rpc::create_test_transactions_and_populate_blockstore,
};
use solana_runtime::{
accounts_background_service::AbsRequestSender,
commitment::BlockCommitment,
genesis_utils::{GenesisConfigInfo, ValidatorVoteKeypairs},
};
use solana_sdk::{
clock::NUM_CONSECUTIVE_LEADER_SLOTS,
genesis_config,
hash::{hash, Hash},
instruction::InstructionError,
packet::PACKET_DATA_SIZE,
poh_config::PohConfig,
signature::{Keypair, Signer},
system_transaction,
transaction::TransactionError,
};
use solana_streamer::socket::SocketAddrSpace;
use solana_transaction_status::TransactionWithStatusMeta;
use solana_vote_program::{
vote_state::{VoteState, VoteStateVersions},
vote_transaction,
};
use std::sync::mpsc::channel;
use std::{
fs::remove_dir_all,
iter,
sync::{atomic::AtomicU64, Arc, RwLock},
};
use trees::{tr, Tree};
#[test]
fn test_is_partition_detected() {

View File

@ -1,7 +1,9 @@
//! The `result` module exposes a Result type that propagates one of many different Error types.
use solana_gossip::{cluster_info, gossip_error::GossipError};
use solana_ledger::blockstore;
use {
solana_gossip::{cluster_info, gossip_error::GossipError},
solana_ledger::blockstore,
};
#[derive(Debug)]
pub enum Error {
@ -98,14 +100,15 @@ impl std::convert::From<GossipError> for Error {
#[cfg(test)]
mod tests {
use crate::result::Error;
use crate::result::Result;
use std::io;
use std::io::Write;
use std::panic;
use std::sync::mpsc::channel;
use std::sync::mpsc::RecvError;
use std::sync::mpsc::RecvTimeoutError;
use {
crate::result::{Error, Result},
std::{
io,
io::Write,
panic,
sync::mpsc::{channel, RecvError, RecvTimeoutError},
},
};
fn send_error() -> Result<()> {
let (s, r) = channel();

View File

@ -22,8 +22,9 @@ use {
contact_info::ContactInfo,
},
solana_ledger::{
blockstore::Blockstore,
leader_schedule_cache::LeaderScheduleCache,
shred::{Shred, ShredType},
{blockstore::Blockstore, leader_schedule_cache::LeaderScheduleCache},
},
solana_measure::measure::Measure,
solana_perf::packet::Packets,

View File

@ -1,15 +1,17 @@
use crossbeam_channel::{Receiver, RecvTimeoutError, Sender};
use solana_ledger::blockstore::Blockstore;
use solana_runtime::bank::RewardInfo;
use solana_sdk::{clock::Slot, pubkey::Pubkey};
use solana_transaction_status::Reward;
use std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc,
use {
crossbeam_channel::{Receiver, RecvTimeoutError, Sender},
solana_ledger::blockstore::Blockstore,
solana_runtime::bank::RewardInfo,
solana_sdk::{clock::Slot, pubkey::Pubkey},
solana_transaction_status::Reward,
std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
thread::{self, Builder, JoinHandle},
time::Duration,
},
thread::{self, Builder, JoinHandle},
time::Duration,
};
pub type RewardsRecorderReceiver = Receiver<(Slot, Vec<(Pubkey, RewardInfo)>)>;

View File

@ -1,12 +1,14 @@
use solana_ledger::{blockstore::Blockstore, blockstore_meta::PerfSample};
use solana_runtime::bank_forks::BankForks;
use std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc, RwLock,
use {
solana_ledger::{blockstore::Blockstore, blockstore_meta::PerfSample},
solana_runtime::bank_forks::BankForks,
std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc, RwLock,
},
thread::{self, sleep, Builder, JoinHandle},
time::{Duration, Instant},
},
thread::{self, sleep, Builder, JoinHandle},
time::{Duration, Instant},
};
const SAMPLE_INTERVAL: u64 = 60;

View File

@ -1,41 +1,45 @@
use crate::{
cluster_slots::ClusterSlots,
duplicate_repair_status::ANCESTOR_HASH_REPAIR_SAMPLE_SIZE,
repair_response,
repair_service::{OutstandingShredRepairs, RepairStats},
request_response::RequestResponse,
result::{Error, Result},
};
use bincode::serialize;
use lru::LruCache;
use rand::{
distributions::{Distribution, WeightedError, WeightedIndex},
Rng,
};
use solana_gossip::{
cluster_info::{ClusterInfo, ClusterInfoError},
contact_info::ContactInfo,
weighted_shuffle::{weighted_best, weighted_shuffle},
};
use solana_ledger::{
ancestor_iterator::{AncestorIterator, AncestorIteratorWithHash},
blockstore::Blockstore,
shred::{Nonce, Shred, SIZE_OF_NONCE},
};
use solana_measure::measure::Measure;
use solana_metrics::inc_new_counter_debug;
use solana_perf::packet::{limited_deserialize, Packets, PacketsRecycler};
use solana_sdk::{
clock::Slot, hash::Hash, packet::PACKET_DATA_SIZE, pubkey::Pubkey, timing::duration_as_ms,
};
use solana_streamer::streamer::{PacketReceiver, PacketSender};
use std::{
collections::HashSet,
net::SocketAddr,
sync::atomic::{AtomicBool, Ordering},
sync::{Arc, RwLock},
thread::{Builder, JoinHandle},
time::{Duration, Instant},
use {
crate::{
cluster_slots::ClusterSlots,
duplicate_repair_status::ANCESTOR_HASH_REPAIR_SAMPLE_SIZE,
repair_response,
repair_service::{OutstandingShredRepairs, RepairStats},
request_response::RequestResponse,
result::{Error, Result},
},
bincode::serialize,
lru::LruCache,
rand::{
distributions::{Distribution, WeightedError, WeightedIndex},
Rng,
},
solana_gossip::{
cluster_info::{ClusterInfo, ClusterInfoError},
contact_info::ContactInfo,
weighted_shuffle::{weighted_best, weighted_shuffle},
},
solana_ledger::{
ancestor_iterator::{AncestorIterator, AncestorIteratorWithHash},
blockstore::Blockstore,
shred::{Nonce, Shred, SIZE_OF_NONCE},
},
solana_measure::measure::Measure,
solana_metrics::inc_new_counter_debug,
solana_perf::packet::{limited_deserialize, Packets, PacketsRecycler},
solana_sdk::{
clock::Slot, hash::Hash, packet::PACKET_DATA_SIZE, pubkey::Pubkey, timing::duration_as_ms,
},
solana_streamer::streamer::{PacketReceiver, PacketSender},
std::{
collections::HashSet,
net::SocketAddr,
sync::{
atomic::{AtomicBool, Ordering},
Arc, RwLock,
},
thread::{Builder, JoinHandle},
time::{Duration, Instant},
},
};
type SlotHash = (Slot, Hash);
@ -752,18 +756,20 @@ impl ServeRepair {
#[cfg(test)]
mod tests {
use super::*;
use crate::{repair_response, result::Error};
use solana_gossip::{socketaddr, socketaddr_any};
use solana_ledger::get_tmp_ledger_path;
use solana_ledger::{
blockstore::make_many_slot_entries,
blockstore_processor::fill_blockstore_slot_with_ticks,
shred::{max_ticks_per_n_shreds, Shred},
use {
super::*,
crate::{repair_response, result::Error},
solana_gossip::{socketaddr, socketaddr_any},
solana_ledger::{
blockstore::make_many_slot_entries,
blockstore_processor::fill_blockstore_slot_with_ticks,
get_tmp_ledger_path,
shred::{max_ticks_per_n_shreds, Shred},
},
solana_perf::packet::Packet,
solana_sdk::{hash::Hash, pubkey::Pubkey, signature::Keypair, timing::timestamp},
solana_streamer::socket::SocketAddrSpace,
};
use solana_perf::packet::Packet;
use solana_sdk::{hash::Hash, pubkey::Pubkey, signature::Keypair, timing::timestamp};
use solana_streamer::socket::SocketAddrSpace;
#[test]
fn test_run_highest_window_request() {

View File

@ -1,12 +1,14 @@
use crate::serve_repair::ServeRepair;
use solana_ledger::blockstore::Blockstore;
use solana_perf::recycler::Recycler;
use solana_streamer::{socket::SocketAddrSpace, streamer};
use std::net::UdpSocket;
use std::sync::atomic::AtomicBool;
use std::sync::mpsc::channel;
use std::sync::{Arc, RwLock};
use std::thread::{self, JoinHandle};
use {
crate::serve_repair::ServeRepair,
solana_ledger::blockstore::Blockstore,
solana_perf::recycler::Recycler,
solana_streamer::{socket::SocketAddrSpace, streamer},
std::{
net::UdpSocket,
sync::{atomic::AtomicBool, mpsc::channel, Arc, RwLock},
thread::{self, JoinHandle},
},
};
pub struct ServeRepairService {
thread_hdls: Vec<JoinHandle<()>>,

View File

@ -1,21 +1,24 @@
//! The `shred_fetch_stage` pulls shreds from UDP sockets and sends it to a channel.
use crate::packet_hasher::PacketHasher;
use lru::LruCache;
use solana_ledger::shred::{get_shred_slot_index_type, ShredFetchStats};
use solana_perf::cuda_runtime::PinnedVec;
use solana_perf::packet::{Packet, PacketsRecycler};
use solana_perf::recycler::Recycler;
use solana_runtime::bank_forks::BankForks;
use solana_sdk::clock::{Slot, DEFAULT_MS_PER_SLOT};
use solana_streamer::streamer::{self, PacketReceiver, PacketSender};
use std::net::UdpSocket;
use std::sync::atomic::AtomicBool;
use std::sync::mpsc::channel;
use std::sync::Arc;
use std::sync::RwLock;
use std::thread::{self, Builder, JoinHandle};
use std::time::Instant;
use {
crate::packet_hasher::PacketHasher,
lru::LruCache,
solana_ledger::shred::{get_shred_slot_index_type, ShredFetchStats},
solana_perf::{
cuda_runtime::PinnedVec,
packet::{Packet, PacketsRecycler},
recycler::Recycler,
},
solana_runtime::bank_forks::BankForks,
solana_sdk::clock::{Slot, DEFAULT_MS_PER_SLOT},
solana_streamer::streamer::{self, PacketReceiver, PacketSender},
std::{
net::UdpSocket,
sync::{atomic::AtomicBool, mpsc::channel, Arc, RwLock},
thread::{self, Builder, JoinHandle},
time::Instant,
},
};
const DEFAULT_LRU_SIZE: usize = 10_000;
pub type ShredsReceived = LruCache<u64, ()>;
@ -223,9 +226,10 @@ impl ShredFetchStage {
#[cfg(test)]
mod tests {
use super::*;
use solana_ledger::blockstore::MAX_DATA_SHREDS_PER_SLOT;
use solana_ledger::shred::Shred;
use {
super::*,
solana_ledger::{blockstore::MAX_DATA_SHREDS_PER_SLOT, shred::Shred},
};
#[test]
fn test_data_code_same_index() {

View File

@ -4,14 +4,13 @@
//! to the GPU.
//!
use crate::sigverify_stage::SigVerifier;
use solana_perf::cuda_runtime::PinnedVec;
use solana_perf::packet::Packets;
use solana_perf::recycler::Recycler;
use solana_perf::sigverify;
pub use solana_perf::sigverify::{
batch_size, ed25519_verify_cpu, ed25519_verify_disabled, init, TxOffset,
};
use {
crate::sigverify_stage::SigVerifier,
solana_perf::{cuda_runtime::PinnedVec, packet::Packets, recycler::Recycler, sigverify},
};
#[derive(Clone)]
pub struct TransactionSigVerifier {

View File

@ -1,13 +1,17 @@
#![allow(clippy::implicit_hasher)]
use crate::sigverify;
use crate::sigverify_stage::SigVerifier;
use solana_ledger::leader_schedule_cache::LeaderScheduleCache;
use solana_ledger::shred::Shred;
use solana_ledger::sigverify_shreds::verify_shreds_gpu;
use solana_perf::{self, packet::Packets, recycler_cache::RecyclerCache};
use solana_runtime::bank_forks::BankForks;
use std::collections::{HashMap, HashSet};
use std::sync::{Arc, RwLock};
use {
crate::{sigverify, sigverify_stage::SigVerifier},
solana_ledger::{
leader_schedule_cache::LeaderScheduleCache, shred::Shred,
sigverify_shreds::verify_shreds_gpu,
},
solana_perf::{self, packet::Packets, recycler_cache::RecyclerCache},
solana_runtime::bank_forks::BankForks,
std::{
collections::{HashMap, HashSet},
sync::{Arc, RwLock},
},
};
#[derive(Clone)]
pub struct ShredSigVerifier {
@ -59,12 +63,16 @@ impl SigVerifier for ShredSigVerifier {
#[cfg(test)]
pub mod tests {
use super::*;
use solana_ledger::genesis_utils::create_genesis_config_with_leader;
use solana_ledger::shred::{Shred, Shredder};
use solana_perf::packet::Packet;
use solana_runtime::bank::Bank;
use solana_sdk::signature::{Keypair, Signer};
use {
super::*,
solana_ledger::{
genesis_utils::create_genesis_config_with_leader,
shred::{Shred, Shredder},
},
solana_perf::packet::Packet,
solana_runtime::bank::Bank,
solana_sdk::signature::{Keypair, Signer},
};
#[test]
fn test_sigverify_shreds_read_slots() {

View File

@ -5,19 +5,21 @@
//! transaction. All processing is done on the CPU by default and on a GPU
//! if perf-libs are available
use crate::sigverify;
use crossbeam_channel::{SendError, Sender as CrossbeamSender};
use solana_measure::measure::Measure;
use solana_perf::packet::Packets;
use solana_sdk::timing;
use solana_streamer::streamer::{self, PacketReceiver, StreamerError};
use std::{
collections::HashMap,
sync::mpsc::{Receiver, RecvTimeoutError},
thread::{self, Builder, JoinHandle},
time::Instant,
use {
crate::sigverify,
crossbeam_channel::{SendError, Sender as CrossbeamSender},
solana_measure::measure::Measure,
solana_perf::packet::Packets,
solana_sdk::timing,
solana_streamer::streamer::{self, PacketReceiver, StreamerError},
std::{
collections::HashMap,
sync::mpsc::{Receiver, RecvTimeoutError},
thread::{self, Builder, JoinHandle},
time::Instant,
},
thiserror::Error,
};
use thiserror::Error;
const MAX_SIGVERIFY_BATCH: usize = 10_000;
@ -264,8 +266,7 @@ impl SigVerifyStage {
#[cfg(test)]
mod tests {
use super::*;
use solana_perf::packet::Packet;
use {super::*, solana_perf::packet::Packet};
fn count_non_discard(packets: &[Packets]) -> usize {
packets

View File

@ -1,25 +1,27 @@
use solana_gossip::cluster_info::{
ClusterInfo, MAX_INCREMENTAL_SNAPSHOT_HASHES, MAX_SNAPSHOT_HASHES,
};
use solana_perf::thread::renice_this_thread;
use solana_runtime::{
snapshot_archive_info::SnapshotArchiveInfoGetter,
snapshot_config::SnapshotConfig,
snapshot_hash::{
FullSnapshotHash, FullSnapshotHashes, IncrementalSnapshotHash, IncrementalSnapshotHashes,
StartingSnapshotHashes,
use {
solana_gossip::cluster_info::{
ClusterInfo, MAX_INCREMENTAL_SNAPSHOT_HASHES, MAX_SNAPSHOT_HASHES,
},
snapshot_package::{PendingSnapshotPackage, SnapshotType},
snapshot_utils,
};
use solana_sdk::{clock::Slot, hash::Hash};
use std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc,
solana_perf::thread::renice_this_thread,
solana_runtime::{
snapshot_archive_info::SnapshotArchiveInfoGetter,
snapshot_config::SnapshotConfig,
snapshot_hash::{
FullSnapshotHash, FullSnapshotHashes, IncrementalSnapshotHash,
IncrementalSnapshotHashes, StartingSnapshotHashes,
},
snapshot_package::{PendingSnapshotPackage, SnapshotType},
snapshot_utils,
},
solana_sdk::{clock::Slot, hash::Hash},
std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
thread::{self, Builder, JoinHandle},
time::Duration,
},
thread::{self, Builder, JoinHandle},
time::Duration,
};
pub struct SnapshotPackagerService {
@ -208,22 +210,26 @@ impl SnapshotGossipManager {
#[cfg(test)]
mod tests {
use super::*;
use bincode::serialize_into;
use solana_runtime::{
accounts_db::AccountStorageEntry,
bank::BankSlotDelta,
snapshot_archive_info::SnapshotArchiveInfo,
snapshot_package::{SnapshotPackage, SnapshotType},
snapshot_utils::{self, ArchiveFormat, SnapshotVersion, SNAPSHOT_STATUS_CACHE_FILE_NAME},
use {
super::*,
bincode::serialize_into,
solana_runtime::{
accounts_db::AccountStorageEntry,
bank::BankSlotDelta,
snapshot_archive_info::SnapshotArchiveInfo,
snapshot_package::{SnapshotPackage, SnapshotType},
snapshot_utils::{
self, ArchiveFormat, SnapshotVersion, SNAPSHOT_STATUS_CACHE_FILE_NAME,
},
},
solana_sdk::hash::Hash,
std::{
fs::{self, remove_dir_all, OpenOptions},
io::Write,
path::{Path, PathBuf},
},
tempfile::TempDir,
};
use solana_sdk::hash::Hash;
use std::{
fs::{self, remove_dir_all, OpenOptions},
io::Write,
path::{Path, PathBuf},
};
use tempfile::TempDir;
// Create temporary placeholder directory for all test files
fn make_tmp_dir_path() -> PathBuf {

View File

@ -1,17 +1,18 @@
use solana_sdk::timing::AtomicInterval;
use std::{
collections::HashMap,
io::BufRead,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
thread::{self, sleep, Builder, JoinHandle},
time::Duration,
};
#[cfg(target_os = "linux")]
use std::{fs::File, io::BufReader, path::Path};
use {
solana_sdk::timing::AtomicInterval,
std::{
collections::HashMap,
io::BufRead,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
thread::{self, sleep, Builder, JoinHandle},
time::Duration,
},
};
const MS_PER_S: u64 = 1_000;
const SAMPLE_INTERVAL_UDP_MS: u64 = 60 * MS_PER_S;

View File

@ -1,38 +1,40 @@
//! The `tpu` module implements the Transaction Processing Unit, a
//! multi-stage transaction processing pipeline in software.
use crate::{
banking_stage::BankingStage,
broadcast_stage::{BroadcastStage, BroadcastStageType, RetransmitSlotsReceiver},
cluster_info_vote_listener::{
ClusterInfoVoteListener, GossipDuplicateConfirmedSlotsSender, GossipVerifiedVoteHashSender,
VerifiedVoteSender, VoteTracker,
use {
crate::{
banking_stage::BankingStage,
broadcast_stage::{BroadcastStage, BroadcastStageType, RetransmitSlotsReceiver},
cluster_info_vote_listener::{
ClusterInfoVoteListener, GossipDuplicateConfirmedSlotsSender,
GossipVerifiedVoteHashSender, VerifiedVoteSender, VoteTracker,
},
fetch_stage::FetchStage,
sigverify::TransactionSigVerifier,
sigverify_stage::SigVerifyStage,
},
fetch_stage::FetchStage,
sigverify::TransactionSigVerifier,
sigverify_stage::SigVerifyStage,
};
use crossbeam_channel::unbounded;
use solana_gossip::cluster_info::ClusterInfo;
use solana_ledger::{blockstore::Blockstore, blockstore_processor::TransactionStatusSender};
use solana_poh::poh_recorder::{PohRecorder, WorkingBankEntry};
use solana_rpc::{
optimistically_confirmed_bank_tracker::BankNotificationSender,
rpc_subscriptions::RpcSubscriptions,
};
use solana_runtime::{
bank_forks::BankForks,
cost_model::CostModel,
vote_sender_types::{ReplayVoteReceiver, ReplayVoteSender},
};
use std::{
net::UdpSocket,
sync::{
atomic::AtomicBool,
mpsc::{channel, Receiver},
Arc, Mutex, RwLock,
crossbeam_channel::unbounded,
solana_gossip::cluster_info::ClusterInfo,
solana_ledger::{blockstore::Blockstore, blockstore_processor::TransactionStatusSender},
solana_poh::poh_recorder::{PohRecorder, WorkingBankEntry},
solana_rpc::{
optimistically_confirmed_bank_tracker::BankNotificationSender,
rpc_subscriptions::RpcSubscriptions,
},
solana_runtime::{
bank_forks::BankForks,
cost_model::CostModel,
vote_sender_types::{ReplayVoteReceiver, ReplayVoteSender},
},
std::{
net::UdpSocket,
sync::{
atomic::AtomicBool,
mpsc::{channel, Receiver},
Arc, Mutex, RwLock,
},
thread,
},
thread,
};
pub const DEFAULT_TPU_COALESCE_MS: u64 = 5;

View File

@ -1,63 +1,67 @@
//! The `tvu` module implements the Transaction Validation Unit, a multi-stage transaction
//! validation pipeline in software.
use crate::{
accounts_hash_verifier::AccountsHashVerifier,
broadcast_stage::RetransmitSlotsSender,
cache_block_meta_service::CacheBlockMetaSender,
cluster_info_vote_listener::{
GossipDuplicateConfirmedSlotsReceiver, GossipVerifiedVoteHashReceiver,
VerifiedVoteReceiver, VoteTracker,
use {
crate::{
accounts_hash_verifier::AccountsHashVerifier,
broadcast_stage::RetransmitSlotsSender,
cache_block_meta_service::CacheBlockMetaSender,
cluster_info_vote_listener::{
GossipDuplicateConfirmedSlotsReceiver, GossipVerifiedVoteHashReceiver,
VerifiedVoteReceiver, VoteTracker,
},
cluster_slots::ClusterSlots,
completed_data_sets_service::CompletedDataSetsSender,
consensus::Tower,
cost_update_service::CostUpdateService,
drop_bank_service::DropBankService,
ledger_cleanup_service::LedgerCleanupService,
replay_stage::{ReplayStage, ReplayStageConfig},
retransmit_stage::RetransmitStage,
rewards_recorder_service::RewardsRecorderSender,
shred_fetch_stage::ShredFetchStage,
sigverify_shreds::ShredSigVerifier,
sigverify_stage::SigVerifyStage,
tower_storage::TowerStorage,
voting_service::VotingService,
},
cluster_slots::ClusterSlots,
completed_data_sets_service::CompletedDataSetsSender,
consensus::Tower,
cost_update_service::CostUpdateService,
drop_bank_service::DropBankService,
ledger_cleanup_service::LedgerCleanupService,
replay_stage::{ReplayStage, ReplayStageConfig},
retransmit_stage::RetransmitStage,
rewards_recorder_service::RewardsRecorderSender,
shred_fetch_stage::ShredFetchStage,
sigverify_shreds::ShredSigVerifier,
sigverify_stage::SigVerifyStage,
tower_storage::TowerStorage,
voting_service::VotingService,
};
use crossbeam_channel::unbounded;
use solana_gossip::cluster_info::ClusterInfo;
use solana_ledger::{
blockstore::Blockstore, blockstore_processor::TransactionStatusSender,
leader_schedule_cache::LeaderScheduleCache,
};
use solana_poh::poh_recorder::PohRecorder;
use solana_rpc::{
max_slots::MaxSlots, optimistically_confirmed_bank_tracker::BankNotificationSender,
rpc_subscriptions::RpcSubscriptions,
};
use solana_runtime::{
accounts_background_service::{
AbsRequestHandler, AbsRequestSender, AccountsBackgroundService, SnapshotRequestHandler,
crossbeam_channel::unbounded,
solana_gossip::cluster_info::ClusterInfo,
solana_ledger::{
blockstore::Blockstore, blockstore_processor::TransactionStatusSender,
leader_schedule_cache::LeaderScheduleCache,
},
accounts_db::AccountShrinkThreshold,
bank_forks::BankForks,
commitment::BlockCommitmentCache,
cost_model::CostModel,
snapshot_config::SnapshotConfig,
snapshot_package::{AccountsPackageReceiver, AccountsPackageSender, PendingSnapshotPackage},
vote_sender_types::ReplayVoteSender,
};
use solana_sdk::{clock::Slot, pubkey::Pubkey, signature::Keypair};
use std::{
boxed::Box,
collections::HashSet,
net::UdpSocket,
sync::{
atomic::AtomicBool,
mpsc::{channel, Receiver},
Arc, Mutex, RwLock,
solana_poh::poh_recorder::PohRecorder,
solana_rpc::{
max_slots::MaxSlots, optimistically_confirmed_bank_tracker::BankNotificationSender,
rpc_subscriptions::RpcSubscriptions,
},
solana_runtime::{
accounts_background_service::{
AbsRequestHandler, AbsRequestSender, AccountsBackgroundService, SnapshotRequestHandler,
},
accounts_db::AccountShrinkThreshold,
bank_forks::BankForks,
commitment::BlockCommitmentCache,
cost_model::CostModel,
snapshot_config::SnapshotConfig,
snapshot_package::{
AccountsPackageReceiver, AccountsPackageSender, PendingSnapshotPackage,
},
vote_sender_types::ReplayVoteSender,
},
solana_sdk::{clock::Slot, pubkey::Pubkey, signature::Keypair},
std::{
boxed::Box,
collections::HashSet,
net::UdpSocket,
sync::{
atomic::AtomicBool,
mpsc::{channel, Receiver},
Arc, Mutex, RwLock,
},
thread,
},
thread,
};
pub struct Tvu {
@ -383,20 +387,22 @@ impl Tvu {
#[cfg(test)]
pub mod tests {
use super::*;
use serial_test::serial;
use solana_gossip::cluster_info::{ClusterInfo, Node};
use solana_ledger::{
blockstore::BlockstoreSignals,
create_new_tmp_ledger,
genesis_utils::{create_genesis_config, GenesisConfigInfo},
use {
super::*,
serial_test::serial,
solana_gossip::cluster_info::{ClusterInfo, Node},
solana_ledger::{
blockstore::BlockstoreSignals,
create_new_tmp_ledger,
genesis_utils::{create_genesis_config, GenesisConfigInfo},
},
solana_poh::poh_recorder::create_test_recorder,
solana_rpc::optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank,
solana_runtime::bank::Bank,
solana_sdk::signature::{Keypair, Signer},
solana_streamer::socket::SocketAddrSpace,
std::sync::atomic::Ordering,
};
use solana_poh::poh_recorder::create_test_recorder;
use solana_rpc::optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank;
use solana_runtime::bank::Bank;
use solana_sdk::signature::{Keypair, Signer};
use solana_streamer::socket::SocketAddrSpace;
use std::sync::atomic::Ordering;
#[ignore]
#[test]

View File

@ -1,6 +1,8 @@
use crate::latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks;
use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey};
use std::collections::{BTreeMap, HashMap};
use {
crate::latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey},
std::collections::{BTreeMap, HashMap},
};
#[derive(Default)]
pub struct UnfrozenGossipVerifiedVoteHashes {

View File

@ -1740,11 +1740,12 @@ pub fn is_snapshot_config_valid(
#[cfg(test)]
mod tests {
use super::*;
use solana_ledger::{create_new_tmp_ledger, genesis_utils::create_genesis_config_with_leader};
use solana_sdk::genesis_config::create_genesis_config;
use solana_sdk::poh_config::PohConfig;
use std::fs::remove_dir_all;
use {
super::*,
solana_ledger::{create_new_tmp_ledger, genesis_utils::create_genesis_config_with_leader},
solana_sdk::{genesis_config::create_genesis_config, poh_config::PohConfig},
std::fs::remove_dir_all,
};
#[test]
fn validator_exit() {
@ -1789,8 +1790,10 @@ mod tests {
fn test_backup_and_clear_blockstore() {
use std::time::Instant;
solana_logger::setup();
use solana_entry::entry;
use solana_ledger::{blockstore, get_tmp_ledger_path};
use {
solana_entry::entry,
solana_ledger::{blockstore, get_tmp_ledger_path},
};
let blockstore_path = get_tmp_ledger_path!();
{
let blockstore = Blockstore::open(&blockstore_path).unwrap();

View File

@ -1,16 +1,18 @@
use crate::{cluster_info_vote_listener::VerifiedLabelVotePacketsReceiver, result::Result};
use crossbeam_channel::Select;
use solana_perf::packet::Packets;
use solana_runtime::bank::Bank;
use solana_sdk::{
account::from_account, clock::Slot, hash::Hash, pubkey::Pubkey, signature::Signature,
slot_hashes::SlotHashes, sysvar,
};
use solana_vote_program::vote_state::Vote;
use std::{
collections::{BTreeMap, HashMap, HashSet},
sync::Arc,
time::Duration,
use {
crate::{cluster_info_vote_listener::VerifiedLabelVotePacketsReceiver, result::Result},
crossbeam_channel::Select,
solana_perf::packet::Packets,
solana_runtime::bank::Bank,
solana_sdk::{
account::from_account, clock::Slot, hash::Hash, pubkey::Pubkey, signature::Signature,
slot_hashes::SlotHashes, sysvar,
},
solana_vote_program::vote_state::Vote,
std::{
collections::{BTreeMap, HashMap, HashSet},
sync::Arc,
time::Duration,
},
};
const MAX_VOTES_PER_VALIDATOR: usize = 1000;
@ -174,11 +176,13 @@ impl VerifiedVotePackets {
#[cfg(test)]
mod tests {
use super::*;
use crate::{result::Error, vote_simulator::VoteSimulator};
use crossbeam_channel::unbounded;
use solana_perf::packet::Packet;
use solana_sdk::slot_hashes::MAX_ENTRIES;
use {
super::*,
crate::{result::Error, vote_simulator::VoteSimulator},
crossbeam_channel::unbounded,
solana_perf::packet::Packet,
solana_sdk::slot_hashes::MAX_ENTRIES,
};
#[test]
fn test_verified_vote_packets_receive_and_process_vote_packets() {

View File

@ -1,32 +1,34 @@
use crate::{
cluster_info_vote_listener::VoteTracker,
cluster_slot_state_verifier::{
DuplicateSlotsTracker, EpochSlotsFrozenSlots, GossipDuplicateConfirmedSlots,
use {
crate::{
cluster_info_vote_listener::VoteTracker,
cluster_slot_state_verifier::{
DuplicateSlotsTracker, EpochSlotsFrozenSlots, GossipDuplicateConfirmedSlots,
},
cluster_slots::ClusterSlots,
consensus::Tower,
fork_choice::SelectVoteAndResetForkResult,
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
progress_map::{ForkProgress, ProgressMap},
replay_stage::{HeaviestForkFailures, ReplayStage},
unfrozen_gossip_verified_vote_hashes::UnfrozenGossipVerifiedVoteHashes,
},
cluster_slots::ClusterSlots,
consensus::Tower,
fork_choice::SelectVoteAndResetForkResult,
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
progress_map::{ForkProgress, ProgressMap},
replay_stage::{HeaviestForkFailures, ReplayStage},
unfrozen_gossip_verified_vote_hashes::UnfrozenGossipVerifiedVoteHashes,
};
use solana_runtime::{
accounts_background_service::AbsRequestSender,
bank::Bank,
bank_forks::BankForks,
genesis_utils::{
create_genesis_config_with_vote_accounts, GenesisConfigInfo, ValidatorVoteKeypairs,
solana_runtime::{
accounts_background_service::AbsRequestSender,
bank::Bank,
bank_forks::BankForks,
genesis_utils::{
create_genesis_config_with_vote_accounts, GenesisConfigInfo, ValidatorVoteKeypairs,
},
},
solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey, signature::Signer},
solana_vote_program::vote_transaction,
std::{
collections::{HashMap, HashSet},
sync::{Arc, RwLock},
},
trees::{tr, Tree, TreeWalk},
};
use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey, signature::Signer};
use solana_vote_program::vote_transaction;
use std::{
collections::{HashMap, HashSet},
sync::{Arc, RwLock},
};
use trees::{tr, Tree, TreeWalk};
pub struct VoteSimulator {
pub validator_keypairs: HashMap<Pubkey, ValidatorVoteKeypairs>,

View File

@ -1,5 +1,4 @@
use solana_sdk::pubkey::Pubkey;
use std::collections::HashSet;
use {solana_sdk::pubkey::Pubkey, std::collections::HashSet};
#[derive(Default)]
pub struct VoteStakeTracker {
@ -49,8 +48,7 @@ impl VoteStakeTracker {
#[cfg(test)]
mod test {
use super::*;
use solana_runtime::commitment::VOTE_THRESHOLD_SIZE;
use {super::*, solana_runtime::commitment::VOTE_THRESHOLD_SIZE};
#[test]
fn test_add_vote_pubkey() {

View File

@ -1,12 +1,14 @@
use crate::tower_storage::{SavedTower, TowerStorage};
use solana_gossip::cluster_info::ClusterInfo;
use solana_measure::measure::Measure;
use solana_poh::poh_recorder::PohRecorder;
use solana_runtime::bank_forks::BankForks;
use solana_sdk::{clock::Slot, transaction::Transaction};
use std::{
sync::{mpsc::Receiver, Arc, Mutex, RwLock},
thread::{self, Builder, JoinHandle},
use {
crate::tower_storage::{SavedTower, TowerStorage},
solana_gossip::cluster_info::ClusterInfo,
solana_measure::measure::Measure,
solana_poh::poh_recorder::PohRecorder,
solana_runtime::bank_forks::BankForks,
solana_sdk::{clock::Slot, transaction::Transaction},
std::{
sync::{mpsc::Receiver, Arc, Mutex, RwLock},
thread::{self, Builder, JoinHandle},
},
};
pub enum VoteOp {

View File

@ -26,10 +26,9 @@ use {
solana_rayon_threadlimit::get_thread_count,
solana_runtime::{bank::Bank, bank_forks::BankForks},
solana_sdk::{clock::Slot, packet::PACKET_DATA_SIZE, pubkey::Pubkey},
std::collections::HashSet,
std::{
cmp::Reverse,
collections::HashMap,
collections::{HashMap, HashSet},
net::{SocketAddr, UdpSocket},
sync::{
atomic::{AtomicBool, Ordering},
@ -950,8 +949,10 @@ mod test {
#[test]
fn test_prune_shreds() {
use crate::serve_repair::ShredRepairType;
use std::net::{IpAddr, Ipv4Addr};
use {
crate::serve_repair::ShredRepairType,
std::net::{IpAddr, Ipv4Addr},
};
solana_logger::setup();
let (common, coding) = Shredder::new_coding_shred_header(5, 5, 5, 6, 6, 0);
let shred = Shred::new_empty_from_header(common, DataShredHeader::default(), coding);

View File

@ -74,8 +74,10 @@
#![allow(clippy::integer_arithmetic)]
extern crate rand;
use rand::{thread_rng, Rng};
use std::collections::{HashMap, VecDeque};
use {
rand::{thread_rng, Rng},
std::collections::{HashMap, VecDeque},
};
#[derive(Clone, Default, Debug, Hash, Eq, PartialEq)]
pub struct Fork {

View File

@ -3,20 +3,28 @@
#[cfg(test)]
mod tests {
use log::*;
use solana_core::ledger_cleanup_service::LedgerCleanupService;
use solana_ledger::blockstore::{make_many_slot_entries, Blockstore};
use solana_ledger::get_tmp_ledger_path;
use solana_ledger::shred::Shred;
use solana_measure::measure::Measure;
use std::collections::VecDeque;
use std::str::FromStr;
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use std::sync::mpsc::channel;
use std::sync::{Arc, Mutex, RwLock};
use std::thread::{self, Builder, JoinHandle};
use std::time::{Duration, Instant};
use systemstat::{CPULoad, Platform, System};
use {
log::*,
solana_core::ledger_cleanup_service::LedgerCleanupService,
solana_ledger::{
blockstore::{make_many_slot_entries, Blockstore},
get_tmp_ledger_path,
shred::Shred,
},
solana_measure::measure::Measure,
std::{
collections::VecDeque,
str::FromStr,
sync::{
atomic::{AtomicBool, AtomicU64, Ordering},
mpsc::channel,
Arc, Mutex, RwLock,
},
thread::{self, Builder, JoinHandle},
time::{Duration, Instant},
},
systemstat::{CPULoad, Platform, System},
};
const DEFAULT_BENCHMARK_SLOTS: u64 = 50;
const DEFAULT_BATCH_SIZE: u64 = 1;

View File

@ -45,56 +45,59 @@ macro_rules! DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS {
#[cfg(test)]
mod tests {
use bincode::serialize_into;
use crossbeam_channel::unbounded;
use fs_extra::dir::CopyOptions;
use itertools::Itertools;
use log::{info, trace};
use solana_core::{
accounts_hash_verifier::AccountsHashVerifier,
snapshot_packager_service::SnapshotPackagerService,
};
use solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo};
use solana_runtime::{
accounts_background_service::{
AbsRequestHandler, AbsRequestSender, AccountsBackgroundService, SnapshotRequestHandler,
use {
bincode::serialize_into,
crossbeam_channel::unbounded,
fs_extra::dir::CopyOptions,
itertools::Itertools,
log::{info, trace},
solana_core::{
accounts_hash_verifier::AccountsHashVerifier,
snapshot_packager_service::SnapshotPackagerService,
},
accounts_db::{self, ACCOUNTS_DB_CONFIG_FOR_TESTING},
accounts_index::AccountSecondaryIndexes,
bank::{Bank, BankSlotDelta},
bank_forks::BankForks,
genesis_utils::{create_genesis_config, GenesisConfigInfo},
snapshot_archive_info::FullSnapshotArchiveInfo,
snapshot_config::SnapshotConfig,
snapshot_package::{
AccountsPackage, PendingSnapshotPackage, SnapshotPackage, SnapshotType,
solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo},
solana_runtime::{
accounts_background_service::{
AbsRequestHandler, AbsRequestSender, AccountsBackgroundService,
SnapshotRequestHandler,
},
accounts_db::{self, ACCOUNTS_DB_CONFIG_FOR_TESTING},
accounts_index::AccountSecondaryIndexes,
bank::{Bank, BankSlotDelta},
bank_forks::BankForks,
genesis_utils::{create_genesis_config, GenesisConfigInfo},
snapshot_archive_info::FullSnapshotArchiveInfo,
snapshot_config::SnapshotConfig,
snapshot_package::{
AccountsPackage, PendingSnapshotPackage, SnapshotPackage, SnapshotType,
},
snapshot_utils::{self, ArchiveFormat, SnapshotVersion},
status_cache::MAX_CACHE_ENTRIES,
},
snapshot_utils::{self, ArchiveFormat, SnapshotVersion},
status_cache::MAX_CACHE_ENTRIES,
};
use solana_sdk::{
clock::Slot,
genesis_config::{ClusterType, GenesisConfig},
hash::{hashv, Hash},
pubkey::Pubkey,
signature::{Keypair, Signer},
system_transaction,
timing::timestamp,
};
use solana_streamer::socket::SocketAddrSpace;
use std::{
collections::HashSet,
fs,
io::{Error, ErrorKind},
path::PathBuf,
sync::{
atomic::{AtomicBool, Ordering},
mpsc::channel,
Arc, RwLock,
solana_sdk::{
clock::Slot,
genesis_config::{ClusterType, GenesisConfig},
hash::{hashv, Hash},
pubkey::Pubkey,
signature::{Keypair, Signer},
system_transaction,
timing::timestamp,
},
time::Duration,
solana_streamer::socket::SocketAddrSpace,
std::{
collections::HashSet,
fs,
io::{Error, ErrorKind},
path::PathBuf,
sync::{
atomic::{AtomicBool, Ordering},
mpsc::channel,
Arc, RwLock,
},
time::Duration,
},
tempfile::TempDir,
};
use tempfile::TempDir;
DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS!(V1_2_0, Development, V1_2_0_Development);
DEFINE_SNAPSHOT_VERSION_PARAMETERIZED_TEST_FUNCTIONS!(V1_2_0, Devnet, V1_2_0_Devnet);