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:20:02 -08:00
parent 5a7b487e3d
commit 139d15cd84
380 changed files with 6067 additions and 5293 deletions

View File

@@ -4,23 +4,25 @@
// 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 crate::snapshot_packager_service::PendingSnapshotPackage;
use rayon::ThreadPool;
use solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES};
use solana_runtime::{
accounts_db,
snapshot_package::{AccountsPackage, AccountsPackagePre, AccountsPackageReceiver},
};
use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey};
use std::collections::{HashMap, HashSet};
use std::{
sync::{
atomic::{AtomicBool, Ordering},
mpsc::RecvTimeoutError,
Arc,
use {
crate::snapshot_packager_service::PendingSnapshotPackage,
rayon::ThreadPool,
solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES},
solana_runtime::{
accounts_db,
snapshot_package::{AccountsPackage, AccountsPackagePre, AccountsPackageReceiver},
},
solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey},
std::{
collections::{HashMap, HashSet},
sync::{
atomic::{AtomicBool, Ordering},
mpsc::RecvTimeoutError,
Arc,
},
thread::{self, Builder, JoinHandle},
time::Duration,
},
thread::{self, Builder, JoinHandle},
time::Duration,
};
pub struct AccountsHashVerifier {
@@ -129,8 +131,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]);
@@ -215,15 +219,16 @@ impl AccountsHashVerifier {
#[cfg(test)]
mod tests {
use super::*;
use solana_gossip::{cluster_info::make_accounts_hashes_message, contact_info::ContactInfo};
use solana_runtime::bank_forks::ArchiveFormat;
use solana_runtime::snapshot_utils::SnapshotVersion;
use solana_sdk::{
hash::hash,
signature::{Keypair, Signer},
use {
super::*,
solana_gossip::{cluster_info::make_accounts_hashes_message, contact_info::ContactInfo},
solana_runtime::{bank_forks::ArchiveFormat, snapshot_utils::SnapshotVersion},
solana_sdk::{
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(
@@ -269,8 +274,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,64 +1,67 @@
//! 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;
use crossbeam_channel::{Receiver as CrossbeamReceiver, RecvTimeoutError};
use itertools::Itertools;
use lru::LruCache;
use retain_mut::RetainMut;
use solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo};
use solana_ledger::{blockstore_processor::TransactionStatusSender, entry::hash_transactions};
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::{PohRecorder, PohRecorderError, TransactionRecorder};
use solana_runtime::{
accounts_db::ErrorCounters,
bank::{
Bank, ExecuteTimings, TransactionBalancesSet, TransactionCheckResult,
TransactionExecutionResult,
use {
crate::packet_hasher::PacketHasher,
crossbeam_channel::{Receiver as CrossbeamReceiver, RecvTimeoutError},
itertools::Itertools,
lru::LruCache,
retain_mut::RetainMut,
solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo},
solana_ledger::{blockstore_processor::TransactionStatusSender, entry::hash_transactions},
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,
cost_tracker::CostTracker,
hashed_transaction::HashedTransaction,
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::{PohRecorder, PohRecorderError, TransactionRecorder},
solana_runtime::{
accounts_db::ErrorCounters,
bank::{
Bank, ExecuteTimings, TransactionBalancesSet, TransactionCheckResult,
TransactionExecutionResult,
},
bank_utils,
cost_model::CostModel,
cost_tracker::CostTracker,
hashed_transaction::HashedTransaction,
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, Transaction, TransactionError},
},
solana_transaction_status::token_balances::{
collect_token_balances, TransactionTokenBalancesSet,
},
std::{
borrow::Cow,
cmp,
collections::{HashMap, VecDeque},
env,
mem::size_of,
net::{SocketAddr, UdpSocket},
ops::DerefMut,
sync::{
atomic::{AtomicU64, AtomicUsize, Ordering},
Arc, Mutex, RwLock, RwLockReadGuard,
},
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, Transaction, TransactionError},
};
use solana_transaction_status::token_balances::{
collect_token_balances, TransactionTokenBalancesSet,
};
use std::{
borrow::Cow,
cmp,
collections::{HashMap, VecDeque},
env,
mem::size_of,
net::{SocketAddr, UdpSocket},
ops::DerefMut,
sync::atomic::{AtomicU64, AtomicUsize, Ordering},
sync::{Arc, Mutex, RwLock, RwLockReadGuard},
thread::{self, Builder, JoinHandle},
time::Duration,
time::Instant,
};
/// (packets, valid_indexes, forwarded)
@@ -1660,44 +1663,46 @@ where
#[cfg(test)]
mod tests {
use super::*;
use crossbeam_channel::unbounded;
use itertools::Itertools;
use solana_gossip::{cluster_info::Node, contact_info::ContactInfo};
use solana_ledger::{
blockstore::{entries_to_test_shreds, Blockstore},
entry::{next_entry, Entry, EntrySlice},
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, WorkingBank, WorkingBankEntry},
poh_service::PohService,
};
use solana_rpc::transaction_status_service::TransactionStatusService;
use solana_runtime::cost_model::CostModel;
use solana_sdk::{
hash::Hash,
instruction::InstructionError,
poh_config::PohConfig,
signature::{Keypair, Signer},
system_instruction::SystemError,
system_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_gossip::{cluster_info::Node, contact_info::ContactInfo},
solana_ledger::{
blockstore::{entries_to_test_shreds, Blockstore},
entry::{next_entry, Entry, EntrySlice},
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, WorkingBank, WorkingBankEntry},
poh_service::PohService,
},
solana_rpc::transaction_status_service::TransactionStatusService,
solana_runtime::cost_model::CostModel,
solana_sdk::{
hash::Hash,
instruction::InstructionError,
poh_config::PohConfig,
signature::{Keypair, Signer},
system_instruction::SystemError,
system_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

@@ -23,8 +23,9 @@ use {
solana_poh::poh_recorder::WorkingBankEntry,
solana_runtime::{bank::Bank, bank_forks::BankForks},
solana_sdk::{
clock::Slot,
pubkey::Pubkey,
timing::{timestamp, AtomicInterval},
{clock::Slot, pubkey::Pubkey},
},
solana_streamer::{
sendmmsg::{batch_send, SendPktsError},
@@ -449,24 +450,28 @@ pub fn broadcast_shreds(
#[cfg(test)]
pub mod test {
use super::*;
use crossbeam_channel::unbounded;
use solana_gossip::cluster_info::{ClusterInfo, Node};
use solana_ledger::{
blockstore::{make_slot_entries, Blockstore},
entry::create_ticks,
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_gossip::cluster_info::{ClusterInfo, Node},
solana_ledger::{
blockstore::{make_slot_entries, Blockstore},
entry::create_ticks,
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,8 @@
use super::*;
use solana_ledger::entry::Entry;
use solana_ledger::shred::Shredder;
use solana_sdk::hash::Hash;
use solana_sdk::signature::Keypair;
use {
super::*,
solana_ledger::{entry::Entry, shred::Shredder},
solana_sdk::{hash::Hash, signature::Keypair},
};
#[derive(Clone)]
pub(super) struct BroadcastFakeShredsRun {
@@ -139,10 +139,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,12 +1,13 @@
use crate::result::Result;
use solana_ledger::{entry::Entry, 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_ledger::{entry::Entry, 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 {
@@ -79,13 +80,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

@@ -511,21 +511,21 @@ impl BroadcastRun for StandardBroadcastRun {
#[cfg(test)]
mod test {
use super::*;
use solana_gossip::cluster_info::{ClusterInfo, Node};
use solana_ledger::genesis_utils::create_genesis_config;
use solana_ledger::{
blockstore::Blockstore, entry::create_ticks, get_tmp_ledger_path,
shred::max_ticks_per_n_shreds,
use {
super::*,
solana_gossip::cluster_info::{ClusterInfo, Node},
solana_ledger::{
blockstore::Blockstore, entry::create_ticks, 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::{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::sync::Arc;
use std::time::Duration;
#[allow(clippy::type_complexity)]
fn setup(

View File

@@ -1,53 +1,56 @@
use crate::{
optimistic_confirmation_verifier::OptimisticConfirmationVerifier,
replay_stage::DUPLICATE_THRESHOLD,
result::{Error, Result},
sigverify,
verified_vote_packets::VerifiedVotePackets,
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,
crds_value::CrdsValueLabel,
};
use solana_ledger::blockstore::Blockstore;
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},
stakes::Stakes,
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,
transaction::Transaction,
};
use solana_vote_program::{self, vote_state::Vote, vote_transaction};
use std::{
collections::HashMap,
sync::{
atomic::{AtomicBool, Ordering},
{Arc, Mutex, RwLock},
use {
crate::{
optimistic_confirmation_verifier::OptimisticConfirmationVerifier,
replay_stage::DUPLICATE_THRESHOLD,
result::{Error, Result},
sigverify,
verified_vote_packets::VerifiedVotePackets,
vote_stake_tracker::VoteStakeTracker,
},
crossbeam_channel::{
unbounded, Receiver as CrossbeamReceiver, RecvTimeoutError, Select,
Sender as CrossbeamSender,
},
itertools::izip,
log::*,
solana_gossip::{
cluster_info::{ClusterInfo, GOSSIP_SLEEP_MILLIS},
crds::Cursor,
crds_value::CrdsValueLabel,
},
solana_ledger::blockstore::Blockstore,
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},
stakes::Stakes,
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,
transaction::Transaction,
},
solana_vote_program::{self, vote_state::Vote, vote_transaction},
std::{
collections::HashMap,
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
@@ -835,21 +838,23 @@ 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, 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, GenesisConfigInfo, ValidatorVoteKeypairs},
vote_sender_types::ReplayVoteSender,
},
solana_sdk::{
hash::Hash,
signature::{Keypair, Signature, Signer},
},
solana_vote_program::vote_state::Vote,
std::collections::BTreeSet,
};
use solana_sdk::{
hash::Hash,
signature::{Keypair, Signature, Signer},
};
use solana_vote_program::vote_state::Vote;
use std::collections::BTreeSet;
#[test]
fn test_max_vote_tx_fits() {

View File

@@ -1,9 +1,11 @@
use crate::{
fork_choice::ForkChoice, heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
progress_map::ProgressMap,
use {
crate::{
fork_choice::ForkChoice, heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
progress_map::ProgressMap,
},
solana_sdk::{clock::Slot, hash::Hash},
std::collections::{BTreeMap, BTreeSet},
};
use solana_sdk::{clock::Slot, hash::Hash};
use std::collections::{BTreeMap, BTreeSet};
pub(crate) type DuplicateSlotsTracker = BTreeSet<Slot>;
pub(crate) type GossipDuplicateConfirmedSlots = BTreeMap<Slot, Hash>;
@@ -305,14 +307,16 @@ pub(crate) fn check_slot_agrees_with_cluster(
#[cfg(test)]
mod test {
use super::*;
use crate::consensus::test::VoteSimulator;
use solana_runtime::bank_forks::BankForks;
use std::{
collections::{HashMap, HashSet},
sync::RwLock,
use {
super::*,
crate::consensus::test::VoteSimulator,
solana_runtime::bank_forks::BankForks,
std::{
collections::{HashMap, HashSet},
sync::RwLock,
},
trees::tr,
};
use trees::tr;
struct InitialState {
heaviest_subtree_fork_choice: HeaviestSubtreeForkChoice,

View File

@@ -186,8 +186,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,19 @@
use crossbeam_channel::{Receiver, RecvTimeoutError, Sender};
use solana_ledger::blockstore::{Blockstore, CompletedDataSetInfo};
use solana_ledger::entry::Entry;
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_ledger::{
blockstore::{Blockstore, CompletedDataSetInfo},
entry::Entry,
},
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 +104,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

@@ -1,40 +1,42 @@
use crate::{
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
progress_map::{LockoutIntervals, ProgressMap},
};
use chrono::prelude::*;
use solana_ledger::{ancestor_iterator::AncestorIterator, blockstore::Blockstore, blockstore_db};
use solana_measure::measure::Measure;
use solana_runtime::{
bank::Bank, bank_forks::BankForks, commitment::VOTE_THRESHOLD_SIZE,
vote_account::ArcVoteAccount,
};
use solana_sdk::{
clock::{Slot, UnixTimestamp},
hash::Hash,
instruction::Instruction,
pubkey::Pubkey,
signature::{Keypair, Signature, Signer},
slot_history::{Check, SlotHistory},
};
use solana_vote_program::{
vote_instruction,
vote_state::{BlockTimestamp, Lockout, Vote, VoteState, MAX_LOCKOUT_HISTORY},
};
use std::{
cmp::Ordering,
collections::{HashMap, HashSet},
fs::{self, File},
io::BufReader,
ops::{
Bound::{Included, Unbounded},
Deref,
use {
crate::{
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
progress_map::{LockoutIntervals, ProgressMap},
},
path::{Path, PathBuf},
sync::Arc,
chrono::prelude::*,
solana_ledger::{ancestor_iterator::AncestorIterator, blockstore::Blockstore, blockstore_db},
solana_measure::measure::Measure,
solana_runtime::{
bank::Bank, bank_forks::BankForks, commitment::VOTE_THRESHOLD_SIZE,
vote_account::ArcVoteAccount,
},
solana_sdk::{
clock::{Slot, UnixTimestamp},
hash::Hash,
instruction::Instruction,
pubkey::Pubkey,
signature::{Keypair, Signature, Signer},
slot_history::{Check, SlotHistory},
},
solana_vote_program::{
vote_instruction,
vote_state::{BlockTimestamp, Lockout, Vote, VoteState, MAX_LOCKOUT_HISTORY},
},
std::{
cmp::Ordering,
collections::{HashMap, HashSet},
fs::{self, File},
io::BufReader,
ops::{
Bound::{Included, Unbounded},
Deref,
},
path::{Path, PathBuf},
sync::Arc,
},
thiserror::Error,
};
use thiserror::Error;
#[derive(PartialEq, Clone, Debug, AbiExample)]
pub enum SwitchForkDecision {
@@ -1355,46 +1357,48 @@ pub fn reconcile_blockstore_roots_with_tower(
#[cfg(test)]
pub mod test {
use super::*;
use crate::{
cluster_info_vote_listener::VoteTracker,
cluster_slot_state_verifier::{DuplicateSlotsTracker, GossipDuplicateConfirmedSlots},
cluster_slots::ClusterSlots,
fork_choice::{ForkChoice, SelectVoteAndResetForkResult},
heaviest_subtree_fork_choice::SlotHashKey,
progress_map::ForkProgress,
replay_stage::{HeaviestForkFailures, ReplayStage},
unfrozen_gossip_verified_vote_hashes::UnfrozenGossipVerifiedVoteHashes,
};
use solana_ledger::{blockstore::make_slot_entries, get_tmp_ledger_path};
use solana_runtime::{
accounts_background_service::AbsRequestSender,
bank::Bank,
bank_forks::BankForks,
genesis_utils::{
create_genesis_config_with_vote_accounts, GenesisConfigInfo, ValidatorVoteKeypairs,
use {
super::*,
crate::{
cluster_info_vote_listener::VoteTracker,
cluster_slot_state_verifier::{DuplicateSlotsTracker, GossipDuplicateConfirmedSlots},
cluster_slots::ClusterSlots,
fork_choice::{ForkChoice, SelectVoteAndResetForkResult},
heaviest_subtree_fork_choice::SlotHashKey,
progress_map::ForkProgress,
replay_stage::{HeaviestForkFailures, ReplayStage},
unfrozen_gossip_verified_vote_hashes::UnfrozenGossipVerifiedVoteHashes,
},
solana_ledger::{blockstore::make_slot_entries, get_tmp_ledger_path},
solana_runtime::{
accounts_background_service::AbsRequestSender,
bank::Bank,
bank_forks::BankForks,
genesis_utils::{
create_genesis_config_with_vote_accounts, GenesisConfigInfo, ValidatorVoteKeypairs,
},
},
solana_sdk::{
account::{Account, AccountSharedData, ReadableAccount, WritableAccount},
clock::Slot,
hash::Hash,
pubkey::Pubkey,
signature::Signer,
slot_history::SlotHistory,
},
solana_vote_program::{
vote_state::{Vote, VoteStateVersions, MAX_LOCKOUT_HISTORY},
vote_transaction,
},
std::{
collections::HashMap,
fs::{remove_file, OpenOptions},
io::{Read, Seek, SeekFrom, Write},
sync::RwLock,
},
tempfile::TempDir,
trees::{tr, Tree, TreeWalk},
};
use solana_sdk::{
account::{Account, AccountSharedData, ReadableAccount, WritableAccount},
clock::Slot,
hash::Hash,
pubkey::Pubkey,
signature::Signer,
slot_history::SlotHistory,
};
use solana_vote_program::{
vote_state::{Vote, VoteStateVersions, MAX_LOCKOUT_HISTORY},
vote_transaction,
};
use std::{
collections::HashMap,
fs::{remove_file, OpenOptions},
io::{Read, Seek, SeekFrom, Write},
sync::RwLock,
};
use tempfile::TempDir;
use trees::{tr, Tree, TreeWalk};
pub(crate) struct VoteSimulator {
pub validator_keypairs: HashMap<Pubkey, ValidatorVoteKeypairs>,

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_runtime::message_processor::ProgramTiming;
use solana_sdk::pubkey::Pubkey;
use {super::*, solana_runtime::message_processor::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,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(crate) 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);
@@ -1044,12 +1046,14 @@ impl<'a> Iterator for AncestorIterator<'a> {
#[cfg(test)]
mod test {
use super::*;
use crate::consensus::test::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::consensus::test::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(crate) 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::consensus::test::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::consensus::test::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;
@@ -72,10 +74,10 @@ pub struct RequestStatus<T> {
#[cfg(test)]
pub(crate) mod tests {
use super::*;
use crate::serve_repair::RepairType;
use solana_ledger::shred::Shred;
use solana_sdk::timing::timestamp;
use {
super::*, crate::serve_repair::RepairType, solana_ledger::shred::Shred,
solana_sdk::timing::timestamp,
};
#[test]
fn test_add_request() {

View File

@@ -1,15 +1,17 @@
use crate::{
cluster_info_vote_listener::SlotVoteTracker,
cluster_slots::SlotPubkeys,
replay_stage::SUPERMINORITY_THRESHOLD,
{consensus::Stake, consensus::VotedStakes},
};
use solana_ledger::blockstore_processor::{ConfirmationProgress, ConfirmationTiming};
use solana_runtime::{bank::Bank, bank_forks::BankForks, vote_account::ArcVoteAccount};
use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey};
use std::{
collections::{BTreeMap, HashMap, HashSet},
sync::{Arc, RwLock},
use {
crate::{
cluster_info_vote_listener::SlotVoteTracker,
cluster_slots::SlotPubkeys,
consensus::{Stake, VotedStakes},
replay_stage::SUPERMINORITY_THRESHOLD,
},
solana_ledger::blockstore_processor::{ConfirmationProgress, ConfirmationTiming},
solana_runtime::{bank::Bank, bank_forks::BankForks, vote_account::ArcVoteAccount},
solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey},
std::{
collections::{BTreeMap, HashMap, HashSet},
sync::{Arc, RwLock},
},
};
type VotedSlot = Slot;

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,40 +1,42 @@
//! 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::{
cluster_info_vote_listener::VerifiedVoteReceiver,
cluster_slots::ClusterSlots,
outstanding_requests::OutstandingRequests,
repair_weight::RepairWeight,
replay_stage::DUPLICATE_THRESHOLD,
result::Result,
serve_repair::{RepairType, ServeRepair, 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::Bank, bank_forks::BankForks, contains::Contains};
use solana_sdk::{
clock::{BankId, Slot},
epoch_schedule::EpochSchedule,
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::{
cluster_info_vote_listener::VerifiedVoteReceiver,
cluster_slots::ClusterSlots,
outstanding_requests::OutstandingRequests,
repair_weight::RepairWeight,
replay_stage::DUPLICATE_THRESHOLD,
result::Result,
serve_repair::{RepairType, ServeRepair, 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::Bank, bank_forks::BankForks, contains::Contains},
solana_sdk::{
clock::{BankId, Slot},
epoch_schedule::EpochSchedule,
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<Slot>;
@@ -711,20 +713,23 @@ impl RepairService {
#[cfg(test)]
mod test {
use super::*;
use crossbeam_channel::unbounded;
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::*,
crossbeam_channel::unbounded,
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_runtime::genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs},
solana_sdk::signature::{Keypair, Signer},
solana_streamer::socket::SocketAddrSpace,
solana_vote_program::vote_transaction,
std::collections::HashSet,
};
use solana_ledger::shred::max_ticks_per_n_shreds;
use solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path};
use solana_runtime::genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs};
use solana_sdk::signature::Keypair;
use solana_sdk::signature::Signer;
use solana_streamer::socket::SocketAddrSpace;
use solana_vote_program::vote_transaction;
use std::collections::HashSet;
fn new_test_cluster_info(contact_info: ContactInfo) -> ClusterInfo {
ClusterInfo::new(

View File

@@ -1,17 +1,19 @@
use crate::{
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, repair_service::RepairTiming,
repair_weighted_traversal, serve_repair::RepairType, tree_diff::TreeDiff,
use {
crate::{
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, repair_service::RepairTiming,
repair_weighted_traversal, serve_repair::RepairType, tree_diff::TreeDiff,
},
solana_ledger::{ancestor_iterator::AncestorIterator, blockstore::Blockstore},
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};
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`
@@ -531,11 +533,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::RepairType, tree_diff::TreeDiff,
use {
crate::{
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, repair_service::RepairService,
serve_repair::RepairType, tree_diff::TreeDiff,
},
solana_ledger::blockstore::Blockstore,
solana_runtime::contains::Contains,
solana_sdk::{clock::Slot, hash::Hash},
std::collections::{HashMap, HashSet},
};
use solana_ledger::blockstore::Blockstore;
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

@@ -1,73 +1,74 @@
//! The `replay_stage` replays transactions broadcast by the leader.
use crate::{
broadcast_stage::RetransmitSlotsSender,
cache_block_meta_service::CacheBlockMetaSender,
cluster_info_vote_listener::{
GossipDuplicateConfirmedSlotsReceiver, GossipVerifiedVoteHashReceiver, VoteTracker,
use {
crate::{
broadcast_stage::RetransmitSlotsSender,
cache_block_meta_service::CacheBlockMetaSender,
cluster_info_vote_listener::{
GossipDuplicateConfirmedSlotsReceiver, GossipVerifiedVoteHashReceiver, VoteTracker,
},
cluster_slot_state_verifier::*,
cluster_slots::ClusterSlots,
cluster_slots_service::ClusterSlotsUpdateSender,
commitment_service::{AggregateCommitmentService, CommitmentAggregationData},
consensus::{
ComputedBankState, Stake, SwitchForkDecision, Tower, VotedStakes, SWITCH_FORK_THRESHOLD,
},
cost_update_service::CostUpdate,
fork_choice::{ForkChoice, SelectVoteAndResetForkResult},
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
progress_map::{ForkProgress, ProgressMap, PropagatedStats},
repair_service::DuplicateSlotsResetReceiver,
rewards_recorder_service::RewardsRecorderSender,
unfrozen_gossip_verified_vote_hashes::UnfrozenGossipVerifiedVoteHashes,
voting_service::VoteOp,
window_service::DuplicateSlotReceiver,
},
cluster_slot_state_verifier::*,
cluster_slots::ClusterSlots,
cluster_slots_service::ClusterSlotsUpdateSender,
commitment_service::{AggregateCommitmentService, CommitmentAggregationData},
consensus::{
ComputedBankState, Stake, SwitchForkDecision, Tower, VotedStakes, SWITCH_FORK_THRESHOLD,
solana_client::rpc_response::SlotUpdate,
solana_gossip::cluster_info::ClusterInfo,
solana_ledger::{
block_error::BlockError,
blockstore::Blockstore,
blockstore_processor::{self, BlockstoreProcessorError, TransactionStatusSender},
entry::VerifyRecyclers,
leader_schedule_cache::LeaderScheduleCache,
},
cost_update_service::CostUpdate,
fork_choice::{ForkChoice, SelectVoteAndResetForkResult},
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
progress_map::{ForkProgress, ProgressMap, PropagatedStats},
repair_service::DuplicateSlotsResetReceiver,
rewards_recorder_service::RewardsRecorderSender,
unfrozen_gossip_verified_vote_hashes::UnfrozenGossipVerifiedVoteHashes,
voting_service::VoteOp,
window_service::DuplicateSlotReceiver,
};
use solana_client::rpc_response::SlotUpdate;
use solana_gossip::cluster_info::ClusterInfo;
use solana_ledger::{
block_error::BlockError,
blockstore::Blockstore,
blockstore_processor::{self, BlockstoreProcessorError, TransactionStatusSender},
entry::VerifyRecyclers,
leader_schedule_cache::LeaderScheduleCache,
};
use solana_measure::measure::Measure;
use solana_metrics::inc_new_counter_info;
use solana_poh::poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS};
use solana_rpc::{
optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender},
rpc_subscriptions::RpcSubscriptions,
};
use solana_runtime::{
accounts_background_service::AbsRequestSender,
bank::{Bank, ExecuteTimings, NewBankOptions},
bank_forks::BankForks,
commitment::BlockCommitmentCache,
vote_sender_types::ReplayVoteSender,
};
use solana_sdk::{
clock::{Slot, MAX_PROCESSING_AGE, NUM_CONSECUTIVE_LEADER_SLOTS},
genesis_config::ClusterType,
hash::Hash,
pubkey::Pubkey,
signature::Signature,
signature::{Keypair, Signer},
timing::timestamp,
transaction::Transaction,
};
use solana_vote_program::vote_state::Vote;
use std::{
collections::{BTreeMap, HashMap, HashSet},
result,
sync::{
atomic::{AtomicBool, Ordering},
mpsc::{Receiver, RecvTimeoutError, Sender},
Arc, Mutex, RwLock,
solana_measure::measure::Measure,
solana_metrics::inc_new_counter_info,
solana_poh::poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS},
solana_rpc::{
optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender},
rpc_subscriptions::RpcSubscriptions,
},
solana_runtime::{
accounts_background_service::AbsRequestSender,
bank::{Bank, ExecuteTimings, NewBankOptions},
bank_forks::BankForks,
commitment::BlockCommitmentCache,
vote_sender_types::ReplayVoteSender,
},
solana_sdk::{
clock::{Slot, MAX_PROCESSING_AGE, NUM_CONSECUTIVE_LEADER_SLOTS},
genesis_config::ClusterType,
hash::Hash,
pubkey::Pubkey,
signature::{Keypair, Signature, Signer},
timing::timestamp,
transaction::Transaction,
},
solana_vote_program::vote_state::Vote,
std::{
collections::{BTreeMap, HashMap, HashSet},
result,
sync::{
atomic::{AtomicBool, Ordering},
mpsc::{Receiver, RecvTimeoutError, Sender},
Arc, Mutex, RwLock,
},
thread::{self, Builder, JoinHandle},
time::{Duration, Instant},
},
thread::{self, Builder, JoinHandle},
time::{Duration, Instant},
};
pub const MAX_ENTRY_RECV_PER_ITER: usize = 512;
@@ -2561,60 +2562,62 @@ impl ReplayStage {
#[cfg(test)]
mod tests {
use super::*;
use crate::{
consensus::test::{initialize_state, VoteSimulator},
consensus::Tower,
progress_map::ValidatorStakeInfo,
replay_stage::ReplayStage,
};
use crossbeam_channel::unbounded;
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,
entry::{self, Entry},
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::{
test::{initialize_state, VoteSimulator},
Tower,
},
progress_map::ValidatorStakeInfo,
replay_stage::ReplayStage,
},
crossbeam_channel::unbounded,
solana_gossip::{cluster_info::Node, crds::Cursor},
solana_ledger::{
blockstore::{entries_to_test_shreds, make_slot_entries, BlockstoreError},
create_new_tmp_ledger,
entry::{self, Entry},
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

@@ -18,8 +18,7 @@ use {
solana_client::rpc_response::SlotUpdate,
solana_gossip::cluster_info::{ClusterInfo, DATA_PLANE_FANOUT},
solana_ledger::{
shred::Shred,
{blockstore::Blockstore, leader_schedule_cache::LeaderScheduleCache},
blockstore::Blockstore, leader_schedule_cache::LeaderScheduleCache, shred::Shred,
},
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,42 +1,46 @@
use crate::{
cluster_slots::ClusterSlots,
repair_response,
repair_service::{OutstandingRepairs, 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,
};
use solana_ledger::{
blockstore::Blockstore,
shred::{Nonce, Shred},
};
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,
pubkey::Pubkey,
signature::{Keypair, Signer},
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,
repair_response,
repair_service::{OutstandingRepairs, 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,
},
solana_ledger::{
blockstore::Blockstore,
shred::{Nonce, Shred},
},
solana_measure::measure::Measure,
solana_metrics::inc_new_counter_debug,
solana_perf::packet::{limited_deserialize, Packets, PacketsRecycler},
solana_sdk::{
clock::Slot,
pubkey::Pubkey,
signature::{Keypair, Signer},
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},
},
};
/// the number of slots to respond with when responding to `Orphan` requests
@@ -635,18 +639,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,17 +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;
use std::sync::mpsc::{Receiver, RecvTimeoutError};
use std::thread::{self, Builder, JoinHandle};
use std::time::Instant;
use thiserror::Error;
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,
};
const MAX_SIGVERIFY_BATCH: usize = 10_000;
@@ -265,8 +269,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,14 +1,16 @@
use solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES};
use solana_perf::thread::renice_this_thread;
use solana_runtime::{snapshot_package::AccountsPackage, snapshot_utils};
use solana_sdk::{clock::Slot, hash::Hash};
use std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc, Mutex,
use {
solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES},
solana_perf::thread::renice_this_thread,
solana_runtime::{snapshot_package::AccountsPackage, snapshot_utils},
solana_sdk::{clock::Slot, hash::Hash},
std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc, Mutex,
},
thread::{self, Builder, JoinHandle},
time::Duration,
},
thread::{self, Builder, JoinHandle},
time::Duration,
};
pub type PendingSnapshotPackage = Arc<Mutex<Option<AccountsPackage>>>;
@@ -76,22 +78,24 @@ impl SnapshotPackagerService {
#[cfg(test)]
mod tests {
use super::*;
use bincode::serialize_into;
use solana_runtime::{
accounts_db::AccountStorageEntry,
bank::BankSlotDelta,
bank_forks::ArchiveFormat,
snapshot_package::AccountsPackage,
snapshot_utils::{self, SnapshotVersion, SNAPSHOT_STATUS_CACHE_FILE_NAME},
use {
super::*,
bincode::serialize_into,
solana_runtime::{
accounts_db::AccountStorageEntry,
bank::BankSlotDelta,
bank_forks::ArchiveFormat,
snapshot_package::AccountsPackage,
snapshot_utils::{self, 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

@@ -8,7 +8,6 @@ use std::{
thread::{self, sleep, Builder, JoinHandle},
time::{Duration, Instant},
};
#[cfg(target_os = "linux")]
use std::{fs::File, io::BufReader, path::Path};

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,64 +1,66 @@
//! 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,
snapshot_packager_service::PendingSnapshotPackage,
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,
snapshot_packager_service::PendingSnapshotPackage,
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, SnapshotConfig},
commitment::BlockCommitmentCache,
cost_model::CostModel,
vote_sender_types::ReplayVoteSender,
};
use solana_sdk::{
pubkey::Pubkey,
signature::{Keypair, Signer},
};
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, SnapshotConfig},
commitment::BlockCommitmentCache,
cost_model::CostModel,
vote_sender_types::ReplayVoteSender,
},
solana_sdk::{
pubkey::Pubkey,
signature::{Keypair, Signer},
},
std::{
boxed::Box,
collections::HashSet,
net::UdpSocket,
sync::{
atomic::AtomicBool,
mpsc::{channel, Receiver},
Arc, Mutex, RwLock,
},
thread,
},
thread,
};
pub struct Tvu {
@@ -377,20 +379,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(crate) struct UnfrozenGossipVerifiedVoteHashes {

View File

@@ -45,7 +45,6 @@ use {
poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS},
poh_service::{self, PohService},
},
solana_rpc::send_transaction_service,
solana_rpc::{
max_slots::MaxSlots,
optimistically_confirmed_bank_tracker::{
@@ -56,6 +55,7 @@ use {
rpc_pubsub_service::{PubSubConfig, PubSubService},
rpc_service::JsonRpcService,
rpc_subscriptions::RpcSubscriptions,
send_transaction_service,
transaction_status_service::TransactionStatusService,
},
solana_runtime::{
@@ -1640,11 +1640,12 @@ pub fn is_snapshot_config_invalid(
#[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() {
@@ -1689,8 +1690,7 @@ mod tests {
fn test_backup_and_clear_blockstore() {
use std::time::Instant;
solana_logger::setup();
use solana_ledger::get_tmp_ledger_path;
use solana_ledger::{blockstore, entry};
use solana_ledger::{blockstore, entry, get_tmp_ledger_path};
let blockstore_path = get_tmp_ledger_path!();
{
let blockstore = Blockstore::open(&blockstore_path).unwrap();

View File

@@ -1,10 +1,12 @@
use crate::{cluster_info_vote_listener::VerifiedLabelVotePacketsReceiver, result::Result};
use solana_gossip::crds_value::CrdsValueLabel;
use solana_perf::packet::Packets;
use solana_sdk::clock::Slot;
use std::{
collections::{hash_map::Entry, HashMap},
time::Duration,
use {
crate::{cluster_info_vote_listener::VerifiedLabelVotePacketsReceiver, result::Result},
solana_gossip::crds_value::CrdsValueLabel,
solana_perf::packet::Packets,
solana_sdk::clock::Slot,
std::{
collections::{hash_map::Entry, HashMap},
time::Duration,
},
};
#[derive(Default)]
@@ -74,10 +76,12 @@ impl VerifiedVotePackets {
#[cfg(test)]
mod tests {
use super::*;
use crate::result::Error;
use crossbeam_channel::{unbounded, RecvTimeoutError};
use solana_perf::packet::{Meta, Packet};
use {
super::*,
crate::result::Error,
crossbeam_channel::{unbounded, RecvTimeoutError},
solana_perf::packet::{Meta, Packet},
};
#[test]
fn test_get_latest_votes() {

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,10 +1,12 @@
use solana_gossip::cluster_info::ClusterInfo;
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 {
solana_gossip::cluster_info::ClusterInfo,
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},
@@ -914,8 +913,10 @@ mod test {
#[test]
fn test_prune_shreds() {
use crate::serve_repair::RepairType;
use std::net::{IpAddr, Ipv4Addr};
use {
crate::serve_repair::RepairType,
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);