Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge stage to main #73

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
df3ee6b
fix memory leak
alexstolr Nov 27, 2023
a028495
remove empty try catch
alexstolr Nov 28, 2023
ca9c1a5
Merge pull request #71 from bloxapp/alexstolr/mem-leak
alexstolr Nov 29, 2023
fd17063
set log level to log (above debug) unless debug explicitly stated
alexstolr Nov 29, 2023
02ed356
add some config prints.
alexstolr Nov 29, 2023
8a80f59
fix bug. App starts even when private key not provided
alexstolr Nov 30, 2023
21efd4c
use custom logger
alexstolr Dec 3, 2023
1c8d259
change all loggers to custom logger
alexstolr Dec 3, 2023
8f0c908
remove unused import
alexstolr Dec 3, 2023
80a9327
Updated all contracts ABI
Dec 5, 2023
3ba7999
Address CR comments.
alexstolr Dec 5, 2023
6a121fb
Merge pull request #72 from bloxapp/alexstolr/4882431538-logs
alexstolr Dec 10, 2023
896e8bf
extended revert logic (#75)
vadiminc Dec 26, 2023
3358409
fix abi addresses
vadiminc Dec 28, 2023
16ec96e
Merge pull request #76 from bloxapp/vc/fix-abi-addresses
Dec 28, 2023
cdd9b4b
Merge pull request #74 from bloxapp/dm/5573351206_updated_abi
Dec 28, 2023
e10eec2
bug fix. release lock when not synced yet.
alexstolr Jan 1, 2024
7857778
Merge pull request #77 from bloxapp/alexstolr/liquidation-bug
alexstolr Jan 2, 2024
1b4a60d
potential stage fix (#78)
vadiminc Jan 18, 2024
47f41d1
Remove Prater liquidatory
zevzek Apr 18, 2024
ee387b7
Merge pull request #79 from ssvlabs/remove-prater-liquidator
systemblox Apr 18, 2024
fb4117b
updated ABIs to latest versions
Sep 5, 2024
b0dabec
Merge pull request #84 from ssvlabs/update-abis-and-code-cleanup
IlyaVi Sep 5, 2024
9bbea8b
Updated gitlab-ci file and removed ci/cd for stage AWS
zevzek Sep 12, 2024
7a9cb2a
Merge pull request #85 from ssvlabs/update-gitlab-ci-file
IlyaVi Sep 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,7 @@ mongo
# Docker compose ganarated files
db-data

.env
.env

# Ignore macOS files
.DS_Store
30 changes: 28 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,33 @@
"Injectable",
"microservices",
"nestjs",
"postgres"
"postgres",
"typeorm"
],
"editor.detectIndentation": false
"editor.detectIndentation": false,
"typescript.tsdk": "node_modules/typescript/lib",
"editor.minimap.renderCharacters": true,
"workbench.editor.decorations.colors": true,
"git.allowNoVerifyCommit": true,
// Formatting
"editor.formatOnSave": true,
"prettier.eslintIntegration": true,
"eslint.run": "onType",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.fontFamily": "Operator Mono, Menlo, Monaco, 'Courier New', monospace",
"terminal.integrated.fontFamily": "'Operator Mono', 'Inconsolata for Powerline', monospace",
// SOP's highlight matching tag setting.
"highlight-matching-tag.styles": {
"opening": {
"full": {
"highlight": "rgba(165, 153, 233, 0.3)"
}
}
},
// SOP's Import Cost Extension Settings.
"importCost.largePackageColor": "#EC3A37F5",
"importCost.mediumPackageColor": "#B362FF",
"importCost.smallPackageColor": "#B362FF"
}
12 changes: 12 additions & 0 deletions src/exceptions/base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export class SSVLiquidatorException extends Error {
public data: any;
public hash: any;

constructor(message: string, data: any, hash?: string) {
super(message);
this.name = this.constructor.name;
this.data = data;
this.hash = hash;
Error.captureStackTrace(this, this.constructor);
}
}
4 changes: 3 additions & 1 deletion src/modules/clusters/cli/cluster.transformer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import TimeAgo from 'javascript-time-ago';
import en from 'javascript-time-ago/locale/en';
import { CustomLogger } from '@cli/shared/services/logger.service';

TimeAgo.addLocale(en);
const timeAgo = new TimeAgo('en-US');
Expand Down Expand Up @@ -45,6 +46,7 @@ const textStatus = (item, extra: any) => {
* @returns List of custom formatted pod data
*/
export const transformClusterData = (items, extra: any) => {
const logger = new CustomLogger('ClusterDataTransformer');
const clusters = [];
try {
for (let i = 0; i < items.length; i++) {
Expand Down Expand Up @@ -80,7 +82,7 @@ export const transformClusterData = (items, extra: any) => {
return order.indexOf(a.status.text) - order.indexOf(b.status.text);
});
} catch (e) {
console.log(e);
logger.error(`Failed to transform cluster data. ${e}`);
}
return clusters;
};
5 changes: 4 additions & 1 deletion src/modules/earnings/cli/earning.transformer.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { CustomLogger } from '@cli/shared/services/logger.service';

/**
* It transforms the items object from sqlite into a custom format
* @param {Array<>} items list of clusters object from the sqlite
* @returns List of custom formatted pod data
*/
export const transformEarningData = items => {
const logger = new CustomLogger('EarningDataTransformer');
const earnings = [];
try {
for (let i = 0; i < items.length; i++) {
Expand All @@ -16,7 +19,7 @@ export const transformEarningData = items => {
});
}
} catch (e) {
console.log(e);
logger.error(`Failed to transform earning data. ${e}`);
}
return earnings;
};
2 changes: 1 addition & 1 deletion src/modules/webapp/metrics/metrics.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class MetricsController {
private async collectStats() {
const clustersActive = await this._clusterService.countActive();
const toLiquidate = await this._clusterService.countLiquidatable();
const liquidatorETHBalance = await this._web3Provider.getETHBalance();
const liquidatorETHBalance = await this._web3Provider.getLiquidatorETHBalance();
this._metricsService.totalActiveClusters.set(clustersActive);
this._metricsService.totalLiquidatableClusters.set(toLiquidate.total);
this._metricsService.burnt10LiquidatableClusters.set(toLiquidate.burnt10);
Expand Down
8 changes: 5 additions & 3 deletions src/services/worker/cron/burn-rates.cron.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { Injectable } from '@nestjs/common';
import { Cron } from '@nestjs/schedule';
import { Cron, CronExpression } from '@nestjs/schedule';

import { BurnRatesTask } from '../tasks/burn-rates.task';
import { CustomLogger } from '@cli/shared/services/logger.service';

@Injectable()
export class BurnRateCron {
private readonly _logger = new CustomLogger(BurnRatesTask.name);
constructor(private _burnRatesTask: BurnRatesTask) {}

@Cron('*/10 * * * * *')
@Cron(CronExpression.EVERY_10_SECONDS)
async syncBurnRates(): Promise<void> {
try {
await this._burnRatesTask.syncBurnRates();
} catch (e) {
console.log('syncBurnRates', e);
this._logger.error(e);
}
}
}
8 changes: 5 additions & 3 deletions src/services/worker/cron/fetch.cron.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { Injectable } from '@nestjs/common';

import { Cron } from '@nestjs/schedule';
import { Cron, CronExpression } from '@nestjs/schedule';
import { FetchTask } from '../tasks/fetch.task';
import { CustomLogger } from '@cli/shared/services/logger.service';

@Injectable()
export class FetchCron {
private readonly _logger = new CustomLogger(FetchCron.name);
constructor(private _fetchTask: FetchTask) {}

@Cron('* * * * * *')
@Cron(CronExpression.EVERY_SECOND)
async fetchNewValidators(): Promise<void> {
try {
await this._fetchTask.fetchAllEvents();
} catch (e) {
console.log(e);
this._logger.error(`Fetching new validators cron task failed. ${e}`);
}
}
}
8 changes: 5 additions & 3 deletions src/services/worker/cron/liquidation.cron.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { Injectable } from '@nestjs/common';
import { Cron } from '@nestjs/schedule';
import { Cron, CronExpression } from '@nestjs/schedule';

import { LiquidationTask } from '../tasks/liquidation.task';
import { CustomLogger } from '@cli/shared/services/logger.service';

@Injectable()
export class LiquidationCron {
private readonly _logger = new CustomLogger(LiquidationCron.name);
constructor(private _liquidationTask: LiquidationTask) {}

@Cron('*/10 * * * * *')
@Cron(CronExpression.EVERY_10_SECONDS)
async liquidate(): Promise<void> {
try {
await this._liquidationTask.liquidate();
} catch (e) {
console.log(e);
this._logger.error(e);
}
}
}
7 changes: 3 additions & 4 deletions src/services/worker/tasks/burn-rates.task.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import { Injectable, Logger } from '@nestjs/common';
import { ConfService } from '@cli/shared/services/conf.service';
import { Injectable } from '@nestjs/common';
import {
Web3Provider,
ERROR_CLUSTER_LIQUIDATED,
} from '@cli/shared/services/web3.provider';
import { ClusterService } from '@cli/modules/clusters/cluster.service';
import { MetricsService } from '@cli/modules/webapp/metrics/services/metrics.service';
import { SystemService, SystemType } from '@cli/modules/system/system.service';
import { CustomLogger } from '@cli/shared/services/logger.service';

@Injectable()
export class BurnRatesTask {
private static CURRENT_BATCH_SIZE = 100;
private static BATCH_SIZE_RATIO = 0.9;
private static MINIMUM_BATCH_SIZE = 10;
private static isProcessLocked = false;
private readonly _logger = new Logger(BurnRatesTask.name);
private readonly _logger = new CustomLogger(BurnRatesTask.name);

constructor(
private _config: ConfService,
private _clusterService: ClusterService,
private _metricsService: MetricsService,
private _systemService: SystemService,
Expand Down
14 changes: 3 additions & 11 deletions src/services/worker/tasks/fetch.task.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Injectable, Logger } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { WorkerService } from '@cli/services/worker/worker.service';
import { SystemService, SystemType } from '@cli/modules/system/system.service';
import { MetricsService } from '@cli/modules/webapp/metrics/services/metrics.service';
import { Web3Provider } from '@cli/shared/services/web3.provider';
import { CustomLogger } from '@cli/shared/services/logger.service';

@Injectable()
export class FetchTask {
private static isProcessLocked = false;
private readonly _logger = new Logger(FetchTask.name);
private readonly _logger = new CustomLogger(FetchTask.name);

constructor(
private _systemService: SystemService,
Expand All @@ -33,15 +34,6 @@ export class FetchTask {
return;
}

try {
await this._web3Provider.getLiquidationThresholdPeriod();
// HERE we can validate the contract owner address
} catch (err) {
throw new Error(
`'The provided contract address is not valid. Error: ${err}`,
);
}

const latestSyncedBlockNumber = await this._systemService.get(
SystemType.GENERAL_LAST_BLOCK_NUMBER,
);
Expand Down
Loading