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
Send messages to EntryNotifierService in Tpu #31889
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cf83004
Add TpuEntryNotifier to send EntryNotifications from Tpu
befae3a
Hook up TpuEntryNotifier with entry_receiver to optionally send out E…
eac5443
Track entry index in WorkingBank and populate correctly in EntrySummary
f0c8be8
Fixup set_bank and WorkingBankEntry test usage
d8c063c
Add PohRecorder test of entry incrementing
45ab263
Only run TpuEntryNotifier when geyser entry notifications are support…
4463dc4
Replace ugly tuple type alias with struct
743b071
Make WorkingBankEntry::entry_index non-Optional
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| use { | ||
| crossbeam_channel::{Receiver, RecvTimeoutError, Sender}, | ||
| solana_entry::entry::EntrySummary, | ||
| solana_ledger::entry_notifier_service::{EntryNotification, EntryNotifierSender}, | ||
| solana_poh::poh_recorder::WorkingBankEntry, | ||
| std::{ | ||
| sync::{ | ||
| atomic::{AtomicBool, Ordering}, | ||
| Arc, | ||
| }, | ||
| thread::{self, Builder, JoinHandle}, | ||
| time::Duration, | ||
| }, | ||
| }; | ||
|
|
||
| pub(crate) struct TpuEntryNotifier { | ||
| thread_hdl: JoinHandle<()>, | ||
| } | ||
|
|
||
| impl TpuEntryNotifier { | ||
| pub(crate) fn new( | ||
| receiver: Receiver<WorkingBankEntry>, | ||
| entry_notification_sender: EntryNotifierSender, | ||
| broadcast_entry_sender: Sender<WorkingBankEntry>, | ||
| exit: Arc<AtomicBool>, | ||
| ) -> Self { | ||
| let thread_hdl = Builder::new() | ||
| .name("solTpuEntry".to_string()) | ||
| .spawn(move || loop { | ||
| if exit.load(Ordering::Relaxed) { | ||
| break; | ||
| } | ||
|
|
||
| if let Err(RecvTimeoutError::Disconnected) = Self::send_entry_notification( | ||
| &receiver, | ||
| &entry_notification_sender, | ||
| &broadcast_entry_sender, | ||
| ) { | ||
| break; | ||
| } | ||
| }) | ||
| .unwrap(); | ||
| Self { thread_hdl } | ||
| } | ||
|
|
||
| pub(crate) fn send_entry_notification( | ||
| receiver: &Receiver<WorkingBankEntry>, | ||
| entry_notification_sender: &EntryNotifierSender, | ||
| broadcast_entry_sender: &Sender<WorkingBankEntry>, | ||
| ) -> Result<(), RecvTimeoutError> { | ||
| let working_bank_entry = receiver.recv_timeout(Duration::from_secs(1))?; | ||
| let slot = working_bank_entry.bank.slot(); | ||
| let index = working_bank_entry.entry_index; | ||
|
|
||
| let entry_summary = EntrySummary { | ||
| num_hashes: working_bank_entry.entry.num_hashes, | ||
| hash: working_bank_entry.entry.hash, | ||
| num_transactions: working_bank_entry.entry.transactions.len() as u64, | ||
| }; | ||
| if let Err(err) = entry_notification_sender.send(EntryNotification { | ||
| slot, | ||
| index, | ||
| entry: entry_summary, | ||
| }) { | ||
| warn!( | ||
| "Failed to send slot {slot:?} entry {index:?} from Tpu to EntryNotifierService, error {err:?}", | ||
| ); | ||
| } | ||
|
|
||
| // TODO: in PohRecorder, we panic if the send to BroadcastStage fails. Should we do the same here? | ||
| if let Err(err) = broadcast_entry_sender.send(working_bank_entry) { | ||
| warn!( | ||
| "Failed to send slot {slot:?} entry {index:?} from Tpu to BroadcastStage, error {err:?}", | ||
| ); | ||
| } | ||
| Ok(()) | ||
| } | ||
|
|
||
| pub(crate) fn join(self) -> thread::Result<()> { | ||
| self.thread_hdl.join() | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
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.
Thoughts on this question?
Also, would you want to see this send in a separate thread?
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.
do we panic in pohrecorder? PohService waits for an exit signal https://github.com/apfitzge/solana/blob/abbf96f17aca9647766559db5b5de714726da033/poh/src/poh_service.rs#L371, and poh_recorder doesn't panic on record either
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.
This is already running in a separate
TpuEntryNotifierthread right? Seems like this send is perfectly fine here since it's nonblockingThere 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.
This is the panic I was referring to:
solana/poh/src/poh_recorder.rs
Line 186 in 37ebb70
It's a bit of a chore to track all the results around, so I might be misreading. But I think that if the BroadcastStage send fails with an Err, this returns an Err, which gets returned to that method with the panic I linked above here. Is that right?