Skip to content

Commit

Permalink
ledger-tool: Adjust logic to obtain TransactionStatusService Blocksto…
Browse files Browse the repository at this point in the history
…re (solana-labs#34646)

TransactionStatusService needs Primary access in order to write
transaction status into the Blockstore if enable_rpc_transaction_history
is set to True. The current logic attempts to get Primary access for the
service.

However, in the event that this function had been called with a
Blockstore that already had Primary access, this second attempt to get
Primary access would fail. So, only attempt to open with Primary access
when necessary AND when the current access level is not sufficient.
  • Loading branch information
steviez authored Jan 4, 2024
1 parent a2d2eb3 commit 9fe2037
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions ledger-tool/src/ledger_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,39 +356,41 @@ pub fn load_and_process_ledger(

let enable_rpc_transaction_history = arg_matches.is_present("enable_rpc_transaction_history");

let (transaction_status_sender, transaction_status_service) =
if geyser_plugin_active || enable_rpc_transaction_history {
// Need Primary (R/W) access to insert transaction data
let tss_blockstore = if enable_rpc_transaction_history {
Arc::new(open_blockstore(
blockstore.ledger_path(),
arg_matches,
AccessType::PrimaryForMaintenance,
))
} else {
blockstore.clone()
};

let (transaction_status_sender, transaction_status_receiver) = unbounded();
let transaction_status_service = TransactionStatusService::new(
transaction_status_receiver,
Arc::default(),
enable_rpc_transaction_history,
transaction_notifier,
tss_blockstore,
false,
exit.clone(),
);
(
Some(TransactionStatusSender {
sender: transaction_status_sender,
}),
Some(transaction_status_service),
)
let (transaction_status_sender, transaction_status_service) = if geyser_plugin_active
|| enable_rpc_transaction_history
{
// Need Primary (R/W) access to insert transaction data;
// obtain Primary access if we do not already have it
let tss_blockstore = if enable_rpc_transaction_history && !blockstore.is_primary_access() {
Arc::new(open_blockstore(
blockstore.ledger_path(),
arg_matches,
AccessType::PrimaryForMaintenance,
))
} else {
(None, None)
blockstore.clone()
};

let (transaction_status_sender, transaction_status_receiver) = unbounded();
let transaction_status_service = TransactionStatusService::new(
transaction_status_receiver,
Arc::default(),
enable_rpc_transaction_history,
transaction_notifier,
tss_blockstore,
false,
exit.clone(),
);
(
Some(TransactionStatusSender {
sender: transaction_status_sender,
}),
Some(transaction_status_service),
)
} else {
(None, None)
};

let result = blockstore_processor::process_blockstore_from_root(
blockstore.as_ref(),
&bank_forks,
Expand Down

0 comments on commit 9fe2037

Please sign in to comment.