Skip to content

Commit

Permalink
Sync @subql dependencies (#264)
Browse files Browse the repository at this point in the history
* Update @subql deps

* Add admin changes, address build issues

---------

Co-authored-by: stwiname <[email protected]>
  • Loading branch information
stwiname and stwiname authored Jun 20, 2024
1 parent 28b2590 commit 0059c71
Show file tree
Hide file tree
Showing 17 changed files with 215 additions and 162 deletions.
2 changes: 2 additions & 0 deletions packages/common-cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Add default value in model class to follow ES2022 rule (#264)

## [4.3.0] - 2024-05-02
### Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/common-cosmos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@protobufs/google": "^0.0.10",
"@protobufs/ibc": "^0.1.0",
"@protobufs/tendermint": "^0.0.10",
"@subql/common": "^3.5.1",
"@subql/common": "^3.8.0",
"@subql/types-cosmos": "workspace:*",
"@subql/x-cosmology-telescope": "^1.4.14",
"fs-extra": "^11.1.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/common-cosmos/src/project/versioned/v1_0_0/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const COSMOS_NODE_NAME = `@subql/node-cosmos`;

export class CosmosRunnerNodeImpl extends RunnerNodeImpl {
@Equals(COSMOS_NODE_NAME, {message: `Runner Cosmos node name incorrect, suppose be '${COSMOS_NODE_NAME}'`})
name: string;
name: string = COSMOS_NODE_NAME;
}

export class CosmosRuntimeDataSourceImpl
Expand Down Expand Up @@ -73,7 +73,7 @@ export class CosmosProjectNetwork extends CommonProjectNetworkV1_0_0<CosmosChain
@Type(() => CosmosCustomModuleImpl)
@IsOptional()
@ValidateNested({each: true})
chaintypes?: Map<string, CosmosCustomModuleImpl>;
declare chaintypes?: Map<string, CosmosCustomModuleImpl>;
}

export class RuntimeDatasourceTemplateImpl extends CosmosRuntimeDataSourceImpl implements RuntimeDatasourceTemplate {
Expand Down Expand Up @@ -137,7 +137,7 @@ export class ProjectManifestV1_0_0Impl
}

@Equals('1.0.0')
specVersion: string;
specVersion = '1.0.0';
@IsString()
name: string;
@IsString()
Expand Down
5 changes: 5 additions & 0 deletions packages/node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Add monitor service to record block indexing actions in order to improve POI accuracy, and provide debug info for Admin api (#264)

### Changed
- Update dependencies (#264)

## [3.11.2] - 2024-06-12
### Fixed
Expand Down
4 changes: 4 additions & 0 deletions packages/node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ RUN rm /app.tgz && \
yarn cache clean && \
rm -rf /root/.npm /root/.cache

# Create ./.monitor directory and set permissions
RUN mkdir -p .monitor && \
chown 1000:1000 .monitor

# Make the user not ROOT
USER 1000

Expand Down
4 changes: 2 additions & 2 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"@nestjs/event-emitter": "^2.0.0",
"@nestjs/platform-express": "^9.4.0",
"@nestjs/schedule": "^3.0.1",
"@subql/common": "^3.5.1",
"@subql/common": "^3.8.0",
"@subql/common-cosmos": "workspace:*",
"@subql/node-core": "^10.1.1",
"@subql/node-core": "^10.6.0",
"@subql/types-cosmos": "workspace:*",
"lodash": "^4.17.21",
"protobufjs": "^6.11.4",
Expand Down
13 changes: 13 additions & 0 deletions packages/node/src/admin/admin.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import { Module } from '@nestjs/common';
import { adminControllers, adminServices } from '@subql/node-core';
import { FetchModule } from '../indexer/fetch.module';

@Module({
imports: [FetchModule],
controllers: [...adminControllers],
providers: [...adminServices],
})
export class AdminModule {}
2 changes: 2 additions & 0 deletions packages/node/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Module } from '@nestjs/common';
import { EventEmitterModule } from '@nestjs/event-emitter';
import { ScheduleModule } from '@nestjs/schedule';
import { DbModule } from '@subql/node-core';
import { AdminModule } from './admin/admin.module';
import { ConfigureModule } from './configure/configure.module';
import { FetchModule } from './indexer/fetch.module';
import { MetaModule } from './meta/meta.module';
Expand All @@ -17,6 +18,7 @@ import { MetaModule } from './meta/meta.module';
ScheduleModule.forRoot(),
FetchModule,
MetaModule,
AdminModule,
],
controllers: [],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
IProjectUpgradeService,
InMemoryCacheService,
createIndexerWorker,
MonitorServiceInterface,
} from '@subql/node-core';
import { SubqueryProject } from '../../configure/SubqueryProject';
import { CosmosClientConnection } from '../cosmosClient.connection';
Expand Down Expand Up @@ -48,6 +49,7 @@ export class WorkerBlockDispatcherService
dynamicDsService: DynamicDsService,
unfinalizedBlocksSevice: UnfinalizedBlocksService,
connectionPoolState: ConnectionPoolStateManager<CosmosClientConnection>,
monitorService?: MonitorServiceInterface,
) {
super(
nodeConfig,
Expand All @@ -74,10 +76,12 @@ export class WorkerBlockDispatcherService
connectionPoolState,
project.root,
projectService.startHeight,
monitorService,
{
tempDir: project.tempDir,
},
),
monitorService,
);
}

Expand Down
7 changes: 5 additions & 2 deletions packages/node/src/indexer/cosmosClient.connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ApiErrorType,
IApiConnectionSpecific,
NetworkMetadataPayload,
exitWithError,
} from '@subql/node-core';
import { getLogger } from '@subql/node-core/dist';
import { CosmosClient, CosmosSafeClient } from './api.service';
Expand Down Expand Up @@ -67,8 +68,10 @@ export class CosmosClientConnection
const rpcClient =
endpoint.includes('ws://') || endpoint.includes('wss://')
? new WebsocketClient(endpoint, (err) => {
logger.error(err, `Websocket connection failed`);
process.exit(1);
exitWithError(
new Error(`Websocket connection failed`, { cause: err }),
logger,
);
})
: new HttpClient(httpEndpoint);

Expand Down
7 changes: 6 additions & 1 deletion packages/node/src/indexer/fetch.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
IProjectUpgradeService,
InMemoryCacheService,
SandboxService,
MonitorService,
} from '@subql/node-core';
import { SubqueryProject } from '../configure/SubqueryProject';
import { ApiService } from './api.service';
Expand Down Expand Up @@ -57,6 +58,7 @@ import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';
dynamicDsService: DynamicDsService,
unfinalizedBlocks: UnfinalizedBlocksService,
connectionPoolState: ConnectionPoolStateManager<CosmosClientConnection>,
monitorService?: MonitorService,
) =>
nodeConfig.workers
? new WorkerBlockDispatcherService(
Expand All @@ -72,6 +74,7 @@ import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';
dynamicDsService,
unfinalizedBlocks,
connectionPoolState,
monitorService,
)
: new BlockDispatcherService(
apiService,
Expand Down Expand Up @@ -100,6 +103,7 @@ import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';
DynamicDsService,
UnfinalizedBlocksService,
ConnectionPoolStateManager,
MonitorService,
],
},
FetchService,
Expand All @@ -116,8 +120,9 @@ import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';
useClass: ProjectService,
provide: 'IProjectService',
},
MonitorService,
UnfinalizedBlocksService,
],
exports: [StoreService, StoreCacheService],
exports: [StoreService, StoreCacheService, MonitorService, PoiService],
})
export class FetchModule {}
6 changes: 6 additions & 0 deletions packages/node/src/indexer/worker/worker-fetch.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
NodeConfig,
SandboxService,
WorkerUnfinalizedBlocksService,
MonitorService,
WorkerMonitorService,
} from '@subql/node-core';
import { SubqueryProject } from '../../configure/SubqueryProject';
import { ApiService } from '../api.service';
Expand Down Expand Up @@ -77,6 +79,10 @@ import { WorkerService } from './worker.service';
provide: InMemoryCacheService,
useFactory: () => new WorkerInMemoryCacheService((global as any).host),
},
{
provide: MonitorService,
useFactory: () => new WorkerMonitorService((global as any).host),
},
],
exports: [],
})
Expand Down
14 changes: 8 additions & 6 deletions packages/node/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { NestFactory } from '@nestjs/core';
import { findAvailablePort, notifyUpdates } from '@subql/common';
import { getLogger, NestLogger } from '@subql/node-core';
import { exitWithError, getLogger, NestLogger } from '@subql/node-core';
import { AppModule } from './app.module';
import { ApiService } from './indexer/api.service';
import { FetchService } from './indexer/fetch.service';
Expand All @@ -28,12 +28,14 @@ export async function bootstrap(): Promise<void> {

const port = validate(argv.port) ?? (await findAvailablePort(DEFAULT_PORT));
if (!port) {
logger.error(
`Unable to find available port (tried ports in range (${port}..${
port + 10
})). Try setting a free port manually by setting the --port flag`,
exitWithError(
new Error(
`Unable to find available port (tried ports in range (${port}..${
port + 10
})). Try setting a free port manually by setting the --port flag`,
),
logger,
);
process.exit(1);
}

if (argv.unsafe) {
Expand Down
5 changes: 2 additions & 3 deletions packages/node/src/subcommands/testing.init.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import { getLogger } from '@subql/node-core';
import { exitWithError, getLogger } from '@subql/node-core';
import { ConfigureModule } from '../configure/configure.module';
import { TestingService } from './testing.service';

Expand All @@ -13,8 +13,7 @@ export async function testingInit(): Promise<void> {
const testingService = new TestingService(nodeConfig, project);
await testingService.run();
} catch (e) {
logger.error(e, 'Testing failed');
process.exit(1);
exitWithError(new Error(`Testing failed`, { cause: e }), logger);
}
process.exit(0);
}
1 change: 0 additions & 1 deletion packages/node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"target": "es2017",
"sourceMap": true,
"tsBuildInfoFile": "dist/.tsbuildinfo",
"rootDir": "src",
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"target": "ES2022",
"noImplicitAny": false,
"noImplicitThis": true,
"moduleResolution": "node",
Expand All @@ -11,7 +11,7 @@
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"lib": ["ES2017", "ES2020"],
"lib": ["ES2022"],
"emitDecoratorMetadata": true,
"declaration": true,
"sourceMap": true,
Expand Down
Loading

0 comments on commit 0059c71

Please sign in to comment.