Add --slots-per-epoch argument
This commit is contained in:
parent
c06ff47a90
commit
04c99cf7ea
@ -16,6 +16,7 @@ use {
|
|||||||
account::{Account, AccountSharedData},
|
account::{Account, AccountSharedData},
|
||||||
clock::{Slot, DEFAULT_MS_PER_SLOT},
|
clock::{Slot, DEFAULT_MS_PER_SLOT},
|
||||||
commitment_config::CommitmentConfig,
|
commitment_config::CommitmentConfig,
|
||||||
|
epoch_schedule::EpochSchedule,
|
||||||
fee_calculator::{FeeCalculator, FeeRateGovernor},
|
fee_calculator::{FeeCalculator, FeeRateGovernor},
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
native_token::sol_to_lamports,
|
native_token::sol_to_lamports,
|
||||||
@ -52,6 +53,7 @@ pub struct TestValidatorGenesis {
|
|||||||
no_bpf_jit: bool,
|
no_bpf_jit: bool,
|
||||||
accounts: HashMap<Pubkey, AccountSharedData>,
|
accounts: HashMap<Pubkey, AccountSharedData>,
|
||||||
programs: Vec<ProgramInfo>,
|
programs: Vec<ProgramInfo>,
|
||||||
|
epoch_schedule: Option<EpochSchedule>,
|
||||||
pub validator_exit: Arc<RwLock<ValidatorExit>>,
|
pub validator_exit: Arc<RwLock<ValidatorExit>>,
|
||||||
pub start_progress: Arc<RwLock<ValidatorStartProgress>>,
|
pub start_progress: Arc<RwLock<ValidatorStartProgress>>,
|
||||||
}
|
}
|
||||||
@ -72,6 +74,11 @@ impl TestValidatorGenesis {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn epoch_schedule(&mut self, epoch_schedule: EpochSchedule) -> &mut Self {
|
||||||
|
self.epoch_schedule = Some(epoch_schedule);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
pub fn rent(&mut self, rent: Rent) -> &mut Self {
|
pub fn rent(&mut self, rent: Rent) -> &mut Self {
|
||||||
self.rent = rent;
|
self.rent = rent;
|
||||||
self
|
self
|
||||||
@ -313,7 +320,9 @@ impl TestValidator {
|
|||||||
solana_sdk::genesis_config::ClusterType::Development,
|
solana_sdk::genesis_config::ClusterType::Development,
|
||||||
accounts.into_iter().collect(),
|
accounts.into_iter().collect(),
|
||||||
);
|
);
|
||||||
genesis_config.epoch_schedule = solana_sdk::epoch_schedule::EpochSchedule::without_warmup();
|
genesis_config.epoch_schedule = config
|
||||||
|
.epoch_schedule
|
||||||
|
.unwrap_or_else(EpochSchedule::without_warmup);
|
||||||
|
|
||||||
let ledger_path = match &config.ledger_path {
|
let ledger_path = match &config.ledger_path {
|
||||||
None => create_new_tmp_ledger!(&genesis_config).0,
|
None => create_new_tmp_ledger!(&genesis_config).0,
|
||||||
|
@ -14,6 +14,7 @@ use {
|
|||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
account::AccountSharedData,
|
account::AccountSharedData,
|
||||||
clock::Slot,
|
clock::Slot,
|
||||||
|
epoch_schedule::EpochSchedule,
|
||||||
native_token::sol_to_lamports,
|
native_token::sol_to_lamports,
|
||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
rpc_port,
|
rpc_port,
|
||||||
@ -146,6 +147,17 @@ fn main() {
|
|||||||
.takes_value(false)
|
.takes_value(false)
|
||||||
.help("Disable the just-in-time compiler and instead use the interpreter for BPF"),
|
.help("Disable the just-in-time compiler and instead use the interpreter for BPF"),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("slots_per_epoch")
|
||||||
|
.long("slots-per-epoch")
|
||||||
|
.value_name("SLOTS")
|
||||||
|
.validator(is_slot)
|
||||||
|
.takes_value(true)
|
||||||
|
.help(
|
||||||
|
"Override the number of slots in an epoch. \
|
||||||
|
If the ledger already exists then this parameter is silently ignored",
|
||||||
|
),
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("clone_account")
|
Arg::with_name("clone_account")
|
||||||
.long("clone")
|
.long("clone")
|
||||||
@ -205,6 +217,7 @@ fn main() {
|
|||||||
Output::Dashboard
|
Output::Dashboard
|
||||||
};
|
};
|
||||||
let rpc_port = value_t_or_exit!(matches, "rpc_port", u16);
|
let rpc_port = value_t_or_exit!(matches, "rpc_port", u16);
|
||||||
|
let slots_per_epoch = value_t!(matches, "slots_per_epoch", Slot).ok();
|
||||||
|
|
||||||
let faucet_addr = Some(SocketAddr::new(
|
let faucet_addr = Some(SocketAddr::new(
|
||||||
IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)),
|
IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)),
|
||||||
@ -359,6 +372,7 @@ fn main() {
|
|||||||
("bpf_program", "--bpf-program"),
|
("bpf_program", "--bpf-program"),
|
||||||
("clone_account", "--clone"),
|
("clone_account", "--clone"),
|
||||||
("mint_address", "--mint"),
|
("mint_address", "--mint"),
|
||||||
|
("slots_per_epoch", "--slots-per-epoch"),
|
||||||
] {
|
] {
|
||||||
if matches.is_present(name) {
|
if matches.is_present(name) {
|
||||||
println!("{} argument ignored, ledger already exists", long);
|
println!("{} argument ignored, ledger already exists", long);
|
||||||
@ -422,6 +436,14 @@ fn main() {
|
|||||||
genesis.warp_slot(warp_slot);
|
genesis.warp_slot(warp_slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(slots_per_epoch) = slots_per_epoch {
|
||||||
|
genesis.epoch_schedule(EpochSchedule::custom(
|
||||||
|
slots_per_epoch,
|
||||||
|
slots_per_epoch,
|
||||||
|
/* enable_warmup_epochs = */ false,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
match genesis.start_with_mint_address(mint_address) {
|
match genesis.start_with_mint_address(mint_address) {
|
||||||
Ok(test_validator) => {
|
Ok(test_validator) => {
|
||||||
if let Some(dashboard) = dashboard {
|
if let Some(dashboard) = dashboard {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user