Add --remove-account option to create-snapshot command (#13971)

(cherry picked from commit c59cb28bbf)

Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
mergify[bot]
2020-12-05 18:48:00 +00:00
committed by GitHub
parent add6989289
commit c1047b48fe

View File

@ -9,7 +9,9 @@ use serde::Serialize;
use serde_json::json; use serde_json::json;
use solana_clap_utils::{ use solana_clap_utils::{
input_parsers::{cluster_type_of, pubkey_of, pubkeys_of}, 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::entry::Entry;
use solana_ledger::{ use solana_ledger::{
@ -1139,6 +1141,16 @@ fn main() {
.takes_value(false) .takes_value(false)
.help("Re-calculate the bank hash and overwrite the original bank hash."), .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(
Arg::with_name("remove_stake_accounts") Arg::with_name("remove_stake_accounts")
.required(false) .required(false)
@ -1678,6 +1690,8 @@ fn main() {
exit(1); exit(1);
} }
let bootstrap_validator_pubkeys = pubkeys_of(&arg_matches, "bootstrap_validator"); 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 = let snapshot_version =
arg_matches 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 { if let Some(bootstrap_validator_pubkeys) = bootstrap_validator_pubkeys {
rehash = true; rehash = true;