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

dev to goerli #230

Merged
merged 97 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
9c158bc
avro streams
AlexandrMov Sep 6, 2023
0f19704
fix e2e
AlexandrMov Sep 18, 2023
e382803
Merge branch 'feat/VAL-189-sr-modules-support' into feat/val-255-sr-m…
AlexandrMov Sep 25, 2023
e017147
pull new code
AlexandrMov Sep 25, 2023
24cc07d
fix e2e tests
AlexandrMov Sep 26, 2023
40d9f97
Merge branch 'develop' into feat/val-255-sr-modules-operators-keys-st…
AlexandrMov Sep 27, 2023
e3f9f51
Merge branch 'develop' into feat/val-255-sr-modules-operators-keys-st…
AlexandrMov Sep 29, 2023
696eced
Merge branch 'develop' into feat/val-255-sr-modules-operators-keys-st…
AlexandrMov Oct 10, 2023
1660b7e
Merge branch 'develop' into feat/val-255-sr-modules-operators-keys-st…
AlexandrMov Oct 18, 2023
9f02fe4
VAL-369: Use postgres in e2e
AlexandrMov Oct 20, 2023
7e729eb
feat: github service-container for e2e tests
AlexandrMov Oct 23, 2023
da5001b
fix: ci
AlexandrMov Oct 23, 2023
0443692
fix tests
AlexandrMov Oct 23, 2023
f14ee77
revert changes
AlexandrMov Oct 23, 2023
01634ac
fix: get rid of console.log
AlexandrMov Oct 23, 2023
478ea5b
chore: review things
infloop Nov 3, 2023
dd89a98
wip: batches spec
eddort Nov 3, 2023
a4a480a
Merge branch 'develop' into feat/val-255-sr-modules-operators-keys-st…
AlexandrMov Nov 7, 2023
a197e9c
cr
AlexandrMov Nov 7, 2023
9d0897a
feat: stream json error handling
eddort Nov 7, 2023
3c531b8
Merge pull request #210 from lidofinance/feat/val-413
eddort Nov 7, 2023
4f90002
Merge branch 'feat/val-255-sr-modules-operators-keys-stream-2' into f…
AlexandrMov Nov 8, 2023
3a05f61
cr 1
AlexandrMov Nov 8, 2023
17ed1ee
experiment
AlexandrMov Nov 8, 2023
1c36f23
VALIDATOR_REGISTRY_ENABLE=false
AlexandrMov Nov 8, 2023
be43c98
rollback
AlexandrMov Nov 8, 2023
8d63546
Merge pull request #194 from lidofinance/feat/VAL-369-use-postgres-in…
Amuhar Nov 8, 2023
cf06652
feat: add timeout to keys and operators stream
eddort Nov 8, 2023
65156a0
Merge pull request #211 from lidofinance/feat/add-timeout-to-stream
eddort Nov 8, 2023
4dd16ab
fix: replace console logs by error
eddort Nov 9, 2023
bf16d5b
feat: better error handling
eddort Nov 12, 2023
850f9b8
feat: keys batch tests
eddort Nov 12, 2023
f89211a
fix: add jsdoc fix for splitHex function
infloop Nov 13, 2023
91bc76f
VAL-422: Make production KAPI docker image without npm dev dependencies
AlexandrMov Nov 13, 2023
c054b44
fix tests
AlexandrMov Nov 13, 2023
2617776
Merge pull request #213 from lidofinance/feat/stream-error-handling
Amuhar Nov 14, 2023
8eeb1f6
Merge pull request #215 from lidofinance/feat/VAL-422-get-rid-of-devd…
Amuhar Nov 15, 2023
305f638
Merge branch 'develop' into feat/val-255-sr-modules-operators-keys-st…
AlexandrMov Nov 20, 2023
789948c
chore: code review
AlexandrMov Nov 20, 2023
dd6d2d3
chore: code review 2
AlexandrMov Nov 20, 2023
89dd289
fix: improve tests and edge-cases
infloop Nov 21, 2023
d8c7488
fix: add test for batching
infloop Nov 21, 2023
32aca14
Merge pull request #214 from lidofinance/feat/VAL-433-keys-batch-tests
Amuhar Nov 21, 2023
eb4b8a2
Merge pull request #149 from lidofinance/feat/val-255-sr-modules-oper…
Amuhar Nov 21, 2023
18f757a
VAL-436: Enhance KAPI mev-m stream endpoint
AlexandrMov Nov 22, 2023
331637c
cr 1
AlexandrMov Nov 22, 2023
84bb7b6
fix: use logger instead console.log
Amuhar Nov 22, 2023
8dd5b47
Merge pull request #218 from lidofinance/remove-console-log
infloop Nov 23, 2023
8422eb8
chore: docs + sorting
AlexandrMov Nov 23, 2023
023fa72
Merge pull request #217 from lidofinance/feat/VAL-436-enhance-kapi-me…
Amuhar Nov 24, 2023
1fdc99a
chore: bump version
infloop Nov 29, 2023
ed05fa8
fix: log
Amuhar Dec 11, 2023
1860c8d
Merge pull request #223 from lidofinance/fix-logs-end-time
Amuhar Dec 12, 2023
d5247d5
feat: add finalizedUsedSigningKeys
eddort Dec 18, 2023
2471e3f
feat: new indexing logic
eddort Dec 19, 2023
92ecf44
fix: revert operatorsWereChanged logic
eddort Dec 19, 2023
183cbbd
fix: tests
eddort Dec 19, 2023
cca8041
feat: add data to endpoints
eddort Dec 20, 2023
244967d
fix: fixtures and entity types
eddort Dec 20, 2023
3fa909b
fix: operators fetch spec
eddort Dec 20, 2023
138e9c3
fix: reorg detection
eddort Dec 20, 2023
39a92e9
feat: add migration
eddort Dec 20, 2023
7b018f3
feat: moduleAddresses filter
eddort Dec 20, 2023
edf5c22
refactor: split update function into two
eddort Dec 20, 2023
c7bb4e3
refactor: move interfaces to a separate file
eddort Dec 20, 2023
7e52c4c
test: processing of all indexing cases
eddort Dec 20, 2023
2796b6f
refactor: rename updater
eddort Dec 20, 2023
1533454
fix: different hash but same number case
eddort Dec 20, 2023
ba06c2c
test: reorg spec
eddort Dec 20, 2023
a8a1bc0
test: reorg cases
eddort Dec 20, 2023
403a91a
fix: block range in isReorgDetected method
eddort Dec 20, 2023
9cef0d3
refactor: connect updater to keys-update service
eddort Dec 20, 2023
e9c83f7
fix: e2e tests
eddort Dec 20, 2023
60efe63
fix: reorg spec
eddort Dec 20, 2023
8f8bb45
fix: sql e2e spec
eddort Dec 20, 2023
ac084c5
test: debug e2e
eddort Dec 21, 2023
91ef826
fix: chronix tests
eddort Dec 21, 2023
05d2553
fix: e2e connects tests
eddort Dec 21, 2023
0c649a1
Merge pull request #228 from lidofinance/fix/e2e-tests
eddort Dec 21, 2023
9906c1e
Merge pull request #227 from lidofinance/feat/new-updater-refactoring
eddort Dec 21, 2023
66ccb66
fix: 425 error while fetching modules
eddort Dec 21, 2023
9599800
fix: 425 http error
eddort Dec 21, 2023
125a332
Merge pull request #226 from lidofinance/feat/gcd-endpoint
eddort Dec 21, 2023
e9d2249
fix: reorg detection
eddort Dec 21, 2023
d72df82
refactor: better logs
eddort Dec 21, 2023
754d6a4
test: reorg handling in registry module
eddort Dec 23, 2023
998c17a
test: key registry
eddort Dec 24, 2023
0d01ef6
test: fix fixtures
eddort Dec 24, 2023
d36ebca
fix: e2e test
eddort Dec 24, 2023
39a42a1
fix: httpExceptionTooEarlyResp
eddort Dec 24, 2023
c60467e
fix: update log message
eddort Dec 24, 2023
aa921b2
fix: remove old e2e tests
eddort Dec 24, 2023
506cdcd
refactor: reorg test
eddort Dec 24, 2023
079d15c
refactor: add comments to reorg check method
eddort Dec 24, 2023
453ac72
fix: reorg spec arg
eddort Dec 24, 2023
1dc39ec
fix: wrong migration
eddort Dec 25, 2023
06f8422
Merge pull request #225 from lidofinance/feat/indexing-reorg
eddort Dec 25, 2023
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
3 changes: 0 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
/dist
/node_modules

# Env
.env

# Logs
logs
*.log
Expand Down
26 changes: 24 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ on: pull_request
jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: node_operator_keys_service_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Checkout repo
uses: actions/[email protected]
Expand All @@ -19,9 +35,15 @@ jobs:
run: yarn lint
- name: Run tests
run: yarn test
- name: Run tests
run: yarn test:e2e
- name: Run E2E tests
run: yarn test:e2e:docker
env:
PROVIDERS_URLS: ${{ secrets.PROVIDERS_URLS }}
CL_API_URLS: "https://e2e-test.lido.fi,"
CHAIN_ID: ${{ secrets.CHAIN_ID }}
CHRONIX_PROVIDER_MAINNET_URL: ${{ secrets.CHRONIX_PROVIDER_MAINNET_URL }}
DB_NAME: node_operator_keys_service_db
DB_PORT: 5432
DB_HOST: localhost
DB_USER: postgres
DB_PASSWORD: postgres
55 changes: 55 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Nest Framework",
"runtimeExecutable": "yarn",
"runtimeArgs": [
"start:debug",
],
"cwd": "${workspaceFolder}/src",
"autoAttachChildProcesses": true,
"restart": true,
"sourceMaps": true,
"stopOnEntry": false,
"console": "integratedTerminal",
},
{
"type": "node",
"request": "launch",
"name": "Debug Jest e2e",
"runtimeExecutable": "yarn",
"runtimeArgs": [
"test:e2e:docker:debug",
],
"cwd": "${workspaceFolder}/src",
"autoAttachChildProcesses": true,
"restart": true,
"sourceMaps": true,
"stopOnEntry": false,
"console": "integratedTerminal",
},
{
"name": "Jest file",
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/jest",
"args": [
"${fileBasenameNoExtension}",
"--runInBand",
"--watch",
"--coverage=false",
"--no-cache"
],
"cwd": "${workspaceRoot}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"sourceMaps": true,
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
}
}
]
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RUN apk add --no-cache git=2.36.6-r0

WORKDIR /app

COPY package.json yarn.lock chronix.config.ts ./
COPY package.json yarn.lock ./
COPY ./tsconfig*.json ./
COPY ./src ./src

Expand Down
15 changes: 15 additions & 0 deletions Dockerfile.e2e
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:18.14.2-alpine3.16 as building

RUN apk add --no-cache git=2.36.6-r0

WORKDIR /app

COPY package.json yarn.lock chronix.config.ts .env ./
COPY jest* ./
COPY ./tsconfig*.json ./

RUN yarn install --frozen-lockfile --non-interactive && yarn cache clean
COPY ./src ./src
RUN yarn typechain

CMD ["yarn", "test:e2e:docker"]
27 changes: 27 additions & 0 deletions docker-compose.e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: '3.7'

services:
e2e_pgdb:
container_name: e2e_pgdb
image: postgres:14-alpine
restart: unless-stopped
environment:
- POSTGRES_DB=${DB_NAME}
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
expose:
- 5432:5432
volumes:
- ./.volumes/pgdata-${CHAIN_ID}/:/var/lib/postgresql/data

e2e_keys_api:
container_name: e2e_keys_api
build:
context: ./
dockerfile: Dockerfile.e2e
environment:
- NODE_ENV=production
- DB_PORT=5432
- DB_HOST=e2e_pgdb
depends_on:
- e2e_pgdb
5 changes: 4 additions & 1 deletion nest-cli.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"collection": "@nestjs/schematics",
"sourceRoot": "src"
"sourceRoot": "src",
"compilerOptions": {
"tsConfigPath": "./tsconfig.build.json"
}
}
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lido-keys-api",
"version": "0.8.2",
"version": "0.10.1",
"description": "Lido Node Operators keys service",
"author": "Lido team",
"private": true,
Expand All @@ -20,7 +20,7 @@
"url": "https://github.com/lidofinance/lido-keys-api/issues"
},
"scripts": {
"postinstall": "rimraf ./node_modules/@ethersproject/abstract-provider/src.ts/*.ts && yarn chronix:compile",
"postinstall": "rimraf ./node_modules/@ethersproject/abstract-provider/src.ts/*.ts",
"mikro-orm": "./node_modules/mikro-orm",
"prebuild": "rimraf dist",
"build": "nest build",
Expand All @@ -34,7 +34,9 @@
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config jest-e2e.json && chronix test",
"test:e2e": "docker-compose --env-file=./.env -f docker-compose.e2e.yml up --build --abort-on-container-exit",
"test:e2e:docker": "mikro-orm schema:drop -r && mikro-orm migration:up && jest -i --config jest-e2e.json && chronix compile && chronix test",
"test:e2e:docker:debug": "mikro-orm schema:drop -r && mikro-orm migration:up && node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest -i --config jest-e2e.json && chronix compile && chronix test",
"typechain": "typechain --target=ethers-v5 --out-dir ./src/generated ./src/staking-router-modules/contracts/abi/*.json",
"chronix:compile": "chronix compile",
"chronix:test": "chronix test",
Expand Down Expand Up @@ -73,6 +75,7 @@
"ethers": "^5.5.4",
"fastify-swagger": "^4.13.1",
"jsonstream": "^1.0.3",
"pg-query-stream": "^4.5.3",
"prom-client": "^14.0.1",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
Expand Down
45 changes: 45 additions & 0 deletions rest-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,51 @@ class NotFoundException implements HttpException {
}
```

#### List of modules, operators, keys and meta

Path: /v2/modules/operators/keys

Returns modules, operators, keys and meta.

Request example:

```bash
curl 'http://localhost:3000/v2/modules/operators/keys
```

Response:

```typescript
type KApiModulesOperatorsKeysResponse = {
key: Key | null;
operator: Operator | null;
meta: { elBlockSnapshot: ELBlockSnapshot } | null;
module: StakingModule | null;
}[];

interface HttpException {
statusCode: number;
message: string;
}

class TooEarlyResponse implements HttpException {
statusCode: number = 425;
message: string = 'Too early response';
}
```

For example:
```json
[
{ "meta": { "elBlockSnapshot": {} }, "module": { "id": 1, "moduleAddress": "0x001" }, "operator": { "id": 1, "moduleAddress": "0x001" }, "key": { "id": 1, "moduleAddress": "0x001" } },
{ "meta": null, "module": null, "operator": { "id": 2, "moduleAddress": "0x001" }, "key": { "id": 2, "moduleAddress": "0x001" } },
{ "meta": null, "module": null, "operator": null, "key": { "id": 3, "moduleAddress": "0x001" } },
{ "meta": null, "module": { "id": 2, "moduleAddress": "0x002" }, "operator": { "id": 1, "moduleAddress": "0x002" }, "key": { "id": 1, "moduleAddress": "0x002" } },
{ "meta": null, "module": null, "operator": { "id": 2, "moduleAddress": "0x002" }, "key": { "id": 2, "moduleAddress": "0x002" } },
{ "meta": null, "module": null, "operator": null, "key": { "id": 3, "moduleAddress": "0x002" } }
]
```

### KAPI status

#### Return KAPI status
Expand Down
29 changes: 29 additions & 0 deletions src/app/database-testing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Module } from '@nestjs/common';
import { MikroOrmModule } from '@mikro-orm/nestjs';
import config from 'mikro-orm.config';
import { ConfigModule, ConfigService } from 'common/config';

@Module({
imports: [
ConfigModule,
MikroOrmModule.forRootAsync({
async useFactory(configService: ConfigService) {
return {
...config,
dbName: configService.get('DB_NAME'),
host: configService.get('DB_HOST'),
port: configService.get('DB_PORT'),
user: configService.get('DB_USER'),
password: configService.get('DB_PASSWORD'),
autoLoadEntities: false,
cache: { enabled: false },
debug: false,
registerRequestContext: true,
allowGlobalContext: true,
};
},
inject: [ConfigService],
}),
],
})
export class DatabaseTestingModule {}
1 change: 1 addition & 0 deletions src/app/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './app.constants';
export * from './app.module';
export * from './app.service';
export * from './database-testing.module';
8 changes: 4 additions & 4 deletions src/app/simple-dvt-deploy.e2e-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { RegistryKeyStorageService } from '../common/registry';
import { ElMetaStorageService } from '../storage/el-meta.storage';
import { SRModuleStorageService } from '../storage/sr-module.storage';
import { KeysUpdateService } from '../jobs/keys-update';
import { ExecutionProvider, ExecutionProviderService } from '../common/execution-provider';
import { ExecutionProvider } from '../common/execution-provider';
import { ConfigService } from '../common/config';
import { PrometheusService } from '../common/prometheus';
import { StakingRouterService } from '../staking-router-modules/staking-router.service';
Expand Down Expand Up @@ -64,8 +64,6 @@ describe('Simple DVT deploy', () => {
});

moduleRef = await Test.createTestingModule({ imports: [AppModule] })
.overrideProvider(ExecutionProviderService)
.useValue(session.provider)
.overrideProvider(SimpleFallbackJsonRpcBatchProvider)
.useValue(session.provider)
.overrideProvider(ExecutionProvider)
Expand All @@ -89,7 +87,9 @@ describe('Simple DVT deploy', () => {
.overrideProvider(ConfigService)
.useValue({
get(path) {
const conf = { LIDO_LOCATOR_ADDRESS: '0xC1d0b3DE6792Bf6b4b37EccdcC24e45978Cfd2Eb' };
const conf = {
LIDO_LOCATOR_ADDRESS: '0xC1d0b3DE6792Bf6b4b37EccdcC24e45978Cfd2Eb',
};
return conf[path];
},
})
Expand Down
9 changes: 9 additions & 0 deletions src/common/execution-provider/execution-provider.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,13 @@ export class ExecutionProviderService {
const block = await this.provider.getBlock(blockHashOrBlockTag);
return { number: block.number, hash: block.hash, timestamp: block.timestamp };
}

/**
*
* Returns full block info
*/
public async getFullBlock(blockHashOrBlockTag: number | string) {
const block = await this.provider.getBlock(blockHashOrBlockTag);
return block;
}
}
1 change: 1 addition & 0 deletions src/common/registry/fetch/interfaces/operator.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export interface RegistryOperator {
totalSigningKeys: number;
usedSigningKeys: number;
moduleAddress: string;
finalizedUsedSigningKeys: number;
}
Loading
Loading