(cherry picked from commit f6a7732ff9
)
Co-authored-by: behzad nouri <behzadnouri@gmail.com>
This commit is contained in:
@ -21,6 +21,7 @@ use solana_ledger::{
|
|||||||
blockstore_db::{self, AccessType, BlockstoreRecoveryMode, Column, Database},
|
blockstore_db::{self, AccessType, BlockstoreRecoveryMode, Column, Database},
|
||||||
blockstore_processor::ProcessOptions,
|
blockstore_processor::ProcessOptions,
|
||||||
rooted_slot_iterator::RootedSlotIterator,
|
rooted_slot_iterator::RootedSlotIterator,
|
||||||
|
shred::Shred,
|
||||||
};
|
};
|
||||||
use solana_runtime::{
|
use solana_runtime::{
|
||||||
bank::{Bank, RewardCalculationEvent},
|
bank::{Bank, RewardCalculationEvent},
|
||||||
@ -741,6 +742,11 @@ fn main() {
|
|||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.default_value("0")
|
.default_value("0")
|
||||||
.help("Start at this slot");
|
.help("Start at this slot");
|
||||||
|
let ending_slot_arg = Arg::with_name("ending_slot")
|
||||||
|
.long("ending-slot")
|
||||||
|
.value_name("SLOT")
|
||||||
|
.takes_value(true)
|
||||||
|
.help("The last slot to iterate to");
|
||||||
let no_snapshot_arg = Arg::with_name("no_snapshot")
|
let no_snapshot_arg = Arg::with_name("no_snapshot")
|
||||||
.long("no-snapshot")
|
.long("no-snapshot")
|
||||||
.takes_value(false)
|
.takes_value(false)
|
||||||
@ -926,13 +932,7 @@ fn main() {
|
|||||||
SubCommand::with_name("parse_full_frozen")
|
SubCommand::with_name("parse_full_frozen")
|
||||||
.about("Parses log for information about critical events about ancestors of the given `ending_slot`")
|
.about("Parses log for information about critical events about ancestors of the given `ending_slot`")
|
||||||
.arg(&starting_slot_arg)
|
.arg(&starting_slot_arg)
|
||||||
.arg(
|
.arg(&ending_slot_arg)
|
||||||
Arg::with_name("ending_slot")
|
|
||||||
.long("ending-slot")
|
|
||||||
.value_name("SLOT")
|
|
||||||
.takes_value(true)
|
|
||||||
.help("The last slot to iterate to"),
|
|
||||||
)
|
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("log_path")
|
Arg::with_name("log_path")
|
||||||
.long("log-path")
|
.long("log-path")
|
||||||
@ -974,6 +974,12 @@ fn main() {
|
|||||||
.arg(&hard_forks_arg)
|
.arg(&hard_forks_arg)
|
||||||
.arg(&max_genesis_archive_unpacked_size_arg)
|
.arg(&max_genesis_archive_unpacked_size_arg)
|
||||||
)
|
)
|
||||||
|
.subcommand(
|
||||||
|
SubCommand::with_name("shred-meta")
|
||||||
|
.about("Prints raw shred metadata")
|
||||||
|
.arg(&starting_slot_arg)
|
||||||
|
.arg(&ending_slot_arg)
|
||||||
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("bank-hash")
|
SubCommand::with_name("bank-hash")
|
||||||
.about("Prints the hash of the working bank after reading the ledger")
|
.about("Prints the hash of the working bank after reading the ledger")
|
||||||
@ -1436,6 +1442,46 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
("shred-meta", Some(arg_matches)) => {
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct ShredMeta<'a> {
|
||||||
|
slot: Slot,
|
||||||
|
full_slot: bool,
|
||||||
|
shred_index: usize,
|
||||||
|
data: bool,
|
||||||
|
code: bool,
|
||||||
|
last_in_slot: bool,
|
||||||
|
data_complete: bool,
|
||||||
|
shred: &'a Shred,
|
||||||
|
};
|
||||||
|
let starting_slot = value_t_or_exit!(arg_matches, "starting_slot", Slot);
|
||||||
|
let ending_slot = value_t!(arg_matches, "ending_slot", Slot).unwrap_or(Slot::MAX);
|
||||||
|
let ledger = open_blockstore(&ledger_path, AccessType::TryPrimaryThenSecondary, None);
|
||||||
|
for (slot, _meta) in ledger
|
||||||
|
.slot_meta_iterator(starting_slot)
|
||||||
|
.unwrap()
|
||||||
|
.take_while(|(slot, _)| *slot <= ending_slot)
|
||||||
|
{
|
||||||
|
let full_slot = ledger.is_full(slot);
|
||||||
|
if let Ok(shreds) = ledger.get_data_shreds_for_slot(slot, 0) {
|
||||||
|
for (shred_index, shred) in shreds.iter().enumerate() {
|
||||||
|
println!(
|
||||||
|
"{:#?}",
|
||||||
|
ShredMeta {
|
||||||
|
slot,
|
||||||
|
full_slot,
|
||||||
|
shred_index,
|
||||||
|
data: shred.is_data(),
|
||||||
|
code: shred.is_code(),
|
||||||
|
data_complete: shred.data_complete(),
|
||||||
|
last_in_slot: shred.last_in_slot(),
|
||||||
|
shred,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
("bank-hash", Some(arg_matches)) => {
|
("bank-hash", Some(arg_matches)) => {
|
||||||
let process_options = ProcessOptions {
|
let process_options = ProcessOptions {
|
||||||
dev_halt_at_slot: Some(0),
|
dev_halt_at_slot: Some(0),
|
||||||
|
Reference in New Issue
Block a user