Break up RPC API into three categories: minimal, full and admin

This commit is contained in:
Michael Vines
2021-02-26 21:42:09 -08:00
parent 81253c9956
commit 24ab84936e
28 changed files with 1784 additions and 1832 deletions

View File

@ -5,6 +5,7 @@ use log::*;
/// discover the rest of the network.
use rand::{thread_rng, Rng};
use solana_client::thin_client::create_client;
use solana_core::validator::ValidatorExit;
use solana_core::{
cluster_info::VALIDATOR_PORT_RANGE, consensus::VOTE_THRESHOLD_DEPTH, contact_info::ContactInfo,
gossip_service::discover_cluster,
@ -15,7 +16,7 @@ use solana_ledger::{
};
use solana_sdk::{
client::SyncClient,
clock::{self, Slot, DEFAULT_MS_PER_SLOT, NUM_CONSECUTIVE_LEADER_SLOTS},
clock::{self, Slot, NUM_CONSECUTIVE_LEADER_SLOTS},
commitment_config::CommitmentConfig,
epoch_schedule::MINIMUM_SLOTS_PER_EPOCH,
hash::Hash,
@ -29,6 +30,7 @@ use solana_sdk::{
use std::{
collections::{HashMap, HashSet},
path::Path,
sync::{Arc, RwLock},
thread::sleep,
time::{Duration, Instant},
};
@ -126,20 +128,6 @@ pub fn send_many_transactions(
expected_balances
}
pub fn validator_exit(entry_point_info: &ContactInfo, nodes: usize) {
let cluster_nodes = discover_cluster(&entry_point_info.gossip, nodes).unwrap();
assert!(cluster_nodes.len() >= nodes);
for node in &cluster_nodes {
let client = create_client(node.client_facing_addr(), VALIDATOR_PORT_RANGE);
assert!(client.validator_exit().unwrap());
}
sleep(Duration::from_millis(DEFAULT_MS_PER_SLOT));
for node in &cluster_nodes {
let client = create_client(node.client_facing_addr(), VALIDATOR_PORT_RANGE);
assert!(client.validator_exit().is_err());
}
}
pub fn verify_ledger_ticks(ledger_path: &Path, ticks_per_slot: usize) {
let ledger = Blockstore::open(ledger_path).unwrap();
let zeroth_slot = ledger.get_slot_entries(0, 0).unwrap();
@ -188,11 +176,12 @@ pub fn sleep_n_epochs(
pub fn kill_entry_and_spend_and_verify_rest(
entry_point_info: &ContactInfo,
entry_point_validator_exit: &Arc<RwLock<ValidatorExit>>,
funding_keypair: &Keypair,
nodes: usize,
slot_millis: u64,
) {
solana_logger::setup();
info!("kill_entry_and_spend_and_verify_rest...");
let cluster_nodes = discover_cluster(&entry_point_info.gossip, nodes).unwrap();
assert!(cluster_nodes.len() >= nodes);
let client = create_client(entry_point_info.client_facing_addr(), VALIDATOR_PORT_RANGE);
@ -211,7 +200,7 @@ pub fn kill_entry_and_spend_and_verify_rest(
));
info!("done sleeping for first 2 warmup epochs");
info!("killing entry point: {}", entry_point_info.id);
assert!(client.validator_exit().unwrap());
entry_point_validator_exit.write().unwrap().exit();
info!("sleeping for some time");
sleep(Duration::from_millis(
slot_millis * NUM_CONSECUTIVE_LEADER_SLOTS,

View File

@ -667,7 +667,7 @@ impl Cluster for LocalCluster {
entry_point_info
.map(|entry_point_info| vec![entry_point_info])
.unwrap_or_default(),
&cluster_validator_info.config,
&safe_clone_config(&cluster_validator_info.config),
true, // should_check_duplicate_instance
);
cluster_validator_info.validator = Some(restarted_node);
@ -707,8 +707,6 @@ mod test {
#[test]
fn test_local_cluster_start_and_exit_with_config() {
solana_logger::setup();
let mut validator_config = ValidatorConfig::default();
validator_config.rpc_config.enable_validator_exit = true;
const NUM_NODES: usize = 1;
let mut config = ClusterConfig {
validator_configs: make_identical_validator_configs(