Skip to content

Commit f22317e

Browse files
Giulio2002domiwei
andauthored
Caplin: Added more logs to --caplin.archive (#13074)
Co-authored-by: Kewei <kewei.train@gmail.com>
1 parent 98545dc commit f22317e

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

cl/antiquary/antiquary.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,13 @@ func (a *Antiquary) Loop() error {
217217
}
218218
}
219219

220-
a.stateSn.OpenFolder()
220+
if a.stateSn != nil {
221+
if err := a.stateSn.OpenFolder(); err != nil {
222+
return err
223+
}
224+
}
225+
log.Info("[Caplin] Stat", "blocks-static", a.sn.BlocksAvailable(), "states-static", a.stateSn.BlocksAvailable(), "blobs-static", a.sn.FrozenBlobs(),
226+
"state-history-enabled", a.states, "block-history-enabled", a.blocks, "blob-history-enabled", a.blobs, "snapgen", a.snapgen)
221227

222228
frozenSlots := a.sn.BlocksAvailable()
223229
if frozenSlots != 0 {

cl/antiquary/state_antiquary.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ func (s *Antiquary) loopStates(ctx context.Context) {
5757
// Execute this each second
5858
reqRetryTimer := time.NewTicker(100 * time.Millisecond)
5959
defer reqRetryTimer.Stop()
60+
6061
if !initial_state.IsGenesisStateSupported(clparams.NetworkType(s.cfg.DepositNetworkID)) {
6162
s.logger.Warn("Genesis state is not supported for this network, no historical states data will be available")
6263
return
6364
}
64-
6565
_, beforeFinalized, err := s.readHistoricalProcessingProgress(ctx)
6666
if err != nil {
6767
s.logger.Error("Failed to read historical processing progress", "err", err)
@@ -81,14 +81,16 @@ func (s *Antiquary) loopStates(ctx context.Context) {
8181
s.logger.Error("Failed to read historical processing progress", "err", err)
8282
continue
8383
}
84+
if s.sn == nil || s.syncedData.Syncing() {
85+
continue
86+
}
87+
8488
// We wait for updated finality.
8589
if finalized == beforeFinalized {
8690
continue
8791
}
8892
beforeFinalized = finalized
89-
if s.sn == nil || s.syncedData.Syncing() {
90-
continue
91-
}
93+
9294
if err := s.IncrementBeaconState(ctx, finalized); err != nil {
9395
if s.currentState != nil {
9496
s.logger.Warn("Could not to increment beacon state, trying again later", "err", err, "slot", s.currentState.Slot())
@@ -140,9 +142,16 @@ func FillStaticValidatorsTableIfNeeded(ctx context.Context, logger log.Logger, s
140142
blocksAvaiable := stateSn.BlocksAvailable()
141143
stateSnRoTx := stateSn.View()
142144
defer stateSnRoTx.Close()
143-
145+
log.Info("[Caplin-Archive] filling validators table", "from", 0, "to", stateSn.BlocksAvailable())
146+
logTicker := time.NewTicker(10 * time.Second)
147+
defer logTicker.Stop()
144148
start := time.Now()
145149
for slot := uint64(0); slot <= stateSn.BlocksAvailable(); slot++ {
150+
select {
151+
case <-logTicker.C:
152+
log.Info("[Caplin-Archive] Filled validators table", "progress", fmt.Sprintf("%d/%d", slot, stateSn.BlocksAvailable()))
153+
default:
154+
}
146155
seg, ok := stateSnRoTx.VisibleSegment(slot, kv.StateEvents)
147156
if !ok {
148157
return false, fmt.Errorf("segment not found for slot %d", slot)
@@ -437,7 +446,7 @@ func (s *Antiquary) IncrementBeaconState(ctx context.Context, to uint64) error {
437446
// We now do some post-processing on the state.
438447
select {
439448
case <-progressTimer.C:
440-
log.Log(logLvl, "State processing progress", "slot", slot, "blk/sec", fmt.Sprintf("%.2f", float64(slot-prevSlot)/60))
449+
log.Log(logLvl, "[Caplin-Archive] Historical States reconstruction", "slot", slot, "blk/sec", fmt.Sprintf("%.2f", float64(slot-prevSlot)/60))
441450
prevSlot = slot
442451
default:
443452
}
@@ -491,7 +500,7 @@ func (s *Antiquary) IncrementBeaconState(ctx context.Context, to uint64) error {
491500
return err
492501
}
493502

494-
log.Info("Historical states antiquated", "slot", s.currentState.Slot(), "root", libcommon.Hash(stateRoot), "latency", endTime)
503+
log.Info("[Caplin-Archive] Historical states antiquated", "slot", s.currentState.Slot(), "root", libcommon.Hash(stateRoot), "latency", endTime)
495504
if s.stateSn != nil {
496505
if err := s.stateSn.OpenFolder(); err != nil {
497506
return err

cl/phase1/stages/forkchoice.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,9 @@ func postForkchoiceOperations(ctx context.Context, tx kv.RwTx, logger log.Logger
307307
if _, err = cfg.attestationDataProducer.ProduceAndCacheAttestationData(tx, headState, headRoot, headState.Slot(), 0); err != nil {
308308
logger.Warn("failed to produce and cache attestation data", "err", err)
309309
}
310+
if err := beacon_indicies.WriteHighestFinalized(tx, cfg.forkChoice.FinalizedSlot()); err != nil {
311+
return err
312+
}
310313
start := time.Now()
311314
cfg.forkChoice.SetSynced(true) // Now we are synced
312315
// Update the head state with the new head state

0 commit comments

Comments
 (0)