Skip to content

Commit 845d053

Browse files
authored
Merge pull request #250 from lidofinance/develop
Develop to main
2 parents 4072905 + 50d8f20 commit 845d053

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

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

Lines changed: 13 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=${ms}) 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,18 @@ 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 past (recalculated finalizationIn=${ms}). Fallback to next frame`,
352+
);
353+
finalizationIn =
354+
this.genesisTimeService.timeToWithdrawalFrame(currentFrame + 1, requestTimestamp) + GAP_AFTER_REPORT;
355+
}
356+
345357
return {
346358
type: currentType,
347359
finalizationIn,

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,7 +2512,7 @@ brace-expansion@^2.0.1:
25122512
dependencies:
25132513
balanced-match "^1.0.0"
25142514

2515-
braces@^3.0.2, braces@~3.0.2:
2515+
braces@^3.0.3, braces@~3.0.2:
25162516
version "3.0.3"
25172517
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
25182518
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
@@ -5013,11 +5013,11 @@ methods@^1.1.2:
50135013
integrity sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==
50145014

50155015
micromatch@^4.0.0, micromatch@^4.0.4:
5016-
version "4.0.5"
5017-
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6"
5018-
integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==
5016+
version "4.0.8"
5017+
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202"
5018+
integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==
50195019
dependencies:
5020-
braces "^3.0.2"
5020+
braces "^3.0.3"
50215021
picomatch "^2.3.1"
50225022

50235023

0 commit comments

Comments
 (0)