Skip to content

Commit 344d5b6

Browse files
authored
Fix housekeeper registerValidator DB query (#733)
* housekeeper registerValidator conversion: add debug data * added more logging for updateValidatorRegistrationsInRedis
1 parent 5d6caae commit 344d5b6

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

services/housekeeper/housekeeper.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,29 +250,38 @@ func (hk *Housekeeper) UpdateProposerDutiesWithoutChecks(headSlot uint64) {
250250

251251
// updateValidatorRegistrationsInRedis saves all latest validator registrations from the database to Redis
252252
func (hk *Housekeeper) updateValidatorRegistrationsInRedis() {
253-
regs, err := hk.db.GetLatestValidatorRegistrations(true)
253+
log := hk.log
254+
log.Infof("updateValidatorRegistrationsInRedis: getting registrations from DB...")
255+
256+
timeStarted := time.Now()
257+
regs, err := hk.db.GetLatestValidatorRegistrations(false)
254258
if err != nil {
255-
hk.log.WithError(err).Error("failed to get latest validator registrations")
259+
log.WithError(err).Error("failed to get latest validator registrations")
256260
return
257261
}
258262

259-
hk.log.Infof("updating %d validator registrations in Redis...", len(regs))
260-
timeStarted := time.Now()
263+
log = log.WithFields(logrus.Fields{
264+
"numRegistrations": len(regs),
265+
"timeNeededDBSec": time.Since(timeStarted).Seconds(),
266+
})
267+
log.Info("updateValidatorRegistrationsInRedis: got registrations from DB, updating Redis (this may take a while)...")
261268

269+
timeStarted = time.Now()
262270
for _, reg := range regs {
263271
// convert DB data to original struct
264272
data, err := reg.ToSignedValidatorRegistration()
265273
if err != nil {
266-
hk.log.WithError(err).Error("failed to convert validator registration entry to signed validator registration")
274+
log.WithError(err).Error("failed to convert validator registration entry to signed validator registration")
267275
continue
268276
}
269277

270278
// save to Redis
271279
err = hk.redis.SetValidatorRegistrationData(data.Message)
272280
if err != nil {
273-
hk.log.WithError(err).Error("failed to set validator registration")
281+
log.WithError(err).Error("failed to set validator registration")
274282
continue
275283
}
276284
}
277-
hk.log.Infof("updating %d validator registrations in Redis done - %f sec", len(regs), time.Since(timeStarted).Seconds())
285+
286+
log.WithField("timeNeededRedisSec", time.Since(timeStarted).Seconds()).Info("updateValidatorRegistrationsInRedis: updating Redis done")
278287
}

0 commit comments

Comments
 (0)