Remove lock around JsonRpcRequestProcessor (bp #10417) (#10450)

automerge
This commit is contained in:
mergify[bot]
2020-06-08 16:45:49 -07:00
committed by GitHub
parent afc89beefa
commit 3110def6c3
4 changed files with 112 additions and 231 deletions

View File

@ -243,6 +243,12 @@ pub struct ClusterInfo {
stats: GossipStats,
}
impl Default for ClusterInfo {
fn default() -> Self {
Self::new_with_invalid_keypair(ContactInfo::default())
}
}
#[derive(Default, Clone)]
pub struct Locality {
/// The bounds of the neighborhood represented by this locality

View File

@ -77,7 +77,10 @@ pub struct JsonRpcRequestProcessor {
storage_state: StorageState,
validator_exit: Arc<RwLock<Option<ValidatorExit>>>,
health: Arc<RpcHealth>,
cluster_info: Arc<ClusterInfo>,
genesis_hash: Hash,
}
impl Metadata for JsonRpcRequestProcessor {}
impl JsonRpcRequestProcessor {
fn bank(&self, commitment: Option<CommitmentConfig>) -> Result<Arc<Bank>> {
@ -133,8 +136,10 @@ impl JsonRpcRequestProcessor {
storage_state: StorageState,
validator_exit: Arc<RwLock<Option<ValidatorExit>>>,
health: Arc<RpcHealth>,
cluster_info: Arc<ClusterInfo>,
genesis_hash: Hash,
) -> Self {
JsonRpcRequestProcessor {
Self {
config,
bank_forks,
block_commitment_cache,
@ -142,6 +147,8 @@ impl JsonRpcRequestProcessor {
storage_state,
validator_exit,
health,
cluster_info,
genesis_hash,
}
}
@ -765,14 +772,6 @@ fn run_transaction_simulation(
(executed[0].0.clone().map(|_| ()), vec![])
}
#[derive(Clone)]
pub struct Meta {
pub request_processor: Arc<RwLock<JsonRpcRequestProcessor>>,
pub cluster_info: Arc<ClusterInfo>,
pub genesis_hash: Hash,
}
impl Metadata for Meta {}
#[rpc(server)]
pub trait RpcSol {
type Metadata;
@ -1058,7 +1057,7 @@ pub trait RpcSol {
pub struct RpcSolImpl;
impl RpcSol for RpcSolImpl {
type Metadata = Meta;
type Metadata = JsonRpcRequestProcessor;
fn confirm_transaction(
&self,
@ -1068,10 +1067,7 @@ impl RpcSol for RpcSolImpl {
) -> RpcResponse<bool> {
debug!("confirm_transaction rpc request received: {:?}", id);
let signature = verify_signature(&id);
meta.request_processor
.read()
.unwrap()
.confirm_transaction(signature, commitment)
meta.confirm_transaction(signature, commitment)
}
fn get_account_info(
@ -1082,10 +1078,7 @@ impl RpcSol for RpcSolImpl {
) -> RpcResponse<Option<RpcAccount>> {
debug!("get_account_info rpc request received: {:?}", pubkey_str);
let pubkey = verify_pubkey(pubkey_str);
meta.request_processor
.read()
.unwrap()
.get_account_info(pubkey, commitment)
meta.get_account_info(pubkey, commitment)
}
fn get_minimum_balance_for_rent_exemption(
@ -1098,10 +1091,7 @@ impl RpcSol for RpcSolImpl {
"get_minimum_balance_for_rent_exemption rpc request received: {:?}",
data_len
);
meta.request_processor
.read()
.unwrap()
.get_minimum_balance_for_rent_exemption(data_len, commitment)
meta.get_minimum_balance_for_rent_exemption(data_len, commitment)
}
fn get_program_accounts(
@ -1115,10 +1105,7 @@ impl RpcSol for RpcSolImpl {
program_id_str
);
let program_id = verify_pubkey(program_id_str)?;
meta.request_processor
.read()
.unwrap()
.get_program_accounts(&program_id, commitment)
meta.get_program_accounts(&program_id, commitment)
}
fn get_inflation_governor(
@ -1127,10 +1114,7 @@ impl RpcSol for RpcSolImpl {
commitment: Option<CommitmentConfig>,
) -> Result<RpcInflationGovernor> {
debug!("get_inflation_governor rpc request received");
meta.request_processor
.read()
.unwrap()
.get_inflation_governor(commitment)
meta.get_inflation_governor(commitment)
}
fn get_inflation_rate(
@ -1139,15 +1123,12 @@ impl RpcSol for RpcSolImpl {
epoch: Option<Epoch>,
) -> Result<RpcInflationRate> {
debug!("get_inflation_rate rpc request received");
meta.request_processor
.read()
.unwrap()
.get_inflation_rate(epoch)
meta.get_inflation_rate(epoch)
}
fn get_epoch_schedule(&self, meta: Self::Metadata) -> Result<EpochSchedule> {
debug!("get_epoch_schedule rpc request received");
meta.request_processor.read().unwrap().get_epoch_schedule()
meta.get_epoch_schedule()
}
fn get_balance(
@ -1158,10 +1139,7 @@ impl RpcSol for RpcSolImpl {
) -> RpcResponse<u64> {
debug!("get_balance rpc request received: {:?}", pubkey_str);
let pubkey = verify_pubkey(pubkey_str);
meta.request_processor
.read()
.unwrap()
.get_balance(pubkey, commitment)
meta.get_balance(pubkey, commitment)
}
fn get_cluster_nodes(&self, meta: Self::Metadata) -> Result<Vec<RpcContactInfo>> {
@ -1202,7 +1180,7 @@ impl RpcSol for RpcSolImpl {
meta: Self::Metadata,
commitment: Option<CommitmentConfig>,
) -> Result<RpcEpochInfo> {
let bank = meta.request_processor.read().unwrap().bank(commitment)?;
let bank = meta.bank(commitment)?;
let epoch_schedule = bank.epoch_schedule();
let slot = bank.slot();
@ -1220,11 +1198,7 @@ impl RpcSol for RpcSolImpl {
meta: Self::Metadata,
block: Slot,
) -> Result<RpcBlockCommitment<BlockCommitmentArray>> {
Ok(meta
.request_processor
.read()
.unwrap()
.get_block_commitment(block))
Ok(meta.get_block_commitment(block))
}
fn get_genesis_hash(&self, meta: Self::Metadata) -> Result<String> {
@ -1238,7 +1212,7 @@ impl RpcSol for RpcSolImpl {
slot: Option<Slot>,
commitment: Option<CommitmentConfig>,
) -> Result<Option<RpcLeaderSchedule>> {
let bank = meta.request_processor.read().unwrap().bank(commitment)?;
let bank = meta.bank(commitment)?;
let slot = slot.unwrap_or_else(|| bank.slot());
let epoch = bank.epoch_schedule().get_epoch(slot);
@ -1265,10 +1239,7 @@ impl RpcSol for RpcSolImpl {
commitment: Option<CommitmentConfig>,
) -> RpcResponse<RpcBlockhashFeeCalculator> {
debug!("get_recent_blockhash rpc request received");
meta.request_processor
.read()
.unwrap()
.get_recent_blockhash(commitment)
meta.get_recent_blockhash(commitment)
}
fn get_fees(
@ -1277,7 +1248,7 @@ impl RpcSol for RpcSolImpl {
commitment: Option<CommitmentConfig>,
) -> RpcResponse<RpcFees> {
debug!("get_fees rpc request received");
meta.request_processor.read().unwrap().get_fees(commitment)
meta.get_fees(commitment)
}
fn get_fee_calculator_for_blockhash(
@ -1289,18 +1260,12 @@ impl RpcSol for RpcSolImpl {
debug!("get_fee_calculator_for_blockhash rpc request received");
let blockhash =
Hash::from_str(&blockhash).map_err(|e| Error::invalid_params(format!("{:?}", e)))?;
meta.request_processor
.read()
.unwrap()
.get_fee_calculator_for_blockhash(&blockhash, commitment)
meta.get_fee_calculator_for_blockhash(&blockhash, commitment)
}
fn get_fee_rate_governor(&self, meta: Self::Metadata) -> RpcResponse<RpcFeeRateGovernor> {
debug!("get_fee_rate_governor rpc request received");
meta.request_processor
.read()
.unwrap()
.get_fee_rate_governor()
meta.get_fee_rate_governor()
}
fn get_signature_confirmation(
@ -1314,11 +1279,7 @@ impl RpcSol for RpcSolImpl {
signature_str
);
let signature = verify_signature(&signature_str)?;
Ok(meta
.request_processor
.read()
.unwrap()
.get_signature_confirmation_status(signature, commitment))
Ok(meta.get_signature_confirmation_status(signature, commitment))
}
fn get_signature_status(
@ -1328,11 +1289,7 @@ impl RpcSol for RpcSolImpl {
commitment: Option<CommitmentConfig>,
) -> Result<Option<transaction::Result<()>>> {
let signature = verify_signature(&signature_str)?;
Ok(meta
.request_processor
.read()
.unwrap()
.get_signature_status(signature, commitment))
Ok(meta.get_signature_status(signature, commitment))
}
fn get_signature_statuses(
@ -1351,14 +1308,11 @@ impl RpcSol for RpcSolImpl {
for signature_str in signature_strs {
signatures.push(verify_signature(&signature_str)?);
}
meta.request_processor
.read()
.unwrap()
.get_signature_statuses(signatures, config)
meta.get_signature_statuses(signatures, config)
}
fn get_slot(&self, meta: Self::Metadata, commitment: Option<CommitmentConfig>) -> Result<u64> {
meta.request_processor.read().unwrap().get_slot(commitment)
meta.get_slot(commitment)
}
fn get_transaction_count(
@ -1367,10 +1321,7 @@ impl RpcSol for RpcSolImpl {
commitment: Option<CommitmentConfig>,
) -> Result<u64> {
debug!("get_transaction_count rpc request received");
meta.request_processor
.read()
.unwrap()
.get_transaction_count(commitment)
meta.get_transaction_count(commitment)
}
fn get_total_supply(
@ -1379,10 +1330,7 @@ impl RpcSol for RpcSolImpl {
commitment: Option<CommitmentConfig>,
) -> Result<u64> {
debug!("get_total_supply rpc request received");
meta.request_processor
.read()
.unwrap()
.get_total_supply(commitment)
meta.get_total_supply(commitment)
}
fn get_largest_accounts(
@ -1391,10 +1339,7 @@ impl RpcSol for RpcSolImpl {
config: Option<RpcLargestAccountsConfig>,
) -> RpcResponse<Vec<RpcAccountBalance>> {
debug!("get_largest_accounts rpc request received");
meta.request_processor
.read()
.unwrap()
.get_largest_accounts(config)
meta.get_largest_accounts(config)
}
fn get_supply(
@ -1403,10 +1348,7 @@ impl RpcSol for RpcSolImpl {
commitment: Option<CommitmentConfig>,
) -> RpcResponse<RpcSupply> {
debug!("get_supply rpc request received");
meta.request_processor
.read()
.unwrap()
.get_supply(commitment)
meta.get_supply(commitment)
}
fn request_airdrop(
@ -1423,22 +1365,10 @@ impl RpcSol for RpcSolImpl {
&commitment
);
let faucet_addr = meta
.request_processor
.read()
.unwrap()
.config
.faucet_addr
.ok_or_else(Error::invalid_request)?;
let faucet_addr = meta.config.faucet_addr.ok_or_else(Error::invalid_request)?;
let pubkey = verify_pubkey(pubkey_str)?;
let blockhash = meta
.request_processor
.read()
.unwrap()
.bank(commitment.clone())?
.confirmed_last_blockhash()
.0;
let blockhash = meta.bank(commitment.clone())?.confirmed_last_blockhash().0;
let transaction = request_airdrop_transaction(&faucet_addr, &pubkey, lamports, blockhash)
.map_err(|err| {
info!("request_airdrop_transaction failed: {:?}", err);
@ -1467,12 +1397,7 @@ impl RpcSol for RpcSolImpl {
_ => 30,
};
loop {
signature_status = meta
.request_processor
.read()
.unwrap()
.get_signature_statuses(vec![signature], None)?
.value[0]
signature_status = meta.get_signature_statuses(vec![signature], None)?.value[0]
.clone()
.filter(|result| result.satisfies_commitment(commitment.unwrap_or_default()))
.map(|x| x.status);
@ -1506,14 +1431,14 @@ impl RpcSol for RpcSolImpl {
.into());
}
if meta.request_processor.read().unwrap().health.check() != RpcHealthStatus::Ok {
if meta.health.check() != RpcHealthStatus::Ok {
return Err(RpcCustomError::SendTransactionPreflightFailure {
message: "RPC node is unhealthy, unable to simulate transaction".into(),
}
.into());
}
let bank = &*meta.request_processor.read().unwrap().bank(None)?;
let bank = &*meta.bank(None)?;
if let (Err(err), _log_output) = run_transaction_simulation(&bank, transaction) {
// Note: it's possible that the transaction simulation failed but the actual
// transaction would succeed, such as when a transaction depends on an earlier
@ -1559,7 +1484,7 @@ impl RpcSol for RpcSolImpl {
Ok(())
};
let bank = &*meta.request_processor.read().unwrap().bank(None)?;
let bank = &*meta.bank(None)?;
let logs = if result.is_ok() {
let sim_result = run_transaction_simulation(&bank, transaction);
result = sim_result.0;
@ -1582,14 +1507,11 @@ impl RpcSol for RpcSolImpl {
meta: Self::Metadata,
commitment: Option<CommitmentConfig>,
) -> Result<String> {
meta.request_processor
.read()
.unwrap()
.get_slot_leader(commitment)
meta.get_slot_leader(commitment)
}
fn minimum_ledger_slot(&self, meta: Self::Metadata) -> Result<Slot> {
meta.request_processor.read().unwrap().minimum_ledger_slot()
meta.minimum_ledger_slot()
}
fn get_vote_accounts(
@ -1597,21 +1519,15 @@ impl RpcSol for RpcSolImpl {
meta: Self::Metadata,
commitment: Option<CommitmentConfig>,
) -> Result<RpcVoteAccountStatus> {
meta.request_processor
.read()
.unwrap()
.get_vote_accounts(commitment)
meta.get_vote_accounts(commitment)
}
fn get_storage_turn_rate(&self, meta: Self::Metadata) -> Result<u64> {
meta.request_processor
.read()
.unwrap()
.get_storage_turn_rate()
meta.get_storage_turn_rate()
}
fn get_storage_turn(&self, meta: Self::Metadata) -> Result<RpcStorageTurn> {
meta.request_processor.read().unwrap().get_storage_turn()
meta.get_storage_turn()
}
fn get_slots_per_segment(
@ -1619,10 +1535,7 @@ impl RpcSol for RpcSolImpl {
meta: Self::Metadata,
commitment: Option<CommitmentConfig>,
) -> Result<u64> {
meta.request_processor
.read()
.unwrap()
.get_slots_per_segment(commitment)
meta.get_slots_per_segment(commitment)
}
fn get_storage_pubkeys_for_slot(
@ -1630,25 +1543,16 @@ impl RpcSol for RpcSolImpl {
meta: Self::Metadata,
slot: Slot,
) -> Result<Vec<String>> {
meta.request_processor
.read()
.unwrap()
.get_storage_pubkeys_for_slot(slot)
meta.get_storage_pubkeys_for_slot(slot)
}
fn validator_exit(&self, meta: Self::Metadata) -> Result<bool> {
meta.request_processor.read().unwrap().validator_exit()
meta.validator_exit()
}
fn get_identity(&self, meta: Self::Metadata) -> Result<RpcIdentity> {
Ok(RpcIdentity {
identity: meta
.request_processor
.read()
.unwrap()
.config
.identity_pubkey
.to_string(),
identity: meta.config.identity_pubkey.to_string(),
})
}
@ -1659,10 +1563,7 @@ impl RpcSol for RpcSolImpl {
}
fn set_log_filter(&self, meta: Self::Metadata, filter: String) -> Result<()> {
meta.request_processor
.read()
.unwrap()
.set_log_filter(filter)
meta.set_log_filter(filter)
}
fn get_confirmed_block(
@ -1671,10 +1572,7 @@ impl RpcSol for RpcSolImpl {
slot: Slot,
encoding: Option<TransactionEncoding>,
) -> Result<Option<ConfirmedBlock>> {
meta.request_processor
.read()
.unwrap()
.get_confirmed_block(slot, encoding)
meta.get_confirmed_block(slot, encoding)
}
fn get_confirmed_blocks(
@ -1683,14 +1581,11 @@ impl RpcSol for RpcSolImpl {
start_slot: Slot,
end_slot: Option<Slot>,
) -> Result<Vec<Slot>> {
meta.request_processor
.read()
.unwrap()
.get_confirmed_blocks(start_slot, end_slot)
meta.get_confirmed_blocks(start_slot, end_slot)
}
fn get_block_time(&self, meta: Self::Metadata, slot: Slot) -> Result<Option<UnixTimestamp>> {
meta.request_processor.read().unwrap().get_block_time(slot)
meta.get_block_time(slot)
}
fn get_confirmed_transaction(
@ -1700,10 +1595,7 @@ impl RpcSol for RpcSolImpl {
encoding: Option<TransactionEncoding>,
) -> Result<Option<ConfirmedTransaction>> {
let signature = verify_signature(&signature_str)?;
meta.request_processor
.read()
.unwrap()
.get_confirmed_transaction(signature, encoding)
meta.get_confirmed_transaction(signature, encoding)
}
fn get_confirmed_signatures_for_address(
@ -1726,10 +1618,7 @@ impl RpcSol for RpcSolImpl {
MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS_SLOT_RANGE
)));
}
meta.request_processor
.read()
.unwrap()
.get_confirmed_signatures_for_address(pubkey, start_slot, end_slot)
meta.get_confirmed_signatures_for_address(pubkey, start_slot, end_slot)
.map(|signatures| {
signatures
.iter()
@ -1739,10 +1628,7 @@ impl RpcSol for RpcSolImpl {
}
fn get_first_available_block(&self, meta: Self::Metadata) -> Result<Slot> {
meta.request_processor
.read()
.unwrap()
.get_first_available_block()
meta.get_first_available_block()
}
}
@ -1811,8 +1697,8 @@ pub mod tests {
const TEST_SLOTS_PER_EPOCH: u64 = 50;
struct RpcHandler {
io: MetaIoHandler<Meta>,
meta: Meta,
io: MetaIoHandler<JsonRpcRequestProcessor>,
meta: JsonRpcRequestProcessor,
bank: Arc<Bank>,
bank_forks: Arc<RwLock<BankForks>>,
blockhash: Hash,
@ -1936,7 +1822,14 @@ pub mod tests {
let tx = system_transaction::transfer(&alice, pubkey, std::u64::MAX, blockhash);
let _ = bank.process_transaction(&tx);
let request_processor = Arc::new(RwLock::new(JsonRpcRequestProcessor::new(
let cluster_info = Arc::new(ClusterInfo::default());
cluster_info.insert_info(ContactInfo::new_with_pubkey_socketaddr(
&leader_pubkey,
&socketaddr!("127.0.0.1:1234"),
));
let meta = JsonRpcRequestProcessor::new(
JsonRpcConfig {
enable_rpc_transaction_history: true,
identity_pubkey: *pubkey,
@ -1948,22 +1841,13 @@ pub mod tests {
StorageState::default(),
validator_exit,
RpcHealth::stub(),
)));
let cluster_info = Arc::new(ClusterInfo::new_with_invalid_keypair(ContactInfo::default()));
cluster_info.insert_info(ContactInfo::new_with_pubkey_socketaddr(
&leader_pubkey,
&socketaddr!("127.0.0.1:1234"),
));
cluster_info,
Hash::default(),
);
let mut io = MetaIoHandler::default();
let rpc = RpcSolImpl;
io.extend_with(rpc.to_delegate());
let meta = Meta {
request_processor,
cluster_info,
genesis_hash: Hash::default(),
};
RpcHandler {
io,
meta,
@ -1998,6 +1882,8 @@ pub mod tests {
StorageState::default(),
validator_exit,
RpcHealth::stub(),
Arc::new(ClusterInfo::default()),
Hash::default(),
);
thread::spawn(move || {
let blockhash = bank.confirmed_last_blockhash().0;
@ -2937,22 +2823,17 @@ pub mod tests {
let mut io = MetaIoHandler::default();
let rpc = RpcSolImpl;
io.extend_with(rpc.to_delegate());
let meta = Meta {
request_processor: {
let request_processor = JsonRpcRequestProcessor::new(
JsonRpcConfig::default(),
new_bank_forks().0,
block_commitment_cache,
blockstore,
StorageState::default(),
validator_exit,
RpcHealth::stub(),
);
Arc::new(RwLock::new(request_processor))
},
cluster_info: Arc::new(ClusterInfo::new_with_invalid_keypair(ContactInfo::default())),
genesis_hash: Hash::default(),
};
let meta = JsonRpcRequestProcessor::new(
JsonRpcConfig::default(),
new_bank_forks().0,
block_commitment_cache,
blockstore,
StorageState::default(),
validator_exit,
RpcHealth::stub(),
Arc::new(ClusterInfo::new_with_invalid_keypair(ContactInfo::default())),
Hash::default(),
);
let req = r#"{"jsonrpc":"2.0","id":1,"method":"sendTransaction","params":["37u9WtQpcm6ULa3Vmu7ySnANv"]}"#;
let res = io.handle_request_sync(req, meta);
@ -2979,24 +2860,19 @@ pub mod tests {
let mut io = MetaIoHandler::default();
let rpc = RpcSolImpl;
io.extend_with(rpc.to_delegate());
let meta = Meta {
request_processor: {
let request_processor = JsonRpcRequestProcessor::new(
JsonRpcConfig::default(),
bank_forks,
block_commitment_cache,
blockstore,
StorageState::default(),
validator_exit,
health.clone(),
);
Arc::new(RwLock::new(request_processor))
},
cluster_info: Arc::new(ClusterInfo::new_with_invalid_keypair(
let meta = JsonRpcRequestProcessor::new(
JsonRpcConfig::default(),
bank_forks,
block_commitment_cache,
blockstore,
StorageState::default(),
validator_exit,
health.clone(),
Arc::new(ClusterInfo::new_with_invalid_keypair(
ContactInfo::new_with_socketaddr(&socketaddr!("127.0.0.1:1234")),
)),
genesis_hash: Hash::default(),
};
Hash::default(),
);
let mut bad_transaction =
system_transaction::transfer(&Keypair::new(), &Pubkey::default(), 42, Hash::default());
@ -3141,6 +3017,8 @@ pub mod tests {
StorageState::default(),
validator_exit,
RpcHealth::stub(),
Arc::new(ClusterInfo::default()),
Hash::default(),
);
assert_eq!(request_processor.validator_exit(), Ok(false));
assert_eq!(exit.load(Ordering::Relaxed), false);
@ -3165,6 +3043,8 @@ pub mod tests {
StorageState::default(),
validator_exit,
RpcHealth::stub(),
Arc::new(ClusterInfo::default()),
Hash::default(),
);
assert_eq!(request_processor.validator_exit(), Ok(true));
assert_eq!(exit.load(Ordering::Relaxed), true);
@ -3249,6 +3129,8 @@ pub mod tests {
StorageState::default(),
validator_exit,
RpcHealth::stub(),
Arc::new(ClusterInfo::default()),
Hash::default(),
);
assert_eq!(
request_processor.get_block_commitment(0),

View File

@ -104,9 +104,7 @@ impl RpcHealth {
#[cfg(test)]
pub(crate) fn stub() -> Arc<Self> {
Arc::new(Self::new(
Arc::new(ClusterInfo::new_with_invalid_keypair(
crate::contact_info::ContactInfo::default(),
)),
Arc::new(ClusterInfo::default()),
None,
42,
Arc::new(AtomicBool::new(false)),

View File

@ -30,7 +30,7 @@ pub struct JsonRpcService {
thread_hdl: JoinHandle<()>,
#[cfg(test)]
pub request_processor: Arc<RwLock<JsonRpcRequestProcessor>>, // Used only by test_rpc_new()...
pub request_processor: JsonRpcRequestProcessor, // Used only by test_rpc_new()...
close_handle: Option<CloseHandle>,
}
@ -248,7 +248,7 @@ impl JsonRpcService {
override_health_check,
));
let request_processor = Arc::new(RwLock::new(JsonRpcRequestProcessor::new(
let request_processor = JsonRpcRequestProcessor::new(
config,
bank_forks.clone(),
block_commitment_cache,
@ -256,7 +256,9 @@ impl JsonRpcService {
storage_state,
validator_exit.clone(),
health.clone(),
)));
cluster_info,
genesis_hash,
);
#[cfg(test)]
let test_request_processor = request_processor.clone();
@ -279,11 +281,7 @@ impl JsonRpcService {
);
let server = ServerBuilder::with_meta_extractor(
io,
move |_req: &hyper::Request<hyper::Body>| Meta {
request_processor: request_processor.clone(),
cluster_info: cluster_info.clone(),
genesis_hash,
},
move |_req: &hyper::Request<hyper::Body>| request_processor.clone(),
)
.threads(num_cpus::get())
.cors(DomainsValidation::AllowOnly(vec![
@ -339,7 +337,6 @@ impl JsonRpcService {
mod tests {
use super::*;
use crate::{
contact_info::ContactInfo,
crds_value::{CrdsData, CrdsValue, SnapshotHash},
rpc::tests::create_validator_exit,
};
@ -364,7 +361,7 @@ mod tests {
let exit = Arc::new(AtomicBool::new(false));
let validator_exit = create_validator_exit(&exit);
let bank = Bank::new(&genesis_config);
let cluster_info = Arc::new(ClusterInfo::new_with_invalid_keypair(ContactInfo::default()));
let cluster_info = Arc::new(ClusterInfo::default());
let ip_addr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
let rpc_addr = SocketAddr::new(
ip_addr,
@ -398,8 +395,6 @@ mod tests {
10_000,
rpc_service
.request_processor
.read()
.unwrap()
.get_balance(Ok(mint_keypair.pubkey()), None)
.unwrap()
.value
@ -483,7 +478,7 @@ mod tests {
#[test]
fn test_health_check_with_trusted_validators() {
let cluster_info = Arc::new(ClusterInfo::new_with_invalid_keypair(ContactInfo::default()));
let cluster_info = Arc::new(ClusterInfo::default());
let health_check_slot_distance = 123;
let override_health_check = Arc::new(AtomicBool::new(false));
let trusted_validators = vec![Pubkey::new_rand(), Pubkey::new_rand(), Pubkey::new_rand()];