Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
Merged
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
64 changes: 54 additions & 10 deletions geyser-plugin-interface/src/geyser_plugin_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
/// In addition, the dynamic library must export a "C" function _create_plugin which
/// creates the implementation of the plugin.
use {
solana_sdk::{clock::UnixTimestamp, signature::Signature, transaction::SanitizedTransaction},
solana_sdk::{
clock::{Slot, UnixTimestamp},
signature::Signature,
transaction::SanitizedTransaction,
},
solana_transaction_status::{Reward, TransactionStatusMeta},
std::{any::Any, error, io},
thiserror::Error,
Expand Down Expand Up @@ -158,9 +162,31 @@ pub enum ReplicaTransactionInfoVersions<'a> {
V0_0_2(&'a ReplicaTransactionInfoV2<'a>),
}

#[derive(Clone, Debug)]
pub struct ReplicaEntryInfo<'a> {
/// The slot number of the block containing this Entry
pub slot: Slot,
/// The Entry's index in the block
pub index: usize,
/// The number of hashes since the previous Entry
pub num_hashes: u64,
/// The Entry's SHA-256 hash, generated from the previous Entry's hash with
/// `solana_entry::entry::next_hash()`
pub hash: &'a [u8],
/// The number of executed transactions in the Entry
pub executed_transaction_count: u64,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m curious why the “executed_” prefix was added here, as Transaction execution is not really a concept at the Entry level.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh, I was mirroring the fields in the block notification. I agree that execution is not something that an Entry is really aware of, but on the other hand, it's not actually incorrect, as only executed transactions get recorded.
I don't feel strongly; happy to remove executed here if you think it's more clear

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Na im good. Thanks

}

/// A wrapper to future-proof ReplicaEntryInfo handling. To make a change to the structure of
/// ReplicaEntryInfo, add an new enum variant wrapping a newer version, which will force plugin
/// implementations to handle the change.
pub enum ReplicaEntryInfoVersions<'a> {
V0_0_1(&'a ReplicaEntryInfo<'a>),
}

#[derive(Clone, Debug)]
pub struct ReplicaBlockInfo<'a> {
pub slot: u64,
pub slot: Slot,
pub blockhash: &'a str,
pub rewards: &'a [Reward],
pub block_time: Option<UnixTimestamp>,
Expand All @@ -170,9 +196,9 @@ pub struct ReplicaBlockInfo<'a> {
/// Extending ReplicaBlockInfo by sending the transaction_entries_count.
#[derive(Clone, Debug)]
pub struct ReplicaBlockInfoV2<'a> {
pub parent_slot: u64,
pub parent_slot: Slot,
pub parent_blockhash: &'a str,
pub slot: u64,
pub slot: Slot,
pub blockhash: &'a str,
pub rewards: &'a [Reward],
pub block_time: Option<UnixTimestamp>,
Expand Down Expand Up @@ -270,7 +296,7 @@ pub trait GeyserPlugin: Any + Send + Sync + std::fmt::Debug {
fn update_account(
&self,
account: ReplicaAccountInfoVersions,
slot: u64,
slot: Slot,
is_startup: bool,
) -> Result<()> {
Ok(())
Expand All @@ -283,20 +309,31 @@ pub trait GeyserPlugin: Any + Send + Sync + std::fmt::Debug {

/// Called when a slot status is updated
#[allow(unused_variables)]
fn update_slot_status(&self, slot: u64, parent: Option<u64>, status: SlotStatus) -> Result<()> {
fn update_slot_status(
&self,
slot: Slot,
parent: Option<u64>,
status: SlotStatus,
) -> Result<()> {
Ok(())
}

/// Called when a transaction is updated at a slot.
/// Called when a transaction is processed in a slot.
#[allow(unused_variables)]
fn notify_transaction(
&self,
transaction: ReplicaTransactionInfoVersions,
slot: u64,
slot: Slot,
) -> Result<()> {
Ok(())
}

/// Called when an entry is executed.
#[allow(unused_variables)]
fn notify_entry(&self, entry: ReplicaEntryInfoVersions) -> Result<()> {
Comment thread
CriesofCarrots marked this conversation as resolved.
Ok(())
}

/// Called when block's metadata is updated.
#[allow(unused_variables)]
fn notify_block_metadata(&self, blockinfo: ReplicaBlockInfoVersions) -> Result<()> {
Expand All @@ -311,9 +348,16 @@ pub trait GeyserPlugin: Any + Send + Sync + std::fmt::Debug {
}

/// Check if the plugin is interested in transaction data
/// Default is false -- if the plugin is not interested in
/// transaction data, please return false.
/// Default is false -- if the plugin is interested in
/// transaction data, please return true.
fn transaction_notifications_enabled(&self) -> bool {
false
}

/// Check if the plugin is interested in entry data
/// Default is false -- if the plugin is interested in
/// entry data, return true.
fn entry_notifications_enabled(&self) -> bool {
false
}
}