This repository was archived by the owner on Jan 22, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Refactor pass feature status to deserialized packet via packet meta #31549
Merged
tao-stones
merged 5 commits into
solana-labs:master
from
tao-stones:refactor-pass-feature-status-to-deserialized-packet-via-packet-meta
May 11, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0e32503
1. add lag to get_transaction_priority_details trait as parameter
tao-stones f5ae802
1. inject bank_fork to packet_deserializer,
tao-stones 0a2d32f
update tests
tao-stones 20c1eb8
use working_bank instead of root_bank
tao-stones 4ccf3a5
update comments
tao-stones File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,7 @@ impl ImmutableDeserializedPacket { | |
|
|
||
| // drop transaction if prioritization fails. | ||
| let mut priority_details = sanitized_transaction | ||
| .get_transaction_priority_details() | ||
| .get_transaction_priority_details(packet.meta().round_compute_unit_price()) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the particular feature flag is then read from packet's meta data, avoiding passing it through call stacks |
||
| .ok_or(DeserializedPacketError::PrioritizationFailure)?; | ||
|
|
||
| // set priority to zero for vote transactions | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,11 @@ use { | |
| }, | ||
| crossbeam_channel::RecvTimeoutError, | ||
| solana_perf::packet::PacketBatch, | ||
| std::time::{Duration, Instant}, | ||
| solana_runtime::bank_forks::BankForks, | ||
| std::{ | ||
| sync::{Arc, RwLock}, | ||
| time::{Duration, Instant}, | ||
| }, | ||
| }; | ||
|
|
||
| /// Results from deserializing packet batches. | ||
|
|
@@ -26,12 +30,18 @@ pub struct ReceivePacketResults { | |
| pub struct PacketDeserializer { | ||
| /// Receiver for packet batches from sigverify stage | ||
| packet_batch_receiver: BankingPacketReceiver, | ||
| /// Provides root bank for deserializer to check feature activation | ||
| bank_forks: Arc<RwLock<BankForks>>, | ||
| } | ||
|
|
||
| impl PacketDeserializer { | ||
| pub fn new(packet_batch_receiver: BankingPacketReceiver) -> Self { | ||
| pub fn new( | ||
| packet_batch_receiver: BankingPacketReceiver, | ||
| bank_forks: Arc<RwLock<BankForks>>, | ||
| ) -> Self { | ||
| Self { | ||
| packet_batch_receiver, | ||
| bank_forks, | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -42,9 +52,16 @@ impl PacketDeserializer { | |
| capacity: usize, | ||
| ) -> Result<ReceivePacketResults, RecvTimeoutError> { | ||
| 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, | ||
| )) | ||
| } | ||
|
|
||
|
|
@@ -53,6 +70,7 @@ impl PacketDeserializer { | |
| fn deserialize_and_collect_packets( | ||
| packet_count: usize, | ||
| banking_batches: &[BankingPacketBatch], | ||
| round_compute_unit_price_enabled: bool, | ||
| ) -> ReceivePacketResults { | ||
| let mut passed_sigverify_count: usize = 0; | ||
| let mut failed_sigverify_count: usize = 0; | ||
|
|
@@ -66,8 +84,11 @@ impl PacketDeserializer { | |
| passed_sigverify_count += packet_indexes.len(); | ||
| failed_sigverify_count += packet_batch.len().saturating_sub(packet_indexes.len()); | ||
|
|
||
| deserialized_packets | ||
| .extend(Self::deserialize_packets(packet_batch, &packet_indexes)); | ||
| deserialized_packets.extend(Self::deserialize_packets( | ||
| packet_batch, | ||
| &packet_indexes, | ||
| round_compute_unit_price_enabled, | ||
| )); | ||
| } | ||
|
|
||
| if let Some(tracer_packet_stats) = &banking_batch.1 { | ||
|
|
@@ -136,9 +157,14 @@ impl PacketDeserializer { | |
| fn deserialize_packets<'a>( | ||
| packet_batch: &'a PacketBatch, | ||
| packet_indexes: &'a [usize], | ||
| round_compute_unit_price_enabled: bool, | ||
| ) -> impl Iterator<Item = ImmutableDeserializedPacket> + 'a { | ||
| packet_indexes.iter().filter_map(move |packet_index| { | ||
| ImmutableDeserializedPacket::new(packet_batch[*packet_index].clone()).ok() | ||
| let mut packet_clone = packet_batch[*packet_index].clone(); | ||
| packet_clone | ||
| .meta_mut() | ||
| .set_round_compute_unit_price(round_compute_unit_price_enabled); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. flag packet with root_bank feature set |
||
| ImmutableDeserializedPacket::new(packet_clone).ok() | ||
| }) | ||
| } | ||
| } | ||
|
|
@@ -160,7 +186,7 @@ mod tests { | |
|
|
||
| #[test] | ||
| fn test_deserialize_and_collect_packets_empty() { | ||
| let results = PacketDeserializer::deserialize_and_collect_packets(0, &[]); | ||
| let results = PacketDeserializer::deserialize_and_collect_packets(0, &[], false); | ||
| assert_eq!(results.deserialized_packets.len(), 0); | ||
| assert!(results.new_tracer_stats_option.is_none()); | ||
| assert_eq!(results.passed_sigverify_count, 0); | ||
|
|
@@ -177,6 +203,7 @@ mod tests { | |
| let results = PacketDeserializer::deserialize_and_collect_packets( | ||
| packet_count, | ||
| &[BankingPacketBatch::new((packet_batches, None))], | ||
| false, | ||
| ); | ||
| assert_eq!(results.deserialized_packets.len(), 2); | ||
| assert!(results.new_tracer_stats_option.is_none()); | ||
|
|
@@ -195,6 +222,7 @@ mod tests { | |
| let results = PacketDeserializer::deserialize_and_collect_packets( | ||
| packet_count, | ||
| &[BankingPacketBatch::new((packet_batches, None))], | ||
| false, | ||
| ); | ||
| assert_eq!(results.deserialized_packets.len(), 1); | ||
| assert!(results.new_tracer_stats_option.is_none()); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing
bank_forkstoPacketReceiverthen toPacketDeserializer, so packets can be flagged with working_bank's feature set.