Add AttesterCache for attestation production (#2478)

## Issue Addressed

- Resolves #2169

## Proposed Changes

Adds the `AttesterCache` to allow validators to produce attestations for older slots. Presently, some arbitrary restrictions can force validators to receive an error when attesting to a slot earlier than the present one. This can cause attestation misses when there is excessive load on the validator client or time sync issues between the VC and BN.

## Additional Info

NA
This commit is contained in:
Paul Hauner
2021-07-29 04:38:26 +00:00
parent 1d4f90e2eb
commit 8efd9fc324
9 changed files with 663 additions and 58 deletions

View File

@@ -547,6 +547,7 @@ where
shuffling_cache: TimeoutRwLock::new(ShufflingCache::new()),
beacon_proposer_cache: <_>::default(),
validator_pubkey_cache: TimeoutRwLock::new(validator_pubkey_cache),
attester_cache: <_>::default(),
disabled_forks: self.disabled_forks,
shutdown_sender: self
.shutdown_sender
@@ -561,6 +562,16 @@ where
.head()
.map_err(|e| format!("Failed to get head: {:?}", e))?;
// Prime the attester cache with the head state.
beacon_chain
.attester_cache
.maybe_cache_state(
&head.beacon_state,
head.beacon_block_root,
&beacon_chain.spec,
)
.map_err(|e| format!("Failed to prime attester cache: {:?}", e))?;
// Only perform the check if it was configured.
if let Some(wss_checkpoint) = beacon_chain.config.weak_subjectivity_checkpoint {
if let Err(e) = beacon_chain.verify_weak_subjectivity_checkpoint(