Skip to content

Commit

Permalink
Cleanup clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ksolana committed Jan 24, 2025
1 parent a9f581c commit 3cda2ff
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 93 deletions.
14 changes: 2 additions & 12 deletions core/benches/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@ use {
rand::{thread_rng, Rng},
rayon::prelude::*,
solana_client::connection_cache::ConnectionCache,
solana_core::{
banking_stage::{
committer::Committer, consumer::Consumer,
leader_slot_metrics::LeaderSlotMetricsTracker, qos_service::QosService,
unprocessed_packet_batches::*, BankingStage, BankingStageStats,
},
banking_trace::BankingTracer,
},
solana_core::{banking_stage::BankingStage, banking_trace::BankingTracer},
solana_entry::entry::{next_hash, Entry},
solana_gossip::cluster_info::{ClusterInfo, Node},
solana_ledger::{
Expand All @@ -34,10 +27,7 @@ use {
genesis_utils::{create_genesis_config, GenesisConfigInfo},
get_tmp_ledger_path_auto_delete,
},
solana_perf::{
packet::{to_packet_batches, Packet},
test_tx::test_tx,
},
solana_perf::packet::to_packet_batches,
solana_poh::poh_recorder::{create_test_recorder, WorkingBankEntry},
solana_runtime::{
bank::Bank, bank_forks::BankForks, prioritization_fee_cache::PrioritizationFeeCache,
Expand Down
82 changes: 4 additions & 78 deletions core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,10 +847,8 @@ impl Consumer {
mod tests {
use {
super::*,
crate::banking_stage::{
immutable_deserialized_packet::DeserializedPacketError,
tests::{create_slow_genesis_config, sanitize_transactions, simulate_poh},
unprocessed_packet_batches::DeserializedPacket,
crate::banking_stage::tests::{
create_slow_genesis_config, sanitize_transactions, simulate_poh,
},
crossbeam_channel::{unbounded, Receiver},
solana_cost_model::{cost_model::CostModel, transaction_cost::TransactionCost},
Expand All @@ -862,10 +860,9 @@ mod tests {
get_tmp_ledger_path_auto_delete,
leader_schedule_cache::LeaderScheduleCache,
},
solana_perf::packet::Packet,
solana_poh::poh_recorder::{PohRecorder, Record, WorkingBankEntry},
solana_poh::poh_recorder::{PohRecorder, Record},
solana_rpc::transaction_status_service::TransactionStatusService,
solana_runtime::{bank_forks::BankForks, prioritization_fee_cache::PrioritizationFeeCache},
solana_runtime::prioritization_fee_cache::PrioritizationFeeCache,
solana_runtime_transaction::runtime_transaction::RuntimeTransaction,
solana_sdk::{
account::AccountSharedData,
Expand Down Expand Up @@ -896,7 +893,6 @@ mod tests {
solana_transaction_status::{TransactionStatusMeta, VersionedTransactionWithStatusMeta},
std::{
borrow::Cow,
path::Path,
sync::{
atomic::{AtomicBool, AtomicU64},
RwLock,
Expand Down Expand Up @@ -999,76 +995,6 @@ mod tests {
account
}

#[allow(clippy::type_complexity)]
fn setup_conflicting_transactions(
ledger_path: &Path,
) -> (
Vec<Transaction>,
Arc<Bank>,
Arc<RwLock<BankForks>>,
Arc<RwLock<PohRecorder>>,
Receiver<WorkingBankEntry>,
GenesisConfigInfo,
JoinHandle<()>,
) {
Blockstore::destroy(ledger_path).unwrap();
let genesis_config_info = create_slow_genesis_config(100_000_000);
let GenesisConfigInfo {
genesis_config,
mint_keypair,
..
} = &genesis_config_info;
let blockstore =
Blockstore::open(ledger_path).expect("Expected to be able to open database ledger");
let (bank, bank_forks) = Bank::new_no_wallclock_throttle_for_tests(genesis_config);
let exit = Arc::new(AtomicBool::default());
let (poh_recorder, entry_receiver, record_receiver) = PohRecorder::new(
bank.tick_height(),
bank.last_blockhash(),
bank.clone(),
Some((4, 4)),
bank.ticks_per_slot(),
Arc::new(blockstore),
&Arc::new(LeaderScheduleCache::new_from_bank(&bank)),
&PohConfig::default(),
exit,
);
let poh_recorder = Arc::new(RwLock::new(poh_recorder));

// Set up unparallelizable conflicting transactions
let pubkey0 = solana_pubkey::new_rand();
let pubkey1 = solana_pubkey::new_rand();
let pubkey2 = solana_pubkey::new_rand();
let transactions = vec![
system_transaction::transfer(mint_keypair, &pubkey0, 1, genesis_config.hash()),
system_transaction::transfer(mint_keypair, &pubkey1, 1, genesis_config.hash()),
system_transaction::transfer(mint_keypair, &pubkey2, 1, genesis_config.hash()),
];
let poh_simulator = simulate_poh(record_receiver, &poh_recorder);

(
transactions,
bank,
bank_forks,
poh_recorder,
entry_receiver,
genesis_config_info,
poh_simulator,
)
}

fn transactions_to_deserialized_packets(
transactions: &[Transaction],
) -> Result<Vec<DeserializedPacket>, DeserializedPacketError> {
transactions
.iter()
.map(|transaction| {
let packet = Packet::from_data(None, transaction)?;
DeserializedPacket::new(packet)
})
.collect()
}

#[test]
fn test_bank_process_and_record_transactions() {
solana_logger::setup();
Expand Down
4 changes: 1 addition & 3 deletions core/src/banking_stage/unprocessed_transaction_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ impl VoteStorage {
mod tests {
use {
super::*,
itertools::iproduct,
solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo},
solana_perf::packet::{Packet, PacketFlags},
solana_runtime::genesis_utils,
Expand Down Expand Up @@ -486,7 +485,6 @@ mod tests {
mint_keypair,
..
} = create_genesis_config(10);
let (current_bank, _bank_forks) = Bank::new_with_bank_forks_for_tests(&genesis_config);

let simple_transactions: Vec<Transaction> = (0..256)
.map(|_id| {
Expand All @@ -502,7 +500,7 @@ mod tests {
})
.collect_vec();

let mut packets: Vec<DeserializedPacket> = simple_transactions
let _packets: Vec<DeserializedPacket> = simple_transactions
.iter()
.enumerate()
.map(|(packets_id, transaction)| {
Expand Down

0 comments on commit 3cda2ff

Please sign in to comment.