From ca1ccd708f771287f8c35ecdeab0953d064ebd49 Mon Sep 17 00:00:00 2001 From: Burton Qin Date: Sat, 18 Jun 2022 16:50:20 +0800 Subject: [PATCH] core: fix double-readlock in validator --- core/src/validator.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/validator.rs b/core/src/validator.rs index 600975dc85de2b..0f14e9c37abb8d 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -699,10 +699,12 @@ impl Validator { }; let mut block_commitment_cache = BlockCommitmentCache::default(); + let bank_forks_guard = bank_forks.read().unwrap(); block_commitment_cache.initialize_slots( - bank_forks.read().unwrap().working_bank().slot(), - bank_forks.read().unwrap().root(), + bank_forks_guard.working_bank().slot(), + bank_forks_guard.root(), ); + drop(bank_forks_guard); let block_commitment_cache = Arc::new(RwLock::new(block_commitment_cache)); let optimistically_confirmed_bank =