Skip to content

Commit d154a95

Browse files
authored
fix: use correct startSlot when calculating cl-rewards with conssolidations (#1574)
Co-authored-by: Patrick Pfeiffer <306324+guybrush@users.noreply.github.com>
1 parent 7506c05 commit d154a95

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

backend/pkg/commons/db/statistics.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ func WriteValidatorStatisticsForDay(day uint64, client rpc.Client) error {
281281

282282
defer func() {
283283
err := tx.Rollback(context.Background())
284-
if err != nil {
284+
if err != nil && err != pgx.ErrTxClosed {
285285
log.Error(err, "error rolling back transaction", 0)
286286
}
287287
}()
@@ -1196,7 +1196,10 @@ func gatherValidatorConsolidations(day uint64, data []*types.ValidatorStatsTable
11961196
metrics.TaskDuration.WithLabelValues("db_update_validator_consolidations_stats").Observe(time.Since(exportStart).Seconds())
11971197
}()
11981198

1199-
firstSlot := day * utils.EpochsPerDay() * utils.Config.Chain.ClConfig.SlotsPerEpoch
1199+
firstSlot := uint64(0)
1200+
if day > 0 {
1201+
firstSlot = utils.GetLastBalanceInfoSlotForDay(day-1) + 1
1202+
}
12001203
lastSlot := utils.GetLastBalanceInfoSlotForDay(day)
12011204

12021205
fields := log.Fields{
@@ -1205,7 +1208,7 @@ func gatherValidatorConsolidations(day uint64, data []*types.ValidatorStatsTable
12051208
"lastSlot": lastSlot,
12061209
}
12071210

1208-
log.Info("gathering consolidation statistics", fields)
1211+
log.InfoWithFields(fields, "gathering consolidation statistics")
12091212
var consolidationData []struct {
12101213
SourceIndex int `db:"source_index"`
12111214
TargetIndex int `db:"target_index"`

0 commit comments

Comments
 (0)