Pass around --max-genesis-archive-unpacked-size (#9161)

automerge
This commit is contained in:
Ryo Onodera
2020-04-30 10:53:34 +09:00
committed by GitHub
parent a0514eb2ae
commit a91236012d
12 changed files with 208 additions and 53 deletions

View File

@ -23,7 +23,7 @@ use solana_core::{
use solana_download_utils::{download_genesis_if_missing, download_snapshot};
use solana_ledger::{
bank_forks::{CompressionType, SnapshotConfig},
hardened_unpack::unpack_genesis_archive,
hardened_unpack::{unpack_genesis_archive, MAX_GENESIS_ARCHIVE_UNPACKED_SIZE},
};
use solana_perf::recycler::enable_recycler_warming;
use solana_sdk::{
@ -366,11 +366,17 @@ fn download_then_check_genesis_hash(
rpc_addr: &SocketAddr,
ledger_path: &std::path::Path,
expected_genesis_hash: Option<Hash>,
max_genesis_archive_unpacked_size: u64,
) -> Result<Hash, String> {
let genesis_package = ledger_path.join("genesis.tar.bz2");
let genesis_config =
if let Ok(tmp_genesis_package) = download_genesis_if_missing(rpc_addr, &genesis_package) {
unpack_genesis_archive(&tmp_genesis_package, &ledger_path)?;
unpack_genesis_archive(
&tmp_genesis_package,
&ledger_path,
max_genesis_archive_unpacked_size,
)
.map_err(|err| format!("Failed to unpack downloaded genesis config: {}", err))?;
let downloaded_genesis = GenesisConfig::load(&ledger_path)
.map_err(|err| format!("Failed to load downloaded genesis config: {}", err))?;
@ -463,6 +469,7 @@ pub fn main() {
let default_dynamic_port_range =
&format!("{}-{}", VALIDATOR_PORT_RANGE.0, VALIDATOR_PORT_RANGE.1);
let default_limit_ledger_size = &DEFAULT_MAX_LEDGER_SHREDS.to_string();
let default_genesis_archive_unpacked_size = &MAX_GENESIS_ARCHIVE_UNPACKED_SIZE.to_string();
let matches = App::new(crate_name!()).about(crate_description!())
.version(solana_clap_utils::version!())
@ -636,14 +643,14 @@ pub fn main() {
.help("Comma separated persistent accounts location"),
)
.arg(
clap::Arg::with_name("gossip_port")
Arg::with_name("gossip_port")
.long("gossip-port")
.value_name("PORT")
.takes_value(true)
.help("Gossip port number for the node"),
)
.arg(
clap::Arg::with_name("gossip_host")
Arg::with_name("gossip_host")
.long("gossip-host")
.value_name("HOST")
.takes_value(true)
@ -652,7 +659,7 @@ pub fn main() {
.help("IP address for the node to advertise in gossip when --entrypoint is not provided [default: 127.0.0.1]"),
)
.arg(
clap::Arg::with_name("dynamic_port_range")
Arg::with_name("dynamic_port_range")
.long("dynamic-port-range")
.value_name("MIN_PORT-MAX_PORT")
.takes_value(true)
@ -661,7 +668,7 @@ pub fn main() {
.help("Range to use for dynamically assigned ports"),
)
.arg(
clap::Arg::with_name("snapshot_interval_slots")
Arg::with_name("snapshot_interval_slots")
.long("snapshot-interval-slots")
.value_name("SNAPSHOT_INTERVAL_SLOTS")
.takes_value(true)
@ -669,7 +676,7 @@ pub fn main() {
.help("Number of slots between generating snapshots, 0 to disable snapshots"),
)
.arg(
clap::Arg::with_name("accounts_hash_interval_slots")
Arg::with_name("accounts_hash_interval_slots")
.long("accounts-hash-slots")
.value_name("ACCOUNTS_HASH_INTERVAL_SLOTS")
.takes_value(true)
@ -677,7 +684,7 @@ pub fn main() {
.help("Number of slots between generating accounts hash."),
)
.arg(
clap::Arg::with_name("limit_ledger_size")
Arg::with_name("limit_ledger_size")
.long("limit-ledger-size")
.value_name("SHRED_COUNT")
.takes_value(true)
@ -687,13 +694,13 @@ pub fn main() {
.help("Keep this amount of shreds in root slots."),
)
.arg(
clap::Arg::with_name("skip_poh_verify")
Arg::with_name("skip_poh_verify")
.long("skip-poh-verify")
.takes_value(false)
.help("Skip ledger verification at node bootup"),
)
.arg(
clap::Arg::with_name("cuda")
Arg::with_name("cuda")
.long("cuda")
.takes_value(false)
.help("Use CUDA"),
@ -762,7 +769,7 @@ pub fn main() {
.help("Disable manual compaction of the ledger database. May increase storage requirements.")
)
.arg(
clap::Arg::with_name("bind_address")
Arg::with_name("bind_address")
.long("bind-address")
.value_name("HOST")
.takes_value(true)
@ -771,7 +778,7 @@ pub fn main() {
.help("IP address to bind the validator ports"),
)
.arg(
clap::Arg::with_name("rpc_bind_address")
Arg::with_name("rpc_bind_address")
.long("rpc-bind-address")
.value_name("HOST")
.takes_value(true)
@ -779,14 +786,14 @@ pub fn main() {
.help("IP address to bind the RPC port [default: use --bind-address]"),
)
.arg(
clap::Arg::with_name("halt_on_trusted_validators_accounts_hash_mismatch")
Arg::with_name("halt_on_trusted_validators_accounts_hash_mismatch")
.long("halt-on-trusted-validators-accounts-hash-mismatch")
.requires("trusted_validators")
.takes_value(false)
.help("Abort the validator if a bank hash mismatch is detected within trusted validator set"),
)
.arg(
clap::Arg::with_name("frozen_accounts")
Arg::with_name("frozen_accounts")
.long("frozen-account")
.validator(is_pubkey)
.value_name("PUBKEY")
@ -804,6 +811,16 @@ pub fn main() {
.takes_value(true)
.help("Type of snapshot compression to use."),
)
.arg(
Arg::with_name("max_genesis_archive_unpacked_size")
.long("max-genesis-archive-unpacked-size")
.value_name("NUMBER")
.takes_value(true)
.default_value(&default_genesis_archive_unpacked_size)
.help(
"maximum total uncompressed file size of downloaded genesis archive",
),
)
.get_matches();
let identity_keypair = Arc::new(keypair_of(&matches, "identity").unwrap_or_else(Keypair::new));
@ -1058,6 +1075,8 @@ pub fn main() {
)
}),
);
let max_genesis_archive_unpacked_size =
value_t_or_exit!(matches, "max_genesis_archive_unpacked_size", u64);
let cluster_entrypoint = entrypoint_addr
.as_ref()
@ -1141,6 +1160,7 @@ pub fn main() {
&rpc_contact_info.rpc,
&ledger_path,
validator_config.expected_genesis_hash,
max_genesis_archive_unpacked_size,
);
if let Ok(genesis_hash) = genesis_hash {