Configurable local cluster native processors (#3676)
This commit is contained in:
parent
d45d8e9670
commit
44b391096d
|
@ -752,7 +752,7 @@ mod tests {
|
||||||
let fullnode_config = FullnodeConfig::default();
|
let fullnode_config = FullnodeConfig::default();
|
||||||
const NUM_NODES: usize = 1;
|
const NUM_NODES: usize = 1;
|
||||||
let cluster =
|
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();
|
let drone_keypair = Keypair::new();
|
||||||
cluster.transfer(&cluster.funding_keypair, &drone_keypair.pubkey(), 1_000_000);
|
cluster.transfer(&cluster.funding_keypair, &drone_keypair.pubkey(), 1_000_000);
|
||||||
|
|
|
@ -68,13 +68,14 @@ pub struct LocalCluster {
|
||||||
impl LocalCluster {
|
impl LocalCluster {
|
||||||
pub fn new(num_nodes: usize, cluster_lamports: u64, lamports_per_node: u64) -> Self {
|
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();
|
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(
|
pub fn new_with_config(
|
||||||
node_stakes: &[u64],
|
node_stakes: &[u64],
|
||||||
cluster_lamports: u64,
|
cluster_lamports: u64,
|
||||||
fullnode_config: &FullnodeConfig,
|
fullnode_config: &FullnodeConfig,
|
||||||
|
native_instruction_processors: &[(String, Pubkey)],
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self::new_with_config_replicators(
|
Self::new_with_config_replicators(
|
||||||
node_stakes,
|
node_stakes,
|
||||||
|
@ -83,6 +84,7 @@ impl LocalCluster {
|
||||||
0,
|
0,
|
||||||
DEFAULT_TICKS_PER_SLOT,
|
DEFAULT_TICKS_PER_SLOT,
|
||||||
DEFAULT_SLOTS_PER_EPOCH,
|
DEFAULT_SLOTS_PER_EPOCH,
|
||||||
|
native_instruction_processors,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +94,7 @@ impl LocalCluster {
|
||||||
fullnode_config: &FullnodeConfig,
|
fullnode_config: &FullnodeConfig,
|
||||||
ticks_per_slot: u64,
|
ticks_per_slot: u64,
|
||||||
slots_per_epoch: u64,
|
slots_per_epoch: u64,
|
||||||
|
native_instruction_processors: &[(String, Pubkey)],
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self::new_with_config_replicators(
|
Self::new_with_config_replicators(
|
||||||
node_stakes,
|
node_stakes,
|
||||||
|
@ -100,6 +103,7 @@ impl LocalCluster {
|
||||||
0,
|
0,
|
||||||
ticks_per_slot,
|
ticks_per_slot,
|
||||||
slots_per_epoch,
|
slots_per_epoch,
|
||||||
|
native_instruction_processors,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +114,7 @@ impl LocalCluster {
|
||||||
num_replicators: usize,
|
num_replicators: usize,
|
||||||
ticks_per_slot: u64,
|
ticks_per_slot: u64,
|
||||||
slots_per_epoch: u64,
|
slots_per_epoch: u64,
|
||||||
|
native_instruction_processors: &[(String, Pubkey)],
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let leader_keypair = Arc::new(Keypair::new());
|
let leader_keypair = Arc::new(Keypair::new());
|
||||||
let leader_pubkey = leader_keypair.pubkey();
|
let leader_pubkey = leader_keypair.pubkey();
|
||||||
|
@ -118,6 +123,9 @@ impl LocalCluster {
|
||||||
GenesisBlock::new_with_leader(cluster_lamports, &leader_pubkey, node_stakes[0]);
|
GenesisBlock::new_with_leader(cluster_lamports, &leader_pubkey, node_stakes[0]);
|
||||||
genesis_block.ticks_per_slot = ticks_per_slot;
|
genesis_block.ticks_per_slot = ticks_per_slot;
|
||||||
genesis_block.slots_per_epoch = slots_per_epoch;
|
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 (genesis_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
|
||||||
let leader_ledger_path = tmp_copy_blocktree!(&genesis_ledger_path);
|
let leader_ledger_path = tmp_copy_blocktree!(&genesis_ledger_path);
|
||||||
let voting_keypair = Keypair::new();
|
let voting_keypair = Keypair::new();
|
||||||
|
@ -444,6 +452,7 @@ mod test {
|
||||||
num_replicators,
|
num_replicators,
|
||||||
16,
|
16,
|
||||||
16,
|
16,
|
||||||
|
&[],
|
||||||
);
|
);
|
||||||
assert_eq!(cluster.fullnodes.len(), NUM_NODES);
|
assert_eq!(cluster.fullnodes.len(), NUM_NODES);
|
||||||
assert_eq!(cluster.replicators.len(), num_replicators);
|
assert_eq!(cluster.replicators.len(), num_replicators);
|
||||||
|
|
|
@ -60,7 +60,7 @@ fn test_fullnode_exit_2() {
|
||||||
let num_nodes = 2;
|
let num_nodes = 2;
|
||||||
let mut fullnode_config = FullnodeConfig::default();
|
let mut fullnode_config = FullnodeConfig::default();
|
||||||
fullnode_config.rpc_config.enable_fullnode_exit = true;
|
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);
|
cluster_tests::fullnode_exit(&local.entry_point_info, num_nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ fn test_leader_failure_4() {
|
||||||
let num_nodes = 4;
|
let num_nodes = 4;
|
||||||
let mut fullnode_config = FullnodeConfig::default();
|
let mut fullnode_config = FullnodeConfig::default();
|
||||||
fullnode_config.rpc_config.enable_fullnode_exit = true;
|
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(
|
cluster_tests::kill_entry_and_spend_and_verify_rest(
|
||||||
&local.entry_point_info,
|
&local.entry_point_info,
|
||||||
&local.funding_keypair,
|
&local.funding_keypair,
|
||||||
|
@ -93,6 +93,7 @@ fn test_two_unbalanced_stakes() {
|
||||||
&fullnode_config,
|
&fullnode_config,
|
||||||
num_ticks_per_slot,
|
num_ticks_per_slot,
|
||||||
num_slots_per_epoch,
|
num_slots_per_epoch,
|
||||||
|
&[],
|
||||||
);
|
);
|
||||||
cluster_tests::sleep_n_epochs(
|
cluster_tests::sleep_n_epochs(
|
||||||
10.0,
|
10.0,
|
||||||
|
@ -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
|
// 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
|
// will be have to be forwarded in order to be confirmed
|
||||||
let fullnode_config = FullnodeConfig::default();
|
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();
|
let cluster_nodes = discover_nodes(&cluster.entry_point_info.gossip, 2).unwrap();
|
||||||
assert!(cluster_nodes.len() >= 2);
|
assert!(cluster_nodes.len() >= 2);
|
||||||
|
@ -137,6 +138,7 @@ fn test_restart_node() {
|
||||||
&fullnode_config,
|
&fullnode_config,
|
||||||
ticks_per_slot,
|
ticks_per_slot,
|
||||||
slots_per_epoch,
|
slots_per_epoch,
|
||||||
|
&[],
|
||||||
);
|
);
|
||||||
let nodes = cluster.get_node_ids();
|
let nodes = cluster.get_node_ids();
|
||||||
cluster_tests::sleep_n_epochs(
|
cluster_tests::sleep_n_epochs(
|
||||||
|
|
|
@ -114,6 +114,7 @@ fn run_replicator_startup_basic(num_nodes: usize, num_replicators: usize) {
|
||||||
num_replicators,
|
num_replicators,
|
||||||
DEFAULT_TICKS_PER_SLOT,
|
DEFAULT_TICKS_PER_SLOT,
|
||||||
DEFAULT_SLOTS_PER_EPOCH,
|
DEFAULT_SLOTS_PER_EPOCH,
|
||||||
|
&[],
|
||||||
);
|
);
|
||||||
|
|
||||||
let cluster_nodes = discover_nodes(
|
let cluster_nodes = discover_nodes(
|
||||||
|
@ -228,6 +229,7 @@ fn test_account_setup() {
|
||||||
num_replicators,
|
num_replicators,
|
||||||
DEFAULT_TICKS_PER_SLOT,
|
DEFAULT_TICKS_PER_SLOT,
|
||||||
DEFAULT_SLOTS_PER_EPOCH,
|
DEFAULT_SLOTS_PER_EPOCH,
|
||||||
|
&[],
|
||||||
);
|
);
|
||||||
|
|
||||||
let _ = discover_nodes(
|
let _ = discover_nodes(
|
||||||
|
|
Loading…
Reference in New Issue