Add geyser block-metadata notification with entry count (#33359)

* Add new ReplicaBlockInfoVersions variant

* Use new variant to return entry count
This commit is contained in:
Tyera 2023-09-26 10:13:17 -06:00 committed by GitHub
parent 4488cc241f
commit ddd029774a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 5 deletions

View File

@ -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();

View File

@ -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,
@ -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

View File

@ -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::*,
@ -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() {
@ -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!(
@ -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,
@ -113,6 +116,7 @@ impl BlockMetadataNotifierImpl {
block_time,
block_height,
executed_transaction_count,
entry_count,
}
}

View File

@ -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,
@ -17,6 +18,7 @@ pub trait BlockMetadataNotifier {
block_time: Option<UnixTimestamp>,
block_height: Option<u64>,
executed_transaction_count: u64,
entry_count: u64,
);
}