Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix panic issue in initializeStateAntiquaryIfNeeded (#11608) #11624

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions cl/antiquary/state_antiquary.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,9 @@ func (s *Antiquary) initializeStateAntiquaryIfNeeded(ctx context.Context, tx kv.
return err
}
// We want to backoff by some slots until we get a correct state from DB.
// we start from 1 * clparams.SlotsPerDump.
backoffStep := uint64(10)
// we start from 10 * clparams.SlotsPerDump.
backoffStrides := uint64(10)
backoffStep := backoffStrides

historicalReader := historical_states_reader.NewHistoricalStatesReader(s.cfg, s.snReader, s.validatorsTable, s.genesisState)

Expand All @@ -447,6 +448,11 @@ func (s *Antiquary) initializeStateAntiquaryIfNeeded(ctx context.Context, tx kv.
if err != nil {
return fmt.Errorf("failed to read historical state at slot %d: %w", attempt, err)
}
if s.currentState == nil {
log.Warn("historical state not found, backoff more and try again", "slot", attempt)
backoffStep += backoffStrides
continue
}

computedBlockRoot, err := s.currentState.BlockRoot()
if err != nil {
Expand All @@ -459,7 +465,7 @@ func (s *Antiquary) initializeStateAntiquaryIfNeeded(ctx context.Context, tx kv.
if computedBlockRoot != expectedBlockRoot {
log.Debug("Block root mismatch, trying again", "slot", attempt, "expected", expectedBlockRoot)
// backoff more
backoffStep += 10
backoffStep += backoffStrides
continue
}
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/ledgerwatch/erigon/cl/phase1/core/state"
"github.com/ledgerwatch/erigon/cl/phase1/core/state/lru"
"github.com/ledgerwatch/erigon/turbo/snapshotsync/freezeblocks"
"github.com/ledgerwatch/log/v3"

libcommon "github.com/ledgerwatch/erigon-lib/common"
)
Expand Down Expand Up @@ -62,6 +63,7 @@ func (r *HistoricalStatesReader) ReadHistoricalState(ctx context.Context, tx kv.

// If this happens, we need to update our static tables
if slot > latestProcessedState || slot > r.validatorTable.Slot() {
log.Warn("slot is ahead of the latest processed state", "slot", slot, "latestProcessedState", latestProcessedState, "validatorTableSlot", r.validatorTable.Slot())
return nil, nil
}

Expand All @@ -74,6 +76,7 @@ func (r *HistoricalStatesReader) ReadHistoricalState(ctx context.Context, tx kv.
return nil, err
}
if block == nil {
log.Warn("block not found", "slot", slot)
return nil, nil
}
blockHeader := block.SignedBeaconBlockHeader().Header
Expand All @@ -84,6 +87,7 @@ func (r *HistoricalStatesReader) ReadHistoricalState(ctx context.Context, tx kv.
return nil, err
}
if slotData == nil {
log.Warn("slot data not found", "slot", slot)
return nil, nil
}
roundedSlot := r.cfg.RoundSlotToEpoch(slot)
Expand All @@ -93,6 +97,7 @@ func (r *HistoricalStatesReader) ReadHistoricalState(ctx context.Context, tx kv.
return nil, fmt.Errorf("failed to read epoch data: %w", err)
}
if epochData == nil {
log.Warn("epoch data not found", "slot", slot, "roundedSlot", roundedSlot)
return nil, nil
}

Expand Down
Loading