mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-04-19 03:01:06 -04:00
Prefer checkpoint cache and NSC over head
This commit is contained in:
@@ -92,10 +92,6 @@ func (s *Service) getRecentPreState(ctx context.Context, c *ethpb.Checkpoint) st
|
||||
// getAttPreState retrieves the att pre state by either from the cache or the DB.
|
||||
// The caller of this function must have a lock on forkchoice.
|
||||
func (s *Service) getAttPreState(ctx context.Context, c *ethpb.Checkpoint) (state.ReadOnlyBeaconState, error) {
|
||||
// If the attestation is recent and canonical we can use the head state to compute the shuffling.
|
||||
if st := s.getRecentPreState(ctx, c); st != nil {
|
||||
return st, nil
|
||||
}
|
||||
// Use a multilock to allow scoped holding of a mutex by a checkpoint root + epoch
|
||||
// allowing us to behave smarter in terms of how this function is used concurrently.
|
||||
epochKey := strconv.FormatUint(uint64(c.Epoch), 10 /* base 10 */)
|
||||
@@ -128,6 +124,10 @@ func (s *Service) getAttPreState(ctx context.Context, c *ethpb.Checkpoint) (stat
|
||||
}
|
||||
return cachedState, nil
|
||||
}
|
||||
// If the attestation is recent and canonical we can use the head state to compute the shuffling.
|
||||
if st := s.getRecentPreState(ctx, c); st != nil {
|
||||
return st, nil
|
||||
}
|
||||
|
||||
// Do not process attestations for old non viable checkpoints otherwise
|
||||
ok, err := s.cfg.ForkChoiceStore.IsViableForCheckpoint(&forkchoicetypes.Checkpoint{Root: [32]byte(c.Root), Epoch: c.Epoch})
|
||||
|
||||
2
changelog/potuz_prefer_cached_over_head.md
Normal file
2
changelog/potuz_prefer_cached_over_head.md
Normal file
@@ -0,0 +1,2 @@
|
||||
### Changed
|
||||
- Prefer the cached epoch transition states and the NSC ones over head state for attestation verification.
|
||||
Reference in New Issue
Block a user