diff --git a/core/src/broadcast_stage.rs b/core/src/broadcast_stage.rs index 38d94214297afc..2fad2740e79b52 100644 --- a/core/src/broadcast_stage.rs +++ b/core/src/broadcast_stage.rs @@ -133,7 +133,8 @@ impl BroadcastStage { mut broadcast_stage_run: impl BroadcastRun, ) -> BroadcastStageReturnType { loop { - let res = broadcast_stage_run.run(blockstore, receiver, socket_sender, blockstore_sender); + let res = + broadcast_stage_run.run(blockstore, receiver, socket_sender, blockstore_sender); let res = Self::handle_error(res); if let Some(res) = res { return res; @@ -192,7 +193,13 @@ impl BroadcastStage { .name("solana-broadcaster".to_string()) .spawn(move || { let _finalizer = Finalizer::new(exit); - Self::run(&btree, &receiver, &socket_sender, &blockstore_sender, bs_run) + Self::run( + &btree, + &receiver, + &socket_sender, + &blockstore_sender, + bs_run, + ) }) .unwrap(); let mut thread_hdls = vec![thread_hdl]; diff --git a/core/src/broadcast_stage/standard_broadcast_run.rs b/core/src/broadcast_stage/standard_broadcast_run.rs index 382cea03104df4..ebe6643bab3a5e 100644 --- a/core/src/broadcast_stage/standard_broadcast_run.rs +++ b/core/src/broadcast_stage/standard_broadcast_run.rs @@ -323,7 +323,12 @@ impl BroadcastRun for StandardBroadcastRun { blockstore_sender: &Sender>>, ) -> Result<()> { let receive_results = broadcast_utils::recv_slot_entries(receiver)?; - self.process_receive_results(blockstore, socket_sender, blockstore_sender, receive_results) + self.process_receive_results( + blockstore, + socket_sender, + blockstore_sender, + receive_results, + ) } fn transmit( &self, diff --git a/core/src/chacha.rs b/core/src/chacha.rs index b928e7ade10819..baa29fdbed0588 100644 --- a/core/src/chacha.rs +++ b/core/src/chacha.rs @@ -157,8 +157,14 @@ mod tests { "abcd1234abcd1234abcd1234abcd1234 abcd1234abcd1234abcd1234abcd1234 abcd1234abcd1234abcd1234abcd1234 abcd1234abcd1234abcd1234abcd1234" ); - chacha_cbc_encrypt_ledger(&blockstore, 0, slots_per_segment as u64, &out_path, &mut key) - .unwrap(); + chacha_cbc_encrypt_ledger( + &blockstore, + 0, + slots_per_segment as u64, + &out_path, + &mut key, + ) + .unwrap(); let mut out_file = File::open(&out_path).unwrap(); let mut buf = vec![]; let size = out_file.read_to_end(&mut buf).unwrap(); diff --git a/core/src/cluster_info.rs b/core/src/cluster_info.rs index 60bbf30392aaa9..e6f4bf457c7437 100644 --- a/core/src/cluster_info.rs +++ b/core/src/cluster_info.rs @@ -1330,7 +1330,8 @@ impl ClusterInfo { ); } _ => { - let rsp = Self::handle_repair(me, recycler, &from_addr, blockstore, request); + let rsp = + Self::handle_repair(me, recycler, &from_addr, blockstore, request); if let Some(rsp) = rsp { let _ignore_disconnect = response_sender.send(rsp); } @@ -2187,7 +2188,8 @@ mod tests { let ledger_path = get_tmp_ledger_path!(); { let blockstore = Arc::new(Blockstore::open(&ledger_path).unwrap()); - let rv = ClusterInfo::run_orphan(&recycler, &socketaddr_any!(), Some(&blockstore), 2, 0); + let rv = + ClusterInfo::run_orphan(&recycler, &socketaddr_any!(), Some(&blockstore), 2, 0); assert!(rv.is_none()); // Create slots 1, 2, 3 with 5 shreds apiece @@ -2198,7 +2200,8 @@ mod tests { .expect("Expect successful ledger write"); // We don't have slot 4, so we don't know how to service this requeset - let rv = ClusterInfo::run_orphan(&recycler, &socketaddr_any!(), Some(&blockstore), 4, 5); + let rv = + ClusterInfo::run_orphan(&recycler, &socketaddr_any!(), Some(&blockstore), 4, 5); assert!(rv.is_none()); // For slot 3, we should return the highest shreds from slots 3, 2, 1 respectively diff --git a/core/src/poh_recorder.rs b/core/src/poh_recorder.rs index d14b7179229460..2c0e8e620e3f0d 100644 --- a/core/src/poh_recorder.rs +++ b/core/src/poh_recorder.rs @@ -486,8 +486,8 @@ mod tests { let prev_hash = Hash::default(); let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let (mut poh_recorder, _entry_receiver) = PohRecorder::new( 0, @@ -513,8 +513,8 @@ mod tests { let prev_hash = Hash::default(); let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let (mut poh_recorder, _entry_receiver) = PohRecorder::new( 0, @@ -540,8 +540,8 @@ mod tests { fn test_poh_recorder_reset_clears_cache() { let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let (mut poh_recorder, _entry_receiver) = PohRecorder::new( 0, Hash::default(), @@ -565,8 +565,8 @@ mod tests { fn test_poh_recorder_clear() { let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(2); let bank = Arc::new(Bank::new(&genesis_config)); let prev_hash = bank.last_blockhash(); @@ -599,8 +599,8 @@ mod tests { fn test_poh_recorder_tick_sent_after_min() { let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(2); let bank = Arc::new(Bank::new(&genesis_config)); let prev_hash = bank.last_blockhash(); @@ -648,8 +648,8 @@ mod tests { fn test_poh_recorder_tick_sent_upto_and_including_max() { let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(2); let bank = Arc::new(Bank::new(&genesis_config)); let prev_hash = bank.last_blockhash(); @@ -695,8 +695,8 @@ mod tests { fn test_poh_recorder_record_to_early() { let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(2); let bank = Arc::new(Bank::new(&genesis_config)); let prev_hash = bank.last_blockhash(); @@ -733,8 +733,8 @@ mod tests { fn test_poh_recorder_record_bad_slot() { let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(2); let bank = Arc::new(Bank::new(&genesis_config)); let prev_hash = bank.last_blockhash(); @@ -773,8 +773,8 @@ mod tests { fn test_poh_recorder_record_at_min_passes() { let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(2); let bank = Arc::new(Bank::new(&genesis_config)); let prev_hash = bank.last_blockhash(); @@ -819,8 +819,8 @@ mod tests { fn test_poh_recorder_record_at_max_fails() { let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(2); let bank = Arc::new(Bank::new(&genesis_config)); let prev_hash = bank.last_blockhash(); @@ -863,8 +863,8 @@ mod tests { fn test_poh_cache_on_disconnect() { let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(2); let bank = Arc::new(Bank::new(&genesis_config)); let prev_hash = bank.last_blockhash(); @@ -901,8 +901,8 @@ mod tests { fn test_reset_current() { let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let (mut poh_recorder, _entry_receiver) = PohRecorder::new( 0, Hash::default(), @@ -928,8 +928,8 @@ mod tests { fn test_reset_with_cached() { let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let (mut poh_recorder, _entry_receiver) = PohRecorder::new( 0, Hash::default(), @@ -956,8 +956,8 @@ mod tests { let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let (mut poh_recorder, _entry_receiver) = PohRecorder::new( 0, Hash::default(), @@ -987,8 +987,8 @@ mod tests { fn test_reset_clear_bank() { let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(2); let bank = Arc::new(Bank::new(&genesis_config)); let (mut poh_recorder, _entry_receiver) = PohRecorder::new( @@ -1018,8 +1018,8 @@ mod tests { pub fn test_clear_signal() { let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(2); let bank = Arc::new(Bank::new(&genesis_config)); let (sender, receiver) = sync_channel(1); @@ -1047,8 +1047,8 @@ mod tests { solana_logger::setup(); let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let ticks_per_slot = 5; let GenesisConfigInfo { mut genesis_config, .. @@ -1100,8 +1100,8 @@ mod tests { let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(2); let bank = Arc::new(Bank::new(&genesis_config)); let prev_hash = bank.last_blockhash(); @@ -1220,8 +1220,8 @@ mod tests { fn test_would_be_leader_soon() { let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(2); let bank = Arc::new(Bank::new(&genesis_config)); let prev_hash = bank.last_blockhash(); @@ -1287,8 +1287,8 @@ mod tests { let ledger_path = get_tmp_ledger_path!(); { // test that virtual ticks are flushed into a newly set bank asap - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let GenesisConfigInfo { genesis_config, .. } = create_genesis_config(2); let bank = Arc::new(Bank::new(&genesis_config)); let genesis_hash = bank.last_blockhash(); diff --git a/core/src/poh_service.rs b/core/src/poh_service.rs index e6576355664f5a..14f6418aec885a 100644 --- a/core/src/poh_service.rs +++ b/core/src/poh_service.rs @@ -137,8 +137,8 @@ mod tests { let prev_hash = bank.last_blockhash(); let ledger_path = get_tmp_ledger_path!(); { - let blockstore = - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"); + let blockstore = Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"); let poh_config = Arc::new(PohConfig { hashes_per_tick: Some(2), target_tick_duration: Duration::from_millis(42), diff --git a/core/tests/ledger_cleanup.rs b/core/tests/ledger_cleanup.rs index a7fdd484a93690..ea1903d08c0188 100644 --- a/core/tests/ledger_cleanup.rs +++ b/core/tests/ledger_cleanup.rs @@ -352,7 +352,8 @@ mod tests { if config.cleanup_blockstore { drop(blockstore); - Blockstore::destroy(&blockstore_path).expect("Expected successful database destruction"); + Blockstore::destroy(&blockstore_path) + .expect("Expected successful database destruction"); } } } diff --git a/ledger/src/blockstore_processor.rs b/ledger/src/blockstore_processor.rs index 59089da44e1a5b..028b9b2708ba24 100644 --- a/ledger/src/blockstore_processor.rs +++ b/ledger/src/blockstore_processor.rs @@ -269,7 +269,8 @@ pub fn process_blockstore( blockstore: &Blockstore, account_paths: Vec, opts: ProcessOptions, -) -> result::Result<(BankForks, Vec, LeaderScheduleCache), BlockstoreProcessorError> { +) -> result::Result<(BankForks, Vec, LeaderScheduleCache), BlockstoreProcessorError> +{ if let Some(num_threads) = opts.override_num_threads { PAR_THREAD_POOL.with(|pool| { *pool.borrow_mut() = rayon::ThreadPoolBuilder::new() @@ -292,7 +293,8 @@ pub fn process_blockstore_from_root( blockstore: &Blockstore, bank: Arc, opts: &ProcessOptions, -) -> result::Result<(BankForks, Vec, LeaderScheduleCache), BlockstoreProcessorError> { +) -> result::Result<(BankForks, Vec, LeaderScheduleCache), BlockstoreProcessorError> +{ info!("processing ledger from root slot {}...", bank.slot()); let allocated = thread_mem_usage::Allocatedp::default(); let initial_allocation = allocated.get(); @@ -974,14 +976,24 @@ pub mod tests { // Fork 1, ending at slot 3 let last_slot1_entry_hash = fill_blockstore_slot_with_ticks(&blockstore, ticks_per_slot, 1, 0, last_entry_hash); - last_entry_hash = - fill_blockstore_slot_with_ticks(&blockstore, ticks_per_slot, 2, 1, last_slot1_entry_hash); + last_entry_hash = fill_blockstore_slot_with_ticks( + &blockstore, + ticks_per_slot, + 2, + 1, + last_slot1_entry_hash, + ); let last_fork1_entry_hash = fill_blockstore_slot_with_ticks(&blockstore, ticks_per_slot, 3, 2, last_entry_hash); // Fork 2, ending at slot 4 - let last_fork2_entry_hash = - fill_blockstore_slot_with_ticks(&blockstore, ticks_per_slot, 4, 1, last_slot1_entry_hash); + let last_fork2_entry_hash = fill_blockstore_slot_with_ticks( + &blockstore, + ticks_per_slot, + 4, + 1, + last_slot1_entry_hash, + ); info!("last_fork1_entry.hash: {:?}", last_fork1_entry_hash); info!("last_fork2_entry.hash: {:?}", last_fork2_entry_hash); @@ -1048,14 +1060,24 @@ pub mod tests { // Fork 1, ending at slot 3 let last_slot1_entry_hash = fill_blockstore_slot_with_ticks(&blockstore, ticks_per_slot, 1, 0, last_entry_hash); - last_entry_hash = - fill_blockstore_slot_with_ticks(&blockstore, ticks_per_slot, 2, 1, last_slot1_entry_hash); + last_entry_hash = fill_blockstore_slot_with_ticks( + &blockstore, + ticks_per_slot, + 2, + 1, + last_slot1_entry_hash, + ); let last_fork1_entry_hash = fill_blockstore_slot_with_ticks(&blockstore, ticks_per_slot, 3, 2, last_entry_hash); // Fork 2, ending at slot 4 - let last_fork2_entry_hash = - fill_blockstore_slot_with_ticks(&blockstore, ticks_per_slot, 4, 1, last_slot1_entry_hash); + let last_fork2_entry_hash = fill_blockstore_slot_with_ticks( + &blockstore, + ticks_per_slot, + 4, + 1, + last_slot1_entry_hash, + ); info!("last_fork1_entry.hash: {:?}", last_fork1_entry_hash); info!("last_fork2_entry.hash: {:?}", last_fork2_entry_hash); diff --git a/ledger/src/leader_schedule_cache.rs b/ledger/src/leader_schedule_cache.rs index 69662ad8fdb2be..981f5babed3a49 100644 --- a/ledger/src/leader_schedule_cache.rs +++ b/ledger/src/leader_schedule_cache.rs @@ -439,7 +439,8 @@ mod tests { let ledger_path = get_tmp_ledger_path!(); { let blockstore = Arc::new( - Blockstore::open(&ledger_path).expect("Expected to be able to open database ledger"), + Blockstore::open(&ledger_path) + .expect("Expected to be able to open database ledger"), ); assert_eq!( diff --git a/local-cluster/src/cluster_tests.rs b/local-cluster/src/cluster_tests.rs index 616fb1920a9555..82eaa1bf68c422 100644 --- a/local-cluster/src/cluster_tests.rs +++ b/local-cluster/src/cluster_tests.rs @@ -301,7 +301,11 @@ fn poll_all_nodes_for_signature( Ok(()) } -fn get_and_verify_slot_entries(blockstore: &Blockstore, slot: Slot, last_entry: &Hash) -> Vec { +fn get_and_verify_slot_entries( + blockstore: &Blockstore, + slot: Slot, + last_entry: &Hash, +) -> Vec { let entries = blockstore.get_slot_entries(slot, 0, None).unwrap(); assert_eq!(entries.verify(last_entry), true); entries diff --git a/local-cluster/tests/archiver.rs b/local-cluster/tests/archiver.rs index 2987afbe01d499..51874b744777ac 100644 --- a/local-cluster/tests/archiver.rs +++ b/local-cluster/tests/archiver.rs @@ -63,8 +63,13 @@ fn run_archiver_startup_basic(num_nodes: usize, num_archivers: usize) { ))); let path = get_tmp_ledger_path!(); let blockstore = Arc::new(Blockstore::open(&path).unwrap()); - Archiver::download_from_archiver(&cluster_info, &archiver_info, &blockstore, slots_per_segment) - .unwrap(); + Archiver::download_from_archiver( + &cluster_info, + &archiver_info, + &blockstore, + slots_per_segment, + ) + .unwrap(); } #[test]