Schedule node for consecutive slots as leader (#3353)
* Also tweak epoch and slot duration * new test for leader schedule
This commit is contained in:
@@ -5,7 +5,6 @@ use solana::fullnode::FullnodeConfig;
|
||||
use solana::gossip_service::discover;
|
||||
use solana::local_cluster::LocalCluster;
|
||||
use solana::poh_service::PohServiceConfig;
|
||||
use solana_sdk::timing::{DEFAULT_SLOTS_PER_EPOCH, DEFAULT_TICKS_PER_SLOT};
|
||||
use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
|
||||
@@ -98,19 +97,27 @@ fn test_leader_failure_3() {
|
||||
fn test_two_unbalanced_stakes() {
|
||||
let mut fullnode_config = FullnodeConfig::default();
|
||||
let num_ticks_per_second = 100;
|
||||
let num_ticks_per_slot = 160;
|
||||
let num_slots_per_epoch = 16;
|
||||
fullnode_config.tick_config =
|
||||
PohServiceConfig::Sleep(Duration::from_millis(100 / num_ticks_per_second));
|
||||
fullnode_config.rpc_config.enable_fullnode_exit = true;
|
||||
let mut cluster = LocalCluster::new_with_config(&[999_990, 3], 1_000_000, &fullnode_config);
|
||||
let mut cluster = LocalCluster::new_with_tick_config(
|
||||
&[999_990, 3],
|
||||
1_000_000,
|
||||
&fullnode_config,
|
||||
num_ticks_per_slot,
|
||||
num_slots_per_epoch,
|
||||
);
|
||||
let num_epochs_to_sleep = 10;
|
||||
let num_ticks_to_sleep = num_epochs_to_sleep * DEFAULT_TICKS_PER_SLOT * DEFAULT_SLOTS_PER_EPOCH;
|
||||
let num_ticks_to_sleep = num_epochs_to_sleep * num_ticks_per_slot * num_slots_per_epoch;
|
||||
sleep(Duration::from_millis(
|
||||
num_ticks_to_sleep / num_ticks_per_second * 100,
|
||||
num_ticks_to_sleep / num_ticks_per_second as u64 * 100,
|
||||
));
|
||||
|
||||
cluster.close_preserve_ledgers();
|
||||
let leader_ledger = cluster.ledger_paths[1].clone();
|
||||
cluster_tests::verify_ledger_ticks(&leader_ledger, DEFAULT_TICKS_PER_SLOT as usize);
|
||||
cluster_tests::verify_ledger_ticks(&leader_ledger, num_ticks_per_slot as usize);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@@ -13,6 +13,8 @@ use solana::replicator::Replicator;
|
||||
use solana::storage_stage::STORAGE_ROTATE_TEST_COUNT;
|
||||
use solana_sdk::genesis_block::GenesisBlock;
|
||||
use solana_sdk::signature::{Keypair, KeypairUtil};
|
||||
use solana_sdk::timing::DEFAULT_SLOTS_PER_EPOCH;
|
||||
use solana_sdk::timing::DEFAULT_TICKS_PER_SLOT;
|
||||
use std::fs::remove_dir_all;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
@@ -25,8 +27,14 @@ fn test_replicator_startup_basic() {
|
||||
const NUM_NODES: usize = 2;
|
||||
let mut fullnode_config = FullnodeConfig::default();
|
||||
fullnode_config.storage_rotate_count = STORAGE_ROTATE_TEST_COUNT;
|
||||
let _cluster =
|
||||
LocalCluster::new_with_config_replicators(&[100; NUM_NODES], 10_000, &fullnode_config, 1);
|
||||
let _cluster = LocalCluster::new_with_config_replicators(
|
||||
&[100; NUM_NODES],
|
||||
10_000,
|
||||
&fullnode_config,
|
||||
1,
|
||||
DEFAULT_TICKS_PER_SLOT,
|
||||
DEFAULT_SLOTS_PER_EPOCH,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@@ -75,8 +75,10 @@ fn test_replay() {
|
||||
let total_balance = 10_000;
|
||||
let leader_balance = 100;
|
||||
let starting_mint_balance = total_balance - leader_balance;
|
||||
let (genesis_block, mint_keypair) =
|
||||
let (mut genesis_block, mint_keypair) =
|
||||
GenesisBlock::new_with_leader(total_balance, &leader.info.id, leader_balance);
|
||||
genesis_block.ticks_per_slot = 160;
|
||||
genesis_block.slots_per_epoch = 16;
|
||||
let (blocktree_path, blockhash) = create_new_tmp_ledger!(&genesis_block);
|
||||
|
||||
let tvu_addr = target1.info.tvu;
|
||||
|
Reference in New Issue
Block a user