mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-11 12:10:05 +00:00
non-canonical IsOptimistic check (#11088)
When requesting with IsOptimistic for a root which is non-canonical and historic, we should check if it is canonical before returning false. Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
This commit is contained in:
parent
7aee67af90
commit
de1ecf2d60
@ -343,8 +343,14 @@ func (s *Service) IsOptimisticForRoot(ctx context.Context, root [32]byte) (bool,
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Historical non-canonical blocks here are returned as optimistic for safety.
|
||||||
|
isCanonical, err := s.IsCanonical(ctx, root)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
if slots.ToEpoch(ss.Slot)+1 < validatedCheckpoint.Epoch {
|
if slots.ToEpoch(ss.Slot)+1 < validatedCheckpoint.Epoch {
|
||||||
return false, nil
|
return !isCanonical, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checkpoint root could be zeros before the first finalized epoch. Use genesis root if the case.
|
// Checkpoint root could be zeros before the first finalized epoch. Use genesis root if the case.
|
||||||
@ -359,13 +365,6 @@ func (s *Service) IsOptimisticForRoot(ctx context.Context, root [32]byte) (bool,
|
|||||||
if ss.Slot > lastValidated.Slot {
|
if ss.Slot > lastValidated.Slot {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
isCanonical, err := s.IsCanonical(ctx, root)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Historical non-canonical blocks here are returned as optimistic for safety.
|
|
||||||
return !isCanonical, nil
|
return !isCanonical, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user