mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
start from finalized checkpoint (#7715)
This commit is contained in:
parent
cd00b6f594
commit
c949913822
@ -346,25 +346,23 @@ func (s *Service) processPastLogs(ctx context.Context) error {
|
||||
}
|
||||
|
||||
s.latestEth1Data.LastRequestedBlock = currentBlockNum
|
||||
b, err := s.beaconDB.HeadBlock(ctx)
|
||||
|
||||
c, err := s.beaconDB.FinalizedCheckpoint(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if b == nil || b.Block == nil {
|
||||
fRoot := bytesutil.ToBytes32(c.Root)
|
||||
// Return if no checkpoint exists yet.
|
||||
if fRoot == params.BeaconConfig().ZeroHash {
|
||||
return nil
|
||||
}
|
||||
r, err := b.Block.HashTreeRoot()
|
||||
fState, err := s.stateGen.StateByRoot(ctx, fRoot)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
currentState, err := s.stateGen.StateByRoot(ctx, r)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not get head state")
|
||||
if fState != nil && fState.Eth1DepositIndex() > 0 {
|
||||
s.depositCache.PrunePendingDeposits(ctx, int64(fState.Eth1DepositIndex()))
|
||||
}
|
||||
if currentState != nil && currentState.Eth1DepositIndex() > 0 {
|
||||
s.depositCache.PrunePendingDeposits(ctx, int64(currentState.Eth1DepositIndex()))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -520,19 +520,23 @@ func (s *Service) initDepositCaches(ctx context.Context, ctrs []*protodb.Deposit
|
||||
return err
|
||||
}
|
||||
// Default to all deposits post-genesis deposits in
|
||||
// the event we cannot find a suitable head state.
|
||||
// the event we cannot find a finalized state.
|
||||
currIndex := genesisState.Eth1DepositIndex()
|
||||
rt := s.beaconDB.LastArchivedRoot(ctx)
|
||||
chkPt, err := s.beaconDB.FinalizedCheckpoint(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rt := bytesutil.ToBytes32(chkPt.Root)
|
||||
if rt != [32]byte{} {
|
||||
currentState, err := s.beaconDB.State(ctx, rt)
|
||||
fState, err := s.stateGen.StateByRoot(ctx, rt)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not get last archived state")
|
||||
return errors.Wrap(err, "could not get finalized state")
|
||||
}
|
||||
if currentState == nil {
|
||||
return errors.Errorf("archived state with root %#x does not exist in the db", rt)
|
||||
if fState == nil {
|
||||
return errors.Errorf("finalized state with root %#x does not exist in the db", rt)
|
||||
}
|
||||
// Set deposit index to the one in the current archived state.
|
||||
currIndex = currentState.Eth1DepositIndex()
|
||||
currIndex = fState.Eth1DepositIndex()
|
||||
}
|
||||
validDepositsCount.Add(float64(currIndex + 1))
|
||||
// Only add pending deposits if the container slice length
|
||||
|
Loading…
Reference in New Issue
Block a user