From f17b80236fbcf95521c3c736472c12b2d77fb37a Mon Sep 17 00:00:00 2001 From: Trent Nelson Date: Tue, 4 May 2021 01:22:18 -0600 Subject: [PATCH] test-validator: Plumb --limit-ledger-size --- core/src/test_validator.rs | 5 ++--- validator/src/bin/solana-test-validator.rs | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/core/src/test_validator.rs b/core/src/test_validator.rs index ae217f0b35..c3d839b084 100644 --- a/core/src/test_validator.rs +++ b/core/src/test_validator.rs @@ -82,6 +82,7 @@ pub struct TestValidatorGenesis { pub validator_exit: Arc>, pub start_progress: Arc>, pub authorized_voter_keypairs: Arc>>>, + pub max_ledger_shreds: Option, } impl TestValidatorGenesis { @@ -497,9 +498,7 @@ impl TestValidator { bpf_jit: !config.no_bpf_jit, validator_exit: config.validator_exit.clone(), rocksdb_compaction_interval: Some(100), // Compact every 100 slots - max_ledger_shreds: Some(10_000), /* 10,000 was derived empirically by watching the size - of the rocksdb/ directory self-limit itself to the - 40MB-150MB range when running `solana-test-validator` */ + max_ledger_shreds: config.max_ledger_shreds, no_wait_for_vote_to_start_leader: true, ..ValidatorConfig::default() }; diff --git a/validator/src/bin/solana-test-validator.rs b/validator/src/bin/solana-test-validator.rs index 9334befbf2..f3ff62885a 100644 --- a/validator/src/bin/solana-test-validator.rs +++ b/validator/src/bin/solana-test-validator.rs @@ -2,7 +2,7 @@ use { clap::{value_t, value_t_or_exit, App, Arg}, fd_lock::FdLock, solana_clap_utils::{ - input_parsers::{pubkey_of, pubkeys_of}, + input_parsers::{pubkey_of, pubkeys_of, value_of}, input_validators::{ is_pubkey, is_pubkey_or_keypair, is_slot, is_url_or_moniker, normalize_to_url_if_moniker, @@ -35,6 +35,12 @@ use { }, }; +/* 10,000 was derived empirically by watching the size + * of the rocksdb/ directory self-limit itself to the + * 40MB-150MB range when running `solana-test-validator` + */ +const DEFAULT_MAX_LEDGER_SHREDS: u64 = 10_000; + #[derive(PartialEq)] enum Output { None, @@ -45,6 +51,7 @@ enum Output { fn main() { let default_rpc_port = rpc_port::DEFAULT_RPC_PORT.to_string(); let default_faucet_port = FAUCET_PORT.to_string(); + let default_limit_ledger_size = DEFAULT_MAX_LEDGER_SHREDS.to_string(); let matches = App::new("solana-test-validator") .about("Test Validator") @@ -248,6 +255,14 @@ fn main() { referenced by the --url argument will be used", ), ) + .arg( + Arg::with_name("limit_ledger_size") + .long("limit-ledger-size") + .value_name("SHRED_COUNT") + .takes_value(true) + .default_value(default_limit_ledger_size.as_str()) + .help("Keep this amount of shreds in root slots."), + ) .get_matches(); let cli_config = if let Some(config_file) = matches.value_of("config_file") { @@ -460,6 +475,7 @@ fn main() { } let mut genesis = TestValidatorGenesis::default(); + genesis.max_ledger_shreds = value_of(&matches, "limit_ledger_size"); admin_rpc_service::run( &ledger_path,