mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 23:48:06 -05:00
Do not HTR the state when checking for optimistic mode (#12143)
* initial impl * review feedback * fix tests * review feedback * some improvements * tests and small improvements * gzl * one more review * fix test * fix other test * get the roots instead of hashing them * fix comment * fix justified case * fix all tests * misc * gzl * fix broken tests * use isOptimisticForRoot once we have the blockroot * Fix is_not_finalized_when_head_is_optimistic but reviewing the logic first * Fix is_not_finalized_when_head_is_optimistic * better root tests * move optimistic check before parsing root * check for last validated checkpoint * add right check for finalized * fix finalized tests * removed impossible condition * fix TestGetSyncCommitteeDuties * Use Ancestor from chaininfo * fix test --------- Co-authored-by: Potuz <potuz@prysmaticlabs.com> Co-authored-by: Nishant Das <nishdas93@gmail.com> Co-authored-by: rauljordan <raul@prysmaticlabs.com> Co-authored-by: terence tsao <terence@prysmaticlabs.com>
This commit is contained in:
@@ -67,6 +67,7 @@ type ChainService struct {
|
||||
ReceiveBlockMockErr error
|
||||
OptimisticCheckRootReceived [32]byte
|
||||
FinalizedRoots map[[32]byte]bool
|
||||
OptimisticRoots map[[32]byte]bool
|
||||
}
|
||||
|
||||
// ForkChoicer mocks the same method in the chain service
|
||||
@@ -74,8 +75,9 @@ func (s *ChainService) ForkChoicer() forkchoice.ForkChoicer {
|
||||
return s.ForkChoiceStore
|
||||
}
|
||||
|
||||
func (s *ChainService) Ancestor(_ context.Context, _ []byte, _ primitives.Slot) ([]byte, error) {
|
||||
return nil, nil
|
||||
func (s *ChainService) Ancestor(ctx context.Context, root []byte, slot primitives.Slot) ([]byte, error) {
|
||||
r, err := s.ForkChoicer().AncestorRoot(ctx, bytesutil.ToBytes32(root), slot)
|
||||
return r[:], err
|
||||
}
|
||||
|
||||
// StateNotifier mocks the same method in the chain service.
|
||||
@@ -461,7 +463,7 @@ func (s *ChainService) InForkchoice(_ [32]byte) bool {
|
||||
// IsOptimisticForRoot mocks the same method in the chain service.
|
||||
func (s *ChainService) IsOptimisticForRoot(_ context.Context, root [32]byte) (bool, error) {
|
||||
s.OptimisticCheckRootReceived = root
|
||||
return s.Optimistic, nil
|
||||
return s.OptimisticRoots[root], nil
|
||||
}
|
||||
|
||||
// UpdateHead mocks the same method in the chain service.
|
||||
|
||||
Reference in New Issue
Block a user