@subql/node-ethereum 4.0.1-0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/indexer/fetch.service.d.ts +1 -1
- package/dist/indexer/fetch.service.js +2 -2
- package/dist/indexer/fetch.service.js.map +1 -1
- package/dist/indexer/indexer.manager.d.ts +4 -4
- package/dist/indexer/indexer.manager.js +1 -2
- package/dist/indexer/indexer.manager.js.map +1 -1
- package/dist/indexer/worker/worker.service.d.ts +3 -1
- package/dist/indexer/worker/worker.service.js +1 -1
- package/dist/indexer/worker/worker.service.js.map +1 -1
- package/package.json +3 -4
|
@@ -17,7 +17,7 @@ export declare class FetchService extends BaseFetchService<SubqlDatasource, IEth
|
|
|
17
17
|
protected getFinalizedHeight(): Promise<number>;
|
|
18
18
|
protected getBestHeight(): Promise<number>;
|
|
19
19
|
protected getChainInterval(): Promise<number>;
|
|
20
|
-
protected getModulos(): number[];
|
|
20
|
+
protected getModulos(dataSources: SubqlDatasource[]): number[];
|
|
21
21
|
protected initBlockDispatcher(): Promise<void>;
|
|
22
22
|
protected preLoopHook(): Promise<void>;
|
|
23
23
|
}
|
|
@@ -53,8 +53,8 @@ let FetchService = class FetchService extends node_core_1.BaseFetchService {
|
|
|
53
53
|
const CHAIN_INTERVAL = (0, utils_ethereum_1.calcInterval)(this.api) * INTERVAL_PERCENT;
|
|
54
54
|
return Math.min(BLOCK_TIME_VARIANCE, CHAIN_INTERVAL);
|
|
55
55
|
}
|
|
56
|
-
getModulos() {
|
|
57
|
-
return (0, node_core_1.getModulos)(
|
|
56
|
+
getModulos(dataSources) {
|
|
57
|
+
return (0, node_core_1.getModulos)(dataSources, common_ethereum_1.isCustomDs, common_ethereum_1.EthereumHandlerKind.Block);
|
|
58
58
|
}
|
|
59
59
|
async initBlockDispatcher() {
|
|
60
60
|
await this.blockDispatcher.init(this.resetForNewDs.b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AiB;GAf3B,YAAY,CAoExB;AApEY,oCAAY","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { SchedulerRegistry } from '@nestjs/schedule';\n\nimport { isCustomDs, EthereumHandlerKind } from '@subql/common-ethereum';\nimport {\n NodeConfig,\n BaseFetchService,\n ApiService,\n getModulos,\n} from '@subql/node-core';\nimport { EthereumBlock, SubqlDatasource } from '@subql/types-ethereum';\nimport { SubqueryProject } from '../configure/SubqueryProject';\nimport { EthereumApi } from '../ethereum';\nimport {\n calcInterval,\n ethereumBlockToHeader,\n} from '../ethereum/utils.ethereum';\nimport { IEthereumBlockDispatcher } from './blockDispatcher';\nimport { EthDictionaryService } from './dictionary/ethDictionary.service';\nimport { ProjectService } from './project.service';\nimport { UnfinalizedBlocksService } from './unfinalizedBlocks.service';\n\nconst BLOCK_TIME_VARIANCE = 5000;\n\nconst INTERVAL_PERCENT = 0.9;\n\n@Injectable()\nexport class FetchService extends BaseFetchService<\n SubqlDatasource,\n IEthereumBlockDispatcher,\n EthereumBlock\n> {\n constructor(\n private apiService: ApiService,\n nodeConfig: NodeConfig,\n @Inject('IProjectService') projectService: ProjectService,\n @Inject('ISubqueryProject') project: SubqueryProject,\n @Inject('IBlockDispatcher')\n blockDispatcher: IEthereumBlockDispatcher,\n dictionaryService: EthDictionaryService,\n private unfinalizedBlocksService: UnfinalizedBlocksService,\n eventEmitter: EventEmitter2,\n schedulerRegistry: SchedulerRegistry,\n ) {\n super(\n nodeConfig,\n projectService,\n project.network,\n blockDispatcher,\n dictionaryService,\n eventEmitter,\n schedulerRegistry,\n );\n }\n\n get api(): EthereumApi {\n return this.apiService.unsafeApi;\n }\n\n protected getGenesisHash(): string {\n return this.apiService.networkMeta.genesisHash;\n }\n\n protected async getFinalizedHeight(): Promise<number> {\n const block = await this.api.getFinalizedBlock();\n\n const header = ethereumBlockToHeader(block);\n\n this.unfinalizedBlocksService.registerFinalizedBlock(header);\n return header.blockHeight;\n }\n\n protected async getBestHeight(): Promise<number> {\n return this.api.getBestBlockHeight();\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n protected async getChainInterval(): Promise<number> {\n const CHAIN_INTERVAL = calcInterval(this.api) * INTERVAL_PERCENT;\n\n return Math.min(BLOCK_TIME_VARIANCE, CHAIN_INTERVAL);\n }\n\n protected getModulos(dataSources: SubqlDatasource[]): number[] {\n return getModulos(dataSources, isCustomDs, EthereumHandlerKind.Block);\n }\n\n protected async initBlockDispatcher(): Promise<void> {\n await this.blockDispatcher.init(this.resetForNewDs.bind(this));\n }\n\n protected async preLoopHook(): Promise<void> {\n // Ethereum doesn't need to do anything here\n return Promise.resolve();\n }\n}\n"]}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { isBlockHandlerProcessor, isCallHandlerProcessor, isEventHandlerProcessor, isCustomDs, isRuntimeDs, SubqlEthereumCustomDataSource, EthereumHandlerKind, EthereumRuntimeHandlerInputMap, SubqlEthereumDataSource } from '@subql/common-ethereum';
|
|
2
|
-
import { NodeConfig, IndexerSandbox, ProcessBlockResponse, BaseIndexerManager, IBlock } from '@subql/node-core';
|
|
2
|
+
import { ApiService, NodeConfig, IndexerSandbox, ProcessBlockResponse, BaseIndexerManager, IBlock } from '@subql/node-core';
|
|
3
3
|
import { EthereumTransaction, EthereumLog, EthereumBlock, SubqlRuntimeDatasource, EthereumBlockFilter, EthereumLogFilter, EthereumTransactionFilter, LightEthereumLog } from '@subql/types-ethereum';
|
|
4
4
|
import { EthereumProjectDs } from '../configure/SubqueryProject';
|
|
5
|
-
import { EthereumApi
|
|
5
|
+
import { EthereumApi } from '../ethereum';
|
|
6
6
|
import SafeEthProvider from '../ethereum/safe-api';
|
|
7
7
|
import { asSecondLayerHandlerProcessor_1_0_0, DsProcessorService } from './ds-processor.service';
|
|
8
8
|
import { DynamicDsService } from './dynamic-ds.service';
|
|
9
9
|
import { SandboxService } from './sandbox.service';
|
|
10
10
|
import { BlockContent } from './types';
|
|
11
11
|
import { UnfinalizedBlocksService } from './unfinalizedBlocks.service';
|
|
12
|
-
export declare class IndexerManager extends BaseIndexerManager<SafeEthProvider, EthereumApi, BlockContent,
|
|
12
|
+
export declare class IndexerManager extends BaseIndexerManager<SafeEthProvider, EthereumApi, BlockContent, ApiService, SubqlEthereumDataSource, SubqlEthereumCustomDataSource, typeof FilterTypeMap, typeof ProcessorTypeMap, EthereumRuntimeHandlerInputMap> {
|
|
13
13
|
protected isRuntimeDs: typeof isRuntimeDs;
|
|
14
14
|
protected isCustomDs: typeof isCustomDs;
|
|
15
15
|
protected updateCustomProcessor: typeof asSecondLayerHandlerProcessor_1_0_0;
|
|
16
|
-
constructor(apiService:
|
|
16
|
+
constructor(apiService: ApiService, nodeConfig: NodeConfig, sandboxService: SandboxService, dsProcessorService: DsProcessorService, dynamicDsService: DynamicDsService, unfinalizedBlocksService: UnfinalizedBlocksService);
|
|
17
17
|
indexBlock(block: IBlock<BlockContent>, dataSources: SubqlEthereumDataSource[]): Promise<ProcessBlockResponse>;
|
|
18
18
|
getBlockHeight(block: BlockContent): number;
|
|
19
19
|
getBlockHash(block: BlockContent): string;
|
|
@@ -15,7 +15,6 @@ exports.IndexerManager = void 0;
|
|
|
15
15
|
const common_1 = require("@nestjs/common");
|
|
16
16
|
const common_ethereum_1 = require("@subql/common-ethereum");
|
|
17
17
|
const node_core_1 = require("@subql/node-core");
|
|
18
|
-
const ethereum_1 = require("../ethereum");
|
|
19
18
|
const block_ethereum_1 = require("../ethereum/block.ethereum");
|
|
20
19
|
const ds_processor_service_1 = require("./ds-processor.service");
|
|
21
20
|
const dynamic_ds_service_1 = require("./dynamic-ds.service");
|
|
@@ -86,7 +85,7 @@ __decorate([
|
|
|
86
85
|
], IndexerManager.prototype, "indexBlock", null);
|
|
87
86
|
IndexerManager = __decorate([
|
|
88
87
|
(0, common_1.Injectable)(),
|
|
89
|
-
__metadata("design:paramtypes", [
|
|
88
|
+
__metadata("design:paramtypes", [node_core_1.ApiService,
|
|
90
89
|
node_core_1.NodeConfig,
|
|
91
90
|
sandbox_service_1.SandboxService,
|
|
92
91
|
ds_processor_service_1.DsProcessorService,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexer.manager.js","sourceRoot":"","sources":["../../src/indexer/indexer.manager.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;AAEnC,2CAA4C;AAC5C,4DAUgC;AAChC,gDAQ0B;AAY1B,0CAA8D;AAC9D,+DAKoC;AAEpC,iEAGgC;AAChC,6DAAwD;AACxD,uDAAmD;AAEnD,2EAAuE;AAGhE,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,8BAUnC;IAKC,YACE,UAA8B,EAC9B,UAAsB,EACtB,cAA8B,EAC9B,kBAAsC,EACtC,gBAAkC,EAClC,wBAAkD;QAElD,KAAK,CACH,UAAU,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,gBAAgB,CACjB,CAAC;QArBM,gBAAW,GAAG,6BAAW,CAAC;QAC1B,eAAU,GAAG,4BAAU,CAAC;QACxB,0BAAqB,GAAG,0DAAmC,CAAC;IAoBtE,CAAC;IAGK,AAAN,KAAK,CAAC,UAAU,CACd,KAA2B,EAC3B,WAAsC;QAEtC,OAAO,KAAK,CAAC,kBAAkB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,CACvD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CACzB,CAAC;IACJ,CAAC;IAED,cAAc,CAAC,KAAmB;QAChC,OAAO,KAAK,CAAC,MAAM,CAAC;IACtB,CAAC;IAED,YAAY,CAAC,KAAmB;QAC9B,OAAO,KAAK,CAAC,IAAI,CAAC;IACpB,CAAC;IAED,4DAA4D;IACpD,KAAK,CAAC,MAAM,CAA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AAA,oCAAmB,EAAC,IAAI,EAAE,MAAM,EAAE,MAAA,EAAE,CAAC,OAAO,0CAAE,OAAO,CAAC,CAAA,EAAA;IAC3D,CAAC,qCAAmB,CAAC,IAAI,CAAC,EAAE,CAC1B,IAAyB,EACzB,MAAiC,EACjC,EAA2B,EAC3B,EAAE,WAAC,OAAA,IAAA,4CAA2B,EAAC,IAAI,EAAE,MAAM,EAAE,MAAA,EAAE,CAAC,OAAO,0CAAE,OAAO,CAAC,CAAA,EAAA;CACpE,CAAC;AAEF,MAAM,aAAa,GAAG;IACpB,CAAC,qCAAmB,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,IAAmB,EAAE,EAAE,CAAC,IAAI;IAChE,CAAC,qCAAmB,CAAC,KAAK,CAAC,EACzB,CAAC,GAAgB,EAAE,EAAE,CACrB,CAAC,IAAoC,EAAE,EAA0B,EAAE,EAAE,CACnE,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;IAC1B,CAAC,qCAAmB,CAAC,IAAI,CAAC,EACxB,CAAC,GAAgB,EAAE,EAAE,CACrB,CAAC,IAAyB,EAAE,EAA0B,EAAE,EAAE,CACxD,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC;CACnC,CAAC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Injectable } from '@nestjs/common';\nimport {\n isBlockHandlerProcessor,\n isCallHandlerProcessor,\n isEventHandlerProcessor,\n isCustomDs,\n isRuntimeDs,\n SubqlEthereumCustomDataSource,\n EthereumHandlerKind,\n EthereumRuntimeHandlerInputMap,\n SubqlEthereumDataSource,\n} from '@subql/common-ethereum';\nimport {\n NodeConfig,\n getLogger,\n profiler,\n IndexerSandbox,\n ProcessBlockResponse,\n BaseIndexerManager,\n IBlock,\n} from '@subql/node-core';\nimport {\n EthereumTransaction,\n EthereumLog,\n EthereumBlock,\n SubqlRuntimeDatasource,\n EthereumBlockFilter,\n EthereumLogFilter,\n EthereumTransactionFilter,\n LightEthereumLog,\n} from '@subql/types-ethereum';\nimport { EthereumProjectDs } from '../configure/SubqueryProject';\nimport { EthereumApi, EthereumApiService } from '../ethereum';\nimport {\n filterBlocksProcessor,\n filterLogsProcessor,\n filterTransactionsProcessor,\n isFullBlock,\n} from '../ethereum/block.ethereum';\nimport SafeEthProvider from '../ethereum/safe-api';\nimport {\n asSecondLayerHandlerProcessor_1_0_0,\n DsProcessorService,\n} from './ds-processor.service';\nimport { DynamicDsService } from './dynamic-ds.service';\nimport { SandboxService } from './sandbox.service';\nimport { BlockContent } from './types';\nimport { UnfinalizedBlocksService } from './unfinalizedBlocks.service';\n\n@Injectable()\nexport class IndexerManager extends BaseIndexerManager<\n SafeEthProvider,\n EthereumApi,\n BlockContent,\n EthereumApiService,\n SubqlEthereumDataSource,\n SubqlEthereumCustomDataSource,\n typeof FilterTypeMap,\n typeof ProcessorTypeMap,\n EthereumRuntimeHandlerInputMap\n> {\n protected isRuntimeDs = isRuntimeDs;\n protected isCustomDs = isCustomDs;\n protected updateCustomProcessor = asSecondLayerHandlerProcessor_1_0_0;\n\n constructor(\n apiService: EthereumApiService,\n nodeConfig: NodeConfig,\n sandboxService: SandboxService,\n dsProcessorService: DsProcessorService,\n dynamicDsService: DynamicDsService,\n unfinalizedBlocksService: UnfinalizedBlocksService,\n ) {\n super(\n apiService,\n nodeConfig,\n sandboxService,\n dsProcessorService,\n dynamicDsService,\n unfinalizedBlocksService,\n FilterTypeMap,\n ProcessorTypeMap,\n );\n }\n\n @profiler()\n async indexBlock(\n block: IBlock<BlockContent>,\n dataSources: SubqlEthereumDataSource[],\n ): Promise<ProcessBlockResponse> {\n return super.internalIndexBlock(block, dataSources, () =>\n this.getApi(block.block),\n );\n }\n\n getBlockHeight(block: BlockContent): number {\n return block.number;\n }\n\n getBlockHash(block: BlockContent): string {\n return block.hash;\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n private async getApi(block: BlockContent): Promise<SafeEthProvider> {\n return this.apiService.safeApi(this.getBlockHeight(block));\n }\n\n protected async indexBlockData(\n block: BlockContent,\n dataSources: EthereumProjectDs[],\n getVM: (d: EthereumProjectDs) => Promise<IndexerSandbox>,\n ): Promise<void> {\n if (isFullBlock(block)) {\n await this.indexBlockContent(block, dataSources, getVM);\n\n for (const tx of block.transactions) {\n await this.indexTransaction(tx, dataSources, getVM);\n\n for (const log of tx.logs ?? []) {\n await this.indexEvent(log, dataSources, getVM);\n }\n }\n } else {\n for (const log of block.logs ?? []) {\n await this.indexEvent(log, dataSources, getVM);\n }\n }\n }\n\n private async indexBlockContent(\n block: EthereumBlock,\n dataSources: EthereumProjectDs[],\n getVM: (d: EthereumProjectDs) => Promise<IndexerSandbox>,\n ): Promise<void> {\n for (const ds of dataSources) {\n await this.indexData(EthereumHandlerKind.Block, block, ds, getVM);\n }\n }\n\n private async indexTransaction(\n tx: EthereumTransaction,\n dataSources: EthereumProjectDs[],\n getVM: (d: EthereumProjectDs) => Promise<IndexerSandbox>,\n ): Promise<void> {\n for (const ds of dataSources) {\n await this.indexData(EthereumHandlerKind.Call, tx, ds, getVM);\n }\n }\n\n private async indexEvent(\n log: EthereumLog | LightEthereumLog,\n dataSources: EthereumProjectDs[],\n getVM: (d: EthereumProjectDs) => Promise<IndexerSandbox>,\n ): Promise<void> {\n for (const ds of dataSources) {\n await this.indexData(EthereumHandlerKind.Event, log, ds, getVM);\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n protected async prepareFilteredData(\n kind: EthereumHandlerKind,\n data: any,\n ds: SubqlRuntimeDatasource,\n ): Promise<any> {\n return DataAbiParser[kind](this.apiService.api)(data, ds);\n }\n}\n\ntype ProcessorTypeMap = {\n [EthereumHandlerKind.Block]: typeof isBlockHandlerProcessor;\n [EthereumHandlerKind.Event]: typeof isEventHandlerProcessor;\n [EthereumHandlerKind.Call]: typeof isCallHandlerProcessor;\n};\n\nconst ProcessorTypeMap = {\n [EthereumHandlerKind.Block]: isBlockHandlerProcessor,\n [EthereumHandlerKind.Event]: isEventHandlerProcessor,\n [EthereumHandlerKind.Call]: isCallHandlerProcessor,\n};\n\nconst FilterTypeMap = {\n [EthereumHandlerKind.Block]: (\n data: EthereumBlock,\n filter: EthereumBlockFilter,\n ds: SubqlEthereumDataSource,\n ) => filterBlocksProcessor(data, filter, ds.options?.address),\n [EthereumHandlerKind.Event]: (\n data: EthereumLog | LightEthereumLog,\n filter: EthereumLogFilter,\n ds: SubqlEthereumDataSource,\n ) => filterLogsProcessor(data, filter, ds.options?.address),\n [EthereumHandlerKind.Call]: (\n data: EthereumTransaction,\n filter: EthereumTransactionFilter,\n ds: SubqlEthereumDataSource,\n ) => filterTransactionsProcessor(data, filter, ds.options?.address),\n};\n\nconst DataAbiParser = {\n [EthereumHandlerKind.Block]: () => (data: EthereumBlock) => data,\n [EthereumHandlerKind.Event]:\n (api: EthereumApi) =>\n (data: EthereumLog | LightEthereumLog, ds: SubqlRuntimeDatasource) =>\n api.parseLog(data, ds),\n [EthereumHandlerKind.Call]:\n (api: EthereumApi) =>\n (data: EthereumTransaction, ds: SubqlRuntimeDatasource) =>\n api.parseTransaction(data, ds),\n};\n"]}
|
|
1
|
+
{"version":3,"file":"indexer.manager.js","sourceRoot":"","sources":["../../src/indexer/indexer.manager.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;AAEnC,2CAA4C;AAC5C,4DAUgC;AAChC,gDAQ0B;AAa1B,+DAKoC;AAEpC,iEAGgC;AAChC,6DAAwD;AACxD,uDAAmD;AAEnD,2EAAuE;AAGhE,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,8BAUnC;IAKC,YACE,UAAsB,EACtB,UAAsB,EACtB,cAA8B,EAC9B,kBAAsC,EACtC,gBAAkC,EAClC,wBAAkD;QAElD,KAAK,CACH,UAAU,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,wBA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EAAE,CACrB,CAAC,IAAyB,EAAE,EAA0B,EAAE,EAAE,CACxD,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC;CACnC,CAAC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Injectable } from '@nestjs/common';\nimport {\n isBlockHandlerProcessor,\n isCallHandlerProcessor,\n isEventHandlerProcessor,\n isCustomDs,\n isRuntimeDs,\n SubqlEthereumCustomDataSource,\n EthereumHandlerKind,\n EthereumRuntimeHandlerInputMap,\n SubqlEthereumDataSource,\n} from '@subql/common-ethereum';\nimport {\n ApiService,\n NodeConfig,\n profiler,\n IndexerSandbox,\n ProcessBlockResponse,\n BaseIndexerManager,\n IBlock,\n} from '@subql/node-core';\nimport {\n EthereumTransaction,\n EthereumLog,\n EthereumBlock,\n SubqlRuntimeDatasource,\n EthereumBlockFilter,\n EthereumLogFilter,\n EthereumTransactionFilter,\n LightEthereumLog,\n} from '@subql/types-ethereum';\nimport { EthereumProjectDs } from '../configure/SubqueryProject';\nimport { EthereumApi } from '../ethereum';\nimport {\n filterBlocksProcessor,\n filterLogsProcessor,\n filterTransactionsProcessor,\n isFullBlock,\n} from '../ethereum/block.ethereum';\nimport SafeEthProvider from '../ethereum/safe-api';\nimport {\n asSecondLayerHandlerProcessor_1_0_0,\n DsProcessorService,\n} from './ds-processor.service';\nimport { DynamicDsService } from './dynamic-ds.service';\nimport { SandboxService } from './sandbox.service';\nimport { BlockContent } from './types';\nimport { UnfinalizedBlocksService } from './unfinalizedBlocks.service';\n\n@Injectable()\nexport class IndexerManager extends BaseIndexerManager<\n SafeEthProvider,\n EthereumApi,\n BlockContent,\n ApiService,\n SubqlEthereumDataSource,\n SubqlEthereumCustomDataSource,\n typeof FilterTypeMap,\n typeof ProcessorTypeMap,\n EthereumRuntimeHandlerInputMap\n> {\n protected isRuntimeDs = isRuntimeDs;\n protected isCustomDs = isCustomDs;\n protected updateCustomProcessor = asSecondLayerHandlerProcessor_1_0_0;\n\n constructor(\n apiService: ApiService,\n nodeConfig: NodeConfig,\n sandboxService: SandboxService,\n dsProcessorService: DsProcessorService,\n dynamicDsService: DynamicDsService,\n unfinalizedBlocksService: UnfinalizedBlocksService,\n ) {\n super(\n apiService,\n nodeConfig,\n sandboxService,\n dsProcessorService,\n dynamicDsService,\n unfinalizedBlocksService,\n FilterTypeMap,\n ProcessorTypeMap,\n );\n }\n\n @profiler()\n async indexBlock(\n block: IBlock<BlockContent>,\n dataSources: SubqlEthereumDataSource[],\n ): Promise<ProcessBlockResponse> {\n return super.internalIndexBlock(block, dataSources, () =>\n this.getApi(block.block),\n );\n }\n\n getBlockHeight(block: BlockContent): number {\n return block.number;\n }\n\n getBlockHash(block: BlockContent): string {\n return block.hash;\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n private async getApi(block: BlockContent): Promise<SafeEthProvider> {\n return this.apiService.safeApi(this.getBlockHeight(block));\n }\n\n protected async indexBlockData(\n block: BlockContent,\n dataSources: EthereumProjectDs[],\n getVM: (d: EthereumProjectDs) => Promise<IndexerSandbox>,\n ): Promise<void> {\n if (isFullBlock(block)) {\n await this.indexBlockContent(block, dataSources, getVM);\n\n for (const tx of block.transactions) {\n await this.indexTransaction(tx, dataSources, getVM);\n\n for (const log of tx.logs ?? []) {\n await this.indexEvent(log, dataSources, getVM);\n }\n }\n } else {\n for (const log of block.logs ?? []) {\n await this.indexEvent(log, dataSources, getVM);\n }\n }\n }\n\n private async indexBlockContent(\n block: EthereumBlock,\n dataSources: EthereumProjectDs[],\n getVM: (d: EthereumProjectDs) => Promise<IndexerSandbox>,\n ): Promise<void> {\n for (const ds of dataSources) {\n await this.indexData(EthereumHandlerKind.Block, block, ds, getVM);\n }\n }\n\n private async indexTransaction(\n tx: EthereumTransaction,\n dataSources: EthereumProjectDs[],\n getVM: (d: EthereumProjectDs) => Promise<IndexerSandbox>,\n ): Promise<void> {\n for (const ds of dataSources) {\n await this.indexData(EthereumHandlerKind.Call, tx, ds, getVM);\n }\n }\n\n private async indexEvent(\n log: EthereumLog | LightEthereumLog,\n dataSources: EthereumProjectDs[],\n getVM: (d: EthereumProjectDs) => Promise<IndexerSandbox>,\n ): Promise<void> {\n for (const ds of dataSources) {\n await this.indexData(EthereumHandlerKind.Event, log, ds, getVM);\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n protected async prepareFilteredData(\n kind: EthereumHandlerKind,\n data: any,\n ds: SubqlRuntimeDatasource,\n ): Promise<any> {\n return DataAbiParser[kind](this.apiService.api)(data, ds);\n }\n}\n\ntype ProcessorTypeMap = {\n [EthereumHandlerKind.Block]: typeof isBlockHandlerProcessor;\n [EthereumHandlerKind.Event]: typeof isEventHandlerProcessor;\n [EthereumHandlerKind.Call]: typeof isCallHandlerProcessor;\n};\n\nconst ProcessorTypeMap = {\n [EthereumHandlerKind.Block]: isBlockHandlerProcessor,\n [EthereumHandlerKind.Event]: isEventHandlerProcessor,\n [EthereumHandlerKind.Call]: isCallHandlerProcessor,\n};\n\nconst FilterTypeMap = {\n [EthereumHandlerKind.Block]: (\n data: EthereumBlock,\n filter: EthereumBlockFilter,\n ds: SubqlEthereumDataSource,\n ) => filterBlocksProcessor(data, filter, ds.options?.address),\n [EthereumHandlerKind.Event]: (\n data: EthereumLog | LightEthereumLog,\n filter: EthereumLogFilter,\n ds: SubqlEthereumDataSource,\n ) => filterLogsProcessor(data, filter, ds.options?.address),\n [EthereumHandlerKind.Call]: (\n data: EthereumTransaction,\n filter: EthereumTransactionFilter,\n ds: SubqlEthereumDataSource,\n ) => filterTransactionsProcessor(data, filter, ds.options?.address),\n};\n\nconst DataAbiParser = {\n [EthereumHandlerKind.Block]: () => (data: EthereumBlock) => data,\n [EthereumHandlerKind.Event]:\n (api: EthereumApi) =>\n (data: EthereumLog | LightEthereumLog, ds: SubqlRuntimeDatasource) =>\n api.parseLog(data, ds),\n [EthereumHandlerKind.Call]:\n (api: EthereumApi) =>\n (data: EthereumTransaction, ds: SubqlRuntimeDatasource) =>\n api.parseTransaction(data, ds),\n};\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { SubqlEthereumDataSource } from '@subql/common-ethereum';
|
|
2
2
|
import { NodeConfig, IProjectService, ProcessBlockResponse, ApiService, BaseWorkerService, IProjectUpgradeService, IBlock } from '@subql/node-core';
|
|
3
3
|
import { EthereumProjectDs } from '../../configure/SubqueryProject';
|
|
4
|
+
import { EthereumApi } from '../../ethereum';
|
|
5
|
+
import SafeEthProvider from '../../ethereum/safe-api';
|
|
4
6
|
import { IndexerManager } from '../indexer.manager';
|
|
5
7
|
import { BlockContent } from '../types';
|
|
6
8
|
export type FetchBlockResponse = {
|
|
@@ -15,7 +17,7 @@ export type WorkerStatusResponse = {
|
|
|
15
17
|
export declare class WorkerService extends BaseWorkerService<BlockContent, FetchBlockResponse, SubqlEthereumDataSource, {}> {
|
|
16
18
|
private apiService;
|
|
17
19
|
private indexerManager;
|
|
18
|
-
constructor(apiService: ApiService<
|
|
20
|
+
constructor(apiService: ApiService<EthereumApi, SafeEthProvider, IBlock<BlockContent>[]>, indexerManager: IndexerManager, projectService: IProjectService<EthereumProjectDs>, projectUpgradeService: IProjectUpgradeService, nodeConfig: NodeConfig);
|
|
19
21
|
protected fetchChainBlock(heights: number, extra: {}): Promise<IBlock<BlockContent>>;
|
|
20
22
|
protected toBlockResponse(block: BlockContent): {
|
|
21
23
|
parentHash: string;
|
|
@@ -26,7 +26,7 @@ let WorkerService = class WorkerService extends node_core_1.BaseWorkerService {
|
|
|
26
26
|
}
|
|
27
27
|
async fetchChainBlock(heights, extra) {
|
|
28
28
|
const [block] = await this.apiService.fetchBlocks([heights]);
|
|
29
|
-
return block
|
|
29
|
+
return block;
|
|
30
30
|
}
|
|
31
31
|
toBlockResponse(block) {
|
|
32
32
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.service.js","sourceRoot":"","sources":["../../../src/indexer/worker/worker.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AAEpD,gDAQ0B;
|
|
1
|
+
{"version":3,"file":"worker.service.js","sourceRoot":"","sources":["../../../src/indexer/worker/worker.service.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;AAEnC,2CAAoD;AAEpD,gDAQ0B;AAK1B,wDAAoD;AAa7C,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,6BAKlC;IACC,YACU,UAIP,EACO,cAA8B,EAEtC,cAAkD,EAElD,qBAA6C,EAC7C,UAAsB;QAEtB,KAAK,CAAC,cAAc,EAAE,qBAAqB,EAAE,UAAU,CAAC,CAAC;QAZjD,eAAU,GAAV,UAAU,CAIjB;QACO,mBAAc,GAAd,cAAc,CAAgB;IAQxC,CAAC;IAES,KAAK,CAAC,eAAe,CAC7B,OAAe,EACf,KAAS;QAET,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7D,OAAO,KAAK,CAAC;IACf,CAAC;IAES,eAAe,CAAC,KAAmB;QAC3C,OAAO;YACL,UAAU,EAAE,KAAK,CAAC,UAAU;SAC7B,CAAC;IACJ,CAAC;IAES,KAAK,CAAC,mBAAmB,CACjC,KAA2B,EAC3B,WAAsC;QAEtC,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IAC5D,CAAC;CACF,CAAA;AA1CY,aAAa;IADzB,IAAA,mBAAU,GAAE;IAcR,WAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;IAEzB,WAAA,IAAA,eAAM,EAAC,wBAAwB,CAAC,CAAA;qCARb,sBAAU;QAKN,gCAAc,kBAK1B,sBAAU;GAjBb,aAAa,CA0CzB;AA1CY,sCAAa","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport { SubqlEthereumDataSource } from '@subql/common-ethereum';\nimport {\n NodeConfig,\n IProjectService,\n ProcessBlockResponse,\n ApiService,\n BaseWorkerService,\n IProjectUpgradeService,\n IBlock,\n} from '@subql/node-core';\nimport { EthereumBlock, LightEthereumBlock } from '@subql/types-ethereum';\nimport { EthereumProjectDs } from '../../configure/SubqueryProject';\nimport { EthereumApi } from '../../ethereum';\nimport SafeEthProvider from '../../ethereum/safe-api';\nimport { IndexerManager } from '../indexer.manager';\nimport { BlockContent } from '../types';\n\nexport type FetchBlockResponse = { parentHash: string } | undefined;\n\nexport type WorkerStatusResponse = {\n threadId: number;\n isIndexing: boolean;\n fetchedBlocks: number;\n toFetchBlocks: number;\n};\n\n@Injectable()\nexport class WorkerService extends BaseWorkerService<\n BlockContent,\n FetchBlockResponse,\n SubqlEthereumDataSource,\n {}\n> {\n constructor(\n private apiService: ApiService<\n EthereumApi,\n SafeEthProvider,\n IBlock<BlockContent>[]\n >,\n private indexerManager: IndexerManager,\n @Inject('IProjectService')\n projectService: IProjectService<EthereumProjectDs>,\n @Inject('IProjectUpgradeService')\n projectUpgradeService: IProjectUpgradeService,\n nodeConfig: NodeConfig,\n ) {\n super(projectService, projectUpgradeService, nodeConfig);\n }\n\n protected async fetchChainBlock(\n heights: number,\n extra: {},\n ): Promise<IBlock<BlockContent>> {\n const [block] = await this.apiService.fetchBlocks([heights]);\n return block;\n }\n\n protected toBlockResponse(block: BlockContent): { parentHash: string } {\n return {\n parentHash: block.parentHash,\n };\n }\n\n protected async processFetchedBlock(\n block: IBlock<BlockContent>,\n dataSources: SubqlEthereumDataSource[],\n ): Promise<ProcessBlockResponse> {\n return this.indexerManager.indexBlock(block, dataSources);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subql/node-ethereum",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Ian He",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@nestjs/schedule": "^3.0.1",
|
|
28
28
|
"@subql/common": "^3.5.0",
|
|
29
29
|
"@subql/common-ethereum": "3.5.0",
|
|
30
|
-
"@subql/node-core": "^8.0.
|
|
30
|
+
"@subql/node-core": "^8.0.1",
|
|
31
31
|
"@subql/testing": "^2.1.1-0",
|
|
32
32
|
"@subql/types-ethereum": "3.5.0",
|
|
33
33
|
"cacheable-lookup": "6",
|
|
@@ -65,6 +65,5 @@
|
|
|
65
65
|
"files": [
|
|
66
66
|
"/dist",
|
|
67
67
|
"/bin"
|
|
68
|
-
]
|
|
69
|
-
"stableVersion": "4.0.0"
|
|
68
|
+
]
|
|
70
69
|
}
|