diff --git a/src/bin/fullnode.rs b/src/bin/fullnode.rs index dd3ef09e3681ed..cc1373a4ce9cee 100644 --- a/src/bin/fullnode.rs +++ b/src/bin/fullnode.rs @@ -83,11 +83,11 @@ fn main() -> () { let testnet_addr: SocketAddr = testnet_address_string.parse().unwrap(); drone_addr.set_ip(testnet_addr.ip()); - Fullnode::new(node, false, ledger_path, keypair, Some(testnet_addr)) + Fullnode::new(node, false, ledger_path, keypair, Some(testnet_addr), true) } else { node.data.leader_id = node.data.id; - Fullnode::new(node, true, ledger_path, keypair, None) + Fullnode::new(node, true, ledger_path, keypair, None, true) }; let mut client = mk_client(&repl_clone); diff --git a/src/drone.rs b/src/drone.rs index e3b8477089821b..9e36b582b53bad 100644 --- a/src/drone.rs +++ b/src/drone.rs @@ -294,6 +294,7 @@ mod tests { exit.clone(), &ledger_path, false, + false, ); //TODO: this seems unstable sleep(Duration::from_millis(900)); diff --git a/src/fullnode.rs b/src/fullnode.rs index ccdfcb53069891..2cd1504869063c 100644 --- a/src/fullnode.rs +++ b/src/fullnode.rs @@ -55,6 +55,7 @@ impl Fullnode { keypair: Keypair, network_entry_for_validator: Option, sigverify_disabled: bool, + json_rpc_enabled: bool, ) -> Self { info!("creating bank..."); let bank = Bank::new_default(leader); @@ -93,6 +94,7 @@ impl Fullnode { exit.clone(), Some(ledger_path), sigverify_disabled, + json_rpc_enabled, ); info!( "validator ready... local request address: {} (advertising {}) connected to: {}", @@ -111,6 +113,7 @@ impl Fullnode { exit.clone(), ledger_path, sigverify_disabled, + json_rpc_enabled, ); info!( "leader ready... local request address: {} (advertising {})", @@ -126,6 +129,7 @@ impl Fullnode { ledger: &str, keypair: Keypair, network_entry_for_validator: Option, + json_rpc_enabled: bool, ) -> Self { Self::new_internal( node, @@ -134,6 +138,7 @@ impl Fullnode { keypair, network_entry_for_validator, false, + json_rpc_enabled, ) } @@ -143,6 +148,7 @@ impl Fullnode { ledger_path: &str, keypair: Keypair, network_entry_for_validator: Option, + json_rpc_enabled: bool, ) -> Self { Self::new_internal( node, @@ -151,6 +157,7 @@ impl Fullnode { keypair, network_entry_for_validator, true, + json_rpc_enabled, ) } @@ -187,6 +194,7 @@ impl Fullnode { exit: Arc, ledger_path: &str, sigverify_disabled: bool, + json_rpc_enabled: bool, ) -> Self { let tick_duration = None; // TODO: To light up PoH, uncomment the following line: @@ -202,10 +210,12 @@ impl Fullnode { ); thread_hdls.extend(rpu.thread_hdls()); - let mut rpc_addr = node.data.contact_info.ncp; - rpc_addr.set_port(RPC_PORT); - let rpc_service = JsonRpcService::new(bank.clone(), rpc_addr); - thread_hdls.extend(rpc_service.thread_hdls()); + if json_rpc_enabled { + let mut rpc_addr = node.data.contact_info.ncp; + rpc_addr.set_port(RPC_PORT); + let rpc_service = JsonRpcService::new(bank.clone(), rpc_addr); + thread_hdls.extend(rpc_service.thread_hdls()); + } let blob_recycler = BlobRecycler::default(); let window = @@ -287,6 +297,7 @@ impl Fullnode { exit: Arc, ledger_path: Option<&str>, _sigverify_disabled: bool, + json_rpc_enabled: bool, ) -> Self { let bank = Arc::new(bank); let mut thread_hdls = vec![]; @@ -298,10 +309,12 @@ impl Fullnode { ); thread_hdls.extend(rpu.thread_hdls()); - let mut rpc_addr = node.data.contact_info.ncp; - rpc_addr.set_port(RPC_PORT); - let rpc_service = JsonRpcService::new(bank.clone(), rpc_addr); - thread_hdls.extend(rpc_service.thread_hdls()); + if json_rpc_enabled { + let mut rpc_addr = node.data.contact_info.ncp; + rpc_addr.set_port(RPC_PORT); + let rpc_service = JsonRpcService::new(bank.clone(), rpc_addr); + thread_hdls.extend(rpc_service.thread_hdls()); + } let blob_recycler = BlobRecycler::default(); let window = @@ -380,7 +393,8 @@ mod tests { let bank = Bank::new(&alice); let exit = Arc::new(AtomicBool::new(false)); let entry = tn.data.clone(); - let v = Fullnode::new_validator(keypair, bank, 0, &[], tn, &entry, exit, None, false); + let v = + Fullnode::new_validator(keypair, bank, 0, &[], tn, &entry, exit, None, false, false); v.exit(); v.join().unwrap(); } @@ -394,7 +408,7 @@ mod tests { let bank = Bank::new(&alice); let exit = Arc::new(AtomicBool::new(false)); let entry = tn.data.clone(); - Fullnode::new_validator(keypair, bank, 0, &[], tn, &entry, exit, None, false) + Fullnode::new_validator(keypair, bank, 0, &[], tn, &entry, exit, None, false, false) }) .collect(); //each validator can exit in parallel to speed many sequential calls to `join` diff --git a/src/thin_client.rs b/src/thin_client.rs index 47c417140596f0..7f3a42ff38f554 100755 --- a/src/thin_client.rs +++ b/src/thin_client.rs @@ -365,6 +365,7 @@ mod tests { exit.clone(), &ledger_path, false, + false, ); sleep(Duration::from_millis(900)); @@ -412,6 +413,7 @@ mod tests { exit.clone(), &ledger_path, false, + false, ); //TODO: remove this sleep, or add a retry so CI is stable sleep(Duration::from_millis(300)); @@ -471,6 +473,7 @@ mod tests { exit.clone(), &ledger_path, false, + false, ); sleep(Duration::from_millis(300)); diff --git a/tests/multinode.rs b/tests/multinode.rs index 1ed62208c49f4e..531d71dadac5ff 100755 --- a/tests/multinode.rs +++ b/tests/multinode.rs @@ -146,7 +146,14 @@ fn test_multi_node_ledger_window() -> result::Result<()> { writer.write_entries(entries).unwrap(); } - let leader = Fullnode::new(leader, true, &leader_ledger_path, leader_keypair, None); + let leader = Fullnode::new( + leader, + true, + &leader_ledger_path, + leader_keypair, + None, + false, + ); // Send leader some tokens to vote let leader_balance = @@ -164,6 +171,7 @@ fn test_multi_node_ledger_window() -> result::Result<()> { &zero_ledger_path, keypair, Some(leader_data.contact_info.ncp), + false, ); // contains the leader and new node @@ -219,7 +227,14 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> { ); ledger_paths.push(zero_ledger_path.clone()); - let server = Fullnode::new(leader, true, &leader_ledger_path, leader_keypair, None); + let server = Fullnode::new( + leader, + true, + &leader_ledger_path, + leader_keypair, + None, + false, + ); // Send leader some tokens to vote let leader_balance = @@ -242,6 +257,7 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> { &ledger_path, keypair, Some(leader_data.contact_info.ncp), + false, ); nodes.push(val); } @@ -277,6 +293,7 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> { &zero_ledger_path, keypair, Some(leader_data.contact_info.ncp), + false, ); nodes.push(val); //contains the leader and new node @@ -336,7 +353,14 @@ fn test_multi_node_basic() { let (alice, leader_ledger_path) = genesis("multi_node_basic", 10_000); ledger_paths.push(leader_ledger_path.clone()); - let server = Fullnode::new(leader, true, &leader_ledger_path, leader_keypair, None); + let server = Fullnode::new( + leader, + true, + &leader_ledger_path, + leader_keypair, + None, + false, + ); // Send leader some tokens to vote let leader_balance = @@ -355,6 +379,7 @@ fn test_multi_node_basic() { &ledger_path, keypair, Some(leader_data.contact_info.ncp), + false, ); nodes.push(val); } @@ -397,7 +422,14 @@ fn test_boot_validator_from_file() -> result::Result<()> { ledger_paths.push(leader_ledger_path.clone()); let leader_data = leader.data.clone(); - let leader_fullnode = Fullnode::new(leader, true, &leader_ledger_path, leader_keypair, None); + let leader_fullnode = Fullnode::new( + leader, + true, + &leader_ledger_path, + leader_keypair, + None, + false, + ); let leader_balance = send_tx_and_retry_get_balance(&leader_data, &alice, &bob_pubkey, Some(500)).unwrap(); assert_eq!(leader_balance, 500); @@ -416,6 +448,7 @@ fn test_boot_validator_from_file() -> result::Result<()> { &ledger_path, keypair, Some(leader_data.contact_info.ncp), + false, ); let mut client = mk_client(&validator_data); let getbal = retry_get_balance(&mut client, &bob_pubkey, Some(leader_balance)); @@ -434,7 +467,7 @@ fn create_leader(ledger_path: &str) -> (NodeInfo, Fullnode) { let leader_keypair = Keypair::new(); let leader = TestNode::new_localhost_with_pubkey(leader_keypair.pubkey()); let leader_data = leader.data.clone(); - let leader_fullnode = Fullnode::new(leader, true, &ledger_path, leader_keypair, None); + let leader_fullnode = Fullnode::new(leader, true, &ledger_path, leader_keypair, None, false); (leader_data, leader_fullnode) } @@ -485,6 +518,7 @@ fn test_leader_restart_validator_start_from_old_ledger() -> result::Result<()> { &stale_ledger_path, keypair, Some(leader_data.contact_info.ncp), + false, ); // trigger broadcast, validator should catch up from leader, whose window contains @@ -547,8 +581,14 @@ fn test_multi_node_dynamic_network() { let alice_arc = Arc::new(RwLock::new(alice)); let leader_data = leader.data.clone(); - let server = - Fullnode::new_without_sigverify(leader, true, &leader_ledger_path, leader_keypair, None); + let server = Fullnode::new_without_sigverify( + leader, + true, + &leader_ledger_path, + leader_keypair, + None, + false, + ); // Send leader some tokens to vote let leader_balance = send_tx_and_retry_get_balance( @@ -622,6 +662,7 @@ fn test_multi_node_dynamic_network() { &ledger_path, keypair, Some(leader_data.contact_info.ncp), + false, ); (rd, val) })