Skip to content

Commit

Permalink
Retaining transaction logs when transaction plugin is loaded. (solana…
Browse files Browse the repository at this point in the history
…-labs#22874)

Transaction logs are not being saved to the database through the plugin interface.

Summary of Changes

Retain the transaction logs when transaction notification plugin is loaded.

Fixes #
lijunwangs/solana-accountsdb-plugin-postgres#6
  • Loading branch information
lijunwangs authored and jeffwashington committed Feb 24, 2022
1 parent c4ca15e commit d215be1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions core/src/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3040,6 +3040,7 @@ mod tests {
true,
None,
blockstore.clone(),
false,
&Arc::new(AtomicBool::new(false)),
);

Expand All @@ -3052,7 +3053,6 @@ mod tests {
0,
Some(TransactionStatusSender {
sender: transaction_status_sender,
enable_cpi_and_log_storage: false,
}),
&gossip_vote_sender,
&QosService::new(Arc::new(RwLock::new(CostModel::default())), 1),
Expand Down Expand Up @@ -3199,6 +3199,7 @@ mod tests {
true,
None,
blockstore.clone(),
false,
&Arc::new(AtomicBool::new(false)),
);

Expand All @@ -3211,7 +3212,6 @@ mod tests {
0,
Some(TransactionStatusSender {
sender: transaction_status_sender,
enable_cpi_and_log_storage: false,
}),
&gossip_vote_sender,
&QosService::new(Arc::new(RwLock::new(CostModel::default())), 1),
Expand Down
2 changes: 1 addition & 1 deletion core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1508,14 +1508,14 @@ fn initialize_rpc_transaction_history_services(
let (transaction_status_sender, transaction_status_receiver) = unbounded();
let transaction_status_sender = Some(TransactionStatusSender {
sender: transaction_status_sender,
enable_cpi_and_log_storage,
});
let transaction_status_service = Some(TransactionStatusService::new(
transaction_status_receiver,
max_complete_transaction_status_slot.clone(),
enable_rpc_transaction_history,
transaction_notifier.clone(),
blockstore.clone(),
enable_cpi_and_log_storage,
exit,
));

Expand Down
12 changes: 2 additions & 10 deletions ledger/src/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1496,28 +1496,20 @@ pub struct TransactionStatusBatch {
#[derive(Clone)]
pub struct TransactionStatusSender {
pub sender: Sender<TransactionStatusMessage>,
pub enable_cpi_and_log_storage: bool,
}

impl TransactionStatusSender {
pub fn send_transaction_status_batch(
&self,
bank: Arc<Bank>,
transactions: Vec<SanitizedTransaction>,
mut execution_results: Vec<TransactionExecutionResult>,
execution_results: Vec<TransactionExecutionResult>,
balances: TransactionBalancesSet,
token_balances: TransactionTokenBalancesSet,
rent_debits: Vec<RentDebits>,
) {
let slot = bank.slot();
if !self.enable_cpi_and_log_storage {
execution_results.iter_mut().for_each(|execution_result| {
if let TransactionExecutionResult::Executed(details) = execution_result {
details.log_messages.take();
details.inner_instructions.take();
}
});
}

if let Err(e) = self
.sender
.send(TransactionStatusMessage::Batch(TransactionStatusBatch {
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4330,6 +4330,7 @@ pub fn create_test_transactions_and_populate_blockstore(
true,
None,
blockstore,
false,
&Arc::new(AtomicBool::new(false)),
);

Expand All @@ -4343,7 +4344,6 @@ pub fn create_test_transactions_and_populate_blockstore(
Some(
&solana_ledger::blockstore_processor::TransactionStatusSender {
sender: transaction_status_sender,
enable_cpi_and_log_storage: false,
},
),
Some(&replay_vote_sender),
Expand Down
12 changes: 11 additions & 1 deletion rpc/src/transaction_status_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl TransactionStatusService {
enable_rpc_transaction_history: bool,
transaction_notifier: Option<TransactionNotifierLock>,
blockstore: Arc<Blockstore>,
enable_cpi_and_log_storage: bool,
exit: &Arc<AtomicBool>,
) -> Self {
let exit = exit.clone();
Expand All @@ -50,6 +51,7 @@ impl TransactionStatusService {
enable_rpc_transaction_history,
transaction_notifier.clone(),
&blockstore,
enable_cpi_and_log_storage,
) {
break;
}
Expand All @@ -64,6 +66,7 @@ impl TransactionStatusService {
enable_rpc_transaction_history: bool,
transaction_notifier: Option<TransactionNotifierLock>,
blockstore: &Arc<Blockstore>,
enable_cpi_and_log_storage: bool,
) -> Result<(), RecvTimeoutError> {
match write_transaction_status_receiver.recv_timeout(Duration::from_secs(1))? {
TransactionStatusMessage::Batch(TransactionStatusBatch {
Expand Down Expand Up @@ -142,7 +145,7 @@ impl TransactionStatusService {
.collect(),
);
let loaded_addresses = transaction.get_loaded_addresses();
let transaction_status_meta = TransactionStatusMeta {
let mut transaction_status_meta = TransactionStatusMeta {
status,
fee,
pre_balances,
Expand All @@ -163,6 +166,12 @@ impl TransactionStatusService {
&transaction,
);
}

if !(enable_cpi_and_log_storage || transaction_notifier.is_some()) {
transaction_status_meta.log_messages.take();
transaction_status_meta.inner_instructions.take();
}

if enable_rpc_transaction_history {
if let Some(memos) = extract_and_fmt_memos(transaction.message()) {
blockstore
Expand Down Expand Up @@ -385,6 +394,7 @@ pub(crate) mod tests {
false,
Some(test_notifier.clone()),
blockstore,
false,
&exit,
);

Expand Down

0 comments on commit d215be1

Please sign in to comment.