Skip to content

Commit

Permalink
fix: unused module init (#182)
Browse files Browse the repository at this point in the history
* fix: structure, unused import

* fix: test

* fix: stub registry source

* fix: stub registry source
  • Loading branch information
vgorkavenko authored Jul 4, 2023
1 parent 19110ac commit 5ac00d7
Show file tree
Hide file tree
Showing 85 changed files with 179 additions and 268 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ jobs:
TEST_EPOCH_NUMBER: 152978
TEST_STATE_SLOT: 4895327
# stub
ETH_NETWORK: 1
EL_RPC_URLS: localhost
VALIDATOR_REGISTRY_SOURCE: file
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ By default, monitoring bot fetches validator keys from Lido contract, but you ca
2. Create file with keys by example [here](docker/validators/custom_mainnet.yaml)
3. Set `VALIDATOR_REGISTRY_FILE_SOURCE_PATH` env var to `<path to your file>`

If you want to implement your own source, it must match [RegistrySource interface](src/common/validators-registry/registry-source.interface.ts) and be included in [RegistryModule providers](src/common/validators-registry/registry.module.ts)
If you want to implement your own source, it must match [RegistrySource interface](src/validators-registry/registry-source.interface.ts) and be included in [RegistryModule providers](src/validators-registry/registry.module.ts)

## Application Env variables

Expand Down
15 changes: 1 addition & 14 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
import { Module } from '@nestjs/common';

import { ConfigModule } from 'common/config';
import { ContractsModule } from 'common/contracts';
import { EthProvidersModule } from 'common/eth-providers';
import { HealthModule } from 'common/health';
import { LoggerModule } from 'common/logger';
import { PrometheusModule } from 'common/prometheus';
import { ClickhouseModule } from 'storage/clickhouse';
import { DatabaseModule } from 'storage/database';

import { InspectorModule } from '../inspector';
import { AppService } from './app.service';

@Module({
imports: [
LoggerModule,
HealthModule,
PrometheusModule,
ConfigModule,
DatabaseModule,
ClickhouseModule,
InspectorModule,
ContractsModule,
EthProvidersModule,
],
imports: [LoggerModule, HealthModule, ConfigModule, PrometheusModule, ClickhouseModule, InspectorModule],
providers: [AppService],
})
export class AppModule {}
5 changes: 1 addition & 4 deletions src/app/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Inject, Injectable, LoggerService, OnApplicationBootstrap, OnModuleInit

import * as buildInfo from 'build-info';
import { ConfigService } from 'common/config';
import { ExecutionProviderService } from 'common/eth-providers';
import { PrometheusService } from 'common/prometheus';

import { InspectorService } from '../inspector';
Expand All @@ -16,20 +15,18 @@ export class AppService implements OnModuleInit, OnApplicationBootstrap {
protected readonly configService: ConfigService,
protected readonly prometheus: PrometheusService,
protected readonly inspectorService: InspectorService,
protected readonly executionProviderService: ExecutionProviderService,
) {}

public async onModuleInit(): Promise<void> {
const env = this.configService.get('NODE_ENV');
const startEpoch = this.configService.get('START_EPOCH');
const network = await this.executionProviderService.getNetworkName();
const version = buildInfo.version;
const commit = buildInfo.commit;
const branch = buildInfo.branch;
const name = APP_NAME;

this.prometheus.buildInfo.labels({ env, name, version, commit, branch }).inc();
this.logger.log('Init app', { env, network, name, version, startEpoch });
this.logger.log('Init app', { env, name, version, startEpoch });
this.logger.log(`DRY RUN ${this.configService.get('DRY_RUN') ? 'enabled' : 'disabled'}`);
this.logger.log(`Slot time: ${this.configService.get('CHAIN_SLOT_TIME_SECONDS')} seconds`);
this.logger.log(`Epoch size: ${this.configService.get('FETCH_INTERVAL_SLOTS')} slots`);
Expand Down
4 changes: 2 additions & 2 deletions src/common/alertmanager/alerts/BasicAlert.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ConfigService } from 'common/config';
import { Epoch } from 'common/eth-providers/consensus-provider/types';
import { RegistrySourceOperator } from 'common/validators-registry';
import { Epoch } from 'common/consensus-provider/types';
import { ClickhouseService } from 'storage';
import { RegistrySourceOperator } from 'validators-registry';

export interface AlertRequestBody {
startsAt: string;
Expand Down
4 changes: 2 additions & 2 deletions src/common/alertmanager/alerts/CriticalMissedAttestations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { join } from 'lodash';

import { sentAlerts } from 'common/alertmanager';
import { ConfigService } from 'common/config';
import { Epoch } from 'common/eth-providers/consensus-provider/types';
import { RegistrySourceOperator } from 'common/validators-registry';
import { Epoch } from 'common/consensus-provider/types';
import { ClickhouseService } from 'storage';
import { RegistrySourceOperator } from 'validators-registry';

import { Alert, AlertRequestBody, AlertRuleResult } from './BasicAlert';

Expand Down
4 changes: 2 additions & 2 deletions src/common/alertmanager/alerts/CriticalMissedProposes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { join } from 'lodash';

import { sentAlerts } from 'common/alertmanager';
import { ConfigService } from 'common/config';
import { Epoch } from 'common/eth-providers/consensus-provider/types';
import { RegistrySourceOperator } from 'common/validators-registry';
import { Epoch } from 'common/consensus-provider/types';
import { ClickhouseService } from 'storage';
import { RegistrySourceOperator } from 'validators-registry';

import { Alert, AlertRequestBody, AlertRuleResult } from './BasicAlert';

Expand Down
4 changes: 2 additions & 2 deletions src/common/alertmanager/alerts/CriticalNegativeDelta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { join } from 'lodash';

import { sentAlerts } from 'common/alertmanager';
import { ConfigService } from 'common/config';
import { Epoch } from 'common/eth-providers/consensus-provider/types';
import { RegistrySourceOperator } from 'common/validators-registry';
import { Epoch } from 'common/consensus-provider/types';
import { ClickhouseService } from 'storage';
import { RegistrySourceOperator } from 'validators-registry';

import { Alert, AlertRequestBody, AlertRuleResult } from './BasicAlert';

Expand Down
4 changes: 2 additions & 2 deletions src/common/alertmanager/alerts/CriticalSlashing.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { join } from 'lodash';

import { ConfigService } from 'common/config';
import { Epoch } from 'common/eth-providers/consensus-provider/types';
import { RegistrySourceOperator } from 'common/validators-registry';
import { Epoch } from 'common/consensus-provider/types';
import { ClickhouseService } from 'storage';
import { RegistrySourceOperator } from 'validators-registry';

import { Alert, AlertRequestBody, AlertRuleResult } from './BasicAlert';

Expand Down
3 changes: 1 addition & 2 deletions src/common/alertmanager/critical-alerts.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Module } from '@nestjs/common';

import { RegistryModule } from 'common/validators-registry';
import { ClickhouseModule } from 'storage/clickhouse';

import { CriticalAlertsService } from './critical-alerts.service';

@Module({
imports: [RegistryModule, ClickhouseModule],
imports: [ClickhouseModule],
providers: [CriticalAlertsService],
exports: [CriticalAlertsService],
})
Expand Down
4 changes: 2 additions & 2 deletions src/common/alertmanager/critical-alerts.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { Inject, Injectable } from '@nestjs/common';
import { got } from 'got-cjs';

import { ConfigService } from 'common/config';
import { Epoch } from 'common/eth-providers/consensus-provider/types';
import { Epoch } from 'common/consensus-provider/types';
import { PrometheusService } from 'common/prometheus';
import { RegistryService, RegistrySourceOperator } from 'common/validators-registry';
import { ClickhouseService } from 'storage';
import { RegistryService, RegistrySourceOperator } from 'validators-registry';

import { AlertRequestBody, PreparedToSendAlert } from './alerts/BasicAlert';
import { CriticalMissedAttestations } from './alerts/CriticalMissedAttestations';
Expand Down
8 changes: 4 additions & 4 deletions src/common/config/env.validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,14 @@ export class EnvironmentVariables {
@Min(1)
@Max(5000000)
@Transform(({ value }) => parseInt(value, 10), { toClassOnly: true })
@ValidateIf((vars) => vars.NODE_ENV != Environment.test)
@ValidateIf((vars) => vars.VALIDATOR_REGISTRY_SOURCE == ValidatorRegistrySource.Lido && vars.NODE_ENV != Environment.test)
public ETH_NETWORK!: Network;

@IsArray()
@ArrayMinSize(1)
@Transform(({ value }) => value.split(','))
@ValidateIf((vars) => vars.NODE_ENV != Environment.test)
public EL_RPC_URLS!: string[];
@ValidateIf((vars) => vars.VALIDATOR_REGISTRY_SOURCE == ValidatorRegistrySource.Lido && vars.NODE_ENV != Environment.test)
public EL_RPC_URLS: string[] = [];

@IsArray()
@ArrayMinSize(1)
Expand Down Expand Up @@ -185,7 +185,7 @@ export class EnvironmentVariables {
@ArrayMinSize(1)
@Transform(({ value }) => value.split(','))
@ValidateIf((vars) => vars.VALIDATOR_REGISTRY_SOURCE == ValidatorRegistrySource.KeysAPI && vars.NODE_ENV != Environment.test)
public VALIDATOR_REGISTRY_KEYSAPI_SOURCE_URLS = [];
public VALIDATOR_REGISTRY_KEYSAPI_SOURCE_URLS!: string[];

@IsInt()
@Transform(({ value }) => parseInt(value, 10), { toClassOnly: true })
Expand Down
File renamed without changes.
17 changes: 0 additions & 17 deletions src/common/contracts/contracts.module.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/common/contracts/index.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/common/eth-providers/eth-providers.module.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/common/eth-providers/index.ts

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion src/common/prometheus/prometheus.constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { APP_NAME } from '../../app';
import { APP_NAME } from 'app';

export const METRICS_URL = '/metrics';
export const METRICS_PREFIX = `${APP_NAME.replace(/[- ]/g, '_')}_`;
Expand Down
2 changes: 1 addition & 1 deletion src/common/prometheus/prometheus.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { join } from 'lodash';
import { LabelValues } from 'prom-client';

import { ConfigService } from 'common/config';
import { RegistrySourceOperator } from 'validators-registry';

import { RegistrySourceOperator } from '../validators-registry';
import { Metric, Options } from './interfaces';
import {
METRICS_PREFIX,
Expand Down
40 changes: 0 additions & 40 deletions src/common/validators-registry/registry.module.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/duty/attestation/attestation.metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { LOGGER_PROVIDER } from '@lido-nestjs/logger';
import { Inject, Injectable, LoggerService } from '@nestjs/common';

import { ConfigService } from 'common/config';
import { Epoch } from 'common/eth-providers/consensus-provider/types';
import { Epoch } from 'common/consensus-provider/types';
import { allSettled } from 'common/functions/allSettled';
import { PrometheusService, TrackTask, setOtherOperatorsMetric, setUserOperatorsMetric } from 'common/prometheus';
import { RegistryService, RegistrySourceOperator } from 'common/validators-registry';
import { ClickhouseService } from 'storage/clickhouse';
import { RegistryService, RegistrySourceOperator } from 'validators-registry';

enum BadAttReason {
HighIncDelay = 'high_inclusion_delay',
Expand Down
7 changes: 3 additions & 4 deletions src/duty/attestation/attestation.module.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { Module } from '@nestjs/common';

import { ConsensusProviderModule } from 'common/eth-providers';
import { RegistryModule } from 'common/validators-registry';
import { ConsensusProviderModule } from 'common/consensus-provider';
import { SummaryModule } from 'duty/summary';
import { ClickhouseModule } from 'storage/clickhouse';

import { SummaryModule } from '../summary';
import { AttestationMetrics } from './attestation.metrics';
import { AttestationRewards } from './attestation.rewards';
import { AttestationService } from './attestation.service';

@Module({
imports: [RegistryModule, ConsensusProviderModule, ClickhouseModule, SummaryModule],
imports: [ConsensusProviderModule, ClickhouseModule, SummaryModule],
providers: [AttestationService, AttestationMetrics, AttestationRewards],
exports: [AttestationService, AttestationMetrics, AttestationRewards],
})
Expand Down
4 changes: 2 additions & 2 deletions src/duty/attestation/attestation.rewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { LOGGER_PROVIDER } from '@lido-nestjs/logger';
import { Inject, Injectable, LoggerService } from '@nestjs/common';

import { ConfigService } from 'common/config';
import { Epoch } from 'common/eth-providers/consensus-provider/types';
import { Epoch } from 'common/consensus-provider/types';
import { unblock } from 'common/functions/unblock';
import { PrometheusService } from 'common/prometheus';
import { SummaryService } from 'duty/summary';

import { SummaryService } from '../summary';
import { getPenalties, getRewards } from './attestation.constants';

@Injectable()
Expand Down
6 changes: 3 additions & 3 deletions src/duty/attestation/attestation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import { streamArray } from 'stream-json/streamers/StreamArray';
import { batch } from 'stream-json/utils/Batch';

import { ConfigService } from 'common/config';
import { AttestationCommitteeInfo, ConsensusProviderService } from 'common/eth-providers';
import { Epoch, Slot } from 'common/eth-providers/consensus-provider/types';
import { AttestationCommitteeInfo, ConsensusProviderService } from 'common/consensus-provider';
import { Epoch, Slot } from 'common/consensus-provider/types';
import { allSettled } from 'common/functions/allSettled';
import { range } from 'common/functions/range';
import { unblock } from 'common/functions/unblock';
import { PrometheusService, TrackTask } from 'common/prometheus';
import { SummaryService } from 'duty/summary';

import { SummaryService } from '../summary';
import { getFlags } from './attestation.constants';

interface SlotAttestation {
Expand Down
2 changes: 1 addition & 1 deletion src/duty/duty.metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { LOGGER_PROVIDER } from '@lido-nestjs/logger';
import { Inject, Injectable, LoggerService } from '@nestjs/common';

import { ConfigService } from 'common/config';
import { Epoch } from 'common/eth-providers/consensus-provider/types';
import { allSettled } from 'common/functions/allSettled';
import { PrometheusService, TrackTask } from 'common/prometheus';

import { Epoch } from '../common/consensus-provider/types';
import { ClickhouseService } from '../storage';
import { AttestationMetrics } from './attestation';
import { ProposeMetrics } from './propose';
Expand Down
6 changes: 2 additions & 4 deletions src/duty/duty.module.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Module } from '@nestjs/common';

import { ConsensusProviderModule } from 'common/eth-providers';
import { BlockCacheModule } from 'common/eth-providers/consensus-provider/block-cache';
import { RegistryModule } from 'common/validators-registry';
import { ConsensusProviderModule } from 'common/consensus-provider';
import { BlockCacheModule } from 'common/consensus-provider/block-cache';
import { ClickhouseModule } from 'storage/clickhouse';

import { AttestationModule } from './attestation';
Expand All @@ -26,7 +25,6 @@ import { WithdrawalsModule } from './withdrawal';
ConsensusProviderModule,
BlockCacheModule,
ClickhouseModule,
RegistryModule,
],
providers: [DutyService, DutyMetrics, DutyRewards],
exports: [DutyService, DutyMetrics],
Expand Down
2 changes: 1 addition & 1 deletion src/duty/duty.rewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { LOGGER_PROVIDER } from '@lido-nestjs/logger';
import { Inject, Injectable, LoggerService } from '@nestjs/common';

import { ConfigService } from 'common/config';
import { Epoch } from 'common/eth-providers/consensus-provider/types';
import { allSettled } from 'common/functions/allSettled';
import { PrometheusService, TrackTask } from 'common/prometheus';

import { Epoch } from '../common/consensus-provider/types';
import { AttestationRewards } from './attestation';
import { ProposeRewards } from './propose';
import { SyncRewards } from './sync';
Expand Down
Loading

0 comments on commit 5ac00d7

Please sign in to comment.