diff --git a/Cargo.lock b/Cargo.lock index a9703fb754..ea8f99e805 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1353,7 +1353,16 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2953d1df47ac0eb70086ccabf0275aa8da8591a28bd358ee2b52bd9f9e3ff9e9" dependencies = [ - "enum-iterator-derive", + "enum-iterator-derive 0.8.1", +] + +[[package]] +name = "enum-iterator" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "706d9e7cf1c7664859d79cd524e4e53ea2b67ea03c98cc2870c5e539695d597e" +dependencies = [ + "enum-iterator-derive 1.2.0", ] [[package]] @@ -1367,6 +1376,17 @@ dependencies = [ "syn 1.0.98", ] +[[package]] +name = "enum-iterator-derive" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "355f93763ef7b0ae1c43c4d8eccc9d5848d84ad1a1d8ce61c421d1ac85a19d05" +dependencies = [ + "proc-macro2 1.0.41", + "quote 1.0.18", + "syn 1.0.98", +] + [[package]] name = "enum-ordinalize" version = "3.1.10" @@ -5806,7 +5826,7 @@ dependencies = [ "base64 0.13.0", "bincode", "eager", - "enum-iterator", + "enum-iterator 0.8.1", "itertools", "libc", "libloading", @@ -6207,7 +6227,7 @@ dependencies = [ "bincode", "bytes", "bzip2", - "enum-iterator", + "enum-iterator 1.4.0", "flate2", "futures 0.3.21", "goauth", @@ -6237,7 +6257,7 @@ version = "1.14.15" dependencies = [ "bincode", "bs58", - "enum-iterator", + "enum-iterator 1.4.0", "prost 0.11.0", "protobuf-src", "serde", diff --git a/core/src/replay_stage.rs b/core/src/replay_stage.rs index ba9158e124..b191147aee 100644 --- a/core/src/replay_stage.rs +++ b/core/src/replay_stage.rs @@ -2600,11 +2600,14 @@ impl ReplayStage { if let Some(ref block_metadata_notifier) = block_metadata_notifier { let block_metadata_notifier = block_metadata_notifier.read().unwrap(); block_metadata_notifier.notify_block_metadata( + bank.parent_slot(), + &bank.parent_hash().to_string(), bank.slot(), &bank.last_blockhash().to_string(), &bank.rewards, Some(bank.clock().unix_timestamp), Some(bank.block_height()), + bank.executed_transaction_count(), ) } bank_complete_time.stop(); diff --git a/geyser-plugin-interface/src/geyser_plugin_interface.rs b/geyser-plugin-interface/src/geyser_plugin_interface.rs index 4b49701b7f..01279b28f7 100644 --- a/geyser-plugin-interface/src/geyser_plugin_interface.rs +++ b/geyser-plugin-interface/src/geyser_plugin_interface.rs @@ -133,8 +133,22 @@ pub struct ReplicaBlockInfo<'a> { pub block_height: Option, } +/// Extending ReplicaBlockInfo by sending the transaction_entries_count. +#[derive(Clone, Debug)] +pub struct ReplicaBlockInfoV2<'a> { + pub parent_slot: u64, + pub parent_blockhash: &'a str, + pub slot: u64, + pub blockhash: &'a str, + pub rewards: &'a [Reward], + pub block_time: Option, + pub block_height: Option, + pub executed_transaction_count: u64, +} + pub enum ReplicaBlockInfoVersions<'a> { V0_0_1(&'a ReplicaBlockInfo<'a>), + V0_0_2(&'a ReplicaBlockInfoV2<'a>), } /// Errors returned by plugin calls diff --git a/geyser-plugin-manager/src/block_metadata_notifier.rs b/geyser-plugin-manager/src/block_metadata_notifier.rs index 3e9a85a9ea..743c1a52d0 100644 --- a/geyser-plugin-manager/src/block_metadata_notifier.rs +++ b/geyser-plugin-manager/src/block_metadata_notifier.rs @@ -5,7 +5,7 @@ use { }, log::*, solana_geyser_plugin_interface::geyser_plugin_interface::{ - ReplicaBlockInfo, ReplicaBlockInfoVersions, + ReplicaBlockInfoV2, ReplicaBlockInfoVersions, }, solana_measure::measure::Measure, solana_metrics::*, @@ -23,11 +23,14 @@ impl BlockMetadataNotifier for BlockMetadataNotifierImpl { /// Notify the block metadata fn notify_block_metadata( &self, + parent_slot: u64, + parent_blockhash: &str, slot: u64, blockhash: &str, rewards: &RwLock>, block_time: Option, block_height: Option, + executed_transaction_count: u64, ) { let mut plugin_manager = self.plugin_manager.write().unwrap(); if plugin_manager.plugins.is_empty() { @@ -37,9 +40,17 @@ impl BlockMetadataNotifier for BlockMetadataNotifierImpl { for plugin in plugin_manager.plugins.iter_mut() { let mut measure = Measure::start("geyser-plugin-update-slot"); - let block_info = - Self::build_replica_block_info(slot, blockhash, &rewards, block_time, block_height); - let block_info = ReplicaBlockInfoVersions::V0_0_1(&block_info); + let block_info = Self::build_replica_block_info( + parent_slot, + parent_blockhash, + slot, + blockhash, + &rewards, + block_time, + block_height, + executed_transaction_count, + ); + let block_info = ReplicaBlockInfoVersions::V0_0_2(&block_info); match plugin.notify_block_metadata(block_info) { Err(err) => { error!( @@ -84,18 +95,24 @@ impl BlockMetadataNotifierImpl { } fn build_replica_block_info<'a>( + parent_slot: u64, + parent_blockhash: &'a str, slot: u64, blockhash: &'a str, rewards: &'a [Reward], block_time: Option, block_height: Option, - ) -> ReplicaBlockInfo<'a> { - ReplicaBlockInfo { + executed_transaction_count: u64, + ) -> ReplicaBlockInfoV2<'a> { + ReplicaBlockInfoV2 { + parent_slot, + parent_blockhash, slot, blockhash, rewards, block_time, block_height, + executed_transaction_count, } } diff --git a/geyser-plugin-manager/src/block_metadata_notifier_interface.rs b/geyser-plugin-manager/src/block_metadata_notifier_interface.rs index 6d4b9f6ad2..663443c6e3 100644 --- a/geyser-plugin-manager/src/block_metadata_notifier_interface.rs +++ b/geyser-plugin-manager/src/block_metadata_notifier_interface.rs @@ -9,11 +9,14 @@ pub trait BlockMetadataNotifier { /// Notify the block metadata fn notify_block_metadata( &self, + parent_slot: u64, + parent_blockhash: &str, slot: u64, blockhash: &str, rewards: &RwLock>, block_time: Option, block_height: Option, + executed_transaction_count: u64, ); } diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 6938379547..2227d0e771 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -6542,6 +6542,12 @@ impl Bank { self.transaction_count.load(Relaxed) } + /// Return the transaction count executed only in this bank + pub fn executed_transaction_count(&self) -> u64 { + self.transaction_count() + .saturating_sub(self.parent().map_or(0, |parent| parent.transaction_count())) + } + pub fn transaction_error_count(&self) -> u64 { self.transaction_error_count.load(Relaxed) } diff --git a/storage-bigtable/Cargo.toml b/storage-bigtable/Cargo.toml index 9ffebe3423..60d13e1dcc 100644 --- a/storage-bigtable/Cargo.toml +++ b/storage-bigtable/Cargo.toml @@ -14,7 +14,7 @@ backoff = { version = "0.4.0", features = ["tokio"] } bincode = "1.3.3" bytes = "1.0" bzip2 = "0.4.4" -enum-iterator = "0.8.1" +enum-iterator = "1.4.0" flate2 = "1.0.24" futures = "0.3.21" goauth = "0.13.0" diff --git a/storage-proto/Cargo.toml b/storage-proto/Cargo.toml index 1362f6b22e..74728b5c08 100644 --- a/storage-proto/Cargo.toml +++ b/storage-proto/Cargo.toml @@ -19,7 +19,7 @@ solana-sdk = { path = "../sdk", version = "=1.14.15" } solana-transaction-status = { path = "../transaction-status", version = "=1.14.15" } [dev-dependencies] -enum-iterator = "0.8.1" +enum-iterator = "1.4.0" [lib] crate-type = ["lib"]