Skip to content

Commit d6c36a2

Browse files
committed
feat: remove sleep, check 0x01 0x02 WC, check file is empty
1 parent ab2ac50 commit d6c36a2

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

features/consolidation.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
ValidatorsInfo,
2222
showSpinner,
2323
logResult,
24-
sleep,
2524
} from 'utils';
2625
import { getVaultHubContract } from 'contracts';
2726
import { waitForTransactionReceipt } from 'viem/actions';
@@ -274,8 +273,6 @@ export const checkValidators = async (
274273
}
275274
await checkSourceValidators(sourceValidatorsInfo.data, finalizedEpoch);
276275

277-
await sleep(1000); // to fight with too many requests issue
278-
279276
const targetValidatorsInfo = await fetchValidatorsInfo(targetPubkeys);
280277
if (targetValidatorsInfo.data == null) {
281278
throw new Error('targetValidatorsInfo.data is null');

utils/arguments.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export const jsonToPermit = (value: string) => {
3333

3434
export const jsonFileToPubkeys = (value: string) => {
3535
const content = readFileSync(value, 'utf-8');
36+
if (content.length === 0) {
37+
throw new Error('File is empty');
38+
}
3639
return JSON.parse(content) as Pubkeys;
3740
};
3841

utils/validators-checks.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,19 @@ export const checkSourceValidators = async (
1414
notActiveValidators.map((v) => v.validator.pubkey).join(', '),
1515
);
1616

17-
const wrongWCSourceValidators = sourceValidatorsInfoData.filter((validator) =>
18-
validator.validator.withdrawal_credentials.startsWith('0x00'),
17+
const correctWCSourceValidators = sourceValidatorsInfoData.filter(
18+
(validator) =>
19+
validator.validator.withdrawal_credentials.startsWith('0x01') ||
20+
validator.validator.withdrawal_credentials.startsWith('0x02'),
1921
);
22+
2023
assert(
21-
wrongWCSourceValidators.length === 0,
24+
sourceValidatorsInfoData.length === correctWCSourceValidators.length,
2225
'All source pubkeys must have a withdrawal credentials starting with 0x01 or 0x02. Wrong pubkeys:' +
23-
wrongWCSourceValidators.map((v) => v.validator.pubkey).join(', '),
26+
sourceValidatorsInfoData
27+
.filter((validator) => !correctWCSourceValidators.includes(validator))
28+
.map((v) => v.validator.pubkey)
29+
.join(', '),
2430
);
2531

2632
const sourceValidatorsWithLess256Epochs = sourceValidatorsInfoData.filter(

0 commit comments

Comments
 (0)