-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Plumb Entry notification into plugin manager #30910
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /// Module responsible for notifying plugins about entries | ||
| use { | ||
| crate::geyser_plugin_manager::GeyserPluginManager, | ||
| log::*, | ||
| solana_entry::entry::Entry, | ||
| solana_geyser_plugin_interface::geyser_plugin_interface::{ | ||
| ReplicaEntryInfo, ReplicaEntryInfoVersions, | ||
| }, | ||
| solana_measure::measure::Measure, | ||
| solana_metrics::*, | ||
| solana_rpc::entry_notifier_interface::EntryNotifier, | ||
| solana_sdk::clock::Slot, | ||
| std::sync::{Arc, RwLock}, | ||
| }; | ||
|
|
||
| pub(crate) struct EntryNotifierImpl { | ||
| plugin_manager: Arc<RwLock<GeyserPluginManager>>, | ||
| } | ||
|
|
||
| impl EntryNotifier for EntryNotifierImpl { | ||
| fn notify_entry<'a>(&'a self, slot: Slot, index: usize, entry: &'a Entry) { | ||
| let mut measure = Measure::start("geyser-plugin-notify_plugins_of_entry_info"); | ||
|
|
||
| let plugin_manager = self.plugin_manager.read().unwrap(); | ||
| if plugin_manager.plugins.is_empty() { | ||
| return; | ||
| } | ||
|
|
||
| let entry_info = Self::build_replica_entry_info(slot, index, entry); | ||
|
|
||
| for plugin in plugin_manager.plugins.iter() { | ||
| if !plugin.entry_notifications_enabled() { | ||
| continue; | ||
| } | ||
| match plugin.notify_entry(ReplicaEntryInfoVersions::V0_0_1(&entry_info)) { | ||
| Err(err) => { | ||
| error!( | ||
| "Failed to notify entry, error: ({}) to plugin {}", | ||
| err, | ||
| plugin.name() | ||
| ) | ||
| } | ||
| Ok(_) => { | ||
| trace!("Successfully notified entry to plugin {}", plugin.name()); | ||
| } | ||
| } | ||
| } | ||
| measure.stop(); | ||
| inc_new_counter_debug!( | ||
| "geyser-plugin-notify_plugins_of_entry_info-us", | ||
| measure.as_us() as usize, | ||
| 10000, | ||
| 10000 | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| impl EntryNotifierImpl { | ||
| pub fn new(plugin_manager: Arc<RwLock<GeyserPluginManager>>) -> Self { | ||
| Self { plugin_manager } | ||
| } | ||
|
|
||
| fn build_replica_entry_info( | ||
| slot: Slot, | ||
| index: usize, | ||
| entry: &'_ Entry, | ||
| ) -> ReplicaEntryInfo<'_> { | ||
| ReplicaEntryInfo { | ||
| slot, | ||
| index, | ||
| num_hashes: entry.num_hashes, | ||
| hash: entry.hash.as_ref(), | ||
| executed_transaction_count: entry.transactions.len() as u64, | ||
| } | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| use { | ||
| solana_entry::entry::Entry, | ||
| solana_sdk::clock::Slot, | ||
| std::sync::{Arc, RwLock}, | ||
| }; | ||
|
|
||
| pub trait EntryNotifier { | ||
| fn notify_entry(&self, slot: Slot, index: usize, entry: &Entry); | ||
| } | ||
|
|
||
| pub type EntryNotifierLock = Arc<RwLock<dyn EntryNotifier + Sync + Send>>; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| #![allow(clippy::integer_arithmetic)] | ||
| mod cluster_tpu_info; | ||
| pub mod entry_notifier_interface; | ||
|
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. I put this in
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. Might move this in a follow-up, depending on where the Entry notification service ends up. |
||
| pub mod max_slots; | ||
| pub mod optimistically_confirmed_bank_tracker; | ||
| pub mod parsed_token_accounts; | ||
|
|
||
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.
While a lot of this file is copied from transaction_notifier.rs, I moved this line down, as there's no reason to build the entry info if
plugins.is_empty(). This is probably inconsequential in terms of perf, but we could make this change in the other notifiers.