@subql/node-ethereum 0.4.1-8 → 0.4.1-storeCache-0.0.3

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 (106) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/README.md +3 -0
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/ethereum/api.ethereum.d.ts +8 -4
  5. package/dist/ethereum/api.ethereum.js +70 -49
  6. package/dist/ethereum/api.ethereum.js.map +1 -1
  7. package/dist/ethereum/api.service.ethereum.js +1 -1
  8. package/dist/ethereum/api.service.ethereum.js.map +1 -1
  9. package/dist/ethereum/block.ethereum.d.ts +1 -1
  10. package/dist/ethereum/block.ethereum.js +9 -12
  11. package/dist/ethereum/block.ethereum.js.map +1 -1
  12. package/dist/ethereum/ethers/json-rpc-batch-provider.d.ts +21 -0
  13. package/dist/ethereum/ethers/json-rpc-batch-provider.js +102 -0
  14. package/dist/ethereum/ethers/json-rpc-batch-provider.js.map +1 -0
  15. package/dist/ethereum/ethers/json-rpc-provider.d.ts +7 -0
  16. package/dist/ethereum/ethers/json-rpc-provider.js +68 -0
  17. package/dist/ethereum/ethers/json-rpc-provider.js.map +1 -0
  18. package/dist/ethereum/ethers/web/_version.d.ts +1 -0
  19. package/dist/ethereum/ethers/web/_version.js +6 -0
  20. package/dist/ethereum/ethers/web/_version.js.map +1 -0
  21. package/dist/ethereum/ethers/web/geturl.d.ts +3 -0
  22. package/dist/ethereum/ethers/web/geturl.js +116 -0
  23. package/dist/ethereum/ethers/web/geturl.js.map +1 -0
  24. package/dist/ethereum/ethers/web/index.d.ts +49 -0
  25. package/dist/ethereum/ethers/web/index.js +433 -0
  26. package/dist/ethereum/ethers/web/index.js.map +1 -0
  27. package/dist/ethereum/ethers/web/types.d.ts +26 -0
  28. package/dist/ethereum/ethers/web/types.js +4 -0
  29. package/dist/ethereum/ethers/web/types.js.map +1 -0
  30. package/dist/ethereum/utils.ethereum.d.ts +1 -1
  31. package/dist/ethereum/utils.ethereum.js +16 -3
  32. package/dist/ethereum/utils.ethereum.js.map +1 -1
  33. package/dist/indexer/blockDispatcher/block-dispatcher.service.d.ts +8 -15
  34. package/dist/indexer/blockDispatcher/block-dispatcher.service.js +20 -108
  35. package/dist/indexer/blockDispatcher/block-dispatcher.service.js.map +1 -1
  36. package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.d.ts +4 -0
  37. package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.js +5 -0
  38. package/dist/indexer/blockDispatcher/ethereum-block-dispatcher.js.map +1 -0
  39. package/dist/indexer/blockDispatcher/index.d.ts +2 -2
  40. package/dist/indexer/blockDispatcher/index.js.map +1 -1
  41. package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.d.ts +12 -17
  42. package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js +48 -134
  43. package/dist/indexer/blockDispatcher/worker-block-dispatcher.service.js.map +1 -1
  44. package/dist/indexer/dynamic-ds.service.d.ts +3 -22
  45. package/dist/indexer/dynamic-ds.service.js +4 -91
  46. package/dist/indexer/dynamic-ds.service.js.map +1 -1
  47. package/dist/indexer/fetch.module.js +24 -6
  48. package/dist/indexer/fetch.module.js.map +1 -1
  49. package/dist/indexer/fetch.service.d.ts +3 -3
  50. package/dist/indexer/fetch.service.js +40 -39
  51. package/dist/indexer/fetch.service.js.map +1 -1
  52. package/dist/indexer/indexer.manager.d.ts +5 -17
  53. package/dist/indexer/indexer.manager.js +25 -70
  54. package/dist/indexer/indexer.manager.js.map +1 -1
  55. package/dist/indexer/indexer.module.js +25 -2
  56. package/dist/indexer/indexer.module.js.map +1 -1
  57. package/dist/indexer/project.service.d.ts +5 -10
  58. package/dist/indexer/project.service.js +49 -100
  59. package/dist/indexer/project.service.js.map +1 -1
  60. package/dist/indexer/sandbox.service.js +6 -1
  61. package/dist/indexer/sandbox.service.js.map +1 -1
  62. package/dist/indexer/unfinalizedBlocks.service.d.ts +12 -12
  63. package/dist/indexer/unfinalizedBlocks.service.js +33 -38
  64. package/dist/indexer/unfinalizedBlocks.service.js.map +1 -1
  65. package/dist/indexer/unfinalizedBlocks.spec.js +41 -34
  66. package/dist/indexer/unfinalizedBlocks.spec.js.map +1 -1
  67. package/dist/indexer/worker/worker.d.ts +22 -8
  68. package/dist/indexer/worker/worker.js +14 -7
  69. package/dist/indexer/worker/worker.js.map +1 -1
  70. package/dist/indexer/worker/worker.service.d.ts +2 -2
  71. package/dist/indexer/worker/worker.service.js +11 -4
  72. package/dist/indexer/worker/worker.service.js.map +1 -1
  73. package/dist/indexer/worker/worker.unfinalizedBlocks.service.d.ts +11 -0
  74. package/dist/indexer/worker/worker.unfinalizedBlocks.service.js +32 -0
  75. package/dist/indexer/worker/worker.unfinalizedBlocks.service.js.map +1 -0
  76. package/dist/init.js +2 -2
  77. package/dist/init.js.map +1 -1
  78. package/dist/meta/meta.module.js +8 -0
  79. package/dist/meta/meta.module.js.map +1 -1
  80. package/dist/meta/meta.service.d.ts +18 -3
  81. package/dist/meta/meta.service.js +89 -5
  82. package/dist/meta/meta.service.js.map +1 -1
  83. package/dist/subcommands/forceClean.service.js +8 -4
  84. package/dist/subcommands/forceClean.service.js.map +1 -1
  85. package/dist/subcommands/reindex.init.js +5 -1
  86. package/dist/subcommands/reindex.init.js.map +1 -1
  87. package/dist/subcommands/reindex.module.js +8 -0
  88. package/dist/subcommands/reindex.module.js.map +1 -1
  89. package/dist/subcommands/reindex.service.d.ts +4 -1
  90. package/dist/subcommands/reindex.service.js +21 -10
  91. package/dist/subcommands/reindex.service.js.map +1 -1
  92. package/dist/utils/project.d.ts +1 -0
  93. package/dist/utils/project.js +13 -1
  94. package/dist/utils/project.js.map +1 -1
  95. package/dist/utils/reindex.d.ts +2 -1
  96. package/dist/utils/reindex.js +6 -2
  97. package/dist/utils/reindex.js.map +1 -1
  98. package/dist/utils/string.js +10 -2
  99. package/dist/utils/string.js.map +1 -1
  100. package/dist/yargs.d.ts +85 -53
  101. package/dist/yargs.js +103 -71
  102. package/dist/yargs.js.map +1 -1
  103. package/package.json +9 -9
  104. package/dist/indexer/blockDispatcher/base-block-dispatcher.d.ts +0 -40
  105. package/dist/indexer/blockDispatcher/base-block-dispatcher.js +0 -99
  106. package/dist/indexer/blockDispatcher/base-block-dispatcher.js.map +0 -1
@@ -1,99 +0,0 @@
1
- "use strict";
2
- // Copyright 2020-2021 OnFinality Limited authors & contributors
3
- // SPDX-License-Identifier: Apache-2.0
4
- var __importDefault = (this && this.__importDefault) || function (mod) {
5
- return (mod && mod.__esModule) ? mod : { "default": mod };
6
- };
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.BaseBlockDispatcher = void 0;
9
- const assert_1 = __importDefault(require("assert"));
10
- const util_1 = require("@polkadot/util");
11
- const node_core_1 = require("@subql/node-core");
12
- const logger = (0, node_core_1.getLogger)('BaseBlockDispatcherService');
13
- const NULL_MERKEL_ROOT = (0, util_1.hexToU8a)('0x00');
14
- function isNullMerkelRoot(operationHash) {
15
- return (0, util_1.u8aEq)(operationHash, NULL_MERKEL_ROOT);
16
- }
17
- class BaseBlockDispatcher {
18
- constructor(nodeConfig, eventEmitter, projectService, queue) {
19
- this.nodeConfig = nodeConfig;
20
- this.eventEmitter = eventEmitter;
21
- this.projectService = projectService;
22
- this.queue = queue;
23
- }
24
- get queueSize() {
25
- return this.queue.size;
26
- }
27
- get freeSize() {
28
- return this.queue.freeSpace;
29
- }
30
- get latestBufferedHeight() {
31
- return this._latestBufferedHeight;
32
- }
33
- set latestBufferedHeight(height) {
34
- this.eventEmitter.emit(node_core_1.IndexerEvent.BlocknumberQueueSize, {
35
- value: this.queueSize,
36
- });
37
- this._latestBufferedHeight = height;
38
- }
39
- setProcessedBlockCount(processedBlockCount) {
40
- this._processedBlockCount = processedBlockCount;
41
- this.eventEmitter.emit(node_core_1.IndexerEvent.BlockProcessedCount, {
42
- processedBlockCount,
43
- timestamp: Date.now(),
44
- });
45
- }
46
- // Compare it with current indexing number, if last corrected is already indexed
47
- // rewind, also flush queued blocks, drop current indexing transaction, set last processed to correct block too
48
- // if rollback is greater than current index flush queue only
49
- async rewind(lastCorrectHeight) {
50
- if (lastCorrectHeight <= this.currentProcessingHeight) {
51
- logger.info(`Found last verified block at height ${lastCorrectHeight}, rewinding...`);
52
- await this.projectService.reindex(lastCorrectHeight);
53
- this.latestProcessedHeight = lastCorrectHeight;
54
- logger.info(`Successful rewind to block ${lastCorrectHeight}!`);
55
- }
56
- this.flushQueue(lastCorrectHeight);
57
- logger.info(`Queued blocks flushed!`); //Also last buffered height reset, next fetching should start after lastCorrectHeight
58
- }
59
- flushQueue(height) {
60
- this.latestBufferedHeight = height;
61
- this.queue.flush();
62
- }
63
- // Is called directly before a block is processed
64
- preProcessBlock(height) {
65
- this.currentProcessingHeight = height;
66
- this.eventEmitter.emit(node_core_1.IndexerEvent.BlockProcessing, {
67
- height,
68
- timestamp: Date.now(),
69
- });
70
- }
71
- // Is called directly after a block is processed
72
- async postProcessBlock(height, processBlockResponse) {
73
- const { dynamicDsCreated, operationHash, reindexBlockHeight } = processBlockResponse;
74
- if (reindexBlockHeight !== null && reindexBlockHeight !== undefined) {
75
- await this.rewind(reindexBlockHeight);
76
- this.latestProcessedHeight = reindexBlockHeight;
77
- }
78
- else {
79
- if (this.nodeConfig.proofOfIndex && !isNullMerkelRoot(operationHash)) {
80
- // We only check if it is undefined, need to be caution here when blockOffset is 0
81
- if (this.projectService.blockOffset === undefined) {
82
- // Which means during project init, it has not found offset and set value
83
- await this.projectService.upsertMetadataBlockOffset(height - 1);
84
- }
85
- // this will return if project service blockOffset already exist
86
- void this.projectService.setBlockOffset(height - 1);
87
- }
88
- if (dynamicDsCreated) {
89
- await this.onDynamicDsCreated(height);
90
- }
91
- (0, assert_1.default)(!this.latestProcessedHeight || height > this.latestProcessedHeight, `Block processed out of order. Height: ${height}. Latest: ${this.latestProcessedHeight}`);
92
- // In memory _processedBlockCount increase, db metadata increase BlockCount in indexer.manager
93
- this.setProcessedBlockCount(this._processedBlockCount + 1);
94
- this.latestProcessedHeight = height;
95
- }
96
- }
97
- }
98
- exports.BaseBlockDispatcher = BaseBlockDispatcher;
99
- //# sourceMappingURL=base-block-dispatcher.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base-block-dispatcher.js","sourceRoot":"","sources":["../../../src/indexer/blockDispatcher/base-block-dispatcher.ts"],"names":[],"mappings":";AAAA,gEAAgE;AAChE,sCAAsC;;;;;;AAEtC,oDAA4B;AAE5B,yCAAiD;AACjD,gDAA+E;AAG/E,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,4BAA4B,CAAC,CAAC;AAsBvD,MAAM,gBAAgB,GAAG,IAAA,eAAQ,EAAC,MAAM,CAAC,CAAC;AAE1C,SAAS,gBAAgB,CAAC,aAAyB;IACjD,OAAO,IAAA,YAAK,EAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;AAChD,CAAC;AAED,MAAsB,mBAAmB;IASvC,YACY,UAAsB,EACtB,YAA2B,EAC3B,cAA8B,EAC9B,KAAQ;QAHR,eAAU,GAAV,UAAU,CAAY;QACtB,iBAAY,GAAZ,YAAY,CAAe;QAC3B,mBAAc,GAAd,cAAc,CAAgB;QAC9B,UAAK,GAAL,KAAK,CAAG;IACjB,CAAC;IAOJ,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;IAC9B,CAAC;IAED,IAAI,oBAAoB;QACtB,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACpC,CAAC;IAED,IAAI,oBAAoB,CAAC,MAAc;QACrC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,wBAAY,CAAC,oBAAoB,EAAE;YACxD,KAAK,EAAE,IAAI,CAAC,SAAS;SACtB,CAAC,CAAC;QACH,IAAI,CAAC,qBAAqB,GAAG,MAAM,CAAC;IACtC,CAAC;IAES,sBAAsB,CAAC,mBA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vB,IAAI,kBAAkB,KAAK,IAAI,IAAI,kBAAkB,KAAK,SAAS,EAAE;YACnE,MAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;YACtC,IAAI,CAAC,qBAAqB,GAAG,kBAAkB,CAAC;SACjD;aAAM;YACL,IAAI,IAAI,CAAC,UAAU,CAAC,YAAY,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE;gBACpE,kFAAkF;gBAClF,IAAI,IAAI,CAAC,cAAc,CAAC,WAAW,KAAK,SAAS,EAAE;oBACjD,yEAAyE;oBACzE,MAAM,IAAI,CAAC,cAAc,CAAC,yBAAyB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;iBACjE;gBACD,gEAAgE;gBAChE,KAAK,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;aACrD;YACD,IAAI,gBAAgB,EAAE;gBACpB,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;aACvC;YACD,IAAA,gBAAM,EACJ,CAAC,IAAI,CAAC,qBAAqB,IAAI,MAAM,GAAG,IAAI,CAAC,qBAAqB,EAClE,yCAAyC,MAAM,aAAa,IAAI,CAAC,qBAAqB,EAAE,CACzF,CAAC;YACF,8FAA8F;YAC9F,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC,CAAC;YAC3D,IAAI,CAAC,qBAAqB,GAAG,MAAM,CAAC;SACrC;IACH,CAAC;CACF;AA9GD,kDA8GC","sourcesContent":["// Copyright 2020-2021 OnFinality Limited authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\nimport assert from 'assert';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { hexToU8a, u8aEq } from '@polkadot/util';\nimport { getLogger, IndexerEvent, IQueue, NodeConfig } from '@subql/node-core';\nimport { ProjectService } from '../project.service';\n\nconst logger = getLogger('BaseBlockDispatcherService');\n\nexport type ProcessBlockResponse = {\n dynamicDsCreated: boolean;\n operationHash: Uint8Array;\n reindexBlockHeight: number;\n};\n\nexport interface IBlockDispatcher {\n init(onDynamicDsCreated: (height: number) => Promise<void>): Promise<void>;\n\n enqueueBlocks(heights: number[], latestBufferHeight?: number): void;\n\n queueSize: number;\n freeSize: number;\n latestBufferedHeight: number | undefined;\n\n // Remove all enqueued blocks, used when a dynamic ds is created\n flushQueue(height: number): void;\n rewind(height: number): Promise<void>;\n}\n\nconst NULL_MERKEL_ROOT = hexToU8a('0x00');\n\nfunction isNullMerkelRoot(operationHash: Uint8Array): boolean {\n return u8aEq(operationHash, NULL_MERKEL_ROOT);\n}\n\nexport abstract class BaseBlockDispatcher<Q extends IQueue>\n implements IBlockDispatcher\n{\n protected _latestBufferedHeight: number;\n protected _processedBlockCount: number;\n protected latestProcessedHeight: number;\n protected currentProcessingHeight: number;\n protected onDynamicDsCreated: (height: number) => Promise<void>;\n\n constructor(\n protected nodeConfig: NodeConfig,\n protected eventEmitter: EventEmitter2,\n protected projectService: ProjectService,\n protected queue: Q,\n ) {}\n\n abstract enqueueBlocks(heights: number[]): void;\n abstract init(\n onDynamicDsCreated: (height: number) => Promise<void>,\n ): Promise<void>;\n\n get queueSize(): number {\n return this.queue.size;\n }\n\n get freeSize(): number {\n return this.queue.freeSpace;\n }\n\n get latestBufferedHeight(): number {\n return this._latestBufferedHeight;\n }\n\n set latestBufferedHeight(height: number) {\n this.eventEmitter.emit(IndexerEvent.BlocknumberQueueSize, {\n value: this.queueSize,\n });\n this._latestBufferedHeight = height;\n }\n\n protected setProcessedBlockCount(processedBlockCount: number): void {\n this._processedBlockCount = processedBlockCount;\n this.eventEmitter.emit(IndexerEvent.BlockProcessedCount, {\n processedBlockCount,\n timestamp: Date.now(),\n });\n }\n\n // Compare it with current indexing number, if last corrected is already indexed\n // rewind, also flush queued blocks, drop current indexing transaction, set last processed to correct block too\n // if rollback is greater than current index flush queue only\n async rewind(lastCorrectHeight: number): Promise<void> {\n if (lastCorrectHeight <= this.currentProcessingHeight) {\n logger.info(\n `Found last verified block at height ${lastCorrectHeight}, rewinding...`,\n );\n await this.projectService.reindex(lastCorrectHeight);\n this.latestProcessedHeight = lastCorrectHeight;\n logger.info(`Successful rewind to block ${lastCorrectHeight}!`);\n }\n this.flushQueue(lastCorrectHeight);\n logger.info(`Queued blocks flushed!`); //Also last buffered height reset, next fetching should start after lastCorrectHeight\n }\n\n flushQueue(height: number): void {\n this.latestBufferedHeight = height;\n this.queue.flush();\n }\n\n // Is called directly before a block is processed\n protected preProcessBlock(height: number): void {\n this.currentProcessingHeight = height;\n this.eventEmitter.emit(IndexerEvent.BlockProcessing, {\n height,\n timestamp: Date.now(),\n });\n }\n\n // Is called directly after a block is processed\n protected async postProcessBlock(\n height: number,\n processBlockResponse: ProcessBlockResponse,\n ): Promise<void> {\n const { dynamicDsCreated, operationHash, reindexBlockHeight } =\n processBlockResponse;\n if (reindexBlockHeight !== null && reindexBlockHeight !== undefined) {\n await this.rewind(reindexBlockHeight);\n this.latestProcessedHeight = reindexBlockHeight;\n } else {\n if (this.nodeConfig.proofOfIndex && !isNullMerkelRoot(operationHash)) {\n // We only check if it is undefined, need to be caution here when blockOffset is 0\n if (this.projectService.blockOffset === undefined) {\n // Which means during project init, it has not found offset and set value\n await this.projectService.upsertMetadataBlockOffset(height - 1);\n }\n // this will return if project service blockOffset already exist\n void this.projectService.setBlockOffset(height - 1);\n }\n if (dynamicDsCreated) {\n await this.onDynamicDsCreated(height);\n }\n assert(\n !this.latestProcessedHeight || height > this.latestProcessedHeight,\n `Block processed out of order. Height: ${height}. Latest: ${this.latestProcessedHeight}`,\n );\n // In memory _processedBlockCount increase, db metadata increase BlockCount in indexer.manager\n this.setProcessedBlockCount(this._processedBlockCount + 1);\n this.latestProcessedHeight = height;\n }\n }\n}\n"]}