Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Commit 74d54cc

Browse files
author
steviez
authored
ledger-tool: Add flag to store tx metadata in verify subcommand (#32400)
1 parent 70f8ced commit 74d54cc

File tree

2 files changed

+51
-32
lines changed

2 files changed

+51
-32
lines changed

ledger-tool/src/ledger_utils.rs

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,12 @@ use {
1919
},
2020
},
2121
solana_measure::measure,
22-
solana_rpc::{
23-
transaction_notifier_interface::TransactionNotifierLock,
24-
transaction_status_service::TransactionStatusService,
25-
},
22+
solana_rpc::transaction_status_service::TransactionStatusService,
2623
solana_runtime::{
2724
accounts_background_service::{
2825
AbsRequestHandlers, AbsRequestSender, AccountsBackgroundService,
2926
PrunedBanksRequestHandler, SnapshotRequestHandler,
3027
},
31-
accounts_update_notifier_interface::AccountsUpdateNotifier,
3228
bank_forks::BankForks,
3329
hardened_unpack::open_genesis_config,
3430
snapshot_config::SnapshotConfig,
@@ -207,9 +203,8 @@ pub fn load_and_process_ledger(
207203
exit(1);
208204
}
209205

210-
let mut accounts_update_notifier = Option::<AccountsUpdateNotifier>::default();
211-
let mut transaction_notifier = Option::<TransactionNotifierLock>::default();
212-
if arg_matches.is_present("geyser_plugin_config") {
206+
let geyser_plugin_active = arg_matches.is_present("geyser_plugin_config");
207+
let (accounts_update_notifier, transaction_notifier) = if geyser_plugin_active {
213208
let geyser_config_files = values_t_or_exit!(arg_matches, "geyser_plugin_config", String)
214209
.into_iter()
215210
.map(PathBuf::from)
@@ -224,9 +219,13 @@ pub fn load_and_process_ledger(
224219
exit(1);
225220
},
226221
);
227-
accounts_update_notifier = geyser_service.get_accounts_update_notifier();
228-
transaction_notifier = geyser_service.get_transaction_notifier();
229-
}
222+
(
223+
geyser_service.get_accounts_update_notifier(),
224+
geyser_service.get_transaction_notifier(),
225+
)
226+
} else {
227+
(None, None)
228+
};
230229

231230
let exit = Arc::new(AtomicBool::new(false));
232231
let (bank_forks, leader_schedule_cache, starting_snapshot_hashes, ..) =
@@ -294,27 +293,41 @@ pub fn load_and_process_ledger(
294293
None,
295294
);
296295

297-
let (transaction_status_sender, transaction_status_service) = if transaction_notifier.is_some()
298-
{
299-
let (transaction_status_sender, transaction_status_receiver) = unbounded();
300-
let transaction_status_service = TransactionStatusService::new(
301-
transaction_status_receiver,
302-
Arc::default(),
303-
false,
304-
transaction_notifier,
305-
blockstore.clone(),
306-
false,
307-
exit.clone(),
308-
);
309-
(
310-
Some(TransactionStatusSender {
311-
sender: transaction_status_sender,
312-
}),
313-
Some(transaction_status_service),
314-
)
315-
} else {
316-
(None, None)
317-
};
296+
let enable_rpc_transaction_history = arg_matches.is_present("enable_rpc_transaction_history");
297+
298+
let (transaction_status_sender, transaction_status_service) =
299+
if geyser_plugin_active || enable_rpc_transaction_history {
300+
// Need Primary (R/W) access to insert transaction data
301+
let tss_blockstore = if enable_rpc_transaction_history {
302+
Arc::new(open_blockstore(
303+
blockstore.ledger_path(),
304+
AccessType::PrimaryForMaintenance,
305+
None,
306+
false,
307+
))
308+
} else {
309+
blockstore.clone()
310+
};
311+
312+
let (transaction_status_sender, transaction_status_receiver) = unbounded();
313+
let transaction_status_service = TransactionStatusService::new(
314+
transaction_status_receiver,
315+
Arc::default(),
316+
enable_rpc_transaction_history,
317+
transaction_notifier,
318+
tss_blockstore,
319+
false,
320+
exit.clone(),
321+
);
322+
(
323+
Some(TransactionStatusSender {
324+
sender: transaction_status_sender,
325+
}),
326+
Some(transaction_status_service),
327+
)
328+
} else {
329+
(None, None)
330+
};
318331

319332
let result = blockstore_processor::process_blockstore_from_root(
320333
blockstore.as_ref(),

ledger-tool/src/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,12 @@ fn main() {
16201620
.takes_value(false)
16211621
.help("Skip ledger PoH and transaction verification."),
16221622
)
1623+
.arg(
1624+
Arg::with_name("enable_rpc_transaction_history")
1625+
.long("enable-rpc-transaction-history")
1626+
.takes_value(false)
1627+
.help("Store transaction info for processed slots into local ledger"),
1628+
)
16231629
.arg(
16241630
Arg::with_name("run_final_hash_calc")
16251631
.long("run-final-accounts-hash-calculation")

0 commit comments

Comments
 (0)