File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
beacon_node/beacon_chain/src Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -3481,9 +3481,15 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
3481
3481
// would be difficult to check that they all lock fork choice first.
3482
3482
let mut ops = {
3483
3483
let _timer = metrics:: start_timer ( & metrics:: BLOCK_PROCESSING_PUBKEY_CACHE_LOCK ) ;
3484
- self . validator_pubkey_cache
3485
- . write ( )
3486
- . import_new_pubkeys ( & state) ?
3484
+ let pubkey_cache = self . validator_pubkey_cache . upgradable_read ( ) ;
3485
+
3486
+ // Only take a write lock if there are new keys to import.
3487
+ if state. validators ( ) . len ( ) > pubkey_cache. len ( ) {
3488
+ parking_lot:: RwLockUpgradableReadGuard :: upgrade ( pubkey_cache)
3489
+ . import_new_pubkeys ( & state) ?
3490
+ } else {
3491
+ vec ! [ ]
3492
+ }
3487
3493
} ;
3488
3494
3489
3495
// Apply the state to the attester cache, only if it is from the previous epoch or later.
You can’t perform that action at this time.
0 commit comments