Skip to content

Commit

Permalink
Merge pull request #250 from lidofinance/develop
Browse files Browse the repository at this point in the history
Develop to main
  • Loading branch information
Tarens2 authored Sep 4, 2024
2 parents 4072905 + 50d8f20 commit 845d053
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 13 additions & 1 deletion src/waiting-time/waiting-time.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,17 @@ export class WaitingTimeService {
const requests = this.queueInfo.getRequests();
const requestTimestamp = request.timestamp.toNumber() * 1000;
const queueStETH = calculateUnfinalizedEthToRequestId(requests, request);
const currentFrame = this.genesisTimeService.getFrameOfEpoch(this.genesisTimeService.getCurrentEpoch());

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

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

ms = this.genesisTimeService.timeToWithdrawalFrame(recalculatedResult.frame, requestTimestamp);
finalizationIn = validateTimeResponseWithFallback(ms) + GAP_AFTER_REPORT;
currentType = recalculatedResult.type;
}

// temporary fallback for negative results, can be deleted after validator balances computation improvements
if (ms < 0) {
this.logger.warn(
`Request with id ${request.id} was recalculated and finalisation still in past (recalculated finalizationIn=${ms}). Fallback to next frame`,
);
finalizationIn =
this.genesisTimeService.timeToWithdrawalFrame(currentFrame + 1, requestTimestamp) + GAP_AFTER_REPORT;
}

return {
type: currentType,
finalizationIn,
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2512,7 +2512,7 @@ brace-expansion@^2.0.1:
dependencies:
balanced-match "^1.0.0"

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

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

[email protected]:
Expand Down

0 comments on commit 845d053

Please sign in to comment.