Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add geyser block-metadata notification with entry count #33359

Merged
merged 2 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/src/replay_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2927,6 +2927,7 @@ impl ReplayStage {
Some(bank.clock().unix_timestamp),
Some(bank.block_height()),
bank.executed_transaction_count(),
r_replay_progress.num_entries as u64,
)
}
bank_complete_time.stop();
Expand Down
17 changes: 16 additions & 1 deletion geyser-plugin-interface/src/geyser_plugin_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ pub struct ReplicaBlockInfo<'a> {
pub block_height: Option<u64>,
}

/// Extending ReplicaBlockInfo by sending the transaction_entries_count.
/// Extending ReplicaBlockInfo by sending the executed_transaction_count.
#[derive(Clone, Debug)]
pub struct ReplicaBlockInfoV2<'a> {
pub parent_slot: Slot,
Expand All @@ -206,9 +206,24 @@ pub struct ReplicaBlockInfoV2<'a> {
pub executed_transaction_count: u64,
}

/// Extending ReplicaBlockInfo by sending the entries_count.
#[derive(Clone, Debug)]
pub struct ReplicaBlockInfoV3<'a> {
pub parent_slot: Slot,
pub parent_blockhash: &'a str,
pub slot: Slot,
pub blockhash: &'a str,
pub rewards: &'a [Reward],
pub block_time: Option<UnixTimestamp>,
pub block_height: Option<u64>,
pub executed_transaction_count: u64,
pub entry_count: u64,
}

pub enum ReplicaBlockInfoVersions<'a> {
V0_0_1(&'a ReplicaBlockInfo<'a>),
V0_0_2(&'a ReplicaBlockInfoV2<'a>),
V0_0_3(&'a ReplicaBlockInfoV3<'a>),
}

/// Errors returned by plugin calls
Expand Down
12 changes: 8 additions & 4 deletions geyser-plugin-manager/src/block_metadata_notifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use {
log::*,
solana_accounts_db::stake_rewards::RewardInfo,
solana_geyser_plugin_interface::geyser_plugin_interface::{
ReplicaBlockInfoV2, ReplicaBlockInfoVersions,
ReplicaBlockInfoV3, ReplicaBlockInfoVersions,
},
solana_measure::measure::Measure,
solana_metrics::*,
Expand All @@ -31,6 +31,7 @@ impl BlockMetadataNotifier for BlockMetadataNotifierImpl {
block_time: Option<UnixTimestamp>,
block_height: Option<u64>,
executed_transaction_count: u64,
entry_count: u64,
) {
let plugin_manager = self.plugin_manager.read().unwrap();
if plugin_manager.plugins.is_empty() {
Expand All @@ -49,8 +50,9 @@ impl BlockMetadataNotifier for BlockMetadataNotifierImpl {
block_time,
block_height,
executed_transaction_count,
entry_count,
);
let block_info = ReplicaBlockInfoVersions::V0_0_2(&block_info);
let block_info = ReplicaBlockInfoVersions::V0_0_3(&block_info);
match plugin.notify_block_metadata(block_info) {
Err(err) => {
error!(
Expand Down Expand Up @@ -103,8 +105,9 @@ impl BlockMetadataNotifierImpl {
block_time: Option<UnixTimestamp>,
block_height: Option<u64>,
executed_transaction_count: u64,
) -> ReplicaBlockInfoV2<'a> {
ReplicaBlockInfoV2 {
entry_count: u64,
) -> ReplicaBlockInfoV3<'a> {
ReplicaBlockInfoV3 {
parent_slot,
parent_blockhash,
slot,
Expand All @@ -113,6 +116,7 @@ impl BlockMetadataNotifierImpl {
block_time,
block_height,
executed_transaction_count,
entry_count,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use {
/// Interface for notifying block metadata changes
pub trait BlockMetadataNotifier {
/// Notify the block metadata
#[allow(clippy::too_many_arguments)]
fn notify_block_metadata(
&self,
parent_slot: u64,
Expand All @@ -17,6 +18,7 @@ pub trait BlockMetadataNotifier {
block_time: Option<UnixTimestamp>,
block_height: Option<u64>,
executed_transaction_count: u64,
entry_count: u64,
);
}

Expand Down