modify-genesis now writes elsewhere and produces a full genesis.tar.bz2

This commit is contained in:
Michael Vines 2020-08-28 18:16:01 -07:00
parent 42620e7f39
commit 8df263340f
2 changed files with 26 additions and 13 deletions

View File

@ -13,7 +13,7 @@ use solana_ledger::entry::Entry;
use solana_ledger::{
ancestor_iterator::AncestorIterator,
bank_forks_utils,
blockstore::{Blockstore, PurgeType},
blockstore::{create_new_ledger, Blockstore, PurgeType},
blockstore_db::{self, AccessType, BlockstoreRecoveryMode, Column, Database},
blockstore_processor::ProcessOptions,
rooted_slot_iterator::RootedSlotIterator,
@ -957,6 +957,13 @@ fn main() {
"Selects the features that will be enabled for the cluster"
),
)
.arg(
Arg::with_name("output_directory")
.index(1)
.value_name("DIR")
.takes_value(true)
.help("Output directory for the modified genesis config"),
)
)
.subcommand(
SubCommand::with_name("shred-version")
@ -1319,6 +1326,7 @@ fn main() {
}
("modify-genesis", Some(arg_matches)) => {
let mut genesis_config = open_genesis_config_by(&ledger_path, arg_matches);
let output_directory = PathBuf::from(arg_matches.value_of("output_directory").unwrap());
if let Some(operating_mode) = arg_matches.value_of("operating_mode") {
genesis_config.operating_mode = match operating_mode {
@ -1336,11 +1344,19 @@ fn main() {
_ => Some(value_t_or_exit!(arg_matches, "hashes_per_tick", u64)),
}
}
genesis_config.write(&ledger_path).unwrap_or_else(|err| {
create_new_ledger(
&output_directory,
&genesis_config,
solana_runtime::hardened_unpack::MAX_GENESIS_ARCHIVE_UNPACKED_SIZE,
AccessType::PrimaryOnly,
)
.unwrap_or_else(|err| {
eprintln!("Failed to write genesis config: {:?}", err);
exit(1);
});
println!("{}", open_genesis_config_by(&ledger_path, arg_matches));
println!("{}", open_genesis_config_by(&output_directory, arg_matches));
}
("shred-version", Some(arg_matches)) => {
let process_options = ProcessOptions {

View File

@ -4,6 +4,7 @@ here=$(dirname "$0")
# shellcheck source=multinode-demo/common.sh
source "$here"/common.sh
set -e
rm -rf "$SOLANA_CONFIG_DIR"/latest-mainnet-beta-snapshot
mkdir -p "$SOLANA_CONFIG_DIR"/latest-mainnet-beta-snapshot
@ -47,21 +48,17 @@ fi
$solana_keygen new --no-passphrase -so "$SOLANA_CONFIG_DIR"/bootstrap-validator/vote-account.json
$solana_keygen new --no-passphrase -so "$SOLANA_CONFIG_DIR"/bootstrap-validator/stake-account.json
cp "$SOLANA_CONFIG_DIR"/latest-mainnet-beta-snapshot/genesis.tar.bz2 \
"$SOLANA_CONFIG_DIR"/bootstrap-validator
$solana_ledger_tool modify-genesis \
--ledger "$SOLANA_CONFIG_DIR"/bootstrap-validator \
--hashes-per-tick sleep \
#--operating-mode preview \
$solana_ledger_tool create-snapshot \
--hashes-per-tick sleep \
--ledger "$SOLANA_CONFIG_DIR"/latest-mainnet-beta-snapshot \
--faucet-pubkey "$SOLANA_CONFIG_DIR"/faucet.json \
--faucet-lamports 500000000000000000 \
--bootstrap-validator "$SOLANA_CONFIG_DIR"/bootstrap-validator/identity.json \
"$SOLANA_CONFIG_DIR"/bootstrap-validator/vote-account.json \
"$SOLANA_CONFIG_DIR"/bootstrap-validator/stake-account.json \
--hashes-per-tick sleep \
"$snapshot_slot" "$SOLANA_CONFIG_DIR"/bootstrap-validator
$solana_ledger_tool modify-genesis \
--ledger "$SOLANA_CONFIG_DIR"/latest-mainnet-beta-snapshot \
--hashes-per-tick sleep \
"$SOLANA_CONFIG_DIR"/bootstrap-validator