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 #83

Merged
merged 4 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-algorand/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 (#83)

## [3.0.2] - 2023-10-26
### Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/common-algorand/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-algorand": "workspace:*",
"class-transformer": "^0.5.1",
"class-validator": "^0.13.2",
Expand Down
14 changes: 3 additions & 11 deletions packages/common-algorand/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 {ProcessorImpl} from '@subql/common';
import {BaseDataSource, ProcessorImpl} from '@subql/common';
import {
CustomDataSourceAsset as AlgorandCustomDataSourceAsset,
AlgorandBlockFilter,
Expand All @@ -11,7 +11,6 @@ import {
AlgorandHandlerKind,
AlgorandRuntimeDataSource,
AlgorandRuntimeHandler,
AlgorandRuntimeHandlerFilter,
AlgorandCustomDataSource,
AlgorandTransactionHandler,
AlgorandTransactionFilter,
Expand Down Expand Up @@ -164,17 +163,13 @@ export class CustomMapping implements BaseMapping<AlgorandCustomHandler> {
file: string;
}

export class RuntimeDataSourceBase implements AlgorandRuntimeDataSource {
export class RuntimeDataSourceBase extends BaseDataSource implements AlgorandRuntimeDataSource {
@IsEnum(AlgorandDataSourceKind, {groups: [AlgorandDataSourceKind.Runtime]})
kind: AlgorandDataSourceKind.Runtime;

@Type(() => RuntimeMapping)
@ValidateNested()
mapping: RuntimeMapping;

@IsOptional()
@IsInt()
startBlock?: number;
}

export class FileReferenceImpl implements FileReference {
Expand All @@ -183,6 +178,7 @@ export class FileReferenceImpl implements FileReference {
}

export class CustomDataSourceBase<K extends string, M extends CustomMapping, O = any>
extends BaseDataSource
implements AlgorandCustomDataSource<K, M>
{
@IsString()
Expand All @@ -192,10 +188,6 @@ export class CustomDataSourceBase<K extends string, M extends CustomMapping, O =
@ValidateNested()
mapping: M;

@IsOptional()
@IsInt()
startBlock?: number;

@Type(() => FileReferenceImpl)
@ValidateNested({each: true})
assets: Map<string, AlgorandCustomDataSourceAsset>;
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 (#83)

## [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-algorand": "workspace:*",
"@subql/node-core": "^6.1.1",
"@subql/node-core": "^6.2.0",
"@subql/types-algorand": "workspace:*",
"algosdk": "^2.2.0",
"axios": "^1.3.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,18 @@ import { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';
import {
NodeConfig,
Worker,
SmartBatchService,
StoreService,
PoiService,
PoiSyncService,
StoreCacheService,
IProjectService,
IDynamicDsService,
HostStore,
HostDynamicDS,
WorkerBlockDispatcher,
IUnfinalizedBlocksService,
HostConnectionPoolState,
ConnectionPoolStateManager,
connectionPoolStateHostFunctions,
baseWorkerFunctions,
storeHostFunctions,
dynamicDsHostFunctions,
IProjectUpgradeService,
HostUnfinalizedBlocks,
cacheHostFunctions,
HostCache,
InMemoryCacheService,
createIndexerWorker,
} from '@subql/node-core';
import { Store, Cache } from '@subql/types-core';
import { AlgorandApiConnection } from '../../algorand';
import {
AlgorandProjectDs,
Expand All @@ -39,50 +26,12 @@ import {
import { DynamicDsService } from '../dynamic-ds.service';
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<AlgorandProjectDs>,
unfinalizedBlocksService: IUnfinalizedBlocksService<BlockContent>,
connectionPoolState: ConnectionPoolStateManager<AlgorandApiConnection>,
root: string,
startHeight: number,
): Promise<IndexerWorker> {
const indexerWorker = Worker.create<
IInitIndexerWorker,
// HostDynamicDS<AlgorandProjectDs> & HostStore & HostUnfinalizedBlocks
HostDynamicDS<AlgorandProjectDs> &
HostStore &
HostCache &
HostUnfinalizedBlocks &
HostConnectionPoolState<AlgorandApiConnection>
>(
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<AlgorandProjectDs, IndexerWorker>
Expand Down Expand Up @@ -119,7 +68,14 @@ export class WorkerBlockDispatcherService
project,
dynamicDsService,
() =>
createIndexerWorker(
createIndexerWorker<
IIndexerWorker,
AlgorandApiConnection,
BlockContent,
AlgorandProjectDs
>(
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 @@ -9,6 +9,7 @@ import {
ConnectionPoolStateManager,
WorkerConnectionPoolStateManager,
InMemoryCacheService,
WorkerInMemoryCacheService,
} from '@subql/node-core';
import { AlgorandApiService, AlgorandApiConnection } from '../../algorand';
import { SubqueryProject } from '../../configure/SubqueryProject';
Expand All @@ -18,7 +19,6 @@ import { IndexerManager } from '../indexer.manager';
import { ProjectService } from '../project.service';
import { SandboxService } from '../sandbox.service';
import { UnfinalizedBlocksService } from '../unfinalizedBlocks.service';
import { WorkerInMemoryCacheService } from './worker.cache.service';
import { WorkerService } from './worker.service';
import { WorkerUnfinalizedBlocksService } from './worker.unfinalizedBlocks.service';

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: 5 additions & 1 deletion packages/node/src/subcommands/testing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import {
ConnectionPoolService,
ConnectionPoolStateManager,
DbModule,
InMemoryCacheService,
PoiService,
PoiSyncService,
StoreCacheService,
StoreService,
TestRunner,
StoreCacheService,
} from '@subql/node-core';
import { AlgorandApiService } from '../algorand';
import { ConfigureModule } from '../configure/configure.module';
Expand All @@ -23,10 +25,12 @@ import { SandboxService } from '../indexer/sandbox.service';
import { UnfinalizedBlocksService } from '../indexer/unfinalizedBlocks.service';
@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 @@ -82,7 +82,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',
},
'dictionary-resolver': {
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 (#83)

## [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 @@ -24,6 +24,6 @@
"algosdk": "^2.2.0"
},
"dependencies": {
"@subql/types-core": "^0.2.0"
"@subql/types-core": "^0.3.0"
}
}
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 {SafeAPI} from './interfaces';
import '@subql/types-core/dist/global';

declare global {
const api: SafeAPI;
Expand Down
Loading