@subql/node-ethereum 1.10.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.
Files changed (118) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +201 -0
  3. package/README.md +76 -0
  4. package/bin/run +4 -0
  5. package/bin/run.cmd +3 -0
  6. package/dist/.tsbuildinfo +1 -0
  7. package/dist/app.module.d.ts +2 -0
  8. package/dist/app.module.js +35 -0
  9. package/dist/app.module.js.map +1 -0
  10. package/dist/configure/SubqueryProject.d.ts +29 -0
  11. package/dist/configure/SubqueryProject.js +82 -0
  12. package/dist/configure/SubqueryProject.js.map +1 -0
  13. package/dist/configure/configure.module.d.ts +7 -0
  14. package/dist/configure/configure.module.js +172 -0
  15. package/dist/configure/configure.module.js.map +1 -0
  16. package/dist/configure/configure.module.spec.d.ts +1 -0
  17. package/dist/configure/configure.module.spec.js +26 -0
  18. package/dist/configure/configure.module.spec.js.map +1 -0
  19. package/dist/ethereum/api.ethereum.d.ts +21 -0
  20. package/dist/ethereum/api.ethereum.js +190 -0
  21. package/dist/ethereum/api.ethereum.js.map +1 -0
  22. package/dist/ethereum/api.service.ethereum.d.ts +8 -0
  23. package/dist/ethereum/api.service.ethereum.js +57 -0
  24. package/dist/ethereum/api.service.ethereum.js.map +1 -0
  25. package/dist/ethereum/block.ethereum.d.ts +15 -0
  26. package/dist/ethereum/block.ethereum.js +87 -0
  27. package/dist/ethereum/block.ethereum.js.map +1 -0
  28. package/dist/ethereum/index.d.ts +2 -0
  29. package/dist/ethereum/index.js +21 -0
  30. package/dist/ethereum/index.js.map +1 -0
  31. package/dist/ethereum/utils.ethereum.d.ts +6 -0
  32. package/dist/ethereum/utils.ethereum.js +131 -0
  33. package/dist/ethereum/utils.ethereum.js.map +1 -0
  34. package/dist/indexer/dictionary.service.d.ts +7 -0
  35. package/dist/indexer/dictionary.service.js +29 -0
  36. package/dist/indexer/dictionary.service.js.map +1 -0
  37. package/dist/indexer/ds-processor.service.d.ts +26 -0
  38. package/dist/indexer/ds-processor.service.js +133 -0
  39. package/dist/indexer/ds-processor.service.js.map +1 -0
  40. package/dist/indexer/dynamic-ds.service.d.ts +23 -0
  41. package/dist/indexer/dynamic-ds.service.js +105 -0
  42. package/dist/indexer/dynamic-ds.service.js.map +1 -0
  43. package/dist/indexer/fetch.module.d.ts +2 -0
  44. package/dist/indexer/fetch.module.js +68 -0
  45. package/dist/indexer/fetch.module.js.map +1 -0
  46. package/dist/indexer/fetch.service.d.ts +43 -0
  47. package/dist/indexer/fetch.service.js +359 -0
  48. package/dist/indexer/fetch.service.js.map +1 -0
  49. package/dist/indexer/indexer.manager.d.ts +36 -0
  50. package/dist/indexer/indexer.manager.js +256 -0
  51. package/dist/indexer/indexer.manager.js.map +1 -0
  52. package/dist/indexer/indexer.module.d.ts +2 -0
  53. package/dist/indexer/indexer.module.js +52 -0
  54. package/dist/indexer/indexer.module.js.map +1 -0
  55. package/dist/indexer/project.service.d.ts +39 -0
  56. package/dist/indexer/project.service.js +255 -0
  57. package/dist/indexer/project.service.js.map +1 -0
  58. package/dist/indexer/sandbox.service.d.ts +12 -0
  59. package/dist/indexer/sandbox.service.js +58 -0
  60. package/dist/indexer/sandbox.service.js.map +1 -0
  61. package/dist/indexer/types.d.ts +10 -0
  62. package/dist/indexer/types.js +11 -0
  63. package/dist/indexer/types.js.map +1 -0
  64. package/dist/indexer/worker/block-dispatcher.service.d.ts +69 -0
  65. package/dist/indexer/worker/block-dispatcher.service.js +356 -0
  66. package/dist/indexer/worker/block-dispatcher.service.js.map +1 -0
  67. package/dist/indexer/worker/worker.d.ts +14 -0
  68. package/dist/indexer/worker/worker.js +85 -0
  69. package/dist/indexer/worker/worker.js.map +1 -0
  70. package/dist/indexer/worker/worker.module.d.ts +2 -0
  71. package/dist/indexer/worker/worker.module.js +33 -0
  72. package/dist/indexer/worker/worker.module.js.map +1 -0
  73. package/dist/indexer/worker/worker.service.d.ts +28 -0
  74. package/dist/indexer/worker/worker.service.js +79 -0
  75. package/dist/indexer/worker/worker.service.js.map +1 -0
  76. package/dist/init.d.ts +1 -0
  77. package/dist/init.js +54 -0
  78. package/dist/init.js.map +1 -0
  79. package/dist/main.d.ts +1 -0
  80. package/dist/main.js +14 -0
  81. package/dist/main.js.map +1 -0
  82. package/dist/meta/meta.controller.d.ts +23 -0
  83. package/dist/meta/meta.controller.js +36 -0
  84. package/dist/meta/meta.controller.js.map +1 -0
  85. package/dist/meta/meta.module.d.ts +2 -0
  86. package/dist/meta/meta.module.js +77 -0
  87. package/dist/meta/meta.module.js.map +1 -0
  88. package/dist/meta/meta.service.d.ts +42 -0
  89. package/dist/meta/meta.service.js +110 -0
  90. package/dist/meta/meta.service.js.map +1 -0
  91. package/dist/subcommands/forceClean.init.d.ts +1 -0
  92. package/dist/subcommands/forceClean.init.js +25 -0
  93. package/dist/subcommands/forceClean.init.js.map +1 -0
  94. package/dist/subcommands/forceClean.module.d.ts +4 -0
  95. package/dist/subcommands/forceClean.module.js +38 -0
  96. package/dist/subcommands/forceClean.module.js.map +1 -0
  97. package/dist/subcommands/forceClean.service.d.ts +8 -0
  98. package/dist/subcommands/forceClean.service.js +65 -0
  99. package/dist/subcommands/forceClean.service.js.map +1 -0
  100. package/dist/subcommands/reindex.init.d.ts +1 -0
  101. package/dist/subcommands/reindex.init.js +25 -0
  102. package/dist/subcommands/reindex.init.js.map +1 -0
  103. package/dist/subcommands/reindex.module.d.ts +4 -0
  104. package/dist/subcommands/reindex.module.js +39 -0
  105. package/dist/subcommands/reindex.module.js.map +1 -0
  106. package/dist/subcommands/reindex.service.d.ts +24 -0
  107. package/dist/subcommands/reindex.service.js +114 -0
  108. package/dist/subcommands/reindex.service.js.map +1 -0
  109. package/dist/utils/project.d.ts +13 -0
  110. package/dist/utils/project.js +191 -0
  111. package/dist/utils/project.js.map +1 -0
  112. package/dist/utils/string.d.ts +4 -0
  113. package/dist/utils/string.js +32 -0
  114. package/dist/utils/string.js.map +1 -0
  115. package/dist/yargs.d.ts +154 -0
  116. package/dist/yargs.js +193 -0
  117. package/dist/yargs.js.map +1 -0
  118. package/package.json +77 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.service.js","sourceRoot":"","sources":["../../src/indexer/fetch.service.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;;;;;;;;;;AAEtC,2CAA2E;AAC3E,yDAAsD;AACtD,+CAA+D;AAC/D,4DAIgC;AAChC,gDAQ0B;AAO1B,mCAA+C;AAC/C,kEAA+E;AAC/E,+DAA0D;AAC1D,4CAAkE;AAClE,6DAAyD;AACzD,6DAAwD;AAGxD,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,OAAO,CAAC,CAAC;AAClC,IAAI,mBAAmB,GAAG,IAAI,CAAC;AAC/B,MAAM,yBAAyB,GAAG,KAAK,CAAC;AACxC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AACpC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,SAAS,uBAAuB,CAC9B,MAAyB;IAEzB,MAAM,UAAU,GAAG,EAAE,CAAC;IACtB,IAAI,MAAM,CAAC,OAAO,EAAE;QAClB,UAAU,CAAC,IAAI,CAAC;YACd,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;KACJ;IACD,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC/B,IAAI,CAAC,KAAK,EAAE;gBACV,SAAS;aACV;YACD,MAAM,KAAK,GAAG,SAAS,CAAC,EAA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,cAAc,CAAC,CAAC;YACpD,OAAO,KAAK,CAAC;SACd;QACD,IAAI,QAAQ,CAAC,mBAAmB,GAAG,gBAAgB,EAAE;YACnD,MAAM,CAAC,IAAI,CACT,kEAAkE,CACnE,CAAC;YACF,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,wBAAY,CAAC,cAAc,CAAC,CAAC;YACpD,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,WAAmB;QACrC,MAAM,IAAI,CAAC,+BAA+B,EAAE,CAAC;QAC7C,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC/C,CAAC;CACF,CAAA;AApNC;IAAC,IAAA,mBAAQ,EAAC,qBAAqB,CAAC;;;;mDAS/B;AAGK;IADL,IAAA,mBAAQ,EAAC,mBAAmB,GAAG,IAAI,CAAC;;;;yDAiBpC;AAGK;IADL,IAAA,mBAAQ,EAAC,mBAAmB,GAAG,IAAI,CAAC;;;;oDAiBpC;AArKU,YAAY;IADxB,IAAA,mBAAU,GAAE;IAcR,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;qCAHP,sBAAU;QACV,sBAAU;QACb,iCAAe,UAEL,sCAAiB;QAClB,qCAAgB;QACpB,6BAAa;QACR,4BAAiB;GAjBnC,YAAY,CA0UxB;AA1UY,oCAAY","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Inject, Injectable, OnApplicationShutdown } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { Interval, SchedulerRegistry } from '@nestjs/schedule';\nimport {\n isCustomDs,\n EthereumHandlerKind,\n SubqlHandlerFilter,\n} from '@subql/common-ethereum';\nimport {\n ApiService,\n Dictionary,\n delay,\n checkMemoryUsage,\n NodeConfig,\n IndexerEvent,\n getLogger,\n} from '@subql/node-core';\nimport {\n DictionaryQueryEntry,\n ApiWrapper,\n EthereumLogFilter,\n EthereumTransactionFilter,\n} from '@subql/types-ethereum';\nimport { range, sortBy, uniqBy } from 'lodash';\nimport { SubqlProjectDs, SubqueryProject } from '../configure/SubqueryProject';\nimport { calcInterval } from '../ethereum/utils.ethereum';\nimport { eventToTopic, functionToSighash } from '../utils/string';\nimport { DictionaryService } from './dictionary.service';\nimport { DynamicDsService } from './dynamic-ds.service';\nimport { IBlockDispatcher } from './worker/block-dispatcher.service';\n\nconst logger = getLogger('fetch');\nlet BLOCK_TIME_VARIANCE = 5000;\nconst DICTIONARY_MAX_QUERY_SIZE = 10000;\nconst CHECK_MEMORY_INTERVAL = 60000;\nconst MINIMUM_BATCH_SIZE = 5;\nconst INTERVAL_PERCENT = 0.9;\n\nfunction eventFilterToQueryEntry(\n filter: EthereumLogFilter,\n): DictionaryQueryEntry {\n const conditions = [];\n if (filter.address) {\n conditions.push({\n field: 'address',\n value: filter.address.toLowerCase(),\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({ field, value: eventToTopic(topic) });\n }\n }\n return {\n entity: 'evmLogs',\n conditions,\n };\n}\n\nfunction callFilterToQueryEntry(\n filter: EthereumTransactionFilter,\n): DictionaryQueryEntry {\n const conditions = [];\n if (filter.from) {\n conditions.push({\n field: 'from',\n value: filter.from.toLowerCase(),\n });\n }\n if (filter.to) {\n conditions.push({\n field: 'to',\n value: filter.to.toLowerCase(),\n });\n }\n if (filter.function) {\n conditions.push({\n field: 'func',\n value: functionToSighash(filter.function),\n });\n }\n return {\n entity: 'evmTransactions',\n conditions,\n };\n}\n\n@Injectable()\nexport class FetchService implements OnApplicationShutdown {\n private latestBestHeight: number;\n private latestFinalizedHeight: number;\n private isShutdown = false;\n private useDictionary: boolean;\n private dictionaryQueryEntries?: DictionaryQueryEntry[];\n private batchSizeScale: number;\n private templateDynamicDatasouces: SubqlProjectDs[];\n\n constructor(\n private apiService: ApiService,\n private nodeConfig: NodeConfig,\n private project: SubqueryProject,\n @Inject('IBlockDispatcher') private blockDispatcher: IBlockDispatcher,\n private dictionaryService: DictionaryService,\n private dynamicDsService: DynamicDsService,\n private eventEmitter: EventEmitter2,\n private schedulerRegistry: SchedulerRegistry,\n ) {\n this.batchSizeScale = 1;\n }\n\n onApplicationShutdown(): void {\n this.isShutdown = true;\n }\n\n get api(): ApiWrapper {\n return this.apiService.api;\n }\n\n async syncDynamicDatascourcesFromMeta(): Promise<void> {\n this.templateDynamicDatasouces =\n await this.dynamicDsService.getDynamicDatasources();\n }\n\n // TODO: if custom ds doesn't support dictionary, use baseFilter, if yes, let\n getDictionaryQueryEntries(): DictionaryQueryEntry[] {\n const queryEntries: DictionaryQueryEntry[] = [];\n\n const dataSources = this.project.dataSources;\n for (const ds of dataSources.concat(this.templateDynamicDatasouces)) {\n for (const handler of ds.mapping.handlers) {\n let filterList: SubqlHandlerFilter[];\n filterList = [handler.filter];\n filterList = filterList.filter((f) => f);\n if (!filterList.length) return [];\n switch (handler.kind) {\n case EthereumHandlerKind.Block:\n return [];\n case EthereumHandlerKind.Call: {\n for (const filter of filterList 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 }\n break;\n }\n case EthereumHandlerKind.Event: {\n for (const filter of filterList as EthereumLogFilter[]) {\n if (filter.address || filter.topics) {\n queryEntries.push(eventFilterToQueryEntry(filter));\n } else {\n return [];\n }\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 updateDictionary(): void {\n this.dictionaryQueryEntries = this.getDictionaryQueryEntries();\n this.useDictionary =\n !!this.dictionaryQueryEntries?.length &&\n !!this.project.network.dictionary;\n }\n\n async init(startHeight: number): Promise<void> {\n if (this.api) {\n const CHAIN_INTERVAL = calcInterval(this.api) * INTERVAL_PERCENT;\n\n BLOCK_TIME_VARIANCE = Math.min(BLOCK_TIME_VARIANCE, CHAIN_INTERVAL);\n\n this.schedulerRegistry.addInterval(\n 'getLatestBlockHead',\n setInterval(() => void this.getBestBlockHead(), BLOCK_TIME_VARIANCE),\n );\n }\n await this.syncDynamicDatascourcesFromMeta();\n this.updateDictionary();\n this.eventEmitter.emit(IndexerEvent.UsingDictionary, {\n value: Number(this.useDictionary),\n });\n await this.getFinalizedBlockHead();\n await this.getBestBlockHead();\n\n await this.blockDispatcher.init(this.resetForNewDs.bind(this));\n\n void this.startLoop(startHeight);\n }\n\n @Interval(CHECK_MEMORY_INTERVAL)\n checkBatchScale(): void {\n if (this.nodeConfig['scale-batch-size']) {\n const scale = checkMemoryUsage(this.batchSizeScale, this.nodeConfig);\n\n if (this.batchSizeScale !== scale) {\n this.batchSizeScale = scale;\n }\n }\n }\n\n @Interval(BLOCK_TIME_VARIANCE * 1000)\n async getFinalizedBlockHead(): Promise<void> {\n if (!this.api) {\n logger.debug(`Skip fetch finalized block until API is ready`);\n return;\n }\n try {\n const currentFinalizedHeight = await this.api.getFinalizedBlockHeight();\n if (this.latestFinalizedHeight !== currentFinalizedHeight) {\n this.latestFinalizedHeight = currentFinalizedHeight;\n this.eventEmitter.emit(IndexerEvent.BlockTarget, {\n height: this.latestFinalizedHeight,\n });\n }\n } catch (e) {\n logger.error(e, `Having a problem when get finalized block`);\n }\n }\n\n @Interval(BLOCK_TIME_VARIANCE * 1000)\n async getBestBlockHead(): Promise<void> {\n if (!this.api) {\n logger.debug(`Skip fetch best block until API is ready`);\n return;\n }\n try {\n const currentBestHeight = await this.api.getLastHeight();\n if (this.latestBestHeight !== currentBestHeight) {\n this.latestBestHeight = currentBestHeight;\n this.eventEmitter.emit(IndexerEvent.BlockBest, {\n height: this.latestBestHeight,\n });\n }\n } catch (e) {\n logger.error(e, `Having a problem when get best block`);\n }\n }\n\n async startLoop(initBlockHeight: number): Promise<void> {\n await this.fillNextBlockBuffer(initBlockHeight);\n }\n\n 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 getModuloBlocks(startHeight: number, endHeight: number): number[] {\n const modulos = this.getModulos();\n const moduloBlocks: number[] = [];\n for (let i = startHeight; i < endHeight; i++) {\n if (modulos.find((m) => i % m === 0)) {\n moduloBlocks.push(i);\n }\n }\n return moduloBlocks;\n }\n\n async fillNextBlockBuffer(initBlockHeight: number): Promise<void> {\n let startBlockHeight: number;\n let scaledBatchSize: number;\n\n const getStartBlockHeight = (): number => {\n return this.blockDispatcher.latestBufferedHeight\n ? this.blockDispatcher.latestBufferedHeight + 1\n : initBlockHeight;\n };\n\n while (!this.isShutdown) {\n startBlockHeight = getStartBlockHeight();\n\n scaledBatchSize = Math.max(\n Math.round(this.batchSizeScale * this.nodeConfig.batchSize),\n Math.min(MINIMUM_BATCH_SIZE, this.nodeConfig.batchSize * 3),\n );\n\n if (\n this.blockDispatcher.freeSize < scaledBatchSize ||\n startBlockHeight > this.latestFinalizedHeight\n ) {\n await delay(1);\n continue;\n }\n if (this.useDictionary) {\n const queryEndBlock = startBlockHeight + DICTIONARY_MAX_QUERY_SIZE;\n const moduloBlocks = this.getModuloBlocks(\n startBlockHeight,\n queryEndBlock,\n );\n try {\n const dictionary = await this.dictionaryService.getDictionary(\n startBlockHeight,\n queryEndBlock,\n scaledBatchSize,\n this.dictionaryQueryEntries,\n );\n\n if (startBlockHeight !== getStartBlockHeight()) {\n logger.debug(\n `Queue was reset for new DS, discarding dictionary query result`,\n );\n continue;\n }\n\n if (\n dictionary &&\n this.dictionaryValidation(dictionary, startBlockHeight)\n ) {\n let { batchBlocks } = dictionary;\n batchBlocks = batchBlocks\n .concat(moduloBlocks)\n .sort((a, b) => a - b);\n if (batchBlocks.length === 0) {\n // There we're no blocks in this query range, we can set a new height we're up to\n this.blockDispatcher.latestBufferedHeight = Math.min(\n queryEndBlock - 1,\n dictionary._metadata.lastProcessedHeight,\n );\n } else {\n const maxBlockSize = Math.min(\n batchBlocks.length,\n this.blockDispatcher.freeSize,\n );\n batchBlocks = batchBlocks.slice(0, maxBlockSize);\n this.blockDispatcher.enqueueBlocks(batchBlocks);\n }\n continue; // skip nextBlockRange() way\n }\n // else use this.nextBlockRange()\n } catch (e) {\n logger.debug(`Fetch dictionary stopped: ${e.message}`);\n this.eventEmitter.emit(IndexerEvent.SkipDictionary);\n }\n }\n // the original method: fill next batch size of blocks\n const endHeight = this.nextEndBlockHeight(\n startBlockHeight,\n scaledBatchSize,\n );\n this.blockDispatcher.enqueueBlocks(\n range(startBlockHeight, endHeight + 1),\n );\n }\n }\n\n private nextEndBlockHeight(\n startBlockHeight: number,\n scaledBatchSize: number,\n ): number {\n let endBlockHeight = startBlockHeight + scaledBatchSize - 1;\n\n if (endBlockHeight > this.latestFinalizedHeight) {\n endBlockHeight = this.latestFinalizedHeight;\n }\n return endBlockHeight;\n }\n\n private dictionaryValidation(\n { _metadata: metaData }: Dictionary,\n startBlockHeight: number,\n ): boolean {\n if (metaData.genesisHash !== this.api.getGenesisHash()) {\n logger.error(\n 'The dictionary that you have specified does not match the chain you are indexing, it will be ignored. Please update your project manifest to reference the correct dictionary',\n );\n this.useDictionary = false;\n this.eventEmitter.emit(IndexerEvent.UsingDictionary, {\n value: Number(this.useDictionary),\n });\n this.eventEmitter.emit(IndexerEvent.SkipDictionary);\n return false;\n }\n if (metaData.lastProcessedHeight < startBlockHeight) {\n logger.warn(\n `Dictionary indexed block is behind current indexing block height`,\n );\n this.eventEmitter.emit(IndexerEvent.SkipDictionary);\n return false;\n }\n return true;\n }\n\n async resetForNewDs(blockHeight: number): Promise<void> {\n await this.syncDynamicDatascourcesFromMeta();\n this.updateDictionary();\n this.blockDispatcher.flushQueue(blockHeight);\n }\n}\n"]}
@@ -0,0 +1,36 @@
1
+ import { ApiService, StoreService, PoiService, NodeConfig } from '@subql/node-core';
2
+ import { EthereumBlockWrapper } from '@subql/types-ethereum';
3
+ import { Sequelize } from 'sequelize';
4
+ import { SubqueryProject } from '../configure/SubqueryProject';
5
+ import { DsProcessorService } from './ds-processor.service';
6
+ import { DynamicDsService } from './dynamic-ds.service';
7
+ import { ProjectService } from './project.service';
8
+ import { SandboxService } from './sandbox.service';
9
+ export declare class IndexerManager {
10
+ private storeService;
11
+ private apiService;
12
+ private poiService;
13
+ private sequelize;
14
+ private project;
15
+ private nodeConfig;
16
+ private sandboxService;
17
+ private dynamicDsService;
18
+ private dsProcessorService;
19
+ private projectService;
20
+ private api;
21
+ private filteredDataSources;
22
+ constructor(storeService: StoreService, apiService: ApiService, poiService: PoiService, sequelize: Sequelize, project: SubqueryProject, nodeConfig: NodeConfig, sandboxService: SandboxService, dynamicDsService: DynamicDsService, dsProcessorService: DsProcessorService, projectService: ProjectService);
23
+ indexBlock(blockContent: EthereumBlockWrapper): Promise<{
24
+ dynamicDsCreated: boolean;
25
+ operationHash: Uint8Array;
26
+ }>;
27
+ start(): Promise<void>;
28
+ private filterDataSources;
29
+ private indexBlockData;
30
+ private indexBlockContent;
31
+ private indexExtrinsic;
32
+ private indexEvent;
33
+ private indexData;
34
+ private filterCustomDsHandlers;
35
+ private transformAndExecuteCustomDs;
36
+ }
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ // Copyright 2020-2022 OnFinality Limited authors & contributors
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
9
+ };
10
+ var __metadata = (this && this.__metadata) || function (k, v) {
11
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.IndexerManager = void 0;
15
+ const common_1 = require("@nestjs/common");
16
+ const util_1 = require("@polkadot/util");
17
+ const common_ethereum_1 = require("@subql/common-ethereum");
18
+ const node_core_1 = require("@subql/node-core");
19
+ const sequelize_1 = require("sequelize");
20
+ const SubqueryProject_1 = require("../configure/SubqueryProject");
21
+ const block_ethereum_1 = require("../ethereum/block.ethereum");
22
+ const yargs_1 = require("../yargs");
23
+ const ds_processor_service_1 = require("./ds-processor.service");
24
+ const dynamic_ds_service_1 = require("./dynamic-ds.service");
25
+ const project_service_1 = require("./project.service");
26
+ const sandbox_service_1 = require("./sandbox.service");
27
+ const NULL_MERKEL_ROOT = (0, util_1.hexToU8a)('0x00');
28
+ const logger = (0, node_core_1.getLogger)('indexer');
29
+ let IndexerManager = class IndexerManager {
30
+ constructor(storeService, apiService, poiService, sequelize, project, nodeConfig, sandboxService, dynamicDsService, dsProcessorService, projectService) {
31
+ this.storeService = storeService;
32
+ this.apiService = apiService;
33
+ this.poiService = poiService;
34
+ this.sequelize = sequelize;
35
+ this.project = project;
36
+ this.nodeConfig = nodeConfig;
37
+ this.sandboxService = sandboxService;
38
+ this.dynamicDsService = dynamicDsService;
39
+ this.dsProcessorService = dsProcessorService;
40
+ this.projectService = projectService;
41
+ logger.info('indexer manager start');
42
+ this.api = this.apiService.api;
43
+ }
44
+ async indexBlock(blockContent) {
45
+ const { blockHeight } = blockContent;
46
+ let dynamicDsCreated = false;
47
+ const tx = await this.sequelize.transaction();
48
+ this.storeService.setTransaction(tx);
49
+ this.storeService.setBlockHeight(blockHeight);
50
+ let operationHash = NULL_MERKEL_ROOT;
51
+ let poiBlockHash;
52
+ try {
53
+ this.filteredDataSources = this.filterDataSources(blockHeight);
54
+ const datasources = this.filteredDataSources.concat(...(await this.dynamicDsService.getDynamicDatasources()));
55
+ await this.indexBlockData(blockContent, datasources,
56
+ // eslint-disable-next-line @typescript-eslint/require-await
57
+ async (ds) => {
58
+ const vm = this.sandboxService.getDsProcessorWrapper(ds, this.api, blockContent);
59
+ // Inject function to create ds into vm
60
+ vm.freeze(async (templateName, args) => {
61
+ const newDs = await this.dynamicDsService.createDynamicDatasource({
62
+ templateName,
63
+ args,
64
+ startBlock: blockHeight,
65
+ }, tx);
66
+ // Push the newly created dynamic ds to be processed this block on any future extrinsics/events
67
+ datasources.push(newDs);
68
+ dynamicDsCreated = true;
69
+ }, 'createDynamicDatasource');
70
+ return vm;
71
+ });
72
+ await this.storeService.setMetadataBatch([
73
+ { key: 'lastProcessedHeight', value: blockHeight },
74
+ { key: 'lastProcessedTimestamp', value: Date.now() },
75
+ ], { transaction: tx });
76
+ // Db Metadata increase BlockCount, in memory ref to block-dispatcher _processedBlockCount
77
+ await this.storeService.incrementBlockCount(tx);
78
+ // Need calculate operationHash to ensure correct offset insert all time
79
+ operationHash = this.storeService.getOperationMerkleRoot();
80
+ if (this.nodeConfig.proofOfIndex) {
81
+ //check if operation is null, then poi will not be inserted
82
+ if (!(0, util_1.u8aEq)(operationHash, NULL_MERKEL_ROOT)) {
83
+ const poiBlock = node_core_1.PoiBlock.create(blockHeight, blockContent.block.hash, operationHash, await this.poiService.getLatestPoiBlockHash(), this.project.id);
84
+ poiBlockHash = poiBlock.hash;
85
+ await this.storeService.setPoi(poiBlock, { transaction: tx });
86
+ this.poiService.setLatestPoiBlockHash(poiBlockHash);
87
+ await this.storeService.setMetadataBatch([{ key: 'lastPoiHeight', value: blockHeight }], { transaction: tx });
88
+ }
89
+ }
90
+ }
91
+ catch (e) {
92
+ await tx.rollback();
93
+ throw e;
94
+ }
95
+ await tx.commit();
96
+ return {
97
+ dynamicDsCreated,
98
+ operationHash,
99
+ };
100
+ }
101
+ async start() {
102
+ await this.projectService.init();
103
+ }
104
+ filterDataSources(processedHeight) {
105
+ let filteredDs = this.project.dataSources;
106
+ if (filteredDs.length === 0) {
107
+ logger.error(`Did not find any dataSource match with network specName ${this.api.getSpecName()}`);
108
+ process.exit(1);
109
+ }
110
+ filteredDs = filteredDs.filter((ds) => ds.startBlock <= processedHeight);
111
+ if (filteredDs.length === 0) {
112
+ logger.error(`Your start block is greater than the current indexed block height in your database. Either change your startBlock (project.yaml) to <= ${processedHeight}
113
+ or delete your database and start again from the currently specified startBlock`);
114
+ process.exit(1);
115
+ }
116
+ // perform filter for custom ds
117
+ if (!filteredDs.length) {
118
+ logger.error(`Did not find any datasources with associated processor`);
119
+ process.exit(1);
120
+ }
121
+ return filteredDs;
122
+ }
123
+ async indexBlockData({ block, logs, transactions }, dataSources, getVM) {
124
+ await this.indexBlockContent(block, dataSources, getVM);
125
+ for (const log of logs) {
126
+ await this.indexEvent(log, dataSources, getVM);
127
+ }
128
+ for (const tx of transactions) {
129
+ await this.indexExtrinsic(tx, dataSources, getVM);
130
+ }
131
+ }
132
+ async indexBlockContent(block, dataSources, getVM) {
133
+ for (const ds of dataSources) {
134
+ await this.indexData(common_ethereum_1.EthereumHandlerKind.Block, block, ds, getVM);
135
+ }
136
+ }
137
+ async indexExtrinsic(tx, dataSources, getVM) {
138
+ for (const ds of dataSources) {
139
+ await this.indexData(common_ethereum_1.EthereumHandlerKind.Call, tx, ds, getVM);
140
+ }
141
+ }
142
+ async indexEvent(log, dataSources, getVM) {
143
+ for (const ds of dataSources) {
144
+ await this.indexData(common_ethereum_1.EthereumHandlerKind.Event, log, ds, getVM);
145
+ }
146
+ }
147
+ async indexData(kind, data, ds, getVM) {
148
+ let vm;
149
+ if ((0, common_ethereum_1.isRuntimeDs)(ds)) {
150
+ const handlers = ds.mapping.handlers.filter((h) => h.kind === kind && FilterTypeMap[kind](data, h.filter));
151
+ for (const handler of handlers) {
152
+ vm = vm !== null && vm !== void 0 ? vm : (await getVM(ds));
153
+ this.nodeConfig.profiler
154
+ ? await (0, node_core_1.profilerWrap)(vm.securedExec.bind(vm), 'handlerPerformance', handler.handler)(handler.handler, [data])
155
+ : await vm.securedExec(handler.handler, [data]);
156
+ }
157
+ }
158
+ else if ((0, common_ethereum_1.isCustomDs)(ds)) {
159
+ const handlers = this.filterCustomDsHandlers(ds, data, ProcessorTypeMap[kind], (data, baseFilter) => {
160
+ switch (kind) {
161
+ case common_ethereum_1.EthereumHandlerKind.Block:
162
+ return block_ethereum_1.EthereumBlockWrapped.filterBlocksProcessor(data, baseFilter);
163
+ case common_ethereum_1.EthereumHandlerKind.Call:
164
+ return block_ethereum_1.EthereumBlockWrapped.filterTransactionsProcessor(data, baseFilter);
165
+ case common_ethereum_1.EthereumHandlerKind.Event:
166
+ return block_ethereum_1.EthereumBlockWrapped.filterLogsProcessor(data, baseFilter);
167
+ default:
168
+ throw new Error('Unsupported handler kind');
169
+ }
170
+ });
171
+ for (const handler of handlers) {
172
+ vm = vm !== null && vm !== void 0 ? vm : (await getVM(ds));
173
+ await this.transformAndExecuteCustomDs(ds, vm, handler, data);
174
+ }
175
+ }
176
+ }
177
+ filterCustomDsHandlers(ds, data, baseHandlerCheck, baseFilter) {
178
+ const plugin = this.dsProcessorService.getDsProcessor(ds);
179
+ return ds.mapping.handlers
180
+ .filter((handler) => {
181
+ const processor = plugin.handlerProcessors[handler.kind];
182
+ if (baseHandlerCheck(processor)) {
183
+ processor.baseFilter;
184
+ return baseFilter(data, processor.baseFilter);
185
+ }
186
+ return false;
187
+ })
188
+ .filter((handler) => {
189
+ const processor = (0, ds_processor_service_1.asSecondLayerHandlerProcessor_1_0_0)(plugin.handlerProcessors[handler.kind]);
190
+ try {
191
+ return processor.filterProcessor({
192
+ filter: handler.filter,
193
+ input: data,
194
+ ds,
195
+ });
196
+ }
197
+ catch (e) {
198
+ logger.error(e, 'Failed to run ds processer filter.');
199
+ throw e;
200
+ }
201
+ });
202
+ }
203
+ async transformAndExecuteCustomDs(ds, vm, handler, data) {
204
+ const plugin = this.dsProcessorService.getDsProcessor(ds);
205
+ const assets = await this.dsProcessorService.getAssets(ds);
206
+ const processor = (0, ds_processor_service_1.asSecondLayerHandlerProcessor_1_0_0)(plugin.handlerProcessors[handler.kind]);
207
+ const transformedData = await processor
208
+ .transformer({
209
+ input: data,
210
+ ds,
211
+ api: this.api,
212
+ filter: handler.filter,
213
+ assets,
214
+ })
215
+ .catch((e) => {
216
+ logger.error(e, 'Failed to transform data with ds processor.');
217
+ throw e;
218
+ });
219
+ // We can not run this in parallel. the transformed data items may be dependent on one another.
220
+ // An example of this is with Acala EVM packing multiple EVM logs into a single Substrate event
221
+ for (const _data of transformedData) {
222
+ await vm.securedExec(handler.handler, [_data]);
223
+ }
224
+ }
225
+ };
226
+ __decorate([
227
+ (0, node_core_1.profiler)(yargs_1.yargsOptions.argv.profiler),
228
+ __metadata("design:type", Function),
229
+ __metadata("design:paramtypes", [Object]),
230
+ __metadata("design:returntype", Promise)
231
+ ], IndexerManager.prototype, "indexBlock", null);
232
+ IndexerManager = __decorate([
233
+ (0, common_1.Injectable)(),
234
+ __metadata("design:paramtypes", [node_core_1.StoreService,
235
+ node_core_1.ApiService,
236
+ node_core_1.PoiService,
237
+ sequelize_1.Sequelize,
238
+ SubqueryProject_1.SubqueryProject,
239
+ node_core_1.NodeConfig,
240
+ sandbox_service_1.SandboxService,
241
+ dynamic_ds_service_1.DynamicDsService,
242
+ ds_processor_service_1.DsProcessorService,
243
+ project_service_1.ProjectService])
244
+ ], IndexerManager);
245
+ exports.IndexerManager = IndexerManager;
246
+ const ProcessorTypeMap = {
247
+ [common_ethereum_1.EthereumHandlerKind.Block]: common_ethereum_1.isBlockHandlerProcessor,
248
+ [common_ethereum_1.EthereumHandlerKind.Event]: common_ethereum_1.isEventHandlerProcessor,
249
+ [common_ethereum_1.EthereumHandlerKind.Call]: common_ethereum_1.isCallHandlerProcessor,
250
+ };
251
+ const FilterTypeMap = {
252
+ [common_ethereum_1.EthereumHandlerKind.Block]: block_ethereum_1.EthereumBlockWrapped.filterBlocksProcessor,
253
+ [common_ethereum_1.EthereumHandlerKind.Event]: block_ethereum_1.EthereumBlockWrapped.filterLogsProcessor,
254
+ [common_ethereum_1.EthereumHandlerKind.Call]: block_ethereum_1.EthereumBlockWrapped.filterTransactionsProcessor,
255
+ };
256
+ //# sourceMappingURL=indexer.manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexer.manager.js","sourceRoot":"","sources":["../../src/indexer/indexer.manager.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;;;;;;;AAEtC,2CAA4C;AAC5C,yCAAiD;AACjD,4DAUgC;AAChC,gDAU0B;AAS1B,yCAAsC;AACtC,kEAA+E;AAC/E,+DAAkE;AAClE,oCAAwC;AACxC,iEAGgC;AAChC,6DAAwD;AACxD,uDAAmD;AACnD,uDAAmD;AAEnD,MAAM,gBAAgB,GAAG,IAAA,eAAQ,EAAC,MAAM,CAAC,CAAC;AAE1C,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,SAAS,CAAC,CAAC;AAG7B,IAAM,cAAc,GAApB,MAAM,cAAc;IAIzB,YACU,YAA0B,EAC1B,UAAsB,EACtB,UAAsB,EACtB,SAAoB,EACpB,OAAwB,EACxB,UAAsB,EACtB,cAA8B,EAC9B,gBAAkC,EAClC,kBAAsC,EACtC,cAA8B;QAT9B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,eAAU,GAAV,UAAU,CAAY;QACtB,eAAU,GAAV,UAAU,CAAY;QACtB,cAAS,GAAT,SAAS,CAAW;QACpB,YAAO,GAAP,OAAO,CAAiB;QACxB,eAAU,GAAV,UAAU,CAAY;QACtB,mBAAc,GAAd,cAAc,CAAgB;QAC9B,qBAAgB,GAAhB,gBAAg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;QACZ,qCAAgB;QACd,yCAAkB;QACtB,gCAAc;GAd7B,cAAc,CAiU1B;AAjUY,wCAAc;AAyU3B,MAAM,gBAAgB,GAAG;IACvB,CAAC,qCAAmB,CAAC,KAAK,CAAC,EAAE,yCAAuB;IACpD,CAAC,qCAAmB,CAAC,KAAK,CAAC,EAAE,yCAAuB;IACpD,CAAC,qCAAmB,CAAC,IAAI,CAAC,EAAE,wCAAsB;CACnD,CAAC;AAEF,MAAM,aAAa,GAAG;IACpB,CAAC,qCAAmB,CAAC,KAAK,CAAC,EAAE,qCAAoB,CAAC,qBAAqB;IACvE,CAAC,qCAAmB,CAAC,KAAK,CAAC,EAAE,qCAAoB,CAAC,mBAAmB;IACrE,CAAC,qCAAmB,CAAC,IAAI,CAAC,EAAE,qCAAoB,CAAC,2BAA2B;CAC7E,CAAC","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Injectable } from '@nestjs/common';\nimport { hexToU8a, u8aEq } from '@polkadot/util';\nimport {\n isBlockHandlerProcessor,\n isCallHandlerProcessor,\n isEventHandlerProcessor,\n isCustomDs,\n isRuntimeDs,\n SubqlEthereumCustomDataSource,\n SubqlCustomHandler,\n EthereumHandlerKind,\n EthereumRuntimeHandlerInputMap,\n} from '@subql/common-ethereum';\nimport {\n ApiService,\n PoiBlock,\n StoreService,\n PoiService,\n NodeConfig,\n getLogger,\n profiler,\n profilerWrap,\n IndexerSandbox,\n} from '@subql/node-core';\nimport {\n ApiWrapper,\n EthereumTransaction,\n EthereumLog,\n SubqlRuntimeHandler,\n EthereumBlockWrapper,\n EthereumBlock,\n} from '@subql/types-ethereum';\nimport { Sequelize } from 'sequelize';\nimport { SubqlProjectDs, SubqueryProject } from '../configure/SubqueryProject';\nimport { EthereumBlockWrapped } from '../ethereum/block.ethereum';\nimport { yargsOptions } from '../yargs';\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';\n\nconst NULL_MERKEL_ROOT = hexToU8a('0x00');\n\nconst logger = getLogger('indexer');\n\n@Injectable()\nexport class IndexerManager {\n private api: ApiWrapper;\n private filteredDataSources: SubqlProjectDs[];\n\n constructor(\n private storeService: StoreService,\n private apiService: ApiService,\n private poiService: PoiService,\n private sequelize: Sequelize,\n private project: SubqueryProject,\n private nodeConfig: NodeConfig,\n private sandboxService: SandboxService,\n private dynamicDsService: DynamicDsService,\n private dsProcessorService: DsProcessorService,\n private projectService: ProjectService,\n ) {\n logger.info('indexer manager start');\n\n this.api = this.apiService.api;\n }\n\n @profiler(yargsOptions.argv.profiler)\n async indexBlock(\n blockContent: EthereumBlockWrapper,\n ): Promise<{ dynamicDsCreated: boolean; operationHash: Uint8Array }> {\n const { blockHeight } = blockContent;\n let dynamicDsCreated = false;\n const tx = await this.sequelize.transaction();\n this.storeService.setTransaction(tx);\n this.storeService.setBlockHeight(blockHeight);\n\n let operationHash = NULL_MERKEL_ROOT;\n let poiBlockHash: Uint8Array;\n\n try {\n this.filteredDataSources = this.filterDataSources(blockHeight);\n\n const datasources = this.filteredDataSources.concat(\n ...(await this.dynamicDsService.getDynamicDatasources()),\n );\n\n await this.indexBlockData(\n blockContent,\n datasources,\n // eslint-disable-next-line @typescript-eslint/require-await\n async (ds: SubqlProjectDs) => {\n const vm = this.sandboxService.getDsProcessorWrapper(\n ds,\n this.api,\n blockContent,\n );\n\n // Inject function to create ds into vm\n vm.freeze(\n async (templateName: string, args?: Record<string, unknown>) => {\n const newDs = await this.dynamicDsService.createDynamicDatasource(\n {\n templateName,\n args,\n startBlock: blockHeight,\n },\n tx,\n );\n // Push the newly created dynamic ds to be processed this block on any future extrinsics/events\n datasources.push(newDs);\n dynamicDsCreated = true;\n },\n 'createDynamicDatasource',\n );\n\n return vm;\n },\n );\n\n await this.storeService.setMetadataBatch(\n [\n { key: 'lastProcessedHeight', value: blockHeight },\n { key: 'lastProcessedTimestamp', value: Date.now() },\n ],\n { transaction: tx },\n );\n // Db Metadata increase BlockCount, in memory ref to block-dispatcher _processedBlockCount\n await this.storeService.incrementBlockCount(tx);\n\n // Need calculate operationHash to ensure correct offset insert all time\n operationHash = this.storeService.getOperationMerkleRoot();\n if (this.nodeConfig.proofOfIndex) {\n //check if operation is null, then poi will not be inserted\n if (!u8aEq(operationHash, NULL_MERKEL_ROOT)) {\n const poiBlock = PoiBlock.create(\n blockHeight,\n blockContent.block.hash,\n operationHash,\n await this.poiService.getLatestPoiBlockHash(),\n this.project.id,\n );\n poiBlockHash = poiBlock.hash;\n await this.storeService.setPoi(poiBlock, { transaction: tx });\n this.poiService.setLatestPoiBlockHash(poiBlockHash);\n await this.storeService.setMetadataBatch(\n [{ key: 'lastPoiHeight', value: blockHeight }],\n { transaction: tx },\n );\n }\n }\n } catch (e) {\n await tx.rollback();\n throw e;\n }\n\n await tx.commit();\n\n return {\n dynamicDsCreated,\n operationHash,\n };\n }\n\n async start(): Promise<void> {\n await this.projectService.init();\n }\n\n private filterDataSources(processedHeight: number): SubqlProjectDs[] {\n let filteredDs = this.project.dataSources;\n if (filteredDs.length === 0) {\n logger.error(\n `Did not find any dataSource match with network specName ${this.api.getSpecName()}`,\n );\n process.exit(1);\n }\n filteredDs = filteredDs.filter((ds) => ds.startBlock <= processedHeight);\n if (filteredDs.length === 0) {\n logger.error(\n `Your start block is greater than the current indexed block height in your database. Either change your startBlock (project.yaml) to <= ${processedHeight}\n or delete your database and start again from the currently specified startBlock`,\n );\n process.exit(1);\n }\n // perform filter for custom ds\n if (!filteredDs.length) {\n logger.error(`Did not find any datasources with associated processor`);\n process.exit(1);\n }\n return filteredDs;\n }\n\n private async indexBlockData(\n { block, logs, 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 log of logs) {\n await this.indexEvent(log, dataSources, getVM);\n }\n\n for (const tx of transactions) {\n await this.indexExtrinsic(tx, dataSources, getVM);\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 indexExtrinsic(\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 private async indexData<K extends EthereumHandlerKind>(\n kind: K,\n data: EthereumRuntimeHandlerInputMap[K],\n ds: SubqlProjectDs,\n getVM: (ds: SubqlProjectDs) => Promise<IndexerSandbox>,\n ): Promise<void> {\n let vm: IndexerSandbox;\n if (isRuntimeDs(ds)) {\n const handlers = (ds.mapping.handlers as SubqlRuntimeHandler[]).filter(\n (h) =>\n h.kind === kind && FilterTypeMap[kind](data as any, h.filter as any),\n );\n\n for (const handler of handlers) {\n vm = vm ?? (await getVM(ds));\n this.nodeConfig.profiler\n ? await profilerWrap(\n vm.securedExec.bind(vm),\n 'handlerPerformance',\n handler.handler,\n )(handler.handler, [data])\n : await vm.securedExec(handler.handler, [data]);\n }\n } else if (isCustomDs(ds)) {\n const handlers = this.filterCustomDsHandlers<K>(\n ds,\n data,\n ProcessorTypeMap[kind],\n (data, baseFilter) => {\n switch (kind) {\n case EthereumHandlerKind.Block:\n return EthereumBlockWrapped.filterBlocksProcessor(\n data as EthereumBlock,\n baseFilter,\n );\n case EthereumHandlerKind.Call:\n return EthereumBlockWrapped.filterTransactionsProcessor(\n data as EthereumTransaction,\n baseFilter,\n );\n case EthereumHandlerKind.Event:\n return EthereumBlockWrapped.filterLogsProcessor(\n data as EthereumLog,\n baseFilter,\n );\n default:\n throw new Error('Unsupported handler kind');\n }\n },\n );\n\n for (const handler of handlers) {\n vm = vm ?? (await getVM(ds));\n await this.transformAndExecuteCustomDs(ds, vm, handler, data);\n }\n }\n }\n\n private filterCustomDsHandlers<K extends EthereumHandlerKind>(\n ds: SubqlEthereumCustomDataSource<string, any>,\n data: EthereumRuntimeHandlerInputMap[K],\n baseHandlerCheck: ProcessorTypeMap[K],\n baseFilter: (\n data: EthereumRuntimeHandlerInputMap[K],\n baseFilter: any,\n ) => boolean,\n ): SubqlCustomHandler[] {\n const plugin = this.dsProcessorService.getDsProcessor(ds);\n\n return ds.mapping.handlers\n .filter((handler) => {\n const processor = plugin.handlerProcessors[handler.kind];\n if (baseHandlerCheck(processor)) {\n processor.baseFilter;\n\n return baseFilter(data, processor.baseFilter);\n }\n return false;\n })\n .filter((handler) => {\n const processor = asSecondLayerHandlerProcessor_1_0_0(\n plugin.handlerProcessors[handler.kind],\n );\n\n try {\n return processor.filterProcessor({\n filter: handler.filter,\n input: data,\n ds,\n });\n } catch (e) {\n logger.error(e, 'Failed to run ds processer filter.');\n throw e;\n }\n });\n }\n\n private async transformAndExecuteCustomDs<K extends EthereumHandlerKind>(\n ds: SubqlEthereumCustomDataSource<string, any>,\n vm: IndexerSandbox,\n handler: SubqlCustomHandler,\n data: EthereumRuntimeHandlerInputMap[K],\n ): Promise<void> {\n const plugin = this.dsProcessorService.getDsProcessor(ds);\n const assets = await this.dsProcessorService.getAssets(ds);\n\n const processor = asSecondLayerHandlerProcessor_1_0_0(\n plugin.handlerProcessors[handler.kind],\n );\n\n const transformedData = await processor\n .transformer({\n input: data,\n ds,\n api: this.api,\n filter: handler.filter,\n assets,\n })\n .catch((e) => {\n logger.error(e, 'Failed to transform data with ds processor.');\n throw e;\n });\n\n // We can not run this in parallel. the transformed data items may be dependent on one another.\n // An example of this is with Acala EVM packing multiple EVM logs into a single Substrate event\n for (const _data of transformedData) {\n await vm.securedExec(handler.handler, [_data]);\n }\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]: EthereumBlockWrapped.filterBlocksProcessor,\n [EthereumHandlerKind.Event]: EthereumBlockWrapped.filterLogsProcessor,\n [EthereumHandlerKind.Call]: EthereumBlockWrapped.filterTransactionsProcessor,\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export declare class IndexerModule {
2
+ }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ // Copyright 2020-2022 OnFinality Limited authors & contributors
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
5
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.IndexerModule = void 0;
12
+ const common_1 = require("@nestjs/common");
13
+ const node_core_1 = require("@subql/node-core");
14
+ const SubqueryProject_1 = require("../configure/SubqueryProject");
15
+ const ethereum_1 = require("../ethereum");
16
+ const dictionary_service_1 = require("./dictionary.service");
17
+ const ds_processor_service_1 = require("./ds-processor.service");
18
+ const dynamic_ds_service_1 = require("./dynamic-ds.service");
19
+ const indexer_manager_1 = require("./indexer.manager");
20
+ const project_service_1 = require("./project.service");
21
+ const sandbox_service_1 = require("./sandbox.service");
22
+ const worker_service_1 = require("./worker/worker.service");
23
+ let IndexerModule = class IndexerModule {
24
+ };
25
+ IndexerModule = __decorate([
26
+ (0, common_1.Module)({
27
+ providers: [
28
+ indexer_manager_1.IndexerManager,
29
+ node_core_1.StoreService,
30
+ {
31
+ provide: node_core_1.ApiService,
32
+ useFactory: async (project) => {
33
+ const apiService = new ethereum_1.EthereumApiService(project);
34
+ await apiService.init();
35
+ return apiService;
36
+ },
37
+ inject: [SubqueryProject_1.SubqueryProject],
38
+ },
39
+ dictionary_service_1.DictionaryService,
40
+ sandbox_service_1.SandboxService,
41
+ ds_processor_service_1.DsProcessorService,
42
+ dynamic_ds_service_1.DynamicDsService,
43
+ node_core_1.PoiService,
44
+ node_core_1.MmrService,
45
+ project_service_1.ProjectService,
46
+ worker_service_1.WorkerService,
47
+ ],
48
+ exports: [node_core_1.StoreService],
49
+ })
50
+ ], IndexerModule);
51
+ exports.IndexerModule = IndexerModule;
52
+ //# sourceMappingURL=indexer.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexer.module.js","sourceRoot":"","sources":["../../src/indexer/indexer.module.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;;;;AAEtC,2CAAwC;AACxC,gDAK0B;AAC1B,kEAA+D;AAC/D,0CAAiD;AACjD,6DAAyD;AACzD,iEAA4D;AAC5D,6DAAwD;AACxD,uDAAmD;AACnD,uDAAmD;AACnD,uDAAmD;AACnD,4DAAwD;AA0BjD,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,aAAa;IAxBzB,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT,gCAAc;YACd,wBAAY;YACZ;gBACE,OAAO,EAAE,sBAAU;gBACnB,UAAU,EAAE,KAAK,EAAE,OAAwB,EAAE,EAAE;oBAC7C,MAAM,UAAU,GAAG,IAAI,6BAAkB,CAAC,OAAO,CAAC,CAAC;oBACnD,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC;oBACxB,OAAO,UAAU,CAAC;gBACpB,CAAC;gBACD,MAAM,EAAE,CAAC,iCAAe,CAAC;aAC1B;YACD,sCAAiB;YACjB,gCAAc;YACd,yCAAkB;YAClB,qCAAgB;YAChB,sBAAU;YACV,sBAAU;YACV,gCAAc;YACd,8BAAa;SACd;QACD,OAAO,EAAE,CAAC,wBAAY,CAAC;KACxB,CAAC;GACW,aAAa,CAAG;AAAhB,sCAAa","sourcesContent":["// Copyright 2020-2022 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Module } from '@nestjs/common';\nimport {\n ApiService,\n StoreService,\n PoiService,\n MmrService,\n} from '@subql/node-core';\nimport { SubqueryProject } from '../configure/SubqueryProject';\nimport { EthereumApiService } from '../ethereum';\nimport { DictionaryService } from './dictionary.service';\nimport { DsProcessorService } from './ds-processor.service';\nimport { DynamicDsService } from './dynamic-ds.service';\nimport { IndexerManager } from './indexer.manager';\nimport { ProjectService } from './project.service';\nimport { SandboxService } from './sandbox.service';\nimport { WorkerService } from './worker/worker.service';\n\n@Module({\n providers: [\n IndexerManager,\n StoreService,\n {\n provide: ApiService,\n useFactory: async (project: SubqueryProject) => {\n const apiService = new EthereumApiService(project);\n await apiService.init();\n return apiService;\n },\n inject: [SubqueryProject],\n },\n DictionaryService,\n SandboxService,\n DsProcessorService,\n DynamicDsService,\n PoiService,\n MmrService,\n ProjectService,\n WorkerService,\n ],\n exports: [StoreService],\n})\nexport class IndexerModule {}\n"]}
@@ -0,0 +1,39 @@
1
+ import { EventEmitter2 } from '@nestjs/event-emitter';
2
+ import { ApiService, NodeConfig, StoreService, PoiService, MmrService } from '@subql/node-core';
3
+ import { Sequelize } from 'sequelize';
4
+ import { SubqueryProject } from '../configure/SubqueryProject';
5
+ import { DsProcessorService } from './ds-processor.service';
6
+ import { DynamicDsService } from './dynamic-ds.service';
7
+ export declare class ProjectService {
8
+ private readonly dsProcessorService;
9
+ private readonly apiService;
10
+ private readonly poiService;
11
+ protected readonly mmrService: MmrService;
12
+ private readonly sequelize;
13
+ private readonly project;
14
+ private readonly storeService;
15
+ private readonly nodeConfig;
16
+ private readonly dynamicDsService;
17
+ private eventEmitter;
18
+ private _schema;
19
+ private metadataRepo;
20
+ private _startHeight;
21
+ private _blockOffset;
22
+ constructor(dsProcessorService: DsProcessorService, apiService: ApiService, poiService: PoiService, mmrService: MmrService, sequelize: Sequelize, project: SubqueryProject, storeService: StoreService, nodeConfig: NodeConfig, dynamicDsService: DynamicDsService, eventEmitter: EventEmitter2);
23
+ get schema(): string;
24
+ get blockOffset(): number;
25
+ get startHeight(): number;
26
+ private getExistingProjectSchema;
27
+ init(): Promise<void>;
28
+ private ensureProject;
29
+ private createProjectSchema;
30
+ private initDbSchema;
31
+ private ensureMetadata;
32
+ upsertMetadataBlockOffset(height: number): Promise<void>;
33
+ getMetadataBlockOffset(): Promise<number | undefined>;
34
+ getLastProcessedHeight(): Promise<number | undefined>;
35
+ private getStartHeight;
36
+ setBlockOffset(offset: number): Promise<void>;
37
+ getProcessedBlockCount(): Promise<number>;
38
+ private getStartBlockFromDataSources;
39
+ }