Skip to content

Commit 21f6801

Browse files
committed
fix: code clean up
1 parent 141110b commit 21f6801

File tree

6 files changed

+18
-19
lines changed

6 files changed

+18
-19
lines changed

src/common/sweep/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export * from './sweep.module';
22
export * from './sweep.service';
3-
export * from './sweep.constants';

src/common/sweep/sweep.constants.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/common/sweep/sweep.service.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
import { Inject, Injectable, LoggerService } from '@nestjs/common';
22
import { LOGGER_PROVIDER } from '@lido-nestjs/logger';
3-
import { GenesisTimeService, SLOTS_PER_EPOCH } from '../genesis-time';
3+
import { SLOTS_PER_EPOCH } from '../genesis-time';
44
import {
55
isFullyWithdrawableValidator,
66
isPartiallyWithdrawableValidator,
77
} from '../../jobs/validators/utils/validator-state-utils';
88
import { FAR_FUTURE_EPOCH } from '../../jobs/validators';
9-
import {
10-
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP,
11-
MAX_WITHDRAWALS_PER_PAYLOAD,
12-
MIN_ACTIVATION_BALANCE,
13-
} from './sweep.constants';
149
import { ConsensusClientService } from '../consensus-provider/consensus-client.service';
1510
import { parseGwei } from '../utils/parse-gwei';
1611
import { bigNumberMin } from '../utils/big-number-min';
@@ -21,6 +16,11 @@ import { OracleV2__factory } from '../contracts/generated';
2116
import { VALIDATORS_EXIT_BUS_ORACLE_CONTRACT_ADDRESSES } from '../contracts/modules/validators-exit-bus-oracle/validators-exit-bus-oracle.constants';
2217
import { ConfigService } from '../config';
2318
import { SimpleFallbackJsonRpcBatchProvider } from '@lido-nestjs/execution';
19+
import {
20+
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP,
21+
MAX_WITHDRAWALS_PER_PAYLOAD,
22+
MIN_ACTIVATION_BALANCE,
23+
} from '../../waiting-time/waiting-time.constants';
2424

2525
@Injectable()
2626
export class SweepService {

src/waiting-time/utils/calculate-sweeping-mean.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { BigNumber } from '@ethersproject/bignumber';
33
import { SLOTS_PER_EPOCH } from 'common/genesis-time';
44
import { MAX_WITHDRAWALS_PER_PAYLOAD } from 'waiting-time/waiting-time.constants';
55

6-
// time to scan all validators and try to withdraw it
6+
/**
7+
* @deprecated
8+
* time to scan all validators and try to withdraw it
9+
*/
710
export const calculateSweepingMean = (totalValidators: number) => {
811
return BigNumber.from(totalValidators).div(BigNumber.from(MAX_WITHDRAWALS_PER_PAYLOAD).mul(SLOTS_PER_EPOCH)).div(2);
912
};

src/waiting-time/waiting-time.constants.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ import { parseEther } from '@ethersproject/units';
33
export const MIN_PER_EPOCH_CHURN_LIMIT = 4;
44
export const CHURN_LIMIT_QUOTIENT = 65536; // 2**16
55

6-
// todo: rename to MIN_ACTIVATION_BALANCE
7-
export const MAX_EFFECTIVE_BALANCE = parseEther('32'); // ETH
6+
// note: currently all lido validators continues holding 32 eth,
7+
// but after electra upgrade maximum in network increased to 2048 eth
8+
export const MIN_ACTIVATION_BALANCE = parseEther('32'); // ETH
89

910
export const MAX_EFFECTIVE_BALANCE_ELECTRA = parseEther('2048');
1011

1112
export const MAX_WITHDRAWALS_PER_PAYLOAD = 2 ** 4;
1213

14+
export const MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP = 2 ** 3;
15+
1316
export const GAP_AFTER_REPORT = 30 * 60 * 1000; // 30 mins
1417

1518
export const WITHDRAWAL_BUNKER_DELAY_FRAMES = 14;

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ import { RewardsService } from 'events/rewards';
1616
import {
1717
CHURN_LIMIT_QUOTIENT,
1818
GAP_AFTER_REPORT,
19-
MAX_EFFECTIVE_BALANCE,
19+
MIN_ACTIVATION_BALANCE,
2020
MIN_PER_EPOCH_CHURN_LIMIT,
2121
WITHDRAWAL_BUNKER_DELAY_FRAMES,
2222
} from './waiting-time.constants';
2323
import {
2424
validateTimeResponseWithFallback,
2525
calculateUnfinalizedEthToRequestId,
2626
calculateFrameByValidatorBalances,
27-
calculateSweepingMean,
2827
} from './utils';
2928
import { transformToRequestDto } from './dto';
3029
import {
@@ -277,7 +276,7 @@ export class WaitingTimeService {
277276

278277
// number epochs needed for closing unfinalizedETH dividing on validator balances and rewards
279278
const lidoQueueInEpochBeforeVEBOExitLimit = unfinalizedETH.div(
280-
MAX_EFFECTIVE_BALANCE.mul(Math.floor(churnLimit)).add(rewardsPerEpoch),
279+
MIN_ACTIVATION_BALANCE.mul(Math.floor(churnLimit)).add(rewardsPerEpoch),
281280
);
282281

283282
// number of validators to exit
@@ -473,7 +472,7 @@ export class WaitingTimeService {
473472

474473
const churnLimit = Math.max(MIN_PER_EPOCH_CHURN_LIMIT, totalValidators / CHURN_LIMIT_QUOTIENT);
475474

476-
const lidoQueueInEpoch = unfinalizedETH.div(MAX_EFFECTIVE_BALANCE.mul(Math.floor(churnLimit)));
475+
const lidoQueueInEpoch = unfinalizedETH.div(MIN_ACTIVATION_BALANCE.mul(Math.floor(churnLimit)));
477476
const sweepingMean = this.validators.getSweepMeanEpochs();
478477
const potentialExitEpoch = BigNumber.from(latestEpoch).add(lidoQueueInEpoch).add(sweepingMean);
479478

0 commit comments

Comments
 (0)