test-validator: Plumb --limit-ledger-size

This commit is contained in:
Trent Nelson 2021-05-04 01:22:18 -06:00 committed by mergify[bot]
parent bc7e741514
commit f17b80236f
2 changed files with 19 additions and 4 deletions

View File

@ -82,6 +82,7 @@ pub struct TestValidatorGenesis {
pub validator_exit: Arc<RwLock<ValidatorExit>>,
pub start_progress: Arc<RwLock<ValidatorStartProgress>>,
pub authorized_voter_keypairs: Arc<RwLock<Vec<Arc<Keypair>>>>,
pub max_ledger_shreds: Option<u64>,
}
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()
};

View File

@ -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,