Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text-dump banking trace files #35385

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/src/banking_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ mod immutable_deserialized_packet;
mod latest_unprocessed_votes;
mod leader_slot_timing_metrics;
mod multi_iterator_scanner;
mod packet_deserializer;
pub mod packet_deserializer;
mod packet_receiver;
mod read_write_account_set;
#[allow(dead_code)]
Expand Down
2 changes: 1 addition & 1 deletion core/src/banking_stage/packet_deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl PacketDeserializer {

/// Deserialize packet batches, aggregates tracer packet stats, and collect
/// them into ReceivePacketResults
fn deserialize_and_collect_packets(
pub fn deserialize_and_collect_packets(
packet_count: usize,
banking_batches: &[BankingPacketBatch],
round_compute_unit_price_enabled: bool,
Expand Down
1 change: 1 addition & 0 deletions ledger-tool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ license = { workspace = true }
edition = { workspace = true }

[dependencies]
bincode = { workspace = true }
bs58 = { workspace = true }
chrono = { workspace = true, features = ["default"] }
clap = { workspace = true }
Expand Down
83 changes: 57 additions & 26 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1560,34 +1560,65 @@ fn main() {
println!("{}", open_genesis_config_by(&output_directory, arg_matches));
}
("shred-version", Some(arg_matches)) => {
let mut process_options = parse_process_options(&ledger_path, arg_matches);
// Respect a user-set --halt-at-slot; otherwise, set Some(0) to avoid
// processing any additional banks and just use the snapshot bank
if process_options.halt_at_slot.is_none() {
process_options.halt_at_slot = Some(0);
use solana_core::banking_trace::TimedTracedEvent;
use solana_core::banking_trace::TracedEvent;
let path = PathBuf::new().join("/dev/stdin");
use std::{fs::File, io::BufReader};
let mut stream = BufReader::new(File::open(&path).unwrap());
/*
let mut bank_starts_by_slot = std::collections::BTreeMap::new();
let mut packet_batches_by_time = std::collections::BTreeMap::new();
let mut hashes_by_slot = std::collections::HashMap::new();
*/

let mut packet_count = 0;
/*
let mut events = vec![];
*/
use solana_sdk::message::AddressLoader;
use solana_sdk::message::v0::LoadedAddresses;
use solana_sdk::message::v0::MessageAddressTableLookup;
#[derive(Clone)]
struct A;
impl AddressLoader for A {
fn load_addresses(self, _: &[MessageAddressTableLookup]) -> Result<LoadedAddresses, solana_sdk::message::AddressLoaderError> { Ok(LoadedAddresses::default()) }
}
let genesis_config = open_genesis_config_by(&ledger_path, arg_matches);
let blockstore = open_blockstore(
&ledger_path,
arg_matches,
get_access_type(&process_options),
);
let (bank_forks, _) = load_and_process_ledger_or_exit(
arg_matches,
&genesis_config,
Arc::new(blockstore),
process_options,
snapshot_archive_path,
incremental_snapshot_archive_path,
);

println!(
"{}",
compute_shred_version(
&genesis_config.hash(),
Some(&bank_forks.read().unwrap().working_bank().hard_forks())
)
);

loop {
let d = bincode::deserialize_from::<_, TimedTracedEvent>(&mut stream);
let Ok(event) = d else {
info!("deserialize error: {:?}", &d);
break;
};
error!("{:?}", event);
let event_time = event.0;
let event = &event.1;
let datetime: chrono::DateTime<chrono::Utc> = event_time.into();
match &event {

TracedEvent::PacketBatch(_label, batch) => {
let sum = batch.0.iter().map(|v| v.len()).sum::<usize>();
packet_count += sum;
let st = solana_core::banking_stage::packet_deserializer::PacketDeserializer::deserialize_and_collect_packets(0, &[batch.clone()], false).deserialized_packets.iter().filter_map(|ip| ip.build_sanitized_transaction(&Arc::new(FeatureSet::all_enabled()), false, A)).collect::<Vec<_>>();
let st_label = format!("({:#?})", st);
for transaction in st {
solana_cli_output::display::println_transaction(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this didn't decode instruction data for loaders like this. i wonder there's better way...

&transaction.to_versioned_transaction(),
None,
" ",
None,
None,
);
}
error!("event parsed: {}: <{}: {}{} = {:?}> {:?}", datetime.format("%Y-%m-%d %H:%M:%S.%f"), packet_count, sum, st_label, &batch.0.iter().map(|v| v.len()).collect::<Vec<_>>(), &event);
}
_ => {
error!("event parsed: {}: {:?}", datetime.format("%Y-%m-%d %H:%M:%S.%f"), &event);
}
//events.push(event);
}
}
}
("bank-hash", Some(arg_matches)) => {
let process_options = parse_process_options(&ledger_path, arg_matches);
Expand Down
Loading