solana_runtime_transaction/
transaction_meta.rs

1//! Transaction Meta contains data that follows a transaction through the
2//! execution pipeline in runtime. Examples of metadata could be limits
3//! specified by compute-budget instructions, simple-vote flag, transaction
4//! costs, durable nonce account etc;
5//!
6//! The premise is if anything qualifies as metadata, then it must be valid
7//! and available as long as the transaction itself is valid and available.
8//! Hence they are not Option<T> type. Their visibility at different states
9//! are defined in traits.
10//!
11//! The StaticMeta and DynamicMeta traits are accessor traits on the
12//! RuntimeTransaction types, not the TransactionMeta itself.
13//!
14use {
15    solana_compute_budget_instruction::compute_budget_instruction_details::ComputeBudgetInstructionDetails,
16    solana_hash::Hash, solana_message::TransactionSignatureDetails,
17};
18
19/// metadata can be extracted statically from sanitized transaction,
20/// for example: message hash, simple-vote-tx flag, limits set by instructions
21pub trait StaticMeta {
22    fn message_hash(&self) -> &Hash;
23    fn is_simple_vote_transaction(&self) -> bool;
24    fn signature_details(&self) -> &TransactionSignatureDetails;
25    fn compute_budget_instruction_details(&self) -> &ComputeBudgetInstructionDetails;
26}
27
28/// Statically loaded meta is a supertrait of Dynamically loaded meta, when
29/// transaction transited successfully into dynamically loaded, it should
30/// have both meta data populated and available.
31/// Dynamic metadata available after accounts addresses are loaded from
32/// on-chain ALT, examples are: transaction usage costs, nonce account.
33pub trait DynamicMeta: StaticMeta {}
34
35#[cfg_attr(feature = "dev-context-only-utils", derive(Clone))]
36#[derive(Debug)]
37pub struct TransactionMeta {
38    pub(crate) message_hash: Hash,
39    pub(crate) is_simple_vote_transaction: bool,
40    pub(crate) signature_details: TransactionSignatureDetails,
41    pub(crate) compute_budget_instruction_details: ComputeBudgetInstructionDetails,
42}