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

Sync @subql dependencies #74

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions packages/common-near/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]
### Added
- Update `@subql/common` and relevant changes to support endBlock feature (#74)

## [3.0.1] - 2023-10-26
### Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/common-near/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"main": "dist/index.js",
"license": "GPL-3.0",
"dependencies": {
"@subql/common": "^3.2.0",
"@subql/common": "^3.3.0",
"@subql/types-near": "workspace:*",
"js-yaml": "^4.1.0",
"reflect-metadata": "^0.1.13"
Expand Down
13 changes: 3 additions & 10 deletions packages/common-near/src/project/models.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2020-2023 SubQuery Pte Ltd authors & contributors
// SPDX-License-Identifier: GPL-3.0

import {BlockFilterImpl, ProcessorImpl} from '@subql/common';
import {BaseDataSource, BlockFilterImpl, ProcessorImpl} from '@subql/common';
import {BaseMapping, FileReference, Processor} from '@subql/types-core';
import {
CustomDataSourceAsset as NearCustomDataSourceAsset,
Expand All @@ -16,7 +16,7 @@
NearHandlerKind,
NearRuntimeDatasource,
NearRuntimeHandler,
NearRuntimeHandlerFilter,

Check warning on line 19 in packages/common-near/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

'NearRuntimeHandlerFilter' is defined but never used
NearCustomDatasource,
ActionType,
NearReceiptHandler,
Expand All @@ -26,7 +26,7 @@
import {
IsArray,
IsEnum,
IsInt,

Check warning on line 29 in packages/common-near/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

'IsInt' is defined but never used
IsOptional,
IsString,
IsObject,
Expand All @@ -34,7 +34,7 @@
registerDecorator,
ValidationArguments,
ValidationOptions,
Min,

Check warning on line 37 in packages/common-near/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

'Min' is defined but never used
ValidateIf,
} from 'class-validator';

Expand All @@ -50,7 +50,7 @@
}

export function IsActionType(validationOptions?: ValidationOptions) {
return function (object: object, propertyName: string) {

Check warning on line 53 in packages/common-near/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

Missing return type on function
registerDecorator({
name: 'isActionType',
target: object.constructor,
Expand All @@ -58,7 +58,7 @@
constraints: [],
options: validationOptions,
validator: {
validate(value: any, args: ValidationArguments) {

Check warning on line 61 in packages/common-near/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

Unexpected any. Specify a different type

Check warning on line 61 in packages/common-near/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

'args' is defined but never used
return Object.values(ActionType).includes(value);
},
},
Expand Down Expand Up @@ -181,7 +181,7 @@
case NearHandlerKind.Block:
return plainToClass(BlockHandler, handler);
default:
throw new Error(`handler ${(handler as any).kind} not supported`);

Check warning on line 184 in packages/common-near/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

Unexpected any. Specify a different type
}
});
})
Expand All @@ -201,17 +201,12 @@
file: string;
}

export class RuntimeDataSourceBase implements NearRuntimeDatasource {
export class RuntimeDataSourceBase extends BaseDataSource implements NearRuntimeDatasource {
@IsEnum(NearDatasourceKind, {groups: [NearDatasourceKind.Runtime]})
kind: NearDatasourceKind.Runtime;
@Type(() => RuntimeMapping)
@ValidateNested()
mapping: RuntimeMapping;
//must be greater than genesis block
@Min(9820210)
@IsOptional()
@IsInt()
startBlock?: number;
}

export class FileReferenceImpl implements FileReference {
Expand All @@ -219,17 +214,15 @@
file: string;
}

export class CustomDataSourceBase<K extends string, M extends CustomMapping, O = any>

Check warning on line 217 in packages/common-near/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

'O' is defined but never used

Check warning on line 217 in packages/common-near/src/project/models.ts

View workflow job for this annotation

GitHub Actions / code-style

Unexpected any. Specify a different type
extends BaseDataSource
implements NearCustomDatasource<K, M>
{
@IsString()
kind: K;
@Type(() => CustomMapping)
@ValidateNested()
mapping: M;
@IsOptional()
@IsInt()
startBlock?: number;
@Type(() => FileReferenceImpl)
@ValidateNested({each: true})
assets: Map<string, NearCustomDataSourceAsset>;
Expand Down
2 changes: 2 additions & 0 deletions packages/node/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
- Update `@subql/node-core` with fixes and support for endBlock feature (#74)

## [3.1.1] - 2023-10-27
### Fixed
Expand Down
4 changes: 2 additions & 2 deletions packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"@nestjs/event-emitter": "^2.0.0",
"@nestjs/platform-express": "^9.4.0",
"@nestjs/schedule": "^3.0.1",
"@subql/common": "^3.2.0",
"@subql/common": "^3.3.0",
"@subql/common-near": "workspace:*",
"@subql/node-core": "^6.1.1",
"@subql/node-core": "^6.2.0",
"@subql/types-near": "workspace:*",
"cron-converter": "^1.0.2",
"eventemitter2": "^6.4.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,18 @@ import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';
import {
NodeConfig,
Worker,
SmartBatchService,
StoreService,
PoiService,
StoreCacheService,
IProjectService,
IDynamicDsService,
HostStore,
HostDynamicDS,
WorkerBlockDispatcher,
IUnfinalizedBlocksService,
HostConnectionPoolState,
ConnectionPoolStateManager,
connectionPoolStateHostFunctions,
IProjectUpgradeService,
baseWorkerFunctions,
storeHostFunctions,
dynamicDsHostFunctions,
HostUnfinalizedBlocks,
PoiSyncService,
cacheHostFunctions,
InMemoryCacheService,
createIndexerWorker,
} from '@subql/node-core';
import { Store, Cache } from '@subql/types-core';
import { NearDatasource } from '@subql/types-near';
import {
NearProjectDs,
Expand All @@ -39,48 +27,12 @@ import { DynamicDsService } from '../dynamic-ds.service';
import { NearApiConnection } from '../nearApi.connection';
import { BlockContent } from '../types';
import { UnfinalizedBlocksService } from '../unfinalizedBlocks.service';
import { IIndexerWorker, IInitIndexerWorker } from '../worker/worker';
import { IIndexerWorker } from '../worker/worker';

type IndexerWorker = IIndexerWorker & {
terminate: () => Promise<number>;
};

async function createIndexerWorker(
store: Store,
cache: Cache,
dynamicDsService: IDynamicDsService<NearDatasource>,
unfinalizedBlocksService: IUnfinalizedBlocksService<BlockContent>,
connectionPoolState: ConnectionPoolStateManager<NearApiConnection>,
root: string,
startHeight: number,
): Promise<IndexerWorker> {
const indexerWorker = Worker.create<
IInitIndexerWorker,
HostDynamicDS<NearDatasource> &
HostStore &
HostUnfinalizedBlocks &
HostConnectionPoolState<NearApiConnection>
>(
path.resolve(__dirname, '../../../dist/indexer/worker/worker.js'),
[...baseWorkerFunctions, 'initWorker'],
{
...storeHostFunctions(store),
...cacheHostFunctions(cache),
...dynamicDsHostFunctions(dynamicDsService),
unfinalizedBlocksProcess:
unfinalizedBlocksService.processUnfinalizedBlockHeader.bind(
unfinalizedBlocksService,
),
...connectionPoolStateHostFunctions(connectionPoolState),
},
root,
);

await indexerWorker.initWorker(startHeight);

return indexerWorker;
}

@Injectable()
export class WorkerBlockDispatcherService
extends WorkerBlockDispatcher<NearDatasource, IndexerWorker>
Expand Down Expand Up @@ -116,7 +68,14 @@ export class WorkerBlockDispatcherService
project,
dynamicDsService,
() =>
createIndexerWorker(
createIndexerWorker<
IIndexerWorker,
NearApiConnection,
BlockContent,
NearDatasource
>(
path.resolve(__dirname, '../../../dist/indexer/worker/worker.js'),
[],
storeService.getStore(),
cacheService.getCache(),
dynamicDsService,
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/indexer/worker/worker-fetch.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ConnectionPoolStateManager,
NodeConfig,
InMemoryCacheService,
WorkerInMemoryCacheService,
} from '@subql/node-core';
import { SubqueryProject } from '../../configure/SubqueryProject';
import { ApiService } from '../api.service';
Expand All @@ -22,7 +23,6 @@ import { SandboxService } from '../sandbox.service';
import { UnfinalizedBlocksService } from '../unfinalizedBlocks.service';
import { WorkerService } from '../worker/worker.service';
import { WorkerUnfinalizedBlocksService } from '../worker/worker.unfinalizedBlocks.service';
import { WorkerInMemoryCacheService } from './worker.cache.service';

@Module({
providers: [
Expand Down
22 changes: 0 additions & 22 deletions packages/node/src/indexer/worker/worker.cache.service.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/node/src/indexer/worker/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ async function initWorker(startHeight: number): Promise<void> {

export type IIndexerWorker = IBaseIndexerWorker;

export type IInitIndexerWorker = IIndexerWorker & {
initWorker: typeof initWorker;
};

(global as any).host = createWorkerHost([], {
initWorker,
});
6 changes: 6 additions & 0 deletions packages/node/src/subcommands/testing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import {
ConnectionPoolService,
ConnectionPoolStateManager,
DbModule,
InMemoryCacheService,
NodeConfig,
PoiService,
PoiSyncService,
StoreCacheService,
StoreService,
TestRunner,
} from '@subql/node-core';
Expand All @@ -28,9 +31,12 @@ import { MetaModule } from '../meta/meta.module';

@Module({
providers: [
InMemoryCacheService,
StoreService,
StoreCacheService,
EventEmitter2,
PoiService,
PoiSyncService,
SandboxService,
DsProcessorService,
DynamicDsService,
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/yargs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export const yargsOptions = yargs(hideBin(process.argv))
},
debug: {
demandOption: false,
describe: `Enable debug logging for specific scopes, this will override log-level. "*" will enable debug everywhere, or comma separated strings for specific scopes. e.g. "SQL,dictionary"`,
describe: `Enable debug logging for specific scopes, this will override log-level. "*" will enable debug everywhere, or comma separated strings for specific scopes. e.g. "SQL,dictionary". To disable specific scopes you can prefix them with '-'. e.g. "*,-SQL"`,
type: 'string',
},
ipfs: {
Expand Down
2 changes: 2 additions & 0 deletions packages/types/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
- Import `@subql/types-core` global into global so its no longer needed to update tsconfig in projects (#74)

## [3.0.1] - 2023-10-26
### Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"/dist"
],
"dependencies": {
"@subql/types-core": "^0.2.0",
"@subql/types-core": "^0.3.0",
"bn.js": "5.2.1",
"near-api-js": "^1.1.0"
},
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0

import {providers} from 'near-api-js';
import '@subql/types-core/dist/global';

declare global {
const api: providers.JsonRpcProvider;
Expand Down
Loading
Loading