Skip to content

Commit

Permalink
ledger-tool: Relax ledger requirements for program subcommand (solana…
Browse files Browse the repository at this point in the history
…-labs#32770)

Several of the program command subcommands do not require a ledger as
they act solely on the program object. So, defer checking the ledger
path until we know we need to load. Additionally, remove genesis arg
from these commands that do not load a genesis.bin
  • Loading branch information
steviez authored Aug 9, 2023
1 parent 31b6b64 commit b97c451
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2172,6 +2172,8 @@ fn main() {

if let ("bigtable", Some(arg_matches)) = matches.subcommand() {
bigtable_process_command(&ledger_path, arg_matches)
} else if let ("program", Some(arg_matches)) = matches.subcommand() {
program(&ledger_path, arg_matches)
} else {
let ledger_path = canonicalize_ledger_path(&ledger_path);

Expand Down Expand Up @@ -4198,9 +4200,6 @@ fn main() {
eprintln!("{err}");
}
}
("program", Some(arg_matches)) => {
program(&ledger_path, arg_matches);
}
("", _) => {
eprintln!("{}", matches.usage());
exit(1);
Expand Down
7 changes: 3 additions & 4 deletions ledger-tool/src/program.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use {
crate::{args::*, ledger_utils::*},
crate::{args::*, canonicalize_ledger_path, ledger_utils::*},
clap::{value_t, App, AppSettings, Arg, ArgMatches, SubCommand},
log::*,
serde::{Deserialize, Serialize},
Expand Down Expand Up @@ -162,13 +162,11 @@ impl ProgramSubCommand for App<'_, '_> {
.subcommand(
SubCommand::with_name("cfg")
.about("generates Control Flow Graph of the program.")
.arg(&max_genesis_arg)
.arg(&program_arg)
)
.subcommand(
SubCommand::with_name("disassemble")
.about("dumps disassembled code of the program.")
.arg(&max_genesis_arg)
.arg(&program_arg)
)
.subcommand(
Expand Down Expand Up @@ -435,7 +433,8 @@ pub fn program(ledger_path: &Path, matches: &ArgMatches<'_>) {
("run", Some(arg_matches)) => arg_matches,
_ => unreachable!(),
};
let bank = load_blockstore(ledger_path, matches);
let ledger_path = canonicalize_ledger_path(ledger_path);
let bank = load_blockstore(&ledger_path, matches);
let loader_id = bpf_loader_upgradeable::id();
let mut transaction_accounts = Vec::new();
let mut instruction_accounts = Vec::new();
Expand Down

0 comments on commit b97c451

Please sign in to comment.