add 'ticks-per-slot' to 'solana-test-validator' (#22701)
* add 'ticks-per-slot' to 'solana-test-validator'
* add input parser validator for "ticks-per-slot" argument
* fix fmt
(cherry picked from commit 0562426661
)
This commit is contained in:
committed by
Michael Vines
parent
93b44d8a4c
commit
28fc733894
@ -97,6 +97,7 @@ pub struct TestValidatorGenesis {
|
||||
no_bpf_jit: bool,
|
||||
accounts: HashMap<Pubkey, AccountSharedData>,
|
||||
programs: Vec<ProgramInfo>,
|
||||
ticks_per_slot: Option<u64>,
|
||||
epoch_schedule: Option<EpochSchedule>,
|
||||
node_config: TestValidatorNodeConfig,
|
||||
pub validator_exit: Arc<RwLock<Exit>>,
|
||||
@ -129,6 +130,11 @@ impl TestValidatorGenesis {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn ticks_per_slot(&mut self, ticks_per_slot: u64) -> &mut Self {
|
||||
self.ticks_per_slot = Some(ticks_per_slot);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn epoch_schedule(&mut self, epoch_schedule: EpochSchedule) -> &mut Self {
|
||||
self.epoch_schedule = Some(epoch_schedule);
|
||||
self
|
||||
@ -471,6 +477,10 @@ impl TestValidator {
|
||||
.epoch_schedule
|
||||
.unwrap_or_else(EpochSchedule::without_warmup);
|
||||
|
||||
if let Some(ticks_per_slot) = config.ticks_per_slot {
|
||||
genesis_config.ticks_per_slot = ticks_per_slot;
|
||||
}
|
||||
|
||||
let ledger_path = match &config.ledger_path {
|
||||
None => create_new_tmp_ledger!(&genesis_config).0,
|
||||
Some(ledger_path) => {
|
||||
|
@ -4,7 +4,7 @@ use {
|
||||
solana_clap_utils::{
|
||||
input_parsers::{pubkey_of, pubkeys_of, value_of},
|
||||
input_validators::{
|
||||
is_pubkey, is_pubkey_or_keypair, is_slot, is_url_or_moniker,
|
||||
is_parsable, is_pubkey, is_pubkey_or_keypair, is_slot, is_url_or_moniker,
|
||||
normalize_to_url_if_moniker,
|
||||
},
|
||||
},
|
||||
@ -192,6 +192,14 @@ fn main() {
|
||||
.takes_value(false)
|
||||
.help("Disable the just-in-time compiler and instead use the interpreter for BPF. Windows always disables JIT."),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("ticks_per_slot")
|
||||
.long("ticks-per-slot")
|
||||
.value_name("TICKS")
|
||||
.validator(is_parsable::<u64>)
|
||||
.takes_value(true)
|
||||
.help("The number of ticks in a slot"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("slots_per_epoch")
|
||||
.long("slots-per-epoch")
|
||||
@ -403,6 +411,7 @@ fn main() {
|
||||
let rpc_port = value_t_or_exit!(matches, "rpc_port", u16);
|
||||
let enable_vote_subscription = matches.is_present("rpc_pubsub_enable_vote_subscription");
|
||||
let faucet_port = value_t_or_exit!(matches, "faucet_port", u16);
|
||||
let ticks_per_slot = value_t!(matches, "ticks_per_slot", u64).ok();
|
||||
let slots_per_epoch = value_t!(matches, "slots_per_epoch", Slot).ok();
|
||||
let gossip_host = matches.value_of("gossip_host").map(|gossip_host| {
|
||||
solana_net_utils::parse_host(gossip_host).unwrap_or_else(|err| {
|
||||
@ -545,6 +554,7 @@ fn main() {
|
||||
("clone_account", "--clone"),
|
||||
("account", "--account"),
|
||||
("mint_address", "--mint"),
|
||||
("ticks_per_slot", "--ticks-per-slot"),
|
||||
("slots_per_epoch", "--slots-per-epoch"),
|
||||
("faucet_sol", "--faucet-sol"),
|
||||
] {
|
||||
@ -630,6 +640,10 @@ fn main() {
|
||||
genesis.warp_slot(warp_slot);
|
||||
}
|
||||
|
||||
if let Some(ticks_per_slot) = ticks_per_slot {
|
||||
genesis.ticks_per_slot(ticks_per_slot);
|
||||
}
|
||||
|
||||
if let Some(slots_per_epoch) = slots_per_epoch {
|
||||
genesis.epoch_schedule(EpochSchedule::custom(
|
||||
slots_per_epoch,
|
||||
|
Reference in New Issue
Block a user