Skip to content

Commit 798be29

Browse files
committed
feat: added logs for negative finalisation time
1 parent 64bccae commit 798be29

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/waiting-time/waiting-time.service.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,17 @@ export class WaitingTimeService {
320320
const requests = this.queueInfo.getRequests();
321321
const requestTimestamp = request.timestamp.toNumber() * 1000;
322322
const queueStETH = calculateUnfinalizedEthToRequestId(requests, request);
323+
const currentFrame = this.genesisTimeService.getFrameOfEpoch(this.genesisTimeService.getCurrentEpoch());
323324

324325
let currentType = type;
325326
let ms = this.genesisTimeService.timeToWithdrawalFrame(frame, requestTimestamp);
326327
let finalizationIn = validateTimeResponseWithFallback(ms) + GAP_AFTER_REPORT;
327328
const isInPast = requestTimestamp + ms - Date.now() < 0;
328329

329330
if (isInPast) {
331+
this.logger.warn(
332+
`Request with id ${request.id} was calculated with finalisation in past (finalizationIn=${finalizationIn}) and going to be recalculated`,
333+
);
330334
// if calculation wrong points to past then validators is not excited in time
331335
// we need recalculate
332336
const recalculatedResult = await this.calculateWithdrawalFrame({
@@ -338,10 +342,17 @@ export class WaitingTimeService {
338342
});
339343

340344
ms = this.genesisTimeService.timeToWithdrawalFrame(recalculatedResult.frame, requestTimestamp);
341-
finalizationIn = validateTimeResponseWithFallback(ms) + GAP_AFTER_REPORT;
342345
currentType = recalculatedResult.type;
343346
}
344347

348+
// temporary fallback for negative results, can be deleted after validator balances computation improvements
349+
if (ms < 0) {
350+
this.logger.warn(
351+
`Request with id ${request.id} was recalculated and finalisation still in points to past (recalculated finalizationIn=${ms}). Fallback to next frame`,
352+
);
353+
finalizationIn = this.genesisTimeService.timeToWithdrawalFrame(currentFrame + 1, requestTimestamp);
354+
}
355+
345356
return {
346357
type: currentType,
347358
finalizationIn,

0 commit comments

Comments
 (0)