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 post accounts state data to geyser transactions #5114

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
42 changes: 42 additions & 0 deletions geyser-plugin-interface/src/geyser_plugin_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,47 @@ pub struct ReplicaTransactionInfoV2<'a> {
pub index: usize,
}

/// Information about a transaction, including index in block and post accounts states data
#[derive(Clone, Debug)]
#[repr(C)]
pub struct ReplicaTransactionInfoV3<'a> {
/// The first signature of the transaction, used for identifying the transaction.
pub signature: &'a Signature,

/// Indicates if the transaction is a simple vote transaction.
pub is_vote: bool,

/// The sanitized transaction.
pub transaction: &'a SanitizedTransaction,

/// Metadata of the transaction status.
pub transaction_status_meta: &'a TransactionStatusMeta,

/// The transaction's index in the block
pub index: usize,
/// States of accounts that was in transaction
pub post_accounts_states: Vec<(&'a [u8], TxnReplicaAccountInfo<'a>)>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[repr(C)]
/// Information about an account being updated in txn
pub struct TxnReplicaAccountInfo<'a> {
/// The lamports for the account
pub lamports: u64,

/// The Pubkey of the owner program account
pub owner: &'a [u8],

/// This account's data contains a loaded program (and is now read-only)
pub executable: bool,

/// The epoch at which this account will next owe rent
pub rent_epoch: u64,

/// The data held in this account.
pub data: &'a [u8],
}

/// A wrapper to future-proof ReplicaTransactionInfo handling.
/// If there were a change to the structure of ReplicaTransactionInfo,
/// there would be new enum entry for the newer version, forcing
Expand All @@ -165,6 +206,7 @@ pub struct ReplicaTransactionInfoV2<'a> {
pub enum ReplicaTransactionInfoVersions<'a> {
V0_0_1(&'a ReplicaTransactionInfo<'a>),
V0_0_2(&'a ReplicaTransactionInfoV2<'a>),
V0_0_3(&'a ReplicaTransactionInfoV3<'a>),
}

#[derive(Clone, Debug)]
Expand Down
33 changes: 29 additions & 4 deletions geyser-plugin-manager/src/transaction_notifier.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use agave_geyser_plugin_interface::geyser_plugin_interface::TxnReplicaAccountInfo;
use solana_account::AccountSharedData;
use solana_account::ReadableAccount;
use solana_pubkey::Pubkey;
/// Module responsible for notifying plugins of transactions
use {
crate::geyser_plugin_manager::GeyserPluginManager,
agave_geyser_plugin_interface::geyser_plugin_interface::{
ReplicaTransactionInfoV2, ReplicaTransactionInfoVersions,
ReplicaTransactionInfoV3, ReplicaTransactionInfoVersions,
},
log::*,
solana_clock::Slot,
Expand Down Expand Up @@ -31,13 +35,15 @@ impl TransactionNotifier for TransactionNotifierImpl {
signature: &Signature,
transaction_status_meta: &TransactionStatusMeta,
transaction: &SanitizedTransaction,
post_accounts_states: Vec<(Pubkey, AccountSharedData)>,
) {
let mut measure = Measure::start("geyser-plugin-notify_plugins_of_transaction_info");
let transaction_log_info = Self::build_replica_transaction_info(
index,
signature,
transaction_status_meta,
transaction,
&post_accounts_states,
);

let plugin_manager = self.plugin_manager.read().unwrap();
Expand All @@ -51,7 +57,7 @@ impl TransactionNotifier for TransactionNotifierImpl {
continue;
}
match plugin.notify_transaction(
ReplicaTransactionInfoVersions::V0_0_2(&transaction_log_info),
ReplicaTransactionInfoVersions::V0_0_3(&transaction_log_info),
slot,
) {
Err(err) => {
Expand Down Expand Up @@ -89,13 +95,32 @@ impl TransactionNotifierImpl {
signature: &'a Signature,
transaction_status_meta: &'a TransactionStatusMeta,
transaction: &'a SanitizedTransaction,
) -> ReplicaTransactionInfoV2<'a> {
ReplicaTransactionInfoV2 {
post_accounts_states: &'a [(Pubkey, AccountSharedData)],
) -> ReplicaTransactionInfoV3<'a> {
ReplicaTransactionInfoV3 {
index,
signature,
is_vote: transaction.is_simple_vote_transaction(),
transaction,
transaction_status_meta,
post_accounts_states: post_accounts_states
.iter()
.map(|(pubkey, data)| {
(
pubkey.as_ref(),
Self::accountinfo_from_shared_account_data(data),
)
})
.collect(),
}
}
fn accountinfo_from_shared_account_data(account: &AccountSharedData) -> TxnReplicaAccountInfo {
TxnReplicaAccountInfo {
lamports: account.lamports(),
owner: account.owner().as_array(),
executable: account.executable(),
rent_epoch: account.rent_epoch(),
data: account.data(),
}
}
}
2 changes: 1 addition & 1 deletion platform-tools-sdk/sbf/c/inc/sol/alt_bn128.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extern "C" {
* @return 0 if executed successfully
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/alt_bn128.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
uint64_t sol_alt_bn128_group_op(const uint64_t, const uint8_t *, const uint64_t, uint8_t *);
#else
typedef uint64_t(*sol_alt_bn128_group_op_pointer_type)(const uint64_t, const uint8_t *, const uint64_t, uint8_t *);
Expand Down
2 changes: 1 addition & 1 deletion platform-tools-sdk/sbf/c/inc/sol/alt_bn128_compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extern "C" {
* @return 0 if executed successfully
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/alt_bn128_compression.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
uint64_t sol_alt_bn128_compression(
const uint64_t op,
const uint8_t *input,
Expand Down
2 changes: 1 addition & 1 deletion platform-tools-sdk/sbf/c/inc/sol/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extern "C" {
* the SBF VM to immediately halt execution. No accounts' data are updated
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/assert.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
void sol_panic_(const char *, uint64_t, uint64_t, uint64_t);
#else
typedef void(*sol_panic__pointer_type)(const char *, uint64_t, uint64_t, uint64_t);
Expand Down
2 changes: 1 addition & 1 deletion platform-tools-sdk/sbf/c/inc/sol/big_mod_exp.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern "C" {
* @return 0 if executed successfully
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/big_mod_exp.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
uint64_t sol_big_mod_exp(const uint8_t *, uint8_t *);
#else
typedef uint64_t(*sol_big_mod_exp_pointer_type)(const uint8_t *, uint8_t *);
Expand Down
2 changes: 1 addition & 1 deletion platform-tools-sdk/sbf/c/inc/sol/blake3.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern "C" {
* @param result 32 byte array to hold the result
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/blake3.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
uint64_t sol_blake3(const SolBytes *, int, const uint8_t *);
#else
typedef uint64_t(*sol_blake3_pointer_type)(const SolBytes *, int, const uint8_t *);
Expand Down
2 changes: 1 addition & 1 deletion platform-tools-sdk/sbf/c/inc/sol/compute_units.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern "C" {
* Prints a string to stdout
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/compute_units.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
uint64_t sol_remaining_compute_units();
#else
typedef uint64_t(*sol_remaining_compute_units_pointer_type)();
Expand Down
2 changes: 1 addition & 1 deletion platform-tools-sdk/sbf/c/inc/sol/cpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ typedef struct {
* Internal cross-program invocation function
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/cpi.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
uint64_t sol_invoke_signed_c(
const SolInstruction *,
const SolAccountInfo *,
Expand Down
2 changes: 1 addition & 1 deletion platform-tools-sdk/sbf/c/inc/sol/keccak.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern "C" {
* @param result 32 byte array to hold the result
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/keccak.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
uint64_t sol_keccak256(const SolBytes *, int, uint8_t *);
#else
typedef uint64_t(*sol_keccak256_pointer_type)(const SolBytes *, int, uint8_t *);
Expand Down
2 changes: 1 addition & 1 deletion platform-tools-sdk/sbf/c/inc/sol/last_restart_slot.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern "C" {
* Get Last Restart Slot
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/last_restart_slot.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
u64 sol_get_last_restart_slot(uint8_t *result);
#else
typedef u64(*sol_get_last_restart_slot_pointer_type)(uint8_t *result);
Expand Down
8 changes: 4 additions & 4 deletions platform-tools-sdk/sbf/c/inc/sol/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern "C" {
* Prints a string to stdout
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/log.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
void sol_log_(const char *, uint64_t);
#else
typedef void(*sol_log__pointer_type)(const char *, uint64_t);
Expand All @@ -30,7 +30,7 @@ static void sol_log_(const char * arg1, uint64_t arg2) {
* Prints a 64 bit values represented in hexadecimal to stdout
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/log.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
void sol_log_64_(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t);
#else
typedef void(*sol_log_64__pointer_type)(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t);
Expand All @@ -45,7 +45,7 @@ static void sol_log_64_(uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t ar
* Prints the current compute unit consumption to stdout
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/log.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
void sol_log_compute_units_();
#else
typedef void(*sol_log_compute_units__pointer_type)();
Expand All @@ -71,7 +71,7 @@ static void sol_log_array(const uint8_t *array, int len) {
* Print the base64 representation of some arrays.
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/log.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
void sol_log_data(SolBytes *, uint64_t);
#else
typedef void(*sol_log_data_pointer_type)(SolBytes *, uint64_t);
Expand Down
2 changes: 1 addition & 1 deletion platform-tools-sdk/sbf/c/inc/sol/poseidon.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extern "C" {
* @param result 32 byte array to hold the result
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/poseidon.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
uint64_t sol_poseidon(
const uint64_t parameters,
const uint64_t endianness,
Expand Down
6 changes: 3 additions & 3 deletions platform-tools-sdk/sbf/c/inc/sol/pubkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ typedef struct {
* @param key The public key to print
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/pubkey.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
void sol_log_pubkey(const SolPubkey *);
#else
typedef void(*sol_log_pubkey_pointer_type)(const SolPubkey *);
Expand Down Expand Up @@ -79,7 +79,7 @@ typedef struct {
* @param program_address Program address created, filled on return
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/pubkey.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
uint64_t sol_create_program_address(const SolSignerSeed *, int, const SolPubkey *, SolPubkey *);
#else
typedef uint64_t(*sol_create_program_address_pointer_type)(const SolSignerSeed *, int, const SolPubkey *, SolPubkey *);
Expand All @@ -99,7 +99,7 @@ static uint64_t sol_create_program_address(const SolSignerSeed * arg1, int arg2,
* @param bump_seed Bump seed required to create a valid program address
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/pubkey.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
uint64_t sol_try_find_program_address(const SolSignerSeed *, int, const SolPubkey *, SolPubkey *, uint8_t *);
#else
typedef uint64_t(*sol_try_find_program_address_pointer_type)(const SolSignerSeed *, int, const SolPubkey *, SolPubkey *, uint8_t *);
Expand Down
4 changes: 2 additions & 2 deletions platform-tools-sdk/sbf/c/inc/sol/return_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extern "C"
* @param bytes_len length of byte array. This may not exceed MAX_RETURN_DATA.
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/return_data.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
void sol_set_return_data(const uint8_t *, uint64_t);
#else
typedef void(*sol_set_return_data_pointer_type)(const uint8_t *, uint64_t);
Expand All @@ -42,7 +42,7 @@ static void sol_set_return_data(const uint8_t * arg1, uint64_t arg2) {
* @param result length of return data (may exceed bytes_len if the return data is longer)
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/return_data.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
uint64_t sol_get_return_data(uint8_t *, uint64_t, SolPubkey *);
#else
typedef uint64_t(*sol_get_return_data_pointer_type)(uint8_t *, uint64_t, SolPubkey *);
Expand Down
2 changes: 1 addition & 1 deletion platform-tools-sdk/sbf/c/inc/sol/secp256k1.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extern "C" {
* @return 0 if executed successfully
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/secp256k1.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
uint64_t sol_secp256k1_recover(const uint8_t *, uint64_t, const uint8_t *, uint8_t *);
#else
typedef uint64_t(*sol_secp256k1_recover_pointer_type)(const uint8_t *, uint64_t, const uint8_t *, uint8_t *);
Expand Down
2 changes: 1 addition & 1 deletion platform-tools-sdk/sbf/c/inc/sol/sha.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern "C" {
* @param result 32 byte array to hold the result
*/
/* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE platform-tools-sdk/sbf/c/inc/sol/inc/sha.inc AND RUN `cargo run --bin gen-headers` */
#ifndef SOL_SBFV2
#ifndef SOL_SBPFV3
uint64_t sol_sha256(const SolBytes *, int, uint8_t *);
#else
typedef uint64_t(*sol_sha256_pointer_type)(const SolBytes *, int, uint8_t *);
Expand Down
4 changes: 4 additions & 0 deletions rpc/src/transaction_notifier_interface.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use solana_pubkey::Pubkey;
use solana_sdk::account::AccountSharedData;

use {
solana_sdk::{clock::Slot, signature::Signature, transaction::SanitizedTransaction},
solana_transaction_status::TransactionStatusMeta,
Expand All @@ -12,6 +15,7 @@ pub trait TransactionNotifier {
signature: &Signature,
transaction_status_meta: &TransactionStatusMeta,
transaction: &SanitizedTransaction,
post_accounts_states: Vec<(Pubkey, AccountSharedData)>,
);
}

Expand Down
8 changes: 8 additions & 0 deletions rpc/src/transaction_status_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ impl TransactionStatusService {
executed_units,
fee_details,
rent_debits,
post_accounts_states,
..
} = committed_tx;

Expand Down Expand Up @@ -185,6 +186,7 @@ impl TransactionStatusService {
transaction.signature(),
&transaction_status_meta,
&transaction,
post_accounts_states,
);
}

Expand Down Expand Up @@ -269,6 +271,7 @@ pub(crate) mod tests {
solana_ledger::{genesis_utils::create_genesis_config, get_tmp_ledger_path_auto_delete},
solana_runtime::bank::{Bank, TransactionBalancesSet},
solana_sdk::{
account::AccountSharedData,
account_utils::StateMut,
clock::Slot,
fee::FeeDetails,
Expand Down Expand Up @@ -325,6 +328,7 @@ pub(crate) mod tests {
signature: &Signature,
transaction_status_meta: &TransactionStatusMeta,
transaction: &SanitizedTransaction,
_post_accounts_states: Vec<(Pubkey, AccountSharedData)>,
) {
self.notifications.insert(
TestNotifierKey {
Expand Down Expand Up @@ -393,6 +397,8 @@ pub(crate) mod tests {
fee_details: FeeDetails::default(),
rent_debits,
loaded_account_stats: TransactionLoadedAccountsStats::default(),
//Do we need to put something here?
post_accounts_states: vec![],
});

let balances = TransactionBalancesSet {
Expand Down Expand Up @@ -519,6 +525,8 @@ pub(crate) mod tests {
fee_details: FeeDetails::default(),
rent_debits: RentDebits::default(),
loaded_account_stats: TransactionLoadedAccountsStats::default(),
//Do we need to put something here?
post_accounts_states: vec![],
});

let balances = TransactionBalancesSet {
Expand Down
2 changes: 2 additions & 0 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3800,6 +3800,7 @@ impl Bank {
loaded_accounts_count: loaded_accounts.len(),
loaded_accounts_data_size,
},
post_accounts_states: loaded_accounts,
})
}
ProcessedTransaction::FeesOnly(fees_only_tx) => Ok(CommittedTransaction {
Expand All @@ -3814,6 +3815,7 @@ impl Bank {
loaded_accounts_count: fees_only_tx.rollback_accounts.count(),
loaded_accounts_data_size,
},
post_accounts_states: vec![],
}),
}
})
Expand Down
Loading