mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-05-02 03:02:54 -04:00
Use Cached Finalized State When Pruning Deposits (#9985)
* use cached finalized state * Minor grammar edits * fmt Co-authored-by: terence tsao <terence@prysmaticlabs.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/encoding/bytesutil"
|
||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
protodb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/time/slots"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -374,9 +375,21 @@ func (s *Service) processPastLogs(ctx context.Context) error {
|
||||
if fRoot == params.BeaconConfig().ZeroHash {
|
||||
return nil
|
||||
}
|
||||
fState, err := s.cfg.stateGen.StateByRoot(ctx, fRoot)
|
||||
if err != nil {
|
||||
return err
|
||||
fState := s.cfg.finalizedStateAtStartup
|
||||
isNil := fState == nil || fState.IsNil()
|
||||
|
||||
// If processing past logs take a long time, we
|
||||
// need to check if this is the correct finalized
|
||||
// state we are referring to and whether our cached
|
||||
// finalized state is referring to our current finalized checkpoint.
|
||||
// The current code does ignore an edge case where the finalized
|
||||
// block is in a different epoch from the checkpoint's epoch.
|
||||
// This only happens in skipped slots, so pruning it is not an issue.
|
||||
if isNil || slots.ToEpoch(fState.Slot()) != c.Epoch {
|
||||
fState, err = s.cfg.stateGen.StateByRoot(ctx, fRoot)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if fState != nil && !fState.IsNil() && fState.Eth1DepositIndex() > 0 {
|
||||
s.cfg.depositCache.PrunePendingDeposits(ctx, int64(fState.Eth1DepositIndex()))
|
||||
|
||||
Reference in New Issue
Block a user