From 13788688785c07a505e3bbe94df3bab974bd359b Mon Sep 17 00:00:00 2001 From: Andrew Fitzgerald Date: Tue, 1 Oct 2024 16:31:19 -0500 Subject: [PATCH 1/2] remove cu price rounding stuff --- core/src/banking_stage.rs | 8 ++--- core/src/banking_stage/packet_deserializer.rs | 32 +++---------------- core/src/banking_stage/packet_receiver.rs | 14 ++------ .../scheduler_controller.rs | 3 +- sdk/src/packet.rs | 17 ---------- 5 files changed, 10 insertions(+), 64 deletions(-) diff --git a/core/src/banking_stage.rs b/core/src/banking_stage.rs index 6f22db2d41a87b..32cc3fbe44dda1 100644 --- a/core/src/banking_stage.rs +++ b/core/src/banking_stage.rs @@ -507,7 +507,6 @@ impl BankingStage { Self::spawn_thread_local_multi_iterator_thread( id, packet_receiver, - bank_forks.clone(), decision_maker.clone(), committer.clone(), transaction_recorder.clone(), @@ -566,7 +565,6 @@ impl BankingStage { bank_thread_hdls.push(Self::spawn_thread_local_multi_iterator_thread( id, packet_receiver, - bank_forks.clone(), decision_maker.clone(), committer.clone(), transaction_recorder.clone(), @@ -631,8 +629,7 @@ impl BankingStage { // Spawn the central scheduler thread bank_thread_hdls.push({ - let packet_deserializer = - PacketDeserializer::new(non_vote_receiver, bank_forks.clone()); + let packet_deserializer = PacketDeserializer::new(non_vote_receiver); let scheduler = PrioGraphScheduler::new(work_senders, finished_work_receiver); let scheduler_controller = SchedulerController::new( decision_maker.clone(), @@ -660,7 +657,6 @@ impl BankingStage { fn spawn_thread_local_multi_iterator_thread( id: u32, packet_receiver: BankingPacketReceiver, - bank_forks: Arc>, decision_maker: DecisionMaker, committer: Committer, transaction_recorder: TransactionRecorder, @@ -668,7 +664,7 @@ impl BankingStage { mut forwarder: Forwarder, unprocessed_transaction_storage: UnprocessedTransactionStorage, ) -> JoinHandle<()> { - let mut packet_receiver = PacketReceiver::new(id, packet_receiver, bank_forks); + let mut packet_receiver = PacketReceiver::new(id, packet_receiver); let consumer = Consumer::new( committer, transaction_recorder, diff --git a/core/src/banking_stage/packet_deserializer.rs b/core/src/banking_stage/packet_deserializer.rs index e310d5505c03c9..78fab3718252f4 100644 --- a/core/src/banking_stage/packet_deserializer.rs +++ b/core/src/banking_stage/packet_deserializer.rs @@ -11,12 +11,8 @@ use { }, crossbeam_channel::RecvTimeoutError, solana_perf::packet::PacketBatch, - solana_runtime::bank_forks::BankForks, solana_sdk::saturating_add_assign, - std::{ - sync::{Arc, RwLock}, - time::{Duration, Instant}, - }, + std::time::{Duration, Instant}, }; /// Results from deserializing packet batches. @@ -33,8 +29,6 @@ pub struct ReceivePacketResults { pub struct PacketDeserializer { /// Receiver for packet batches from sigverify stage packet_batch_receiver: BankingPacketReceiver, - /// Provides working bank for deserializer to check feature activation - bank_forks: Arc>, } #[derive(Default, Debug, PartialEq)] @@ -83,13 +77,9 @@ impl PacketReceiverStats { } impl PacketDeserializer { - pub fn new( - packet_batch_receiver: BankingPacketReceiver, - bank_forks: Arc>, - ) -> Self { + pub fn new(packet_batch_receiver: BankingPacketReceiver) -> Self { Self { packet_batch_receiver, - bank_forks, } } @@ -104,15 +94,9 @@ impl PacketDeserializer { ) -> Result { let (packet_count, packet_batches) = self.receive_until(recv_timeout, capacity)?; - // Note: this can be removed after feature `round_compute_unit_price` is activated in - // mainnet-beta - let _working_bank = self.bank_forks.read().unwrap().working_bank(); - let round_compute_unit_price_enabled = false; // TODO get from working_bank.feature_set - Ok(Self::deserialize_and_collect_packets( packet_count, &packet_batches, - round_compute_unit_price_enabled, packet_filter, )) } @@ -122,7 +106,6 @@ impl PacketDeserializer { fn deserialize_and_collect_packets( packet_count: usize, banking_batches: &[BankingPacketBatch], - round_compute_unit_price_enabled: bool, packet_filter: impl Fn( ImmutableDeserializedPacket, ) -> Result, @@ -147,7 +130,6 @@ impl PacketDeserializer { deserialized_packets.extend(Self::deserialize_packets( packet_batch, &packet_indexes, - round_compute_unit_price_enabled, &mut packet_stats, &packet_filter, )); @@ -218,17 +200,13 @@ impl PacketDeserializer { fn deserialize_packets<'a>( packet_batch: &'a PacketBatch, packet_indexes: &'a [usize], - round_compute_unit_price_enabled: bool, packet_stats: &'a mut PacketReceiverStats, packet_filter: &'a impl Fn( ImmutableDeserializedPacket, ) -> Result, ) -> impl Iterator + 'a { packet_indexes.iter().filter_map(move |packet_index| { - let mut packet_clone = packet_batch[*packet_index].clone(); - packet_clone - .meta_mut() - .set_round_compute_unit_price(round_compute_unit_price_enabled); + let packet_clone = packet_batch[*packet_index].clone(); match ImmutableDeserializedPacket::new(packet_clone) .and_then(|packet| packet_filter(packet).map_err(Into::into)) @@ -260,7 +238,7 @@ mod tests { #[test] fn test_deserialize_and_collect_packets_empty() { - let results = PacketDeserializer::deserialize_and_collect_packets(0, &[], false, Ok); + let results = PacketDeserializer::deserialize_and_collect_packets(0, &[], Ok); assert_eq!(results.deserialized_packets.len(), 0); assert!(results.new_tracer_stats_option.is_none()); assert_eq!(results.packet_stats.passed_sigverify_count, 0); @@ -277,7 +255,6 @@ mod tests { let results = PacketDeserializer::deserialize_and_collect_packets( packet_count, &[BankingPacketBatch::new((packet_batches, None))], - false, Ok, ); assert_eq!(results.deserialized_packets.len(), 2); @@ -297,7 +274,6 @@ mod tests { let results = PacketDeserializer::deserialize_and_collect_packets( packet_count, &[BankingPacketBatch::new((packet_batches, None))], - false, Ok, ); assert_eq!(results.deserialized_packets.len(), 1); diff --git a/core/src/banking_stage/packet_receiver.rs b/core/src/banking_stage/packet_receiver.rs index 65c0d5816472c4..6b77d103c69670 100644 --- a/core/src/banking_stage/packet_receiver.rs +++ b/core/src/banking_stage/packet_receiver.rs @@ -9,12 +9,8 @@ use { crate::{banking_trace::BankingPacketReceiver, tracer_packet_stats::TracerPacketStats}, crossbeam_channel::RecvTimeoutError, solana_measure::{measure::Measure, measure_us}, - solana_runtime::bank_forks::BankForks, solana_sdk::{saturating_add_assign, timing::timestamp}, - std::{ - sync::{atomic::Ordering, Arc, RwLock}, - time::Duration, - }, + std::{sync::atomic::Ordering, time::Duration}, }; pub struct PacketReceiver { @@ -23,14 +19,10 @@ pub struct PacketReceiver { } impl PacketReceiver { - pub fn new( - id: u32, - banking_packet_receiver: BankingPacketReceiver, - bank_forks: Arc>, - ) -> Self { + pub fn new(id: u32, banking_packet_receiver: BankingPacketReceiver) -> Self { Self { id, - packet_deserializer: PacketDeserializer::new(banking_packet_receiver, bank_forks), + packet_deserializer: PacketDeserializer::new(banking_packet_receiver), } } diff --git a/core/src/banking_stage/transaction_scheduler/scheduler_controller.rs b/core/src/banking_stage/transaction_scheduler/scheduler_controller.rs index 9966a0527d0286..47a4c8f5a39736 100644 --- a/core/src/banking_stage/transaction_scheduler/scheduler_controller.rs +++ b/core/src/banking_stage/transaction_scheduler/scheduler_controller.rs @@ -733,8 +733,7 @@ mod tests { let decision_maker = DecisionMaker::new(Pubkey::new_unique(), poh_recorder.clone()); let (banking_packet_sender, banking_packet_receiver) = unbounded(); - let packet_deserializer = - PacketDeserializer::new(banking_packet_receiver, bank_forks.clone()); + let packet_deserializer = PacketDeserializer::new(banking_packet_receiver); let (consume_work_senders, consume_work_receivers) = create_channels(num_threads); let (finished_consume_work_sender, finished_consume_work_receiver) = unbounded(); diff --git a/sdk/src/packet.rs b/sdk/src/packet.rs index 1aa93308820d47..23bd5980879525 100644 --- a/sdk/src/packet.rs +++ b/sdk/src/packet.rs @@ -29,10 +29,6 @@ bitflags! { const REPAIR = 0b0000_0100; const SIMPLE_VOTE_TX = 0b0000_1000; const TRACER_PACKET = 0b0001_0000; - /// to be set by bank.feature_set.is_active(round_compute_unit_price::id()) at the moment - /// the packet is built. - /// This field can be removed when the above feature gate is adopted by mainnet-beta. - const ROUND_COMPUTE_UNIT_PRICE = 0b0010_0000; /// For tracking performance const PERF_TRACK_PACKET = 0b0100_0000; /// For marking packets from staked nodes @@ -250,14 +246,6 @@ impl Meta { self.flags.set(PacketFlags::SIMPLE_VOTE_TX, is_simple_vote); } - #[inline] - pub fn set_round_compute_unit_price(&mut self, round_compute_unit_price: bool) { - self.flags.set( - PacketFlags::ROUND_COMPUTE_UNIT_PRICE, - round_compute_unit_price, - ); - } - #[inline] pub fn forwarded(&self) -> bool { self.flags.contains(PacketFlags::FORWARDED) @@ -283,11 +271,6 @@ impl Meta { self.flags.contains(PacketFlags::PERF_TRACK_PACKET) } - #[inline] - pub fn round_compute_unit_price(&self) -> bool { - self.flags.contains(PacketFlags::ROUND_COMPUTE_UNIT_PRICE) - } - #[inline] pub fn is_from_staked_node(&self) -> bool { self.flags.contains(PacketFlags::FROM_STAKED_NODE) From 69ef158cf1bfdad0f62c70429d5853471aba4900 Mon Sep 17 00:00:00 2001 From: Andrew Fitzgerald Date: Wed, 2 Oct 2024 08:58:54 -0500 Subject: [PATCH 2/2] UNUSED --- sdk/src/packet.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/src/packet.rs b/sdk/src/packet.rs index 23bd5980879525..f0258710dcf423 100644 --- a/sdk/src/packet.rs +++ b/sdk/src/packet.rs @@ -29,6 +29,8 @@ bitflags! { const REPAIR = 0b0000_0100; const SIMPLE_VOTE_TX = 0b0000_1000; const TRACER_PACKET = 0b0001_0000; + // Previously used - this can now be re-used for something else. + const UNUSED = 0b0010_0000; /// For tracking performance const PERF_TRACK_PACKET = 0b0100_0000; /// For marking packets from staked nodes