diff --git a/beacon-light-client/plonky2/get_balances_input/get_balances_input.ts b/beacon-light-client/plonky2/get_balances_input/get_balances_input.ts index df30e08ca..1766a330f 100644 --- a/beacon-light-client/plonky2/get_balances_input/get_balances_input.ts +++ b/beacon-light-client/plonky2/get_balances_input/get_balances_input.ts @@ -15,6 +15,7 @@ import { computeEpochAt } from '../../../libs/typescript/ts-utils/ssz-utils'; import validator_commitment_constants from '../constants/validator_commitment_constants.json'; import config from "../common_config.json"; import { Validator } from '../../../relay/types/types'; +import { CommandLineOptionsBuilder } from '../cmdline'; const CIRCUIT_SIZE = 8; let TAKE: number; @@ -22,24 +23,9 @@ let TAKE: number; (async () => { const { ssz } = await import('@lodestar/types'); - const options = yargs - .usage( - 'Usage: -redis-host -redis-port -take ', - ) - .option('redis-host ', { - alias: 'redis-host', - describe: 'The Redis host', - type: 'string', - default: config['redis-host'], - description: 'Sets a custom redis connection', - }) - .option('redis-port', { - alias: 'redis-port', - describe: 'The Redis port', - type: 'number', - default: Number(config['redis-port']), - description: 'Sets a custom redis connection', - }) + const options = new CommandLineOptionsBuilder() + .usage('Usage: -redis-host -redis-port -take ') + .withRedisOpts() .option('beacon-node', { alias: 'beacon-node', describe: 'The beacon node url', @@ -68,12 +54,13 @@ let TAKE: number; default: false, description: 'Runs the tool without doing actual calculations.', }) - .options('offset', { + .option('offset', { alias: 'offset', describe: 'Index offset in the validator set', type: 'number', default: undefined, - }).argv; + }) + .build(); const redis = new RedisLocal(options['redis-host'], options['redis-port']); diff --git a/beacon-light-client/plonky2/validators_commitment_mapper_tree/delete_old_data.ts b/beacon-light-client/plonky2/validators_commitment_mapper_tree/delete_old_data.ts index 62e77a82c..d6806396c 100644 --- a/beacon-light-client/plonky2/validators_commitment_mapper_tree/delete_old_data.ts +++ b/beacon-light-client/plonky2/validators_commitment_mapper_tree/delete_old_data.ts @@ -1,34 +1,22 @@ import { Redis as RedisLocal } from '../../../relay/implementations/redis'; import validator_commitment_constants from '../constants/validator_commitment_constants.json'; -import yargs from 'yargs'; import { createProofStorage } from '../proof_storage/proof_storage'; +import { CommandLineOptionsBuilder } from '../cmdline'; + +require('dotenv').config({ path: '../.env' }); (async () => { - const options = yargs - .usage( - 'Usage: -redis-host -redis-port -take ', - ) - .option('redis-host ', { - alias: 'redis-host', - describe: 'The Redis host', - type: 'string', - default: '127.0.0.1', - description: 'Sets a custom redis connection', - }) - .option('redis-port', { - alias: 'redis-port', - describe: 'The Redis port', - type: 'number', - default: 6379, - description: 'Sets a custom redis connection', - }) + const options = new CommandLineOptionsBuilder() + .usage('Usage: -redis-host -redis-port -take ') + .withProofStorageOpts() .option('oldest-epoch', { alias: 'oldest-epoch', describe: 'The oldest epoch for which we keep data', type: 'number', demandOption: true, - }).argv; + }) + .build(); const redis = new RedisLocal(options['redis-host'], options['redis-port']); const proofStorage = createProofStorage(options) diff --git a/beacon-light-client/plonky2/validators_commitment_mapper_tree/get_changed_validators.ts b/beacon-light-client/plonky2/validators_commitment_mapper_tree/get_changed_validators.ts index b801e2333..e132f0bc2 100644 --- a/beacon-light-client/plonky2/validators_commitment_mapper_tree/get_changed_validators.ts +++ b/beacon-light-client/plonky2/validators_commitment_mapper_tree/get_changed_validators.ts @@ -1,67 +1,46 @@ -import yargs from 'yargs'; -import config from "../common_config.json"; +import { CommandLineOptionsBuilder } from '../cmdline'; import { CommitmentMapperScheduler } from './scheduler'; +import config from "../common_config.json"; (async () => { - const options = yargs - .usage( - 'Usage: -redis-host -redis-port -take ', - ) - .option('redis-host ', { - alias: 'redis-host', - describe: 'The Redis host', - type: 'string', - default: config['redis-host'], - description: 'Sets a custom redis connection', - }) - .option('redis-port', { - alias: 'redis-port', - describe: 'The Redis port', - type: 'number', - default: Number(config['redis-port']), - description: 'Sets a custom redis connection', - }) + const options = new CommandLineOptionsBuilder() + .usage('Usage: -redis-host -redis-port -take ') + .withRedisOpts() .option('beacon-node', { - alias: 'beacon-node', describe: 'The beacon node url', type: 'string', default: config['beacon-node'], description: 'Sets a custom beacon node url', }) .option('sync-epoch', { - alias: 'sync-epoch', describe: 'The sync epoch', type: 'number', default: undefined, description: 'Starts syncing from this epoch', }) - .options('offset', { - alias: 'offset', + .option('offset', { describe: 'Index offset in the validator set', type: 'number', default: undefined, }) .option('take', { - alias: 'take', describe: 'The number of validators to take', type: 'number', default: Infinity, description: 'Sets the number of validators to take', }) .option('mock', { - alias: 'mock', describe: 'Runs the tool without doing actual calculations', type: 'boolean', default: false, description: 'Runs the tool without doing actual calculations.', }) .option('run-once', { - alias: 'run-once', describe: 'Should run script for one epoch', type: 'boolean', default: false, }) - .argv; + .build(); const scheduler = new CommitmentMapperScheduler(); await scheduler.init(options);