Adds TX signature to `TransactionContext` in debug mode (#29597)
Adds TX signature to TransactionContext in debug mode.
This commit is contained in:
parent
dda34b208c
commit
db277d320b
|
@ -4227,6 +4227,8 @@ impl Bank {
|
|||
{
|
||||
transaction_context.enable_cap_accounts_data_allocations_per_transaction();
|
||||
}
|
||||
#[cfg(debug_assertions)]
|
||||
transaction_context.set_signature(tx.signature());
|
||||
|
||||
let pre_account_state_info =
|
||||
self.get_transaction_account_state_info(&transaction_context, tx.message());
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
//! Data shared between program runtime and built-in programs as well as SBF programs.
|
||||
#![deny(clippy::indexing_slicing)]
|
||||
|
||||
#[cfg(all(not(target_os = "solana"), debug_assertions))]
|
||||
use crate::signature::Signature;
|
||||
#[cfg(not(target_os = "solana"))]
|
||||
use crate::{
|
||||
account::WritableAccount,
|
||||
|
@ -68,6 +70,9 @@ pub struct TransactionContext {
|
|||
rent: Option<Rent>,
|
||||
#[cfg(not(target_os = "solana"))]
|
||||
is_cap_accounts_data_allocations_per_transaction_enabled: bool,
|
||||
/// Useful for debugging to filter by or to look it up on the explorer
|
||||
#[cfg(all(not(target_os = "solana"), debug_assertions))]
|
||||
signature: Signature,
|
||||
}
|
||||
|
||||
impl TransactionContext {
|
||||
|
@ -97,6 +102,8 @@ impl TransactionContext {
|
|||
accounts_resize_delta: RefCell::new(0),
|
||||
rent,
|
||||
is_cap_accounts_data_allocations_per_transaction_enabled: false,
|
||||
#[cfg(all(not(target_os = "solana"), debug_assertions))]
|
||||
signature: Signature::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,6 +125,18 @@ impl TransactionContext {
|
|||
self.rent.is_some()
|
||||
}
|
||||
|
||||
/// Stores the signature of the current transaction
|
||||
#[cfg(all(not(target_os = "solana"), debug_assertions))]
|
||||
pub fn set_signature(&mut self, signature: &Signature) {
|
||||
self.signature = *signature;
|
||||
}
|
||||
|
||||
/// Returns the signature of the current transaction
|
||||
#[cfg(all(not(target_os = "solana"), debug_assertions))]
|
||||
pub fn get_signature(&self) -> &Signature {
|
||||
&self.signature
|
||||
}
|
||||
|
||||
/// Returns the total number of accounts loaded in this Transaction
|
||||
pub fn get_number_of_accounts(&self) -> IndexOfAccount {
|
||||
self.accounts.len() as IndexOfAccount
|
||||
|
|
Loading…
Reference in New Issue