From 314102cb541b80fa302d13e48ba96f4f602b681a Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Tue, 22 Jun 2021 12:50:35 -0700 Subject: [PATCH] Remove redundant JsonRpcConfig::identity_pubkey field --- core/src/test_validator.rs | 5 +---- rpc/src/rpc.rs | 15 +++++++++------ validator/src/main.rs | 1 - 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/core/src/test_validator.rs b/core/src/test_validator.rs index 7e6437245f..e41b4017ae 100644 --- a/core/src/test_validator.rs +++ b/core/src/test_validator.rs @@ -460,9 +460,6 @@ impl TestValidator { let tpu = node.info.tpu; let gossip = node.info.gossip; - let mut rpc_config = config.rpc_config.clone(); - rpc_config.identity_pubkey = validator_identity.pubkey(); - { let mut authorized_voter_keypairs = config.authorized_voter_keypairs.write().unwrap(); if !authorized_voter_keypairs @@ -481,7 +478,7 @@ impl TestValidator { node.info.rpc_pubsub.port(), ), )), - rpc_config, + rpc_config: config.rpc_config.clone(), accounts_hash_interval_slots: 100, account_paths: vec![ledger_path.join("accounts")], poh_verify: false, // Skip PoH verification of ledger on startup for speed diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index bf4c08350c..34dbede52e 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -130,7 +130,6 @@ fn is_finalized( pub struct JsonRpcConfig { pub enable_rpc_transaction_history: bool, pub enable_cpi_and_log_storage: bool, - pub identity_pubkey: Pubkey, pub faucet_addr: Option, pub health_check_slot_distance: u64, pub enable_bigtable_ledger_storage: bool, @@ -2228,7 +2227,7 @@ pub mod rpc_minimal { fn get_identity(&self, meta: Self::Metadata) -> Result { debug!("get_identity rpc request received"); Ok(RpcIdentity { - identity: meta.config.identity_pubkey.to_string(), + identity: meta.cluster_info.id().to_string(), }) } @@ -4055,7 +4054,10 @@ pub mod tests { let tx = system_transaction::transfer(&alice, pubkey, std::u64::MAX, blockhash); let _ = bank.process_transaction(&tx); - let cluster_info = Arc::new(ClusterInfo::default()); + let cluster_info = Arc::new(ClusterInfo::new_with_invalid_keypair(ContactInfo { + id: alice.pubkey(), + ..ContactInfo::default() + })); let tpu_address = cluster_info.my_contact_info().tpu; cluster_info.insert_info(ContactInfo::new_with_pubkey_socketaddr( @@ -4080,7 +4082,6 @@ pub mod tests { let (meta, receiver) = JsonRpcRequestProcessor::new( JsonRpcConfig { enable_rpc_transaction_history: true, - identity_pubkey: *pubkey, ..JsonRpcConfig::default() }, None, @@ -5815,14 +5816,16 @@ pub mod tests { #[test] fn test_rpc_get_identity() { let bob_pubkey = solana_sdk::pubkey::new_rand(); - let RpcHandler { io, meta, .. } = start_rpc_handler_with_tx(&bob_pubkey); + let RpcHandler { + io, meta, alice, .. + } = start_rpc_handler_with_tx(&bob_pubkey); let req = r#"{"jsonrpc":"2.0","id":1,"method":"getIdentity"}"#; let res = io.handle_request_sync(req, meta); let expected = json!({ "jsonrpc": "2.0", "result": { - "identity": bob_pubkey.to_string() + "identity": alice.pubkey().to_string() }, "id": 1 }); diff --git a/validator/src/main.rs b/validator/src/main.rs index 1559619194..1e8323022b 100644 --- a/validator/src/main.rs +++ b/validator/src/main.rs @@ -2194,7 +2194,6 @@ pub fn main() { enable_bigtable_ledger_storage: matches .is_present("enable_rpc_bigtable_ledger_storage"), enable_bigtable_ledger_upload: matches.is_present("enable_bigtable_ledger_upload"), - identity_pubkey: identity_keypair.pubkey(), faucet_addr: matches.value_of("rpc_faucet_addr").map(|address| { solana_net_utils::parse_host_port(address).expect("failed to parse faucet address") }),