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    crate::compute_budget_instruction_details::ComputeBudgetInstructionDetails,
16    solana_compute_budget::compute_budget_limits::ComputeBudgetLimits,
17    solana_sdk::{
18        feature_set::FeatureSet, hash::Hash, message::TransactionSignatureDetails,
19        transaction::Result,
20    },
21};
22
23/// metadata can be extracted statically from sanitized transaction,
24/// for example: message hash, simple-vote-tx flag, limits set by instructions
25pub trait StaticMeta {
26    fn message_hash(&self) -> &Hash;
27    fn is_simple_vote_transaction(&self) -> bool;
28    fn signature_details(&self) -> &TransactionSignatureDetails;
29    fn compute_budget_limits(&self, feature_set: &FeatureSet) -> Result<ComputeBudgetLimits>;
30}
31
32/// Statically loaded meta is a supertrait of Dynamically loaded meta, when
33/// transaction transited successfully into dynamically loaded, it should
34/// have both meta data populated and available.
35/// Dynamic metadata available after accounts addresses are loaded from
36/// on-chain ALT, examples are: transaction usage costs, nonce account.
37pub trait DynamicMeta: StaticMeta {}
38
39#[derive(Debug)]
40pub struct TransactionMeta {
41    pub(crate) message_hash: Hash,
42    pub(crate) is_simple_vote_transaction: bool,
43    pub(crate) signature_details: TransactionSignatureDetails,
44    pub(crate) compute_budget_instruction_details: ComputeBudgetInstructionDetails,
45}