Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable local cluster native processors #3676

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bench-tps/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ mod tests {
let fullnode_config = FullnodeConfig::default();
const NUM_NODES: usize = 1;
let cluster =
LocalCluster::new_with_config(&[999_990; NUM_NODES], 2_000_000, &fullnode_config);
LocalCluster::new_with_config(&[999_990; NUM_NODES], 2_000_000, &fullnode_config, &[]);

let drone_keypair = Keypair::new();
cluster.transfer(&cluster.funding_keypair, &drone_keypair.pubkey(), 1_000_000);
Expand Down
11 changes: 10 additions & 1 deletion core/src/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ pub struct LocalCluster {
impl LocalCluster {
pub fn new(num_nodes: usize, cluster_lamports: u64, lamports_per_node: u64) -> Self {
let stakes: Vec<_> = (0..num_nodes).map(|_| lamports_per_node).collect();
Self::new_with_config(&stakes, cluster_lamports, &FullnodeConfig::default())
Self::new_with_config(&stakes, cluster_lamports, &FullnodeConfig::default(), &[])
}

pub fn new_with_config(
node_stakes: &[u64],
cluster_lamports: u64,
fullnode_config: &FullnodeConfig,
native_instruction_processors: &[(String, Pubkey)],
) -> Self {
Self::new_with_config_replicators(
node_stakes,
Expand All @@ -83,6 +84,7 @@ impl LocalCluster {
0,
DEFAULT_TICKS_PER_SLOT,
DEFAULT_SLOTS_PER_EPOCH,
native_instruction_processors,
)
}

Expand All @@ -92,6 +94,7 @@ impl LocalCluster {
fullnode_config: &FullnodeConfig,
ticks_per_slot: u64,
slots_per_epoch: u64,
native_instruction_processors: &[(String, Pubkey)],
) -> Self {
Self::new_with_config_replicators(
node_stakes,
Expand All @@ -100,6 +103,7 @@ impl LocalCluster {
0,
ticks_per_slot,
slots_per_epoch,
native_instruction_processors,
)
}

Expand All @@ -110,6 +114,7 @@ impl LocalCluster {
num_replicators: usize,
ticks_per_slot: u64,
slots_per_epoch: u64,
native_instruction_processors: &[(String, Pubkey)],
) -> Self {
let leader_keypair = Arc::new(Keypair::new());
let leader_pubkey = leader_keypair.pubkey();
Expand All @@ -118,6 +123,9 @@ impl LocalCluster {
GenesisBlock::new_with_leader(cluster_lamports, &leader_pubkey, node_stakes[0]);
genesis_block.ticks_per_slot = ticks_per_slot;
genesis_block.slots_per_epoch = slots_per_epoch;
genesis_block
.native_instruction_processors
.extend_from_slice(native_instruction_processors);
let (genesis_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
let leader_ledger_path = tmp_copy_blocktree!(&genesis_ledger_path);
let voting_keypair = Keypair::new();
Expand Down Expand Up @@ -444,6 +452,7 @@ mod test {
num_replicators,
16,
16,
&[],
);
assert_eq!(cluster.fullnodes.len(), NUM_NODES);
assert_eq!(cluster.replicators.len(), num_replicators);
Expand Down
8 changes: 5 additions & 3 deletions core/tests/local_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn test_fullnode_exit_2() {
let num_nodes = 2;
let mut fullnode_config = FullnodeConfig::default();
fullnode_config.rpc_config.enable_fullnode_exit = true;
let local = LocalCluster::new_with_config(&[100; 2], 10_000, &fullnode_config);
let local = LocalCluster::new_with_config(&[100; 2], 10_000, &fullnode_config, &[]);
cluster_tests::fullnode_exit(&local.entry_point_info, num_nodes);
}

Expand All @@ -71,7 +71,7 @@ fn test_leader_failure_4() {
let num_nodes = 4;
let mut fullnode_config = FullnodeConfig::default();
fullnode_config.rpc_config.enable_fullnode_exit = true;
let local = LocalCluster::new_with_config(&[100; 4], 10_000, &fullnode_config);
let local = LocalCluster::new_with_config(&[100; 4], 10_000, &fullnode_config, &[]);
cluster_tests::kill_entry_and_spend_and_verify_rest(
&local.entry_point_info,
&local.funding_keypair,
Expand All @@ -93,6 +93,7 @@ fn test_two_unbalanced_stakes() {
&fullnode_config,
num_ticks_per_slot,
num_slots_per_epoch,
&[],
);
cluster_tests::sleep_n_epochs(
10.0,
Expand All @@ -113,7 +114,7 @@ fn test_forwarding() {
// Set up a cluster where one node is never the leader, so all txs sent to this node
// will be have to be forwarded in order to be confirmed
let fullnode_config = FullnodeConfig::default();
let cluster = LocalCluster::new_with_config(&[999_990, 3], 2_000_000, &fullnode_config);
let cluster = LocalCluster::new_with_config(&[999_990, 3], 2_000_000, &fullnode_config, &[]);

let cluster_nodes = discover_nodes(&cluster.entry_point_info.gossip, 2).unwrap();
assert!(cluster_nodes.len() >= 2);
Expand All @@ -137,6 +138,7 @@ fn test_restart_node() {
&fullnode_config,
ticks_per_slot,
slots_per_epoch,
&[],
);
let nodes = cluster.get_node_ids();
cluster_tests::sleep_n_epochs(
Expand Down
2 changes: 2 additions & 0 deletions core/tests/replicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ fn run_replicator_startup_basic(num_nodes: usize, num_replicators: usize) {
num_replicators,
DEFAULT_TICKS_PER_SLOT,
DEFAULT_SLOTS_PER_EPOCH,
&[],
);

let cluster_nodes = discover_nodes(
Expand Down Expand Up @@ -228,6 +229,7 @@ fn test_account_setup() {
num_replicators,
DEFAULT_TICKS_PER_SLOT,
DEFAULT_SLOTS_PER_EPOCH,
&[],
);

let _ = discover_nodes(
Expand Down