From 7981865fd2bac4bd03612670a6921d293a47d47e Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Sat, 16 Feb 2019 05:42:11 -0700 Subject: [PATCH] Boot unused confirmation-time from Bank This broken metric is already submitted to influx. Why make it available via RPC too? If so, why store it in the bank and not in the RPC service? --- src/bank.rs | 22 ----------------- src/compute_leader_confirmation_service.rs | 3 --- src/rpc.rs | 28 ---------------------- src/thin_client.rs | 25 ------------------- 4 files changed, 78 deletions(-) diff --git a/src/bank.rs b/src/bank.rs index 056528532..b85a65877 100644 --- a/src/bank.rs +++ b/src/bank.rs @@ -35,7 +35,6 @@ use solana_sdk::transaction::Transaction; use solana_sdk::vote_program; use std; use std::result; -use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Arc, RwLock}; use std::time::Instant; @@ -102,9 +101,6 @@ pub struct Bank { /// FIFO queue of `last_id` items last_id_queue: RwLock, - // The latest confirmation time for the network - confirmation_time: AtomicUsize, - /// Tracks and updates the leader schedule based on the votes and account stakes /// processed by the bank pub leader_scheduler: Arc>, @@ -118,7 +114,6 @@ impl Default for Bank { accounts: Accounts::default(), last_id_queue: RwLock::new(LastIdQueue::default()), status_cache: RwLock::new(BankStatusCache::default()), - confirmation_time: AtomicUsize::new(std::usize::MAX), leader_scheduler: Arc::new(RwLock::new(LeaderScheduler::default())), subscriptions: RwLock::new(None), } @@ -154,7 +149,6 @@ impl Bank { accounts: self.accounts.copy_for_tpu(), status_cache: RwLock::new(status_cache), last_id_queue: RwLock::new(self.last_id_queue.read().unwrap().clone()), - confirmation_time: AtomicUsize::new(self.confirmation_time()), leader_scheduler: self.leader_scheduler.clone(), subscriptions: RwLock::new(None), } @@ -792,15 +786,6 @@ impl Bank { self.accounts.hash_internal_state() } - pub fn confirmation_time(&self) -> usize { - self.confirmation_time.load(Ordering::Relaxed) - } - - pub fn set_confirmation_time(&self, confirmation: usize) { - self.confirmation_time - .store(confirmation, Ordering::Relaxed); - } - fn send_account_notifications( &self, txs: &[Transaction], @@ -1208,13 +1193,6 @@ mod tests { assert_eq!(bank0.hash_internal_state(), bank1.hash_internal_state()); } #[test] - fn test_confirmation_time() { - let def_bank = Bank::default(); - assert_eq!(def_bank.confirmation_time(), std::usize::MAX); - def_bank.set_confirmation_time(90); - assert_eq!(def_bank.confirmation_time(), 90); - } - #[test] fn test_interleaving_locks() { let (genesis_block, mint_keypair) = GenesisBlock::new(3); let bank = Bank::new(&genesis_block); diff --git a/src/compute_leader_confirmation_service.rs b/src/compute_leader_confirmation_service.rs index 148f572cd..29ed8991c 100644 --- a/src/compute_leader_confirmation_service.rs +++ b/src/compute_leader_confirmation_service.rs @@ -105,7 +105,6 @@ impl ComputeLeaderConfirmationService { let confirmation_ms = now - super_majority_timestamp; *last_valid_validator_timestamp = super_majority_timestamp; - bank.set_confirmation_time(confirmation_ms as usize); submit( influxdb::Point::new(&"leader-confirmation") @@ -215,7 +214,6 @@ pub mod tests { genesis_block.bootstrap_leader_id, &mut last_confirmation_time, ); - assert_eq!(bank.confirmation_time(), std::usize::MAX); // Get another validator to vote, so we now have 2/3 consensus let voting_keypair = &vote_accounts[7].0; @@ -227,7 +225,6 @@ pub mod tests { genesis_block.bootstrap_leader_id, &mut last_confirmation_time, ); - assert!(bank.confirmation_time() != std::usize::MAX); assert!(last_confirmation_time > 0); } } diff --git a/src/rpc.rs b/src/rpc.rs index af9930121..7a3977c7b 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -155,9 +155,6 @@ pub trait RpcSol { #[rpc(meta, name = "getBalance")] fn get_balance(&self, _: Self::Metadata, _: String) -> Result; - #[rpc(meta, name = "getConfirmationTime")] - fn get_confirmation_time(&self, _: Self::Metadata) -> Result; - #[rpc(meta, name = "getLastId")] fn get_last_id(&self, _: Self::Metadata) -> Result; @@ -210,13 +207,6 @@ impl RpcSol for RpcSolImpl { let pubkey = verify_pubkey(id)?; meta.request_processor.read().unwrap().get_balance(pubkey) } - fn get_confirmation_time(&self, meta: Self::Metadata) -> Result { - info!("get_confirmation_time rpc request received"); - meta.request_processor - .read() - .unwrap() - .get_confirmation_time() - } fn get_last_id(&self, meta: Self::Metadata) -> Result { info!("get_last_id rpc request received"); meta.request_processor.read().unwrap().get_last_id() @@ -378,9 +368,6 @@ impl JsonRpcRequestProcessor { let val = self.bank.get_balance(&pubkey); Ok(val) } - fn get_confirmation_time(&self) -> Result { - Ok(self.bank.confirmation_time()) - } fn get_last_id(&self) -> Result { let id = self.bank.last_id(); Ok(bs58::encode(id).into_string()) @@ -662,21 +649,6 @@ mod tests { assert_eq!(expected, result); } - #[test] - fn test_rpc_get_confirmation() { - let bob_pubkey = Keypair::new().pubkey(); - let (io, meta, _last_id, _alice) = start_rpc_handler_with_tx(bob_pubkey); - - let req = format!(r#"{{"jsonrpc":"2.0","id":1,"method":"getConfirmationTime"}}"#); - let res = io.handle_request_sync(&req, meta); - let expected = format!(r#"{{"jsonrpc":"2.0","result":18446744073709551615,"id":1}}"#); - let expected: Response = - serde_json::from_str(&expected).expect("expected response deserialization"); - let result: Response = serde_json::from_str(&res.expect("actual response")) - .expect("actual response deserialization"); - assert_eq!(expected, result); - } - #[test] fn test_rpc_get_last_id() { let bob_pubkey = Keypair::new().pubkey(); diff --git a/src/thin_client.rs b/src/thin_client.rs index cf4b37356..948164454 100644 --- a/src/thin_client.rs +++ b/src/thin_client.rs @@ -193,28 +193,6 @@ impl ThinClient { }) } - /// Request the confirmation time from the leader node - pub fn get_confirmation_time(&mut self) -> usize { - trace!("get_confirmation_time"); - loop { - debug!("get_confirmation_time send_to {}", &self.rpc_addr); - - let response = - self.rpc_client - .make_rpc_request(1, RpcRequest::GetConfirmationTime, None); - - match response { - Ok(value) => { - let confirmation = value.as_u64().unwrap() as usize; - return confirmation; - } - Err(error) => { - debug!("thin_client get_confirmation_time error: {:?}", error); - } - }; - } - } - /// Request the transaction count. If the response packet is dropped by the network, /// this method will try again 5 times. pub fn transaction_count(&mut self) -> u64 { @@ -531,9 +509,6 @@ mod tests { let transaction_count = client.transaction_count(); assert_eq!(transaction_count, 0); - let confirmation = client.get_confirmation_time(); - assert_eq!(confirmation, 18446744073709551615); - let last_id = client.get_last_id(); info!("test_thin_client last_id: {:?}", last_id);