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 6 commits into
base: master
Choose a base branch
from

Conversation

4r33x
Copy link

@4r33x 4r33x commented Mar 2, 2025

Problem

Subscribing to both transactions and accounts and then synchronizing their updates is a major pain when you need all the data. Not only is it difficult to implement correctly, but it also introduces excessive redundant allocations and increases system latency. This PR adds post-transaction account states to transaction notifications.

Summary of Changes

Added ReplicaTransactionInfoV3 with a new field post_accounts_states, which has the type:
Vec<(&Pubkey, TxnReplicaAccountInfo<'a>)>.

TxnReplicaAccountInfo<'a> contains account data without the pubkey field.

This data is passed from loaded_accounts: Vec<(Pubkey, AccountSharedData)>, which was previously just dropped after CommittedTransaction was created

Concerns

There should be no performance impact or additional allocations but I aimed to make minimal changes and follow the existing code style in geyser-plugin-interface. To achieve this, I avoided importing AccountSharedData into geyser-plugin-interface (because it adds new dependency to geyser-plugin-interface), leading to a single instance where an additional redundant allocation occurs:

    fn build_replica_transaction_info<'a>(
        index: usize,
        signature: &'a Signature,
        transaction_status_meta: &'a TransactionStatusMeta,
        transaction: &'a SanitizedTransaction,
        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(),
        }
    }

This additional allocation could be avoided by importing AccountSharedData and Pubkey into geyser-plugin-interface and changing post_accounts_states to use owned types.

@mergify mergify bot requested a review from a team March 2, 2025 19:54
@4r33x 4r33x marked this pull request as ready for review March 3, 2025 00:35
@4r33x 4r33x requested a review from a team as a code owner March 3, 2025 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant