@subql/node-ethereum 2.6.1 → 2.6.2-1
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 +4 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/ethereum/api.service.ethereum.d.ts +1 -0
- package/dist/ethereum/api.service.ethereum.js +27 -0
- package/dist/ethereum/api.service.ethereum.js.map +1 -1
- package/dist/indexer/fetch.service.js +6 -2
- package/dist/indexer/fetch.service.js.map +1 -1
- package/dist/indexer/indexer.manager.js +1 -1
- package/dist/indexer/indexer.manager.js.map +1 -1
- package/dist/yargs.d.ts +6 -1
- package/dist/yargs.js +5 -0
- package/dist/yargs.js.map +1 -1
- package/package.json +3 -2
|
@@ -74,6 +74,33 @@ let EthereumApiService = class EthereumApiService extends node_core_1.ApiService
|
|
|
74
74
|
get api() {
|
|
75
75
|
return this.unsafeApi;
|
|
76
76
|
}
|
|
77
|
+
safeApi(height) {
|
|
78
|
+
const maxRetries = 5;
|
|
79
|
+
const handler = {
|
|
80
|
+
get: (target, prop, receiver) => {
|
|
81
|
+
const originalMethod = target[prop];
|
|
82
|
+
if (typeof originalMethod === 'function') {
|
|
83
|
+
return async (...args) => {
|
|
84
|
+
let retries = 0;
|
|
85
|
+
let currentApi = target;
|
|
86
|
+
while (retries < maxRetries) {
|
|
87
|
+
try {
|
|
88
|
+
return await originalMethod.apply(currentApi, args);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
logger.warn(`Request failed with api at height ${height} (retry ${retries}): ${error.message}`);
|
|
92
|
+
currentApi = this.unsafeApi.getSafeApi(height);
|
|
93
|
+
retries++;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
throw new Error(`Maximum retries (${maxRetries}) exceeded for api at height ${height}`);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return Reflect.get(target, prop, receiver);
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
return new Proxy(this.unsafeApi.getSafeApi(height), handler);
|
|
103
|
+
}
|
|
77
104
|
async fetchBlockBatches(api, batch) {
|
|
78
105
|
return api.fetchBlocks(batch);
|
|
79
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.service.ethereum.js","sourceRoot":"","sources":["../../src/ethereum/api.service.ethereum.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;;;;;;;;;;AAEtC,2CAAoD;AACpD,yDAAsD;AAEtD,gDAM0B;AAE1B,kEAA+D;AAC/D,qDAAyD;AAIzD,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC;AAEhC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AAG1B,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,sBAIvC;IACC,YACsC,OAAwB,EAC5D,qBAAmE,EAC3D,YAA2B;QAEnC,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAJO,YAAO,GAAP,OAAO,CAAiB;QAEpD,iBAAY,GAAZ,YAAY,CAAe;IAGrC,CAAC;IAID,KAAK,CAAC,IAAI;QACR,IAAI;YACF,IAAI,OAA6B,CAAC;YAClC,IAAI;gBACF,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;aAChC;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACjB;YAED,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC;gBAC/C,CAAC,CAAC,OAAO,CAAC,QAAQ;gBAClB,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAEvB,MAAM,kBAAkB,GAA0C,EAAE,CAAC;YAErE,MAAM,OAAO,CAAC,GAAG,CACf,SAAS,CAAC,G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AAC;CACF,CAAA;AAjIY,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;IAOR,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;qCAAkB,iCAAe;QACrC,iCAAqB;QACtB,6BAAa;GAR1B,kBAAkB,CAiI9B;AAjIY,gDAAkB","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { ProjectNetworkV1_0_0 } from '@subql/common-ethereum';\nimport {\n ApiService,\n ConnectionPoolService,\n NetworkMetadataPayload,\n getLogger,\n IndexerEvent,\n} from '@subql/node-core';\nimport { EthereumBlockWrapper } from '@subql/types-ethereum';\nimport { SubqueryProject } from '../configure/SubqueryProject';\nimport { EthereumApiConnection } from './api.connection';\nimport { EthereumApi } from './api.ethereum';\nimport SafeEthProvider from './safe-api';\n\nconst logger = getLogger('api');\n\nconst MAX_RECONNECT_ATTEMPTS = 5;\n\n@Injectable()\nexport class EthereumApiService extends ApiService<\n EthereumApi,\n SafeEthProvider,\n EthereumBlockWrapper\n> {\n constructor(\n @Inject('ISubqueryProject') private project: SubqueryProject,\n connectionPoolService: ConnectionPoolService<EthereumApiConnection>,\n private eventEmitter: EventEmitter2,\n ) {\n super(connectionPoolService);\n }\n\n networkMeta: NetworkMetadataPayload;\n\n async init(): Promise<EthereumApiService> {\n try {\n let network: ProjectNetworkV1_0_0;\n try {\n network = this.project.network;\n } catch (e) {\n logger.error(Object.keys(e));\n process.exit(1);\n }\n\n const endpoints = Array.isArray(network.endpoint)\n ? network.endpoint\n : [network.endpoint];\n\n const endpointToApiIndex: Record<string, EthereumApiConnection> = {};\n\n await Promise.all(\n endpoints.map(async (endpoint, i) => {\n const connection = await EthereumApiConnection.create(\n endpoint,\n this.fetchBlockBatches,\n this.eventEmitter,\n );\n\n const api = connection.unsafeApi;\n\n this.eventEmitter.emit(IndexerEvent.ApiConnected, {\n value: 1,\n apiIndex: i,\n endpoint: endpoint,\n });\n\n if (!this.networkMeta) {\n this.networkMeta = connection.networkMeta;\n }\n\n if (network.chainId !== api.getChainId().toString()) {\n throw this.metadataMismatchError(\n 'ChainId',\n network.chainId,\n api.getChainId().toString(),\n );\n }\n\n endpointToApiIndex[endpoint] = connection;\n }),\n );\n\n this.connectionPoolService.addBatchToConnections(endpointToApiIndex);\n\n return this;\n } catch (e) {\n logger.error(e, 'Failed to init api service');\n process.exit(1);\n }\n }\n\n private metadataMismatchError(\n metadata: string,\n expected: string,\n actual: string,\n ): Error {\n return Error(\n `Value of ${metadata} does not match across all endpoints. Please check that your endpoints are for the same network.\\n\n Expected: ${expected}\n Actual: ${actual}`,\n );\n }\n\n get api(): EthereumApi {\n return this.unsafeApi;\n }\n\n safeApi(height: number): SafeEthProvider {\n const maxRetries = 5;\n\n const handler: ProxyHandler<SafeEthProvider> = {\n get: (target, prop, receiver) => {\n const originalMethod = target[prop as keyof SafeEthProvider];\n if (typeof originalMethod === 'function') {\n return async (...args: any[]) => {\n let retries = 0;\n let currentApi = target;\n\n while (retries < maxRetries) {\n try {\n return await originalMethod.apply(currentApi, args);\n } catch (error) {\n logger.warn(\n `Request failed with api at height ${height} (retry ${retries}): ${error.message}`,\n );\n currentApi = this.unsafeApi.getSafeApi(height);\n retries++;\n }\n }\n\n throw new Error(\n `Maximum retries (${maxRetries}) exceeded for api at height ${height}`,\n );\n };\n }\n return Reflect.get(target, prop, receiver);\n },\n };\n\n return new Proxy(this.unsafeApi.getSafeApi(height), handler);\n }\n\n private async fetchBlockBatches(\n api: EthereumApi,\n batch: number[],\n ): Promise<EthereumBlockWrapper[]> {\n return api.fetchBlocks(batch);\n }\n}\n"]}
|
|
@@ -24,18 +24,22 @@ const lodash_1 = require("lodash");
|
|
|
24
24
|
const SubqueryProject_1 = require("../configure/SubqueryProject");
|
|
25
25
|
const utils_ethereum_1 = require("../ethereum/utils.ethereum");
|
|
26
26
|
const string_1 = require("../utils/string");
|
|
27
|
+
const yargs_1 = require("../yargs");
|
|
27
28
|
const dictionary_service_1 = require("./dictionary.service");
|
|
28
29
|
const ds_processor_service_1 = require("./ds-processor.service");
|
|
29
30
|
const dynamic_ds_service_1 = require("./dynamic-ds.service");
|
|
30
31
|
const unfinalizedBlocks_service_1 = require("./unfinalizedBlocks.service");
|
|
31
32
|
const BLOCK_TIME_VARIANCE = 5000;
|
|
32
33
|
const INTERVAL_PERCENT = 0.9;
|
|
33
|
-
const QUERY_ADDRESS_LIMIT = 50;
|
|
34
34
|
function eventFilterToQueryEntry(filter, dsOptions) {
|
|
35
|
+
const queryAddressLimit = yargs_1.yargsOptions.argv['query-address-limit'];
|
|
35
36
|
const conditions = [];
|
|
36
37
|
if (Array.isArray(dsOptions)) {
|
|
37
38
|
const addresses = dsOptions.map((option) => option.address).filter(Boolean);
|
|
38
|
-
if (addresses.length
|
|
39
|
+
if (addresses.length > queryAddressLimit) {
|
|
40
|
+
logger.warn(`Addresses length: ${addresses} is exceeding limit: ${queryAddressLimit}. Consider increasing this value with the flag --query-address-limit `);
|
|
41
|
+
}
|
|
42
|
+
if (addresses.length !== 0 && addresses.length <= queryAddressLimit) {
|
|
39
43
|
conditions.push({
|
|
40
44
|
field: 'address',
|
|
41
45
|
value: addresses,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.service.js","sourceRoot":"","sources":["../../src/indexer/fetch.service.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;;;;;;;;;;AAEtC,2CAAoD;AACpD,yDAAsD;AACtD,+CAAqD;AAErD,4DAMgC;AAChC,gDAA4E;AAI5E,mCAAiD;AACjD,kEAA+E;AAG/E,+DAA0D;AAC1D,4CAAkE;AAElE,6DAAyD;AACzD,iEAA4D;AAC5D,6DAAwD;AACxD,2EAGqC;AAErC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B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AM,CAAC,MAAM,EACrB;oBACA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;iBACrC;aACF;SACF;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAES,KAAK,CAAC,mBAAmB;QACjC,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACjE,CAAC;IAES,KAAK,CAAC,wBAAwB,CACtC,QAAkB;QAElB,OAAO,OAAO,CAAC,OAAO;QACpB,yBAAyB;QACzB,QAAQ,CAAC,WAAW,KAAK,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE;YAChD,6BAA6B;YAC7B,QAAQ,CAAC,WAAW,KAAK,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAC1D,CAAC;IACJ,CAAC;IAES,KAAK,CAAC,WAAW;QACzB,4CAA4C;QAC5C,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF,CAAA;AAvHY,YAAY;IADxB,IAAA,mBAAU,GAAE;IAUR,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;IAC1B,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;qCAHf,sBAAU;QACV,sBAAU;QACe,iCAAe,UAGjC,sCAAiB;QAChB,yCAAkB;QACpB,qCAAgB;QACA,oDAAwB;QAC5C,6BAAa;QACR,4BAAiB;GAjB3B,YAAY,CAuHxB;AAvHY,oCAAY","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { SchedulerRegistry } from '@nestjs/schedule';\n\nimport {\n isCustomDs,\n EthereumHandlerKind,\n EthereumLogFilter,\n SubqlEthereumProcessorOptions,\n EthereumTransactionFilter,\n} from '@subql/common-ethereum';\nimport { NodeConfig, BaseFetchService, ApiService } from '@subql/node-core';\nimport { DictionaryQueryCondition, DictionaryQueryEntry } from '@subql/types';\nimport { SubqlDatasource } from '@subql/types-ethereum';\nimport { MetaData } from '@subql/utils';\nimport { groupBy, sortBy, uniqBy } from 'lodash';\nimport { SubqlProjectDs, SubqueryProject } from '../configure/SubqueryProject';\nimport { EthereumApi, EthereumApiService } from '../ethereum';\nimport SafeEthProvider from '../ethereum/safe-api';\nimport { calcInterval } from '../ethereum/utils.ethereum';\nimport { eventToTopic, functionToSighash } from '../utils/string';\nimport { IEthereumBlockDispatcher } from './blockDispatcher';\nimport { DictionaryService } from './dictionary.service';\nimport { DsProcessorService } from './ds-processor.service';\nimport { DynamicDsService } from './dynamic-ds.service';\nimport {\n blockToHeader,\n UnfinalizedBlocksService,\n} from './unfinalizedBlocks.service';\n\nconst BLOCK_TIME_VARIANCE = 5000;\n\nconst INTERVAL_PERCENT = 0.9;\nconst QUERY_ADDRESS_LIMIT = 50;\n\nfunction eventFilterToQueryEntry(\n filter: EthereumLogFilter,\n dsOptions: SubqlEthereumProcessorOptions | SubqlEthereumProcessorOptions[],\n): DictionaryQueryEntry {\n const conditions: DictionaryQueryCondition[] = [];\n\n if (Array.isArray(dsOptions)) {\n const addresses = dsOptions.map((option) => option.address).filter(Boolean);\n\n if (addresses.length !== 0 && addresses.length <= QUERY_ADDRESS_LIMIT) {\n conditions.push({\n field: 'address',\n value: addresses,\n matcher: 'in',\n });\n }\n } else {\n if (dsOptions?.address) {\n conditions.push({\n field: 'address',\n value: dsOptions.address.toLowerCase(),\n matcher: 'equalTo',\n });\n }\n }\n if (filter.topics) {\n for (let i = 0; i < Math.min(filter.topics.length, 4); i++) {\n const topic = filter.topics[i];\n if (!topic) {\n continue;\n }\n const field = `topics${i}`;\n conditions.push({\n field,\n value: eventToTopic(topic),\n matcher: 'equalTo',\n });\n }\n }\n return {\n entity: 'evmLogs',\n conditions,\n };\n}\n\nfunction callFilterToQueryEntry(\n filter: EthereumTransactionFilter,\n): DictionaryQueryEntry {\n const conditions: DictionaryQueryCondition[] = [];\n if (filter.from) {\n conditions.push({\n field: 'from',\n value: filter.from.toLowerCase(),\n matcher: 'equalTo',\n });\n }\n if (filter.to) {\n conditions.push({\n field: 'to',\n value: filter.to.toLowerCase(),\n matcher: 'equalTo',\n });\n } else if (filter.to === null) {\n conditions.push({\n field: 'to',\n value: true as any, // TODO update types to allow boolean\n matcher: 'isNull',\n });\n }\n if (filter.function) {\n conditions.push({\n field: 'func',\n value: functionToSighash(filter.function),\n matcher: 'equalTo',\n });\n }\n return {\n entity: 'evmTransactions',\n conditions,\n };\n}\n\ntype GroupedSubqlProjectDs = SubqlDatasource & {\n groupedOptions?: SubqlEthereumProcessorOptions[];\n};\nexport function buildDictionaryQueryEntries(\n dataSources: GroupedSubqlProjectDs[],\n startBlock: number,\n): DictionaryQueryEntry[] {\n const queryEntries: DictionaryQueryEntry[] = [];\n\n // Only run the ds that is equal or less than startBlock\n // sort array from lowest ds.startBlock to highest\n const filteredDs = dataSources\n .filter((ds) => ds.startBlock <= startBlock)\n .sort((a, b) => a.startBlock - b.startBlock);\n\n for (const ds of filteredDs) {\n for (const handler of ds.mapping.handlers) {\n // No filters, cant use dictionary\n if (!handler.filter) return [];\n\n switch (handler.kind) {\n case EthereumHandlerKind.Block:\n return [];\n case EthereumHandlerKind.Call: {\n const filter = handler.filter as EthereumTransactionFilter;\n if (\n filter.from !== undefined ||\n filter.to !== undefined ||\n filter.function\n ) {\n queryEntries.push(callFilterToQueryEntry(filter));\n } else {\n return [];\n }\n break;\n }\n case EthereumHandlerKind.Event: {\n const filter = handler.filter as EthereumLogFilter;\n if (ds.groupedOptions) {\n queryEntries.push(\n eventFilterToQueryEntry(filter, ds.groupedOptions),\n );\n } else if (ds.options?.address || filter.topics) {\n queryEntries.push(eventFilterToQueryEntry(filter, ds.options));\n } else {\n return [];\n }\n break;\n }\n default:\n }\n }\n }\n\n return uniqBy(\n queryEntries,\n (item) =>\n `${item.entity}|${JSON.stringify(\n sortBy(item.conditions, (c) => c.field),\n )}`,\n );\n}\n\n@Injectable()\nexport class FetchService extends BaseFetchService<\n ApiService,\n SubqlDatasource,\n IEthereumBlockDispatcher,\n DictionaryService\n> {\n constructor(\n apiService: ApiService,\n nodeConfig: NodeConfig,\n @Inject('ISubqueryProject') project: SubqueryProject,\n @Inject('IBlockDispatcher')\n blockDispatcher: IEthereumBlockDispatcher,\n dictionaryService: DictionaryService,\n dsProcessorService: DsProcessorService,\n dynamicDsService: DynamicDsService,\n private unfinalizedBlocksService: UnfinalizedBlocksService,\n eventEmitter: EventEmitter2,\n schedulerRegistry: SchedulerRegistry,\n ) {\n super(\n apiService,\n nodeConfig,\n project,\n blockDispatcher,\n dictionaryService,\n dsProcessorService,\n dynamicDsService,\n eventEmitter,\n schedulerRegistry,\n );\n }\n\n get api(): EthereumApi {\n return this.apiService.unsafeApi;\n }\n\n buildDictionaryQueryEntries(startBlock: number): DictionaryQueryEntry[] {\n const groupdDynamicDs: GroupedSubqlProjectDs[] = Object.values(\n groupBy(this.templateDynamicDatasouces, (ds) => ds.name),\n ).map((grouped: SubqlProjectDs[]) => {\n const options = grouped.map((ds) => ds.options);\n const ref = grouped[0];\n\n return {\n ...ref,\n groupedOptions: options,\n };\n });\n\n // Only run the ds that is equal or less than startBlock\n // sort array from lowest ds.startBlock to highest\n const filteredDs: GroupedSubqlProjectDs[] =\n this.project.dataSources.concat(groupdDynamicDs);\n\n return buildDictionaryQueryEntries(filteredDs, startBlock);\n }\n\n protected async getFinalizedHeight(): Promise<number> {\n const block = await this.api.getFinalizedBlock();\n\n const header = blockToHeader(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 async getChainId(): Promise<string> {\n return Promise.resolve(this.api.getChainId().toString());\n }\n\n protected getModulos(): number[] {\n const modulos: number[] = [];\n for (const ds of this.project.dataSources) {\n if (isCustomDs(ds)) {\n continue;\n }\n for (const handler of ds.mapping.handlers) {\n if (\n handler.kind === EthereumHandlerKind.Block &&\n handler.filter &&\n handler.filter.modulo\n ) {\n modulos.push(handler.filter.modulo);\n }\n }\n }\n return modulos;\n }\n\n protected async initBlockDispatcher(): Promise<void> {\n await this.blockDispatcher.init(this.resetForNewDs.bind(this));\n }\n\n protected async validatateDictionaryMeta(\n metaData: MetaData,\n ): Promise<boolean> {\n return Promise.resolve(\n // When alias is not used\n metaData.genesisHash !== this.api.getGenesisHash() &&\n // Case when an alias is used\n metaData.genesisHash !== this.dictionaryService.chainId,\n );\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
|
+
{"version":3,"file":"fetch.service.js","sourceRoot":"","sources":["../../src/indexer/fetch.service.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;;;;;;;;;;AAEtC,2CAAoD;AACpD,yDAAsD;AACtD,+CAAqD;AAErD,4DAMgC;AAChC,gDAA4E;AAI5E,mCAAiD;AACjD,kEAA+E;AAG/E,+DAA0D;AAC1D,4CAAkE;AAClE,oCAAwC;AAExC,6DAAyD;AACzD,iEAA4D;AAC5D,6DAAwD;AACxD,2EAGqC;AAErC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,SAAS,uBAAuB,CAC9B,MAAyB,EACzB,SAA0E;IAE1E,MAAM,iBAAiB,GAAG,oBAAY,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAEnE,MAAM,UAAU,GAA+B,EAAE,CAAC;IAElD,IAAI,KAAK,CAAC,OAAO,CAAC,SA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ACA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;iBACrC;aACF;SACF;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAES,KAAK,CAAC,mBAAmB;QACjC,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACjE,CAAC;IAES,KAAK,CAAC,wBAAwB,CACtC,QAAkB;QAElB,OAAO,OAAO,CAAC,OAAO;QACpB,yBAAyB;QACzB,QAAQ,CAAC,WAAW,KAAK,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE;YAChD,6BAA6B;YAC7B,QAAQ,CAAC,WAAW,KAAK,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAC1D,CAAC;IACJ,CAAC;IAES,KAAK,CAAC,WAAW;QACzB,4CAA4C;QAC5C,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF,CAAA;AAvHY,YAAY;IADxB,IAAA,mBAAU,GAAE;IAUR,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;IAC1B,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;qCAHf,sBAAU;QACV,sBAAU;QACe,iCAAe,UAGjC,sCAAiB;QAChB,yCAAkB;QACpB,qCAAgB;QACA,oDAAwB;QAC5C,6BAAa;QACR,4BAAiB;GAjB3B,YAAY,CAuHxB;AAvHY,oCAAY","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Inject, Injectable } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { SchedulerRegistry } from '@nestjs/schedule';\n\nimport {\n isCustomDs,\n EthereumHandlerKind,\n EthereumLogFilter,\n SubqlEthereumProcessorOptions,\n EthereumTransactionFilter,\n} from '@subql/common-ethereum';\nimport { NodeConfig, BaseFetchService, ApiService } from '@subql/node-core';\nimport { DictionaryQueryCondition, DictionaryQueryEntry } from '@subql/types';\nimport { SubqlDatasource } from '@subql/types-ethereum';\nimport { MetaData } from '@subql/utils';\nimport { groupBy, sortBy, uniqBy } from 'lodash';\nimport { SubqlProjectDs, SubqueryProject } from '../configure/SubqueryProject';\nimport { EthereumApi, EthereumApiService } from '../ethereum';\nimport SafeEthProvider from '../ethereum/safe-api';\nimport { calcInterval } from '../ethereum/utils.ethereum';\nimport { eventToTopic, functionToSighash } from '../utils/string';\nimport { yargsOptions } from '../yargs';\nimport { IEthereumBlockDispatcher } from './blockDispatcher';\nimport { DictionaryService } from './dictionary.service';\nimport { DsProcessorService } from './ds-processor.service';\nimport { DynamicDsService } from './dynamic-ds.service';\nimport {\n blockToHeader,\n UnfinalizedBlocksService,\n} from './unfinalizedBlocks.service';\n\nconst BLOCK_TIME_VARIANCE = 5000;\n\nconst INTERVAL_PERCENT = 0.9;\n\nfunction eventFilterToQueryEntry(\n filter: EthereumLogFilter,\n dsOptions: SubqlEthereumProcessorOptions | SubqlEthereumProcessorOptions[],\n): DictionaryQueryEntry {\n const queryAddressLimit = yargsOptions.argv['query-address-limit'];\n\n const conditions: DictionaryQueryCondition[] = [];\n\n if (Array.isArray(dsOptions)) {\n const addresses = dsOptions.map((option) => option.address).filter(Boolean);\n\n if (addresses.length > queryAddressLimit) {\n logger.warn(\n `Addresses length: ${addresses} is exceeding limit: ${queryAddressLimit}. Consider increasing this value with the flag --query-address-limit `,\n );\n }\n\n if (addresses.length !== 0 && addresses.length <= queryAddressLimit) {\n conditions.push({\n field: 'address',\n value: addresses,\n matcher: 'in',\n });\n }\n } else {\n if (dsOptions?.address) {\n conditions.push({\n field: 'address',\n value: dsOptions.address.toLowerCase(),\n matcher: 'equalTo',\n });\n }\n }\n if (filter.topics) {\n for (let i = 0; i < Math.min(filter.topics.length, 4); i++) {\n const topic = filter.topics[i];\n if (!topic) {\n continue;\n }\n const field = `topics${i}`;\n conditions.push({\n field,\n value: eventToTopic(topic),\n matcher: 'equalTo',\n });\n }\n }\n return {\n entity: 'evmLogs',\n conditions,\n };\n}\n\nfunction callFilterToQueryEntry(\n filter: EthereumTransactionFilter,\n): DictionaryQueryEntry {\n const conditions: DictionaryQueryCondition[] = [];\n if (filter.from) {\n conditions.push({\n field: 'from',\n value: filter.from.toLowerCase(),\n matcher: 'equalTo',\n });\n }\n if (filter.to) {\n conditions.push({\n field: 'to',\n value: filter.to.toLowerCase(),\n matcher: 'equalTo',\n });\n } else if (filter.to === null) {\n conditions.push({\n field: 'to',\n value: true as any, // TODO update types to allow boolean\n matcher: 'isNull',\n });\n }\n if (filter.function) {\n conditions.push({\n field: 'func',\n value: functionToSighash(filter.function),\n matcher: 'equalTo',\n });\n }\n return {\n entity: 'evmTransactions',\n conditions,\n };\n}\n\ntype GroupedSubqlProjectDs = SubqlDatasource & {\n groupedOptions?: SubqlEthereumProcessorOptions[];\n};\nexport function buildDictionaryQueryEntries(\n dataSources: GroupedSubqlProjectDs[],\n startBlock: number,\n): DictionaryQueryEntry[] {\n const queryEntries: DictionaryQueryEntry[] = [];\n\n // Only run the ds that is equal or less than startBlock\n // sort array from lowest ds.startBlock to highest\n const filteredDs = dataSources\n .filter((ds) => ds.startBlock <= startBlock)\n .sort((a, b) => a.startBlock - b.startBlock);\n\n for (const ds of filteredDs) {\n for (const handler of ds.mapping.handlers) {\n // No filters, cant use dictionary\n if (!handler.filter) return [];\n\n switch (handler.kind) {\n case EthereumHandlerKind.Block:\n return [];\n case EthereumHandlerKind.Call: {\n const filter = handler.filter as EthereumTransactionFilter;\n if (\n filter.from !== undefined ||\n filter.to !== undefined ||\n filter.function\n ) {\n queryEntries.push(callFilterToQueryEntry(filter));\n } else {\n return [];\n }\n break;\n }\n case EthereumHandlerKind.Event: {\n const filter = handler.filter as EthereumLogFilter;\n if (ds.groupedOptions) {\n queryEntries.push(\n eventFilterToQueryEntry(filter, ds.groupedOptions),\n );\n } else if (ds.options?.address || filter.topics) {\n queryEntries.push(eventFilterToQueryEntry(filter, ds.options));\n } else {\n return [];\n }\n break;\n }\n default:\n }\n }\n }\n\n return uniqBy(\n queryEntries,\n (item) =>\n `${item.entity}|${JSON.stringify(\n sortBy(item.conditions, (c) => c.field),\n )}`,\n );\n}\n\n@Injectable()\nexport class FetchService extends BaseFetchService<\n ApiService,\n SubqlDatasource,\n IEthereumBlockDispatcher,\n DictionaryService\n> {\n constructor(\n apiService: ApiService,\n nodeConfig: NodeConfig,\n @Inject('ISubqueryProject') project: SubqueryProject,\n @Inject('IBlockDispatcher')\n blockDispatcher: IEthereumBlockDispatcher,\n dictionaryService: DictionaryService,\n dsProcessorService: DsProcessorService,\n dynamicDsService: DynamicDsService,\n private unfinalizedBlocksService: UnfinalizedBlocksService,\n eventEmitter: EventEmitter2,\n schedulerRegistry: SchedulerRegistry,\n ) {\n super(\n apiService,\n nodeConfig,\n project,\n blockDispatcher,\n dictionaryService,\n dsProcessorService,\n dynamicDsService,\n eventEmitter,\n schedulerRegistry,\n );\n }\n\n get api(): EthereumApi {\n return this.apiService.unsafeApi;\n }\n\n buildDictionaryQueryEntries(startBlock: number): DictionaryQueryEntry[] {\n const groupdDynamicDs: GroupedSubqlProjectDs[] = Object.values(\n groupBy(this.templateDynamicDatasouces, (ds) => ds.name),\n ).map((grouped: SubqlProjectDs[]) => {\n const options = grouped.map((ds) => ds.options);\n const ref = grouped[0];\n\n return {\n ...ref,\n groupedOptions: options,\n };\n });\n\n // Only run the ds that is equal or less than startBlock\n // sort array from lowest ds.startBlock to highest\n const filteredDs: GroupedSubqlProjectDs[] =\n this.project.dataSources.concat(groupdDynamicDs);\n\n return buildDictionaryQueryEntries(filteredDs, startBlock);\n }\n\n protected async getFinalizedHeight(): Promise<number> {\n const block = await this.api.getFinalizedBlock();\n\n const header = blockToHeader(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 async getChainId(): Promise<string> {\n return Promise.resolve(this.api.getChainId().toString());\n }\n\n protected getModulos(): number[] {\n const modulos: number[] = [];\n for (const ds of this.project.dataSources) {\n if (isCustomDs(ds)) {\n continue;\n }\n for (const handler of ds.mapping.handlers) {\n if (\n handler.kind === EthereumHandlerKind.Block &&\n handler.filter &&\n handler.filter.modulo\n ) {\n modulos.push(handler.filter.modulo);\n }\n }\n }\n return modulos;\n }\n\n protected async initBlockDispatcher(): Promise<void> {\n await this.blockDispatcher.init(this.resetForNewDs.bind(this));\n }\n\n protected async validatateDictionaryMeta(\n metaData: MetaData,\n ): Promise<boolean> {\n return Promise.resolve(\n // When alias is not used\n metaData.genesisHash !== this.api.getGenesisHash() &&\n // Case when an alias is used\n metaData.genesisHash !== this.dictionaryService.chainId,\n );\n }\n\n protected async preLoopHook(): Promise<void> {\n // Ethereum doesn't need to do anything here\n return Promise.resolve();\n }\n}\n"]}
|
|
@@ -48,7 +48,7 @@ let IndexerManager = class IndexerManager extends node_core_1.BaseIndexerManager
|
|
|
48
48
|
}
|
|
49
49
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
50
50
|
async getApi(block) {
|
|
51
|
-
return this.apiService.
|
|
51
|
+
return this.apiService.safeApi(this.getBlockHeight(block));
|
|
52
52
|
}
|
|
53
53
|
async indexBlockData({ block, transactions }, dataSources, getVM) {
|
|
54
54
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexer.manager.js","sourceRoot":"","sources":["../../src/indexer/indexer.manager.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;;;;;;;;;;AAEtC,2CAAoD;AACpD,4DAUgC;AAChC,gDAQ0B;AAa1B,+DAAkE;AAElE,iE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MAAA,EAAE,CAAC,OAAO,0CAAE,OAAO,CACpB,CAAA;KAAA;CACJ,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,CAAC,CAAC,IAAiB,EAAE,EAA0B,EAAE,EAAE,CACtE,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-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Inject, 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 ApiService,\n} from '@subql/node-core';\nimport {\n EthereumTransaction,\n EthereumLog,\n EthereumBlockWrapper,\n EthereumBlock,\n SubqlRuntimeDatasource,\n EthereumBlockFilter,\n EthereumLogFilter,\n EthereumTransactionFilter,\n} from '@subql/types-ethereum';\nimport { SubqlProjectDs } from '../configure/SubqueryProject';\nimport { EthereumApi, EthereumApiService } from '../ethereum';\nimport { EthereumBlockWrapped } 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 { ProjectService } from './project.service';\nimport { SandboxService } from './sandbox.service';\nimport { UnfinalizedBlocksService } from './unfinalizedBlocks.service';\n\nconst logger = getLogger('indexer');\n\n@Injectable()\nexport class IndexerManager extends BaseIndexerManager<\n SafeEthProvider,\n EthereumApi,\n EthereumBlockWrapper,\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 @Inject('IProjectService') private projectService: ProjectService,\n ) {\n super(\n apiService,\n nodeConfig,\n sandboxService,\n dsProcessorService,\n dynamicDsService,\n unfinalizedBlocksService,\n FilterTypeMap,\n ProcessorTypeMap,\n );\n }\n\n async start(): Promise<void> {\n await this.projectService.init();\n logger.info('indexer manager started');\n }\n\n @profiler()\n async indexBlock(\n block: EthereumBlockWrapper,\n dataSources: SubqlEthereumDataSource[],\n ): Promise<ProcessBlockResponse> {\n return super.internalIndexBlock(block, dataSources, () =>\n this.getApi(block),\n );\n }\n\n getBlockHeight(block: EthereumBlockWrapper): number {\n return block.blockHeight;\n }\n\n getBlockHash(block: EthereumBlockWrapper): string {\n return block.block.hash;\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n private async getApi(block: EthereumBlockWrapper): Promise<SafeEthProvider> {\n return this.apiService.api.getSafeApi(this.getBlockHeight(block));\n }\n\n protected async indexBlockData(\n { block, transactions }: EthereumBlockWrapper,\n dataSources: SubqlProjectDs[],\n getVM: (d: SubqlProjectDs) => Promise<IndexerSandbox>,\n ): Promise<void> {\n await this.indexBlockContent(block, dataSources, getVM);\n\n for (const tx of 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 }\n\n private async indexBlockContent(\n block: EthereumBlock,\n dataSources: SubqlProjectDs[],\n getVM: (d: SubqlProjectDs) => 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: SubqlProjectDs[],\n getVM: (d: SubqlProjectDs) => 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,\n dataSources: SubqlProjectDs[],\n getVM: (d: SubqlProjectDs) => 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 ) =>\n EthereumBlockWrapped.filterBlocksProcessor(\n data,\n filter,\n ds.options?.address,\n ),\n [EthereumHandlerKind.Event]: (\n data: EthereumLog,\n filter: EthereumLogFilter,\n ds: SubqlEthereumDataSource,\n ) =>\n EthereumBlockWrapped.filterLogsProcessor(data, filter, ds.options?.address),\n [EthereumHandlerKind.Call]: (\n data: EthereumTransaction,\n filter: EthereumTransactionFilter,\n ds: SubqlEthereumDataSource,\n ) =>\n EthereumBlockWrapped.filterTransactionsProcessor(\n data,\n filter,\n ds.options?.address,\n ),\n};\n\nconst DataAbiParser = {\n [EthereumHandlerKind.Block]: () => (data: EthereumBlock) => data,\n [EthereumHandlerKind.Event]:\n (api: EthereumApi) => (data: EthereumLog, 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,gEAAgE;AAChE,sCAAsC;;;;;;;;;;;;;;;AAEtC,2CAAoD;AACpD,4DAUgC;AAChC,gDAQ0B;AAa1B,+DAAkE;AAElE,iEAGgC;AAChC,6DAAwD;AACxD,uDAAmD;AACnD,uDAAmD;AACnD,2EAAuE;AAEvE,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,SAAS,CAAC,CAAC;AAG7B,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,8BAUnC;IAKC,YACE,UAAsB,EACtB,UAAsB,EACtB,cAA8B,EAC9B,kBAAsC,EACtC,gBAAkC,EAClC,wBAAkD,EACf,cAA8B;QAEjE,KAAK,CACH,UAAU,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,gBAAgB,CACjB,CAAC;QAXiC,mBAAc,GAAd,cAAc,CAAgB;QAXzD,gBAAW,GAAG,6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AAE,CACxD,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC;CACnC,CAAC","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Inject, 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 ApiService,\n} from '@subql/node-core';\nimport {\n EthereumTransaction,\n EthereumLog,\n EthereumBlockWrapper,\n EthereumBlock,\n SubqlRuntimeDatasource,\n EthereumBlockFilter,\n EthereumLogFilter,\n EthereumTransactionFilter,\n} from '@subql/types-ethereum';\nimport { SubqlProjectDs } from '../configure/SubqueryProject';\nimport { EthereumApi, EthereumApiService } from '../ethereum';\nimport { EthereumBlockWrapped } 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 { ProjectService } from './project.service';\nimport { SandboxService } from './sandbox.service';\nimport { UnfinalizedBlocksService } from './unfinalizedBlocks.service';\n\nconst logger = getLogger('indexer');\n\n@Injectable()\nexport class IndexerManager extends BaseIndexerManager<\n SafeEthProvider,\n EthereumApi,\n EthereumBlockWrapper,\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 @Inject('IProjectService') private projectService: ProjectService,\n ) {\n super(\n apiService,\n nodeConfig,\n sandboxService,\n dsProcessorService,\n dynamicDsService,\n unfinalizedBlocksService,\n FilterTypeMap,\n ProcessorTypeMap,\n );\n }\n\n async start(): Promise<void> {\n await this.projectService.init();\n logger.info('indexer manager started');\n }\n\n @profiler()\n async indexBlock(\n block: EthereumBlockWrapper,\n dataSources: SubqlEthereumDataSource[],\n ): Promise<ProcessBlockResponse> {\n return super.internalIndexBlock(block, dataSources, () =>\n this.getApi(block),\n );\n }\n\n getBlockHeight(block: EthereumBlockWrapper): number {\n return block.blockHeight;\n }\n\n getBlockHash(block: EthereumBlockWrapper): string {\n return block.block.hash;\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n private async getApi(block: EthereumBlockWrapper): Promise<SafeEthProvider> {\n return this.apiService.safeApi(this.getBlockHeight(block));\n }\n\n protected async indexBlockData(\n { block, transactions }: EthereumBlockWrapper,\n dataSources: SubqlProjectDs[],\n getVM: (d: SubqlProjectDs) => Promise<IndexerSandbox>,\n ): Promise<void> {\n await this.indexBlockContent(block, dataSources, getVM);\n\n for (const tx of 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 }\n\n private async indexBlockContent(\n block: EthereumBlock,\n dataSources: SubqlProjectDs[],\n getVM: (d: SubqlProjectDs) => 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: SubqlProjectDs[],\n getVM: (d: SubqlProjectDs) => 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,\n dataSources: SubqlProjectDs[],\n getVM: (d: SubqlProjectDs) => 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 ) =>\n EthereumBlockWrapped.filterBlocksProcessor(\n data,\n filter,\n ds.options?.address,\n ),\n [EthereumHandlerKind.Event]: (\n data: EthereumLog,\n filter: EthereumLogFilter,\n ds: SubqlEthereumDataSource,\n ) =>\n EthereumBlockWrapped.filterLogsProcessor(data, filter, ds.options?.address),\n [EthereumHandlerKind.Call]: (\n data: EthereumTransaction,\n filter: EthereumTransactionFilter,\n ds: SubqlEthereumDataSource,\n ) =>\n EthereumBlockWrapped.filterTransactionsProcessor(\n data,\n filter,\n ds.options?.address,\n ),\n};\n\nconst DataAbiParser = {\n [EthereumHandlerKind.Block]: () => (data: EthereumBlock) => data,\n [EthereumHandlerKind.Event]:\n (api: EthereumApi) => (data: EthereumLog, 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"]}
|
package/dist/yargs.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ export declare const yargsOptions: import("yargs").Argv<import("yargs").Omit<imp
|
|
|
75
75
|
describe: string;
|
|
76
76
|
type: "string";
|
|
77
77
|
};
|
|
78
|
-
}>, "unsafe" | "mmr-store-type" | "mmr-path" | "db-schema" | "subquery" | "batch-size" | "block-confirmations" | "config" | "debug" | "dictionary-resolver" | "dictionary-timeout" | "disable-historical" | "ipfs" | "local" | "log-level" | "multi-chain" | "network-dictionary" | "network-endpoint" | "output-fmt" | "port" | "profiler" | "proof-of-index" | "query-limit" | "scale-batch-size" | "pg-ca" | "pg-key" | "pg-cert" | "store-cache-threshold" | "store-get-cache-size" | "store-cache-async" | "store-flush-interval" | "subquery-name" | "subscription" | "timeout" | "timestamp-field" | "unfinalized-blocks" | "workers" | "root"> & import("yargs").InferredOptionTypes<{
|
|
78
|
+
}>, "unsafe" | "mmr-store-type" | "mmr-path" | "db-schema" | "subquery" | "batch-size" | "block-confirmations" | "config" | "debug" | "dictionary-resolver" | "dictionary-timeout" | "disable-historical" | "ipfs" | "local" | "log-level" | "multi-chain" | "network-dictionary" | "network-endpoint" | "output-fmt" | "port" | "profiler" | "proof-of-index" | "query-limit" | "scale-batch-size" | "pg-ca" | "pg-key" | "pg-cert" | "store-cache-threshold" | "store-get-cache-size" | "store-cache-async" | "store-flush-interval" | "subquery-name" | "subscription" | "timeout" | "timestamp-field" | "unfinalized-blocks" | "workers" | "root" | "query-address-limit"> & import("yargs").InferredOptionTypes<{
|
|
79
79
|
'batch-size': {
|
|
80
80
|
demandOption: false;
|
|
81
81
|
describe: string;
|
|
@@ -291,4 +291,9 @@ export declare const yargsOptions: import("yargs").Argv<import("yargs").Omit<imp
|
|
|
291
291
|
describe: string;
|
|
292
292
|
type: "string";
|
|
293
293
|
};
|
|
294
|
+
'query-address-limit': {
|
|
295
|
+
describe: string;
|
|
296
|
+
type: "number";
|
|
297
|
+
default: number;
|
|
298
|
+
};
|
|
294
299
|
}>>;
|
package/dist/yargs.js
CHANGED
|
@@ -367,6 +367,11 @@ exports.yargsOptions = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)
|
|
|
367
367
|
describe: 'This is a hidden flag only used from the main thread to workers. It provides a root directory for the project. This is a temp directory with IPFS and GitHub projects.',
|
|
368
368
|
type: 'string',
|
|
369
369
|
},
|
|
370
|
+
'query-address-limit': {
|
|
371
|
+
describe: 'Set the limit for address on dictionary queries for dynamic datasources',
|
|
372
|
+
type: 'number',
|
|
373
|
+
default: 100,
|
|
374
|
+
},
|
|
370
375
|
})
|
|
371
376
|
.hide('root'); // root is hidden because its for internal use
|
|
372
377
|
//# sourceMappingURL=yargs.js.map
|
package/dist/yargs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yargs.js","sourceRoot":"","sources":["../src/yargs.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;AAEtC,oDAAqD;AACrD,2CAAwC;AACxC,wDAAgC;AAEnB,QAAA,YAAY,GAAG,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KACrD,GAAG,CAAC,YAAY,CAAC;KACjB,OAAO,CAAC;IACP,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE,sCAAsC;IAChD,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QAChB,IAAA,mBAAU,EACR,IAAI,CAAC,KAAgB,EACrB,IAAI,CAAC,SAA+B,EACpC,IAAI,CAAC,QAA8B,CACpC,CAAC;QACF,4EAA4E;QAC5E,8DAA8D;QAC9D,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;QAC9D,OAAO,WAAW,EAAE,CAAC;IACvB,CAAC;CACF,CAAC;K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E,SAAS;QACf,OAAO,EAAE,KAAK;KACf;IACD,OAAO,EAAE;QACP,YAAY,EAAE,KAAK;QACnB,QAAQ,EAAE,8DAA8D;QACxE,IAAI,EAAE,QAAQ;KACf;IACD,iBAAiB,EAAE;QACjB,YAAY,EAAE,KAAK;QACnB,QAAQ,EAAE,oDAAoD;QAC9D,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,KAAK;KACf;IACD,oBAAoB,EAAE;QACpB,YAAY,EAAE,KAAK;QACnB,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,8CAA8C;QACxD,IAAI,EAAE,SAAS;KAChB;IACD,MAAM,EAAE;QACN,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,KAAK;QACnB,QAAQ,EAAE,wDAAwD;KACnE;IACD,OAAO,EAAE;QACP,KAAK,EAAE,GAAG;QACV,YAAY,EAAE,KAAK;QACnB,QAAQ,EACN,0FAA0F;QAC5F,IAAI,EAAE,QAAQ;KACf;IACD,IAAI,EAAE;QACJ,QAAQ,EACN,wKAAwK;QAC1K,IAAI,EAAE,QAAQ;KACf;CACF,CAAC;KACD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,8CAA8C","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { initLogger } from '@subql/node-core/logger';\nimport { hideBin } from 'yargs/helpers';\nimport yargs from 'yargs/yargs';\n\nexport const yargsOptions = yargs(hideBin(process.argv))\n .env('SUBQL_NODE')\n .command({\n command: 'test',\n describe: 'Run tests for a SubQuery application',\n builder: {},\n handler: (argv) => {\n initLogger(\n argv.debug as boolean,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n );\n // lazy import to make sure logger is instantiated before all other services\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { testingInit } = require('./subcommands/testing.init');\n return testingInit();\n },\n })\n .command({\n command: 'force-clean',\n describe:\n 'Clean the database dropping project schemas and tables. Once the command is executed, the application would exit upon completion.',\n builder: {},\n handler: (argv) => {\n initLogger(\n argv.debug as boolean,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n );\n\n // lazy import to make sure logger is instantiated before all other services\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { forceCleanInit } = require('./subcommands/forceClean.init');\n return forceCleanInit();\n },\n })\n .command({\n command: 'reindex',\n describe:\n 'Reindex to specified block height. Historical must be enabled for the targeted project (--disable-historical=false). Once the command is executed, the application would exit upon completion.',\n builder: (yargs) =>\n yargs.options('targetHeight', {\n type: 'number',\n description: 'set targetHeight',\n require: true,\n }),\n handler: (argv) => {\n initLogger(\n argv.debug as boolean,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n );\n // lazy import to make sure logger is instantiated before all other services\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { reindexInit } = require('./subcommands/reindex.init');\n return reindexInit(argv.targetHeight);\n },\n })\n .command({\n command: 'mmr-regen',\n describe:\n 'Re-generate mmr between Filebased/Postgres mmr and Proof of index',\n builder: (yargs) =>\n yargs.options({\n probe: {\n type: 'boolean',\n description:\n 'Fetch latest mmr height information from file based/postgres DB and Poi table',\n demandOption: false,\n default: false,\n },\n targetHeight: {\n type: 'number',\n description: 'Re-genrate mmr value from this block height',\n demandOption: false,\n },\n resetOnly: {\n type: 'boolean',\n description:\n 'Only reset the mmr value in both POI and file based/postgres DB to target height',\n demandOption: false,\n default: false,\n },\n unsafe: {\n type: 'boolean',\n description: 'Allow sync mmr from Poi table to file or a postgres DB',\n demandOption: false,\n default: false,\n },\n 'mmr-store-type': {\n demandOption: false,\n describe:\n 'When regenerate MMR store in either a file or a postgres DB',\n type: 'string',\n choices: ['file', 'postgres'],\n default: 'file',\n },\n 'mmr-path': {\n alias: 'm',\n demandOption: false,\n describe:\n 'File based only : local path of the merkle mountain range (.mmr) file',\n type: 'string',\n },\n 'db-schema': {\n demandOption: false,\n describe: 'Db schema name of the project',\n type: 'string',\n },\n subquery: {\n alias: 'f',\n demandOption: true,\n default: process.cwd(),\n describe: 'Local path or IPFS cid of the subquery project',\n type: 'string',\n },\n }),\n handler: (argv) => {\n initLogger(\n argv.debug as boolean,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n );\n\n // lazy import to make sure logger is instantiated before all other services\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { mmrRegenerateInit } = require('./subcommands/mmrRegenerate.init');\n return mmrRegenerateInit(\n argv.probe,\n argv.resetOnly,\n argv.unsafe,\n argv.targetHeight,\n );\n },\n })\n .command({\n command: 'mmr-migrate',\n describe: 'Migrate MMR data from storage file to postgres DB',\n builder: (yargs) =>\n yargs.options({\n direction: {\n type: 'string',\n description: 'set direction of migration (file -> DB or DB -> file)',\n demandOption: false,\n choices: ['dbToFile', 'fileToDb'],\n default: 'dbToFile',\n },\n 'mmr-path': {\n alias: 'm',\n demandOption: false,\n describe: 'Local path of the merkle mountain range (.mmr) file',\n type: 'string',\n },\n 'db-schema': {\n demandOption: false,\n describe: 'Db schema name of the project',\n type: 'string',\n },\n subquery: {\n alias: 'f',\n demandOption: true,\n default: process.cwd(),\n describe: 'Local path or IPFS cid of the subquery project',\n type: 'string',\n },\n }),\n handler: (argv) => {\n initLogger(\n argv.debug as boolean,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n );\n\n // lazy import to make sure logger is instantiated before all other services\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { mmrMigrateInit } = require('./subcommands/mmrMigrate.init');\n return mmrMigrateInit(argv.direction);\n },\n })\n .options({\n 'batch-size': {\n demandOption: false,\n describe: 'Batch size of blocks to fetch in one round',\n type: 'number',\n },\n 'block-confirmations': {\n demandOption: false,\n default: 20,\n describe:\n 'The number of blocks behind the head to be considered finalized, this has no effect with Ethereum',\n type: 'number',\n },\n config: {\n alias: 'c',\n demandOption: false,\n describe: 'Specify configuration file',\n type: 'string',\n },\n 'db-schema': {\n demandOption: false,\n describe: 'Db schema name of the project',\n type: 'string',\n },\n debug: {\n demandOption: false,\n describe:\n 'Show debug information to console output. will forcefully set log level to debug',\n type: 'boolean',\n default: false,\n },\n 'dictionary-resolver': {\n demandOption: false,\n describe: 'Use SubQuery Network dictionary resolver',\n type: 'string',\n default: false,\n },\n 'dictionary-timeout': {\n demandOption: false,\n describe: 'Max timeout for dictionary query',\n type: 'number',\n },\n 'disable-historical': {\n demandOption: false,\n default: false,\n describe: 'Disable storing historical state entities',\n type: 'boolean',\n },\n ipfs: {\n demandOption: false,\n describe: 'IPFS gateway endpoint',\n type: 'string',\n },\n local: {\n deprecated: true,\n type: 'boolean',\n demandOption: false,\n describe: 'Use local mode',\n },\n 'log-level': {\n demandOption: false,\n describe: 'Specify log level to print. Ignored when --debug is used',\n type: 'string',\n choices: ['fatal', 'error', 'warn', 'info', 'debug', 'trace', 'silent'],\n },\n 'mmr-path': {\n alias: 'm',\n demandOption: false,\n describe: 'Local path of the merkle mountain range (.mmr) file',\n type: 'string',\n },\n 'multi-chain': {\n demandOption: false,\n default: false,\n describe:\n 'Enables indexing multiple subquery projects into the same database schema',\n type: 'boolean',\n },\n 'network-dictionary': {\n alias: 'd',\n demandOption: false,\n describe: 'Specify the dictionary api for this network',\n type: 'string',\n },\n 'network-endpoint': {\n demandOption: false,\n type: 'string',\n describe: 'Blockchain network endpoint to connect',\n },\n 'output-fmt': {\n demandOption: false,\n describe: 'Print log as json or plain text',\n type: 'string',\n choices: ['json', 'colored'],\n },\n port: {\n alias: 'p',\n demandOption: false,\n describe: 'The port the service will bind to',\n type: 'number',\n },\n profiler: {\n demandOption: false,\n describe: 'Show profiler information to console output',\n type: 'boolean',\n default: false,\n },\n 'proof-of-index': {\n demandOption: false,\n describe: 'Enable/disable proof of index',\n type: 'boolean',\n default: false,\n },\n 'mmr-store-type': {\n demandOption: false,\n describe: 'Store MMR in either a file or a postgres DB',\n type: 'string',\n choices: ['file', 'postgres'],\n default: 'file',\n },\n 'query-limit': {\n demandOption: false,\n describe:\n 'The limit of items a project can query with store.getByField at once',\n type: 'number',\n default: 100,\n },\n 'scale-batch-size': {\n type: 'boolean',\n demandOption: false,\n describe: 'scale batch size based on memory usage',\n default: false,\n },\n 'pg-ca': {\n demandOption: false,\n describe:\n 'Postgres ca certificate - to enable TLS/SSL connections to your PostgreSQL, path to the server certificate file are required, e.g /path/to/server-certificates/root.crt',\n type: 'string',\n },\n 'pg-key': {\n demandOption: false,\n describe:\n 'Postgres client key - Path to key file e.g /path/to/client-key/postgresql.key',\n type: 'string',\n },\n 'pg-cert': {\n demandOption: false,\n describe:\n 'Postgres client certificate - Path to client certificate e.g /path/to/client-certificates/postgresql.crt',\n type: 'string',\n },\n 'store-cache-threshold': {\n demandOption: false,\n describe:\n 'Store cache will flush data to the database when number of records excess this threshold',\n type: 'number',\n },\n 'store-get-cache-size': {\n demandOption: false,\n describe: 'Store get cache size for each model',\n type: 'number',\n },\n 'store-cache-async': {\n demandOption: false,\n describe:\n 'If enabled the store cache will flush data asyncronously relative to indexing data',\n type: 'boolean',\n },\n 'store-flush-interval': {\n demandOption: false,\n describe:\n 'The interval, in seconds, at which data is flushed from the cache. ' +\n 'This ensures that data is persisted regularly when there is either not much data or the project is up to date.',\n type: 'number',\n default: 5,\n },\n subquery: {\n alias: 'f',\n demandOption: true,\n default: process.cwd(),\n describe: 'Local path or IPFS cid of the subquery project',\n type: 'string',\n },\n 'subquery-name': {\n deprecated: true,\n demandOption: false,\n describe: 'Name of the subquery project',\n type: 'string',\n },\n subscription: {\n demandOption: false,\n describe: 'Enable subscription by create notification triggers',\n type: 'boolean',\n default: false,\n },\n timeout: {\n demandOption: false,\n describe: 'Timeout for indexer sandbox to execute the mapping functions',\n type: 'number',\n },\n 'timestamp-field': {\n demandOption: false,\n describe: 'Enable/disable created_at and updated_at in schema',\n type: 'boolean',\n default: false,\n },\n 'unfinalized-blocks': {\n demandOption: false,\n default: false,\n describe: 'Enable to fetch and index unfinalized blocks',\n type: 'boolean',\n },\n unsafe: {\n type: 'boolean',\n demandOption: false,\n describe: 'Allows usage of any built-in module within the sandbox',\n },\n workers: {\n alias: 'w',\n demandOption: false,\n describe:\n 'Number of worker threads to use for fetching and processing blocks. Disabled by default.',\n type: 'number',\n },\n root: {\n describe:\n 'This is a hidden flag only used from the main thread to workers. It provides a root directory for the project. This is a temp directory with IPFS and GitHub projects.',\n type: 'string',\n },\n })\n .hide('root'); // root is hidden because its for internal use\n"]}
|
|
1
|
+
{"version":3,"file":"yargs.js","sourceRoot":"","sources":["../src/yargs.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;AAEtC,oDAAqD;AACrD,2CAAwC;AACxC,wDAAgC;AAEnB,QAAA,YAAY,GAAG,IAAA,eAAK,EAAC,IAAA,iBAAO,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KACrD,GAAG,CAAC,YAAY,CAAC;KACjB,OAAO,CAAC;IACP,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE,sCAAsC;IAChD,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QAChB,IAAA,mBAAU,EACR,IAAI,CAAC,KAAgB,EACrB,IAAI,CAAC,SAA+B,EACpC,IAAI,CAAC,QAA8B,CACpC,CAAC;QACF,4EAA4E;QAC5E,8DAA8D;QAC9D,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;QAC9D,OAAO,WAAW,EAAE,CAAC;IACvB,CAAC;CACF,CAAC;KACD,OAAO,CAAC;IACP,OAAO,EAAE,aAAa;IACtB,QAAQ,EACN,mIAAmI;IACrI,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QAChB,IAAA,mBAAU,EACR,IAAI,CAAC,KAAgB,EACrB,IAAI,CAAC,SAA+B,EACpC,IAAI,CAAC,QAA8B,CACpC,CAAC;QAEF,4EAA4E;QAC5E,8DAA8D;QAC9D,MAAM,EAAE,cAAc,EAAE,GAAG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ACnB,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,8CAA8C;QACxD,IAAI,EAAE,SAAS;KAChB;IACD,MAAM,EAAE;QACN,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,KAAK;QACnB,QAAQ,EAAE,wDAAwD;KACnE;IACD,OAAO,EAAE;QACP,KAAK,EAAE,GAAG;QACV,YAAY,EAAE,KAAK;QACnB,QAAQ,EACN,0FAA0F;QAC5F,IAAI,EAAE,QAAQ;KACf;IACD,IAAI,EAAE;QACJ,QAAQ,EACN,wKAAwK;QAC1K,IAAI,EAAE,QAAQ;KACf;IACD,qBAAqB,EAAE;QACrB,QAAQ,EACN,yEAAyE;QAC3E,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,GAAG;KACb;CACF,CAAC;KACD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,8CAA8C","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { initLogger } from '@subql/node-core/logger';\nimport { hideBin } from 'yargs/helpers';\nimport yargs from 'yargs/yargs';\n\nexport const yargsOptions = yargs(hideBin(process.argv))\n .env('SUBQL_NODE')\n .command({\n command: 'test',\n describe: 'Run tests for a SubQuery application',\n builder: {},\n handler: (argv) => {\n initLogger(\n argv.debug as boolean,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n );\n // lazy import to make sure logger is instantiated before all other services\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { testingInit } = require('./subcommands/testing.init');\n return testingInit();\n },\n })\n .command({\n command: 'force-clean',\n describe:\n 'Clean the database dropping project schemas and tables. Once the command is executed, the application would exit upon completion.',\n builder: {},\n handler: (argv) => {\n initLogger(\n argv.debug as boolean,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n );\n\n // lazy import to make sure logger is instantiated before all other services\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { forceCleanInit } = require('./subcommands/forceClean.init');\n return forceCleanInit();\n },\n })\n .command({\n command: 'reindex',\n describe:\n 'Reindex to specified block height. Historical must be enabled for the targeted project (--disable-historical=false). Once the command is executed, the application would exit upon completion.',\n builder: (yargs) =>\n yargs.options('targetHeight', {\n type: 'number',\n description: 'set targetHeight',\n require: true,\n }),\n handler: (argv) => {\n initLogger(\n argv.debug as boolean,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n );\n // lazy import to make sure logger is instantiated before all other services\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { reindexInit } = require('./subcommands/reindex.init');\n return reindexInit(argv.targetHeight);\n },\n })\n .command({\n command: 'mmr-regen',\n describe:\n 'Re-generate mmr between Filebased/Postgres mmr and Proof of index',\n builder: (yargs) =>\n yargs.options({\n probe: {\n type: 'boolean',\n description:\n 'Fetch latest mmr height information from file based/postgres DB and Poi table',\n demandOption: false,\n default: false,\n },\n targetHeight: {\n type: 'number',\n description: 'Re-genrate mmr value from this block height',\n demandOption: false,\n },\n resetOnly: {\n type: 'boolean',\n description:\n 'Only reset the mmr value in both POI and file based/postgres DB to target height',\n demandOption: false,\n default: false,\n },\n unsafe: {\n type: 'boolean',\n description: 'Allow sync mmr from Poi table to file or a postgres DB',\n demandOption: false,\n default: false,\n },\n 'mmr-store-type': {\n demandOption: false,\n describe:\n 'When regenerate MMR store in either a file or a postgres DB',\n type: 'string',\n choices: ['file', 'postgres'],\n default: 'file',\n },\n 'mmr-path': {\n alias: 'm',\n demandOption: false,\n describe:\n 'File based only : local path of the merkle mountain range (.mmr) file',\n type: 'string',\n },\n 'db-schema': {\n demandOption: false,\n describe: 'Db schema name of the project',\n type: 'string',\n },\n subquery: {\n alias: 'f',\n demandOption: true,\n default: process.cwd(),\n describe: 'Local path or IPFS cid of the subquery project',\n type: 'string',\n },\n }),\n handler: (argv) => {\n initLogger(\n argv.debug as boolean,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n );\n\n // lazy import to make sure logger is instantiated before all other services\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { mmrRegenerateInit } = require('./subcommands/mmrRegenerate.init');\n return mmrRegenerateInit(\n argv.probe,\n argv.resetOnly,\n argv.unsafe,\n argv.targetHeight,\n );\n },\n })\n .command({\n command: 'mmr-migrate',\n describe: 'Migrate MMR data from storage file to postgres DB',\n builder: (yargs) =>\n yargs.options({\n direction: {\n type: 'string',\n description: 'set direction of migration (file -> DB or DB -> file)',\n demandOption: false,\n choices: ['dbToFile', 'fileToDb'],\n default: 'dbToFile',\n },\n 'mmr-path': {\n alias: 'm',\n demandOption: false,\n describe: 'Local path of the merkle mountain range (.mmr) file',\n type: 'string',\n },\n 'db-schema': {\n demandOption: false,\n describe: 'Db schema name of the project',\n type: 'string',\n },\n subquery: {\n alias: 'f',\n demandOption: true,\n default: process.cwd(),\n describe: 'Local path or IPFS cid of the subquery project',\n type: 'string',\n },\n }),\n handler: (argv) => {\n initLogger(\n argv.debug as boolean,\n argv.outputFmt as 'json' | 'colored',\n argv.logLevel as string | undefined,\n );\n\n // lazy import to make sure logger is instantiated before all other services\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { mmrMigrateInit } = require('./subcommands/mmrMigrate.init');\n return mmrMigrateInit(argv.direction);\n },\n })\n .options({\n 'batch-size': {\n demandOption: false,\n describe: 'Batch size of blocks to fetch in one round',\n type: 'number',\n },\n 'block-confirmations': {\n demandOption: false,\n default: 20,\n describe:\n 'The number of blocks behind the head to be considered finalized, this has no effect with Ethereum',\n type: 'number',\n },\n config: {\n alias: 'c',\n demandOption: false,\n describe: 'Specify configuration file',\n type: 'string',\n },\n 'db-schema': {\n demandOption: false,\n describe: 'Db schema name of the project',\n type: 'string',\n },\n debug: {\n demandOption: false,\n describe:\n 'Show debug information to console output. will forcefully set log level to debug',\n type: 'boolean',\n default: false,\n },\n 'dictionary-resolver': {\n demandOption: false,\n describe: 'Use SubQuery Network dictionary resolver',\n type: 'string',\n default: false,\n },\n 'dictionary-timeout': {\n demandOption: false,\n describe: 'Max timeout for dictionary query',\n type: 'number',\n },\n 'disable-historical': {\n demandOption: false,\n default: false,\n describe: 'Disable storing historical state entities',\n type: 'boolean',\n },\n ipfs: {\n demandOption: false,\n describe: 'IPFS gateway endpoint',\n type: 'string',\n },\n local: {\n deprecated: true,\n type: 'boolean',\n demandOption: false,\n describe: 'Use local mode',\n },\n 'log-level': {\n demandOption: false,\n describe: 'Specify log level to print. Ignored when --debug is used',\n type: 'string',\n choices: ['fatal', 'error', 'warn', 'info', 'debug', 'trace', 'silent'],\n },\n 'mmr-path': {\n alias: 'm',\n demandOption: false,\n describe: 'Local path of the merkle mountain range (.mmr) file',\n type: 'string',\n },\n 'multi-chain': {\n demandOption: false,\n default: false,\n describe:\n 'Enables indexing multiple subquery projects into the same database schema',\n type: 'boolean',\n },\n 'network-dictionary': {\n alias: 'd',\n demandOption: false,\n describe: 'Specify the dictionary api for this network',\n type: 'string',\n },\n 'network-endpoint': {\n demandOption: false,\n type: 'string',\n describe: 'Blockchain network endpoint to connect',\n },\n 'output-fmt': {\n demandOption: false,\n describe: 'Print log as json or plain text',\n type: 'string',\n choices: ['json', 'colored'],\n },\n port: {\n alias: 'p',\n demandOption: false,\n describe: 'The port the service will bind to',\n type: 'number',\n },\n profiler: {\n demandOption: false,\n describe: 'Show profiler information to console output',\n type: 'boolean',\n default: false,\n },\n 'proof-of-index': {\n demandOption: false,\n describe: 'Enable/disable proof of index',\n type: 'boolean',\n default: false,\n },\n 'mmr-store-type': {\n demandOption: false,\n describe: 'Store MMR in either a file or a postgres DB',\n type: 'string',\n choices: ['file', 'postgres'],\n default: 'file',\n },\n 'query-limit': {\n demandOption: false,\n describe:\n 'The limit of items a project can query with store.getByField at once',\n type: 'number',\n default: 100,\n },\n 'scale-batch-size': {\n type: 'boolean',\n demandOption: false,\n describe: 'scale batch size based on memory usage',\n default: false,\n },\n 'pg-ca': {\n demandOption: false,\n describe:\n 'Postgres ca certificate - to enable TLS/SSL connections to your PostgreSQL, path to the server certificate file are required, e.g /path/to/server-certificates/root.crt',\n type: 'string',\n },\n 'pg-key': {\n demandOption: false,\n describe:\n 'Postgres client key - Path to key file e.g /path/to/client-key/postgresql.key',\n type: 'string',\n },\n 'pg-cert': {\n demandOption: false,\n describe:\n 'Postgres client certificate - Path to client certificate e.g /path/to/client-certificates/postgresql.crt',\n type: 'string',\n },\n 'store-cache-threshold': {\n demandOption: false,\n describe:\n 'Store cache will flush data to the database when number of records excess this threshold',\n type: 'number',\n },\n 'store-get-cache-size': {\n demandOption: false,\n describe: 'Store get cache size for each model',\n type: 'number',\n },\n 'store-cache-async': {\n demandOption: false,\n describe:\n 'If enabled the store cache will flush data asyncronously relative to indexing data',\n type: 'boolean',\n },\n 'store-flush-interval': {\n demandOption: false,\n describe:\n 'The interval, in seconds, at which data is flushed from the cache. ' +\n 'This ensures that data is persisted regularly when there is either not much data or the project is up to date.',\n type: 'number',\n default: 5,\n },\n subquery: {\n alias: 'f',\n demandOption: true,\n default: process.cwd(),\n describe: 'Local path or IPFS cid of the subquery project',\n type: 'string',\n },\n 'subquery-name': {\n deprecated: true,\n demandOption: false,\n describe: 'Name of the subquery project',\n type: 'string',\n },\n subscription: {\n demandOption: false,\n describe: 'Enable subscription by create notification triggers',\n type: 'boolean',\n default: false,\n },\n timeout: {\n demandOption: false,\n describe: 'Timeout for indexer sandbox to execute the mapping functions',\n type: 'number',\n },\n 'timestamp-field': {\n demandOption: false,\n describe: 'Enable/disable created_at and updated_at in schema',\n type: 'boolean',\n default: false,\n },\n 'unfinalized-blocks': {\n demandOption: false,\n default: false,\n describe: 'Enable to fetch and index unfinalized blocks',\n type: 'boolean',\n },\n unsafe: {\n type: 'boolean',\n demandOption: false,\n describe: 'Allows usage of any built-in module within the sandbox',\n },\n workers: {\n alias: 'w',\n demandOption: false,\n describe:\n 'Number of worker threads to use for fetching and processing blocks. Disabled by default.',\n type: 'number',\n },\n root: {\n describe:\n 'This is a hidden flag only used from the main thread to workers. It provides a root directory for the project. This is a temp directory with IPFS and GitHub projects.',\n type: 'string',\n },\n 'query-address-limit': {\n describe:\n 'Set the limit for address on dictionary queries for dynamic datasources',\n type: 'number',\n default: 100,\n },\n })\n .hide('root'); // root is hidden because its for internal use\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subql/node-ethereum",
|
|
3
|
-
"version": "2.6.1",
|
|
3
|
+
"version": "2.6.2-1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Ian He",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -67,5 +67,6 @@
|
|
|
67
67
|
"files": [
|
|
68
68
|
"/dist",
|
|
69
69
|
"/bin"
|
|
70
|
-
]
|
|
70
|
+
],
|
|
71
|
+
"stableVersion": "2.6.2-0"
|
|
71
72
|
}
|