From c1047b48fea92a433003135df7fa07de6825eac7 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 5 Dec 2020 18:48:00 +0000 Subject: [PATCH] Add --remove-account option to create-snapshot command (#13971) (cherry picked from commit c59cb28bbf89c94898a33ecf4e31b1f5cfe0ee0b) Co-authored-by: Michael Vines --- ledger-tool/src/main.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index 699539543f..0899714fbc 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -9,7 +9,9 @@ use serde::Serialize; use serde_json::json; use solana_clap_utils::{ input_parsers::{cluster_type_of, pubkey_of, pubkeys_of}, - input_validators::{is_parsable, is_pubkey_or_keypair, is_slot, is_valid_percentage}, + input_validators::{ + is_parsable, is_pubkey, is_pubkey_or_keypair, is_slot, is_valid_percentage, + }, }; use solana_ledger::entry::Entry; use solana_ledger::{ @@ -1139,6 +1141,16 @@ fn main() { .takes_value(false) .help("Re-calculate the bank hash and overwrite the original bank hash."), ) + .arg( + Arg::with_name("accounts_to_remove") + .required(false) + .long("remove-account") + .takes_value(true) + .value_name("PUBKEY") + .validator(is_pubkey) + .multiple(true) + .help("List if accounts to remove while creating the snapshot"), + ) .arg( Arg::with_name("remove_stake_accounts") .required(false) @@ -1678,6 +1690,8 @@ fn main() { exit(1); } let bootstrap_validator_pubkeys = pubkeys_of(&arg_matches, "bootstrap_validator"); + let accounts_to_remove = + pubkeys_of(&arg_matches, "accounts_to_remove").unwrap_or_default(); let snapshot_version = arg_matches @@ -1749,6 +1763,14 @@ fn main() { } } + for address in accounts_to_remove { + if let Some(mut account) = bank.get_account(&address) { + rehash = true; + account.lamports = 0; + bank.store_account(&address, &account); + } + } + if let Some(bootstrap_validator_pubkeys) = bootstrap_validator_pubkeys { rehash = true;