@subql/node-ethereum 5.0.1 → 5.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.
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter2 } from '@nestjs/event-emitter';
2
2
  import { ApiConnectionError, NetworkMetadataPayload, IApiConnectionSpecific, IBlock } from '@subql/node-core';
3
- import { EthereumBlock, LightEthereumBlock } from '@subql/types-ethereum';
3
+ import { EthereumBlock, IEthereumEndpointConfig, LightEthereumBlock } from '@subql/types-ethereum';
4
4
  import { EthereumApi } from './api.ethereum';
5
5
  import SafeEthProvider from './safe-api';
6
6
  export type FetchFunc = ((api: EthereumApi, batch: number[]) => Promise<IBlock<EthereumBlock>[]>) | ((api: EthereumApi, batch: number[]) => Promise<IBlock<LightEthereumBlock>[]>);
@@ -10,7 +10,7 @@ export declare class EthereumApiConnection implements IApiConnectionSpecific<Eth
10
10
  private fetchBlocksBatches;
11
11
  readonly networkMeta: NetworkMetadataPayload;
12
12
  private constructor();
13
- static create(endpoint: string, blockConfirmations: number, fetchBlocksBatches: GetFetchFunc, eventEmitter: EventEmitter2, unfinalizedBlocks: boolean): Promise<EthereumApiConnection>;
13
+ static create(endpoint: string, blockConfirmations: number, fetchBlocksBatches: GetFetchFunc, eventEmitter: EventEmitter2, unfinalizedBlocks: boolean, config?: IEthereumEndpointConfig): Promise<EthereumApiConnection>;
14
14
  safeApi(height: number): SafeEthProvider;
15
15
  apiConnect(): Promise<void>;
16
16
  apiDisconnect(): Promise<void>;
@@ -18,8 +18,8 @@ class EthereumApiConnection {
18
18
  genesisHash: unsafeApi.getGenesisHash(),
19
19
  };
20
20
  }
21
- static async create(endpoint, blockConfirmations, fetchBlocksBatches, eventEmitter, unfinalizedBlocks) {
22
- const api = new api_ethereum_1.EthereumApi(endpoint, blockConfirmations, eventEmitter, unfinalizedBlocks);
21
+ static async create(endpoint, blockConfirmations, fetchBlocksBatches, eventEmitter, unfinalizedBlocks, config) {
22
+ const api = new api_ethereum_1.EthereumApi(endpoint, blockConfirmations, eventEmitter, unfinalizedBlocks, config);
23
23
  await api.init();
24
24
  return new EthereumApiConnection(api, fetchBlocksBatches);
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"api.connection.js","sourceRoot":"","sources":["../../src/ethereum/api.connection.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AAGnC,gDAU0B;AAE1B,iDAA6C;AAa7C,MAAa,qBAAqB;IAWvB;IACC;IAJD,WAAW,CAAyB;IAE7C,YACS,SAAsB,EACrB,kBAAgC;QADjC,cAAS,GAAT,SAAS,CAAa;QACrB,uBAAkB,GAAlB,kBAAkB,CAAc;QAExC,IAAI,CAAC,WAAW,GAAG;YACjB,KAAK,EAAE,SAAS,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE;YACxC,QAAQ,EAAE,SAAS,CAAC,WAAW,EAAE;YACjC,WAAW,EAAE,SAAS,CAAC,cAAc,EAAE;SACxC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,QAAgB,EAChB,kBAA0B,EAC1B,kBAAgC,EAChC,YAA2B,EAC3B,iBAA0B;QAE1B,MAAM,GAAG,GAAG,IAAI,0BAAW,CACzB,QAAQ,EACR,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,CAClB,CAAC;QAEF,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAEjB,OAAO,IAAI,qBAAqB,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,CAAC,MAAc;QACpB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,WAAW,CACf,OAAiB;QAEjB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACxE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,WAAW,GAAG,qBAAqB,CAAC,WAAW,CAAC;IAEhD,MAAM,CAAC,WAAW,CAAC,CAAQ;QACzB,IAAI,eAAmC,CAAC;QACxC,IAAI,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,2CAA2C,CAAC,EAAE;YACrE,eAAe,GAAG,IAAI,wBAAY,CAAC,CAAC,CAAC,CAAC;SACvC;aAAM,IAAI,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE;YACrD,eAAe,GAAG,IAAI,8BAAkB,CAAC,CAAC,CAAC,CAAC;SAC7C;aAAM,IAAI,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,0BAA0B,CAAC,EAAE;YAC3D,eAAe,GAAG,IAAI,0BAAc,CAAC,CAAC,CAAC,CAAC;SACzC;aAAM,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAC,EAAE;YACtD,eAAe,GAAG,IAAI,8BAAkB,CAAC,CAAC,CAAC,CAAC;SAC7C;aAAM;YACL,eAAe,GAAG,IAAI,8BAAkB,CACtC,CAAC,CAAC,IAAI,EACN,CAAC,CAAC,OAAO,EACT,wBAAY,CAAC,OAAO,CACrB,CAAC;SACH;QACD,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;AAhFD,sDAgFC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport {\n ApiConnectionError,\n ApiErrorType,\n DisconnectionError,\n LargeResponseError,\n NetworkMetadataPayload,\n RateLimitError,\n TimeoutError,\n IApiConnectionSpecific,\n IBlock,\n} from '@subql/node-core';\nimport { EthereumBlock, LightEthereumBlock } from '@subql/types-ethereum';\nimport { EthereumApi } from './api.ethereum';\nimport SafeEthProvider from './safe-api';\n\nexport type FetchFunc =\n | ((api: EthereumApi, batch: number[]) => Promise<IBlock<EthereumBlock>[]>)\n | ((\n api: EthereumApi,\n batch: number[],\n ) => Promise<IBlock<LightEthereumBlock>[]>);\n\n// We use a function to get the fetch function because it can change depending on the skipBlocks feature\nexport type GetFetchFunc = () => FetchFunc;\n\nexport class EthereumApiConnection\n implements\n IApiConnectionSpecific<\n EthereumApi,\n SafeEthProvider,\n IBlock<EthereumBlock>[] | IBlock<LightEthereumBlock>[]\n >\n{\n readonly networkMeta: NetworkMetadataPayload;\n\n private constructor(\n public unsafeApi: EthereumApi,\n private fetchBlocksBatches: GetFetchFunc,\n ) {\n this.networkMeta = {\n chain: unsafeApi.getChainId().toString(),\n specName: unsafeApi.getSpecName(),\n genesisHash: unsafeApi.getGenesisHash(),\n };\n }\n\n static async create(\n endpoint: string,\n blockConfirmations: number,\n fetchBlocksBatches: GetFetchFunc,\n eventEmitter: EventEmitter2,\n unfinalizedBlocks: boolean,\n ): Promise<EthereumApiConnection> {\n const api = new EthereumApi(\n endpoint,\n blockConfirmations,\n eventEmitter,\n unfinalizedBlocks,\n );\n\n await api.init();\n\n return new EthereumApiConnection(api, fetchBlocksBatches);\n }\n\n safeApi(height: number): SafeEthProvider {\n throw new Error(`Not Implemented`);\n }\n\n async apiConnect(): Promise<void> {\n await this.unsafeApi.connect();\n }\n\n async apiDisconnect(): Promise<void> {\n await this.unsafeApi.disconnect();\n }\n\n async fetchBlocks(\n heights: number[],\n ): Promise<IBlock<EthereumBlock>[] | IBlock<LightEthereumBlock>[]> {\n const blocks = await this.fetchBlocksBatches()(this.unsafeApi, heights);\n return blocks;\n }\n\n handleError = EthereumApiConnection.handleError;\n\n static handleError(e: Error): ApiConnectionError {\n let formatted_error: ApiConnectionError;\n if (e.message.startsWith(`No response received from RPC endpoint in`)) {\n formatted_error = new TimeoutError(e);\n } else if (e.message.startsWith(`disconnected from `)) {\n formatted_error = new DisconnectionError(e);\n } else if (e.message.startsWith(`Rate Limited at endpoint`)) {\n formatted_error = new RateLimitError(e);\n } else if (e.message.includes(`Exceeded max limit of`)) {\n formatted_error = new LargeResponseError(e);\n } else {\n formatted_error = new ApiConnectionError(\n e.name,\n e.message,\n ApiErrorType.Default,\n );\n }\n return formatted_error;\n }\n}\n"]}
1
+ {"version":3,"file":"api.connection.js","sourceRoot":"","sources":["../../src/ethereum/api.connection.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;AAGnC,gDAU0B;AAM1B,iDAA6C;AAa7C,MAAa,qBAAqB;IAWvB;IACC;IAJD,WAAW,CAAyB;IAE7C,YACS,SAAsB,EACrB,kBAAgC;QADjC,cAAS,GAAT,SAAS,CAAa;QACrB,uBAAkB,GAAlB,kBAAkB,CAAc;QAExC,IAAI,CAAC,WAAW,GAAG;YACjB,KAAK,EAAE,SAAS,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE;YACxC,QAAQ,EAAE,SAAS,CAAC,WAAW,EAAE;YACjC,WAAW,EAAE,SAAS,CAAC,cAAc,EAAE;SACxC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CACjB,QAAgB,EAChB,kBAA0B,EAC1B,kBAAgC,EAChC,YAA2B,EAC3B,iBAA0B,EAC1B,MAAgC;QAEhC,MAAM,GAAG,GAAG,IAAI,0BAAW,CACzB,QAAQ,EACR,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,MAAM,CACP,CAAC;QAEF,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAEjB,OAAO,IAAI,qBAAqB,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,CAAC,MAAc;QACpB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MA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@nestjs/event-emitter';\nimport {\n ApiConnectionError,\n ApiErrorType,\n DisconnectionError,\n LargeResponseError,\n NetworkMetadataPayload,\n RateLimitError,\n TimeoutError,\n IApiConnectionSpecific,\n IBlock,\n} from '@subql/node-core';\nimport {\n EthereumBlock,\n IEthereumEndpointConfig,\n LightEthereumBlock,\n} from '@subql/types-ethereum';\nimport { EthereumApi } from './api.ethereum';\nimport SafeEthProvider from './safe-api';\n\nexport type FetchFunc =\n | ((api: EthereumApi, batch: number[]) => Promise<IBlock<EthereumBlock>[]>)\n | ((\n api: EthereumApi,\n batch: number[],\n ) => Promise<IBlock<LightEthereumBlock>[]>);\n\n// We use a function to get the fetch function because it can change depending on the skipBlocks feature\nexport type GetFetchFunc = () => FetchFunc;\n\nexport class EthereumApiConnection\n implements\n IApiConnectionSpecific<\n EthereumApi,\n SafeEthProvider,\n IBlock<EthereumBlock>[] | IBlock<LightEthereumBlock>[]\n >\n{\n readonly networkMeta: NetworkMetadataPayload;\n\n private constructor(\n public unsafeApi: EthereumApi,\n private fetchBlocksBatches: GetFetchFunc,\n ) {\n this.networkMeta = {\n chain: unsafeApi.getChainId().toString(),\n specName: unsafeApi.getSpecName(),\n genesisHash: unsafeApi.getGenesisHash(),\n };\n }\n\n static async create(\n endpoint: string,\n blockConfirmations: number,\n fetchBlocksBatches: GetFetchFunc,\n eventEmitter: EventEmitter2,\n unfinalizedBlocks: boolean,\n config?: IEthereumEndpointConfig,\n ): Promise<EthereumApiConnection> {\n const api = new EthereumApi(\n endpoint,\n blockConfirmations,\n eventEmitter,\n unfinalizedBlocks,\n config,\n );\n\n await api.init();\n\n return new EthereumApiConnection(api, fetchBlocksBatches);\n }\n\n safeApi(height: number): SafeEthProvider {\n throw new Error(`Not Implemented`);\n }\n\n async apiConnect(): Promise<void> {\n await this.unsafeApi.connect();\n }\n\n async apiDisconnect(): Promise<void> {\n await this.unsafeApi.disconnect();\n }\n\n async fetchBlocks(\n heights: number[],\n ): Promise<IBlock<EthereumBlock>[] | IBlock<LightEthereumBlock>[]> {\n const blocks = await this.fetchBlocksBatches()(this.unsafeApi, heights);\n return blocks;\n }\n\n handleError = EthereumApiConnection.handleError;\n\n static handleError(e: Error): ApiConnectionError {\n let formatted_error: ApiConnectionError;\n if (e.message.startsWith(`No response received from RPC endpoint in`)) {\n formatted_error = new TimeoutError(e);\n } else if (e.message.startsWith(`disconnected from `)) {\n formatted_error = new DisconnectionError(e);\n } else if (e.message.startsWith(`Rate Limited at endpoint`)) {\n formatted_error = new RateLimitError(e);\n } else if (e.message.includes(`Exceeded max limit of`)) {\n formatted_error = new LargeResponseError(e);\n } else {\n formatted_error = new ApiConnectionError(\n e.name,\n e.message,\n ApiErrorType.Default,\n );\n }\n return formatted_error;\n }\n}\n"]}
@@ -2,13 +2,14 @@ import { Block, TransactionReceipt } from '@ethersproject/abstract-provider';
2
2
  import { BaseProvider } from '@ethersproject/providers';
3
3
  import { EventEmitter2 } from '@nestjs/event-emitter';
4
4
  import { IBlock } from '@subql/node-core';
5
- import { ApiWrapper, EthereumBlock, EthereumTransaction, EthereumResult, EthereumLog, SubqlRuntimeDatasource, LightEthereumBlock, LightEthereumLog } from '@subql/types-ethereum';
5
+ import { ApiWrapper, EthereumBlock, EthereumTransaction, EthereumResult, EthereumLog, SubqlRuntimeDatasource, LightEthereumBlock, LightEthereumLog, IEthereumEndpointConfig } from '@subql/types-ethereum';
6
6
  import SafeEthProvider from './safe-api';
7
7
  export declare class EthereumApi implements ApiWrapper {
8
8
  private endpoint;
9
9
  private blockConfirmations;
10
10
  private eventEmitter;
11
11
  private unfinalizedBlocks;
12
+ private config?;
12
13
  private client;
13
14
  private nonBatchClient?;
14
15
  private _genesisBlock?;
@@ -22,8 +23,9 @@ export declare class EthereumApi implements ApiWrapper {
22
23
  * @param {number} blockConfirmations - Used to determine how many blocks behind the head a block is considered finalized. Not used if the network has a concrete finalization mechanism.
23
24
  * @param {object} eventEmitter - Used to monitor the number of RPC requests
24
25
  */
25
- constructor(endpoint: string, blockConfirmations: number, eventEmitter: EventEmitter2, unfinalizedBlocks?: boolean);
26
+ constructor(endpoint: string, blockConfirmations: number, eventEmitter: EventEmitter2, unfinalizedBlocks?: boolean, config?: IEthereumEndpointConfig | undefined);
26
27
  private get genesisBlock();
28
+ private applyBatchSize;
27
29
  init(): Promise<void>;
28
30
  private getSupportsTag;
29
31
  private injectClient;
@@ -62,6 +62,7 @@ class EthereumApi {
62
62
  blockConfirmations;
63
63
  eventEmitter;
64
64
  unfinalizedBlocks;
65
+ config;
65
66
  client;
66
67
  // This is used within the sandbox when HTTP is used
67
68
  nonBatchClient;
@@ -79,11 +80,12 @@ class EthereumApi {
79
80
  * @param {number} blockConfirmations - Used to determine how many blocks behind the head a block is considered finalized. Not used if the network has a concrete finalization mechanism.
80
81
  * @param {object} eventEmitter - Used to monitor the number of RPC requests
81
82
  */
82
- constructor(endpoint, blockConfirmations, eventEmitter, unfinalizedBlocks = false) {
83
+ constructor(endpoint, blockConfirmations, eventEmitter, unfinalizedBlocks = false, config) {
83
84
  this.endpoint = endpoint;
84
85
  this.blockConfirmations = blockConfirmations;
85
86
  this.eventEmitter = eventEmitter;
86
87
  this.unfinalizedBlocks = unfinalizedBlocks;
88
+ this.config = config;
87
89
  const { hostname, protocol, searchParams } = new URL(endpoint);
88
90
  const protocolStr = protocol.replace(':', '');
89
91
  logger.info(`Api host: ${hostname}, method: ${protocolStr}`);
@@ -92,6 +94,7 @@ class EthereumApi {
92
94
  url: this.endpoint,
93
95
  headers: {
94
96
  'User-Agent': `Subquery-Node ${packageVersion}`,
97
+ ...config?.headers,
95
98
  },
96
99
  allowGzip: true,
97
100
  throttleLimit: 5,
@@ -103,6 +106,7 @@ class EthereumApi {
103
106
  });
104
107
  this.client = new ((0, op_provider_1.OPFormatterMixin)(json_rpc_batch_provider_1.JsonRpcBatchProvider))(connection);
105
108
  this.nonBatchClient = new ((0, op_provider_1.OPFormatterMixin)(json_rpc_provider_1.JsonRpcProvider))(connection);
109
+ this.applyBatchSize(config?.batchSize);
106
110
  }
107
111
  else if (protocolStr === 'ws' || protocolStr === 'wss') {
108
112
  this.client = new ((0, op_provider_1.OPFormatterMixin)(providers_1.WebSocketProvider))(this.endpoint);
@@ -117,6 +121,16 @@ class EthereumApi {
117
121
  }
118
122
  return this._genesisBlock;
119
123
  }
124
+ applyBatchSize(batchSize) {
125
+ if (batchSize === null || batchSize === undefined)
126
+ return;
127
+ if (batchSize <= 0 && !!this.nonBatchClient) {
128
+ logger.info('Endpoint config batch size is 0, not using batch requests');
129
+ this.client = this.nonBatchClient;
130
+ return;
131
+ }
132
+ this.client.setBatchSize(batchSize);
133
+ }
120
134
  async init() {
121
135
  this.injectClient();
122
136
  const network = await this.client.getNetwork();
@@ -128,6 +142,7 @@ class EthereumApi {
128
142
  else {
129
143
  this.client = new celo_provider_1.CeloJsonRpcBatchProvider(this.client.connection);
130
144
  this.nonBatchClient = new celo_provider_1.CeloJsonRpcProvider(this.client.connection);
145
+ this.applyBatchSize(this.config?.batchSize);
131
146
  }
132
147
  }
133
148
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"api.ethereum.js","sourceRoot":"","sources":["../../src/ethereum/api.ethereum.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;AAEnC,oDAA4B;AAC5B,4CAAoB;AACpB,gDAAwB;AACxB,kDAA0B;AAC1B,4CAA+C;AAM/C,wDAA2E;AAE3E,gDAA8D;AAW9D,wEAA+C;AAC/C,4CAA0D;AAC1D,8CAAkD;AAClD,+DAIqC;AACrC,8EAAwE;AACxE,kEAA6D;AAC7D,yDAA2D;AAE3D,0DAAyC;AACzC,qDAO0B;AAE1B,8DAA8D;AAC9D,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAElE,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,cAAc,CAAC,CAAC;AAEzC,KAAK,UAAU,UAAU,CACvB,EAA0B;IAE1B,IAAI,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C,OAAO,IAAI,KAAK,CAAC,6BAA6B,QAAQ,EAAE,CAAC,CAAC;SAC3D;QAED,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AAhaD,kCAgaC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport assert from 'assert';\nimport fs from 'fs';\nimport http from 'http';\nimport https from 'https';\nimport { Interface } from '@ethersproject/abi';\nimport {\n BlockTag,\n Block,\n TransactionReceipt,\n} from '@ethersproject/abstract-provider';\nimport { WebSocketProvider, BaseProvider } from '@ethersproject/providers';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { getLogger, IBlock, timeout } from '@subql/node-core';\nimport {\n ApiWrapper,\n EthereumBlock,\n EthereumTransaction,\n EthereumResult,\n EthereumLog,\n SubqlRuntimeDatasource,\n LightEthereumBlock,\n LightEthereumLog,\n} from '@subql/types-ethereum';\nimport CacheableLookup from 'cacheable-lookup';\nimport { hexDataSlice, hexValue } from 'ethers/lib/utils';\nimport { retryOnFailEth } from '../utils/project';\nimport {\n CeloJsonRpcBatchProvider,\n CeloJsonRpcProvider,\n CeloWsProvider,\n} from './ethers/celo/celo-provider';\nimport { JsonRpcBatchProvider } from './ethers/json-rpc-batch-provider';\nimport { JsonRpcProvider } from './ethers/json-rpc-provider';\nimport { OPFormatterMixin } from './ethers/op/op-provider';\nimport { ConnectionInfo } from './ethers/web';\nimport SafeEthProvider from './safe-api';\nimport {\n formatBlock,\n formatBlockUtil,\n formatLog,\n formatReceipt,\n formatTransaction,\n handleNumber,\n} from './utils.ethereum';\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { version: packageVersion } = require('../../package.json');\n\nconst logger = getLogger('api.ethereum');\n\nasync function loadAssets(\n ds: SubqlRuntimeDatasource,\n): Promise<Record<string, string>> {\n if (!ds.assets) {\n return {};\n }\n const res: Record<string, string> = {};\n\n for (const [name, { file }] of ds.assets.entries()) {\n try {\n res[name] = await fs.promises.readFile(file, { encoding: 'utf8' });\n } catch (e) {\n throw new Error(`Failed to load datasource asset ${file}`);\n }\n }\n\n return res;\n}\n\nfunction getHttpAgents() {\n // By default Nodejs doesn't cache DNS lookups\n // https://httptoolkit.com/blog/configuring-nodejs-dns/\n const lookup = new CacheableLookup();\n\n const options: http.AgentOptions = {\n keepAlive: true,\n /*, maxSockets: 100*/\n };\n\n const httpAgent = new http.Agent(options);\n const httpsAgent = new https.Agent(options);\n\n lookup.install(httpAgent);\n lookup.install(httpsAgent);\n\n return {\n http: httpAgent,\n https: httpsAgent,\n };\n}\n\nexport class EthereumApi implements ApiWrapper {\n private client: JsonRpcProvider;\n\n // This is used within the sandbox when HTTP is used\n private nonBatchClient?: JsonRpcProvider;\n private _genesisBlock?: Record<string, any>;\n private contractInterfaces: Record<string, Interface> = {};\n private chainId?: number;\n private name?: string;\n\n // Ethereum POS\n private _supportsFinalization = true;\n\n get supportsFinalization(): boolean {\n return this._supportsFinalization;\n }\n\n /**\n * @param {string} endpoint - The endpoint of the RPC provider\n * @param {number} blockConfirmations - Used to determine how many blocks behind the head a block is considered finalized. Not used if the network has a concrete finalization mechanism.\n * @param {object} eventEmitter - Used to monitor the number of RPC requests\n */\n constructor(\n private endpoint: string,\n private blockConfirmations: number,\n private eventEmitter: EventEmitter2,\n private unfinalizedBlocks = false,\n ) {\n const { hostname, protocol, searchParams } = new URL(endpoint);\n\n const protocolStr = protocol.replace(':', '');\n\n logger.info(`Api host: ${hostname}, method: ${protocolStr}`);\n if (protocolStr === 'https' || protocolStr === 'http') {\n const connection: ConnectionInfo = {\n url: this.endpoint,\n headers: {\n 'User-Agent': `Subquery-Node ${packageVersion}`,\n },\n allowGzip: true,\n throttleLimit: 5,\n throttleSlotInterval: 1,\n agents: getHttpAgents(),\n };\n searchParams.forEach((value, name, searchParams) => {\n (connection.headers as any)[name] = value;\n });\n this.client = new (OPFormatterMixin(JsonRpcBatchProvider))(connection);\n this.nonBatchClient = new (OPFormatterMixin(JsonRpcProvider))(connection);\n } else if (protocolStr === 'ws' || protocolStr === 'wss') {\n this.client = new (OPFormatterMixin(WebSocketProvider))(this.endpoint);\n } else {\n throw new Error(`Unsupported protocol: ${protocol}`);\n }\n }\n\n private get genesisBlock(): Record<string, any> {\n if (!this._genesisBlock) {\n throw new Error('Genesis block is not available');\n }\n return this._genesisBlock;\n }\n\n async init(): Promise<void> {\n this.injectClient();\n\n const network = await this.client.getNetwork();\n\n //celo\n if (network.chainId === 42220) {\n if (this.client instanceof WebSocketProvider) {\n this.client = new CeloWsProvider(this.client.connection.url);\n } else {\n this.client = new CeloJsonRpcBatchProvider(this.client.connection);\n this.nonBatchClient = new CeloJsonRpcProvider(this.client.connection);\n }\n }\n\n try {\n const [genesisBlock, supportsFinalization, supportsSafe] =\n await Promise.all([\n this.getGenesisBlock(network.chainId),\n this.getSupportsTag('finalized'),\n this.getSupportsTag('safe'),\n ]);\n\n this._genesisBlock = genesisBlock;\n this._supportsFinalization = supportsFinalization && supportsSafe;\n this.chainId = network.chainId;\n this.name = network.name;\n } catch (e) {\n if ((e as Error).message.startsWith('Invalid response')) {\n if (!this.nonBatchClient) {\n throw new Error('No suitable client found');\n }\n this.client = this.nonBatchClient;\n\n logger.warn(\n `The RPC Node at ${this.endpoint} cannot process batch requests. ` +\n `Switching to non-batch mode for subsequent requests. Please consider checking if batch processing is supported on the RPC node.`,\n );\n\n return this.init();\n }\n\n throw e;\n }\n }\n\n private async getSupportsTag(tag: BlockTag): Promise<boolean> {\n try {\n // We set the timeout here because there is a bug in ethers where it will never resolve\n // It was happening with arbitrum on a syncing node\n await timeout(this.client.getBlock(tag), 2);\n\n return true;\n } catch (e) {\n logger.info(`Chain doesnt support ${tag} tag`);\n return false;\n }\n }\n\n private injectClient(): void {\n const orig = this.client.send.bind(this.client);\n Object.defineProperty(this.client, 'send', {\n value: (method: string, args: any[]) => {\n this.eventEmitter.emit('rpcCall');\n return orig(method, args);\n },\n });\n }\n\n private async getGenesisBlock(chainId: number): Promise<Block> {\n const tag = () => {\n switch (chainId) {\n // BEVM Canary\n case 1501:\n return 4157986;\n default:\n return 'earliest';\n }\n };\n\n const block = await this.client.getBlock(tag());\n if (block === null) {\n throw new Error(`Getting genesis block returned null from tag: ${tag()}`);\n }\n return block;\n }\n\n async getFinalizedBlock(): Promise<Block> {\n const height = this.supportsFinalization\n ? 'finalized'\n : (await this.getBestBlockHeight()) - this.blockConfirmations;\n\n const block = await this.client.getBlock(height);\n // The finalized block could sometimes fail to fetch,\n // due to some nodes on the network falling behind the synced node.\n if (!block) {\n throw new Error(`get finalized block \"${height}\" failed `);\n }\n return block;\n }\n\n async getFinalizedBlockHeight(): Promise<number> {\n return (await this.getFinalizedBlock()).number;\n }\n\n async getBestBlockHeight(): Promise<number> {\n // Cronos \"safe\" tag doesn't currently work as indended\n const tag =\n !this.unfinalizedBlocks &&\n this.supportsFinalization &&\n this.chainId !== 25\n ? 'safe'\n : 'latest';\n return (await this.client.getBlock(tag)).number;\n }\n\n getRuntimeChain(): string {\n assert(this.name, 'Api has not been initialised');\n return this.name;\n }\n\n getChainId(): number {\n assert(this.chainId, 'Api has not been initialised');\n return this.chainId;\n }\n\n getGenesisHash(): string {\n return this.genesisBlock.hash;\n }\n\n getSpecName(): string {\n return 'ethereum';\n }\n\n async getBlockByHeightOrHash(heightOrHash: number | string): Promise<Block> {\n if (typeof heightOrHash === 'number') {\n heightOrHash = hexValue(heightOrHash);\n }\n return this.client.getBlock(heightOrHash);\n }\n\n private async getBlockPromise(num: number, includeTx = true): Promise<any> {\n const rawBlock = await this.client.send('eth_getBlockByNumber', [\n hexValue(num),\n includeTx,\n ]);\n\n if (!rawBlock) {\n throw new Error(`Failed to fetch block ${num}`);\n }\n\n const block = formatBlock(rawBlock);\n\n block.stateRoot = this.client.formatter.hash(block.stateRoot);\n\n return block;\n }\n async getTransactionReceipt(\n transactionHash: string | Promise<string>,\n ): Promise<TransactionReceipt> {\n return retryOnFailEth<TransactionReceipt>(\n this.client.getTransactionReceipt.bind(this.client, transactionHash),\n );\n }\n\n async fetchBlock(blockNumber: number): Promise<IBlock<EthereumBlock>> {\n try {\n const block = await this.getBlockPromise(blockNumber, true);\n const logsRaw = await this.client.getLogs({\n blockHash: block.hash,\n });\n\n // Certain RPC may not accommodate for blockHash, and would return wrong logs\n if (logsRaw.length) {\n logsRaw.forEach((l) => {\n if (l.blockHash.toLowerCase() !== block.hash.toLowerCase()) {\n throw new Error(\n `Log BlockHash does not match block: ${blockNumber}, blockHash ${\n block.hash\n }. Log ${handleNumber(\n l.logIndex,\n ).toNumber()} got block ${handleNumber(\n l.blockNumber,\n ).toNumber()} blockHash ${\n l.blockHash\n }. Please check with rpc provider`,\n );\n }\n });\n }\n\n block.logs = logsRaw.map((l) => formatLog(l, block));\n block.transactions = block.transactions.map((tx) => ({\n ...formatTransaction(tx, block),\n receipt: () =>\n this.getTransactionReceipt(tx.hash).then((r) => formatReceipt(r)),\n logs: block.logs.filter((l) => l.transactionHash === tx.hash),\n }));\n\n this.eventEmitter.emit('fetchBlock');\n return formatBlockUtil(block);\n } catch (e: any) {\n throw this.handleError(e);\n }\n }\n\n private async fetchLightBlock(\n blockNumber: number,\n ): Promise<IBlock<LightEthereumBlock>> {\n const block = await this.getBlockPromise(blockNumber, false);\n const logs = await this.client.getLogs({ blockHash: block.hash });\n\n const lightBlock: LightEthereumBlock = {\n ...block,\n logs: logs.map((l) => formatLog(l, block)),\n };\n return formatBlockUtil<LightEthereumBlock>(lightBlock);\n }\n\n async fetchBlocks(bufferBlocks: number[]): Promise<IBlock<EthereumBlock>[]> {\n return Promise.all(bufferBlocks.map(async (num) => this.fetchBlock(num)));\n }\n\n async fetchBlocksLight(\n bufferBlocks: number[],\n ): Promise<IBlock<LightEthereumBlock>[]> {\n return Promise.all(\n bufferBlocks.map(async (num) => this.fetchLightBlock(num)),\n );\n }\n\n get api(): BaseProvider {\n return this.client;\n }\n\n getSafeApi(blockHeight: number): SafeEthProvider {\n // We cannot use a batch http client because OnF don't support routing historical queries in batches to an archive nodes\n const client =\n this.client instanceof WebSocketProvider\n ? this.client\n : this.nonBatchClient;\n\n assert(client, 'Unable to find client to make SafeApi');\n\n return new SafeEthProvider(client, blockHeight);\n }\n\n private buildInterface(\n abiName: string,\n assets: Record<string, string>,\n ): Interface {\n if (!assets[abiName]) {\n throw new Error(`ABI named \"${abiName}\" not referenced in assets`);\n }\n\n // This assumes that all datasources have a different abi name or they are the same abi\n if (!this.contractInterfaces[abiName]) {\n // Constructing the interface validates the ABI\n try {\n let abiObj = JSON.parse(assets[abiName]);\n\n /*\n * Allows parsing JSON artifacts as well as ABIs\n * https://trufflesuite.github.io/artifact-updates/background.html#what-are-artifacts\n */\n if (!Array.isArray(abiObj) && abiObj.abi) {\n abiObj = abiObj.abi;\n }\n\n this.contractInterfaces[abiName] = new Interface(abiObj);\n } catch (e: any) {\n logger.error(`Unable to parse ABI: ${e.message}`);\n throw new Error('ABI is invalid');\n }\n }\n\n return this.contractInterfaces[abiName];\n }\n\n async parseLog<T extends EthereumResult = EthereumResult>(\n log: EthereumLog | LightEthereumLog,\n ds: SubqlRuntimeDatasource,\n ): Promise<\n EthereumLog | LightEthereumLog | EthereumLog<T> | LightEthereumLog<T>\n > {\n try {\n if (!ds?.options?.abi) {\n logger.warn('No ABI provided for datasource');\n return log;\n }\n const iface = this.buildInterface(ds.options.abi, await loadAssets(ds));\n\n log.args = iface?.parseLog(log).args as T;\n\n return log;\n } catch (e: any) {\n logger.warn(`Failed to parse log data: ${e.message}`);\n return log;\n }\n }\n\n async parseTransaction<T extends EthereumResult = EthereumResult>(\n transaction: EthereumTransaction,\n ds: SubqlRuntimeDatasource,\n ): Promise<EthereumTransaction<T> | EthereumTransaction> {\n try {\n if (!ds?.options?.abi) {\n if (transaction.input !== '0x') {\n logger.warn('No ABI provided for datasource');\n }\n return transaction;\n }\n const assets = await loadAssets(ds);\n const iface = this.buildInterface(ds.options.abi, assets);\n const func = iface.getFunction(hexDataSlice(transaction.input, 0, 4));\n const args = iface.decodeFunctionData(func, transaction.input) as T;\n\n transaction.logs =\n transaction.logs &&\n ((await Promise.all(\n transaction.logs.map(async (log) => this.parseLog(log, ds)),\n )) as Array<EthereumLog | EthereumLog<T>>);\n\n transaction.args = args;\n return transaction;\n } catch (e: any) {\n logger.warn(`Failed to parse transaction data: ${e.message}`);\n return transaction;\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async connect(): Promise<void> {\n logger.error('Ethereum API connect is not implemented');\n throw new Error('Not implemented');\n }\n\n async disconnect(): Promise<void> {\n if (this.client instanceof WebSocketProvider) {\n await this.client.destroy();\n } else {\n logger.warn('Disconnect called on HTTP provider');\n }\n }\n\n handleError(e: Error): Error {\n if ((e as any)?.status === 429) {\n const { hostname } = new URL(this.endpoint);\n return new Error(`Rate Limited at endpoint: ${hostname}`);\n }\n\n return e;\n }\n}\n"]}
1
+ {"version":3,"file":"api.ethereum.js","sourceRoot":"","sources":["../../src/ethereum/api.ethereum.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;AAEnC,oDAA4B;AAC5B,4CAAoB;AACpB,gDAAwB;AACxB,kDAA0B;AAC1B,4CAA+C;AAM/C,wDAA2E;AAE3E,gDAA8D;AAY9D,wEAA+C;AAC/C,4CAA0D;AAC1D,8CAAkD;AAClD,+DAIqC;AACrC,8EAAwE;AACxE,kEAA6D;AAC7D,yDAA2D;AAE3D,0DAAyC;AACzC,qDAO0B;AAE1B,8DAA8D;AAC9D,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAElE,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,cAAc,CAAC,CAAC;AAEzC,KAAK,UAAU,UAAU,CACvB,EAA0B;IAE1B,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE;QACd,OAAO,EAAE,CAAC;KACX;IACD,MAAM,GAAG,GAA2B,EAAE,CAAC;IAEvC,KAAK,MAAM,CAAC,IAAI,EAAE,E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C,CAAC;QACxD,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,IAAI,CAAC,MAAM,YAAY,6BAAiB,EAAE;YAC5C,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;SAC7B;aAAM;YACL,MAAM,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;SACnD;IACH,CAAC;IAED,WAAW,CAAC,CAAQ;QAClB,IAAK,CAAS,EAAE,MAAM,KAAK,GAAG,EAAE;YAC9B,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5C,OAAO,IAAI,KAAK,CAAC,6BAA6B,QAAQ,EAAE,CAAC,CAAC;SAC3D;QAED,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AA/aD,kCA+aC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport assert from 'assert';\nimport fs from 'fs';\nimport http from 'http';\nimport https from 'https';\nimport { Interface } from '@ethersproject/abi';\nimport {\n BlockTag,\n Block,\n TransactionReceipt,\n} from '@ethersproject/abstract-provider';\nimport { WebSocketProvider, BaseProvider } from '@ethersproject/providers';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport { getLogger, IBlock, timeout } from '@subql/node-core';\nimport {\n ApiWrapper,\n EthereumBlock,\n EthereumTransaction,\n EthereumResult,\n EthereumLog,\n SubqlRuntimeDatasource,\n LightEthereumBlock,\n LightEthereumLog,\n IEthereumEndpointConfig,\n} from '@subql/types-ethereum';\nimport CacheableLookup from 'cacheable-lookup';\nimport { hexDataSlice, hexValue } from 'ethers/lib/utils';\nimport { retryOnFailEth } from '../utils/project';\nimport {\n CeloJsonRpcBatchProvider,\n CeloJsonRpcProvider,\n CeloWsProvider,\n} from './ethers/celo/celo-provider';\nimport { JsonRpcBatchProvider } from './ethers/json-rpc-batch-provider';\nimport { JsonRpcProvider } from './ethers/json-rpc-provider';\nimport { OPFormatterMixin } from './ethers/op/op-provider';\nimport { ConnectionInfo } from './ethers/web';\nimport SafeEthProvider from './safe-api';\nimport {\n formatBlock,\n formatBlockUtil,\n formatLog,\n formatReceipt,\n formatTransaction,\n handleNumber,\n} from './utils.ethereum';\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { version: packageVersion } = require('../../package.json');\n\nconst logger = getLogger('api.ethereum');\n\nasync function loadAssets(\n ds: SubqlRuntimeDatasource,\n): Promise<Record<string, string>> {\n if (!ds.assets) {\n return {};\n }\n const res: Record<string, string> = {};\n\n for (const [name, { file }] of ds.assets.entries()) {\n try {\n res[name] = await fs.promises.readFile(file, { encoding: 'utf8' });\n } catch (e) {\n throw new Error(`Failed to load datasource asset ${file}`);\n }\n }\n\n return res;\n}\n\nfunction getHttpAgents() {\n // By default Nodejs doesn't cache DNS lookups\n // https://httptoolkit.com/blog/configuring-nodejs-dns/\n const lookup = new CacheableLookup();\n\n const options: http.AgentOptions = {\n keepAlive: true,\n /*, maxSockets: 100*/\n };\n\n const httpAgent = new http.Agent(options);\n const httpsAgent = new https.Agent(options);\n\n lookup.install(httpAgent);\n lookup.install(httpsAgent);\n\n return {\n http: httpAgent,\n https: httpsAgent,\n };\n}\n\nexport class EthereumApi implements ApiWrapper {\n private client: JsonRpcProvider;\n\n // This is used within the sandbox when HTTP is used\n private nonBatchClient?: JsonRpcProvider;\n private _genesisBlock?: Record<string, any>;\n private contractInterfaces: Record<string, Interface> = {};\n private chainId?: number;\n private name?: string;\n\n // Ethereum POS\n private _supportsFinalization = true;\n\n get supportsFinalization(): boolean {\n return this._supportsFinalization;\n }\n\n /**\n * @param {string} endpoint - The endpoint of the RPC provider\n * @param {number} blockConfirmations - Used to determine how many blocks behind the head a block is considered finalized. Not used if the network has a concrete finalization mechanism.\n * @param {object} eventEmitter - Used to monitor the number of RPC requests\n */\n constructor(\n private endpoint: string,\n private blockConfirmations: number,\n private eventEmitter: EventEmitter2,\n private unfinalizedBlocks = false,\n private config?: IEthereumEndpointConfig,\n ) {\n const { hostname, protocol, searchParams } = new URL(endpoint);\n\n const protocolStr = protocol.replace(':', '');\n\n logger.info(`Api host: ${hostname}, method: ${protocolStr}`);\n if (protocolStr === 'https' || protocolStr === 'http') {\n const connection: ConnectionInfo = {\n url: this.endpoint,\n headers: {\n 'User-Agent': `Subquery-Node ${packageVersion}`,\n ...config?.headers,\n },\n allowGzip: true,\n throttleLimit: 5,\n throttleSlotInterval: 1,\n agents: getHttpAgents(),\n };\n searchParams.forEach((value, name, searchParams) => {\n (connection.headers as any)[name] = value;\n });\n this.client = new (OPFormatterMixin(JsonRpcBatchProvider))(connection);\n this.nonBatchClient = new (OPFormatterMixin(JsonRpcProvider))(connection);\n this.applyBatchSize(config?.batchSize);\n } else if (protocolStr === 'ws' || protocolStr === 'wss') {\n this.client = new (OPFormatterMixin(WebSocketProvider))(this.endpoint);\n } else {\n throw new Error(`Unsupported protocol: ${protocol}`);\n }\n }\n\n private get genesisBlock(): Record<string, any> {\n if (!this._genesisBlock) {\n throw new Error('Genesis block is not available');\n }\n return this._genesisBlock;\n }\n\n private applyBatchSize(batchSize?: number): void {\n if (batchSize === null || batchSize === undefined) return;\n\n if (batchSize <= 0 && !!this.nonBatchClient) {\n logger.info('Endpoint config batch size is 0, not using batch requests');\n this.client = this.nonBatchClient;\n return;\n }\n (this.client as JsonRpcBatchProvider).setBatchSize(batchSize);\n }\n\n async init(): Promise<void> {\n this.injectClient();\n\n const network = await this.client.getNetwork();\n\n //celo\n if (network.chainId === 42220) {\n if (this.client instanceof WebSocketProvider) {\n this.client = new CeloWsProvider(this.client.connection.url);\n } else {\n this.client = new CeloJsonRpcBatchProvider(this.client.connection);\n this.nonBatchClient = new CeloJsonRpcProvider(this.client.connection);\n this.applyBatchSize(this.config?.batchSize);\n }\n }\n\n try {\n const [genesisBlock, supportsFinalization, supportsSafe] =\n await Promise.all([\n this.getGenesisBlock(network.chainId),\n this.getSupportsTag('finalized'),\n this.getSupportsTag('safe'),\n ]);\n\n this._genesisBlock = genesisBlock;\n this._supportsFinalization = supportsFinalization && supportsSafe;\n this.chainId = network.chainId;\n this.name = network.name;\n } catch (e) {\n if ((e as Error).message.startsWith('Invalid response')) {\n if (!this.nonBatchClient) {\n throw new Error('No suitable client found');\n }\n this.client = this.nonBatchClient;\n\n logger.warn(\n `The RPC Node at ${this.endpoint} cannot process batch requests. ` +\n `Switching to non-batch mode for subsequent requests. Please consider checking if batch processing is supported on the RPC node.`,\n );\n\n return this.init();\n }\n\n throw e;\n }\n }\n\n private async getSupportsTag(tag: BlockTag): Promise<boolean> {\n try {\n // We set the timeout here because there is a bug in ethers where it will never resolve\n // It was happening with arbitrum on a syncing node\n await timeout(this.client.getBlock(tag), 2);\n\n return true;\n } catch (e) {\n logger.info(`Chain doesnt support ${tag} tag`);\n return false;\n }\n }\n\n private injectClient(): void {\n const orig = this.client.send.bind(this.client);\n Object.defineProperty(this.client, 'send', {\n value: (method: string, args: any[]) => {\n this.eventEmitter.emit('rpcCall');\n return orig(method, args);\n },\n });\n }\n\n private async getGenesisBlock(chainId: number): Promise<Block> {\n const tag = () => {\n switch (chainId) {\n // BEVM Canary\n case 1501:\n return 4157986;\n default:\n return 'earliest';\n }\n };\n\n const block = await this.client.getBlock(tag());\n if (block === null) {\n throw new Error(`Getting genesis block returned null from tag: ${tag()}`);\n }\n return block;\n }\n\n async getFinalizedBlock(): Promise<Block> {\n const height = this.supportsFinalization\n ? 'finalized'\n : (await this.getBestBlockHeight()) - this.blockConfirmations;\n\n const block = await this.client.getBlock(height);\n // The finalized block could sometimes fail to fetch,\n // due to some nodes on the network falling behind the synced node.\n if (!block) {\n throw new Error(`get finalized block \"${height}\" failed `);\n }\n return block;\n }\n\n async getFinalizedBlockHeight(): Promise<number> {\n return (await this.getFinalizedBlock()).number;\n }\n\n async getBestBlockHeight(): Promise<number> {\n // Cronos \"safe\" tag doesn't currently work as indended\n const tag =\n !this.unfinalizedBlocks &&\n this.supportsFinalization &&\n this.chainId !== 25\n ? 'safe'\n : 'latest';\n return (await this.client.getBlock(tag)).number;\n }\n\n getRuntimeChain(): string {\n assert(this.name, 'Api has not been initialised');\n return this.name;\n }\n\n getChainId(): number {\n assert(this.chainId, 'Api has not been initialised');\n return this.chainId;\n }\n\n getGenesisHash(): string {\n return this.genesisBlock.hash;\n }\n\n getSpecName(): string {\n return 'ethereum';\n }\n\n async getBlockByHeightOrHash(heightOrHash: number | string): Promise<Block> {\n if (typeof heightOrHash === 'number') {\n heightOrHash = hexValue(heightOrHash);\n }\n return this.client.getBlock(heightOrHash);\n }\n\n private async getBlockPromise(num: number, includeTx = true): Promise<any> {\n const rawBlock = await this.client.send('eth_getBlockByNumber', [\n hexValue(num),\n includeTx,\n ]);\n\n if (!rawBlock) {\n throw new Error(`Failed to fetch block ${num}`);\n }\n\n const block = formatBlock(rawBlock);\n\n block.stateRoot = this.client.formatter.hash(block.stateRoot);\n\n return block;\n }\n async getTransactionReceipt(\n transactionHash: string | Promise<string>,\n ): Promise<TransactionReceipt> {\n return retryOnFailEth<TransactionReceipt>(\n this.client.getTransactionReceipt.bind(this.client, transactionHash),\n );\n }\n\n async fetchBlock(blockNumber: number): Promise<IBlock<EthereumBlock>> {\n try {\n const block = await this.getBlockPromise(blockNumber, true);\n const logsRaw = await this.client.getLogs({\n blockHash: block.hash,\n });\n\n // Certain RPC may not accommodate for blockHash, and would return wrong logs\n if (logsRaw.length) {\n logsRaw.forEach((l) => {\n if (l.blockHash.toLowerCase() !== block.hash.toLowerCase()) {\n throw new Error(\n `Log BlockHash does not match block: ${blockNumber}, blockHash ${\n block.hash\n }. Log ${handleNumber(\n l.logIndex,\n ).toNumber()} got block ${handleNumber(\n l.blockNumber,\n ).toNumber()} blockHash ${\n l.blockHash\n }. Please check with rpc provider`,\n );\n }\n });\n }\n\n block.logs = logsRaw.map((l) => formatLog(l, block));\n block.transactions = block.transactions.map((tx) => ({\n ...formatTransaction(tx, block),\n receipt: () =>\n this.getTransactionReceipt(tx.hash).then((r) => formatReceipt(r)),\n logs: block.logs.filter((l) => l.transactionHash === tx.hash),\n }));\n\n this.eventEmitter.emit('fetchBlock');\n return formatBlockUtil(block);\n } catch (e: any) {\n throw this.handleError(e);\n }\n }\n\n private async fetchLightBlock(\n blockNumber: number,\n ): Promise<IBlock<LightEthereumBlock>> {\n const block = await this.getBlockPromise(blockNumber, false);\n const logs = await this.client.getLogs({ blockHash: block.hash });\n\n const lightBlock: LightEthereumBlock = {\n ...block,\n logs: logs.map((l) => formatLog(l, block)),\n };\n return formatBlockUtil<LightEthereumBlock>(lightBlock);\n }\n\n async fetchBlocks(bufferBlocks: number[]): Promise<IBlock<EthereumBlock>[]> {\n return Promise.all(bufferBlocks.map(async (num) => this.fetchBlock(num)));\n }\n\n async fetchBlocksLight(\n bufferBlocks: number[],\n ): Promise<IBlock<LightEthereumBlock>[]> {\n return Promise.all(\n bufferBlocks.map(async (num) => this.fetchLightBlock(num)),\n );\n }\n\n get api(): BaseProvider {\n return this.client;\n }\n\n getSafeApi(blockHeight: number): SafeEthProvider {\n // We cannot use a batch http client because OnF don't support routing historical queries in batches to an archive nodes\n const client =\n this.client instanceof WebSocketProvider\n ? this.client\n : this.nonBatchClient;\n\n assert(client, 'Unable to find client to make SafeApi');\n\n return new SafeEthProvider(client, blockHeight);\n }\n\n private buildInterface(\n abiName: string,\n assets: Record<string, string>,\n ): Interface {\n if (!assets[abiName]) {\n throw new Error(`ABI named \"${abiName}\" not referenced in assets`);\n }\n\n // This assumes that all datasources have a different abi name or they are the same abi\n if (!this.contractInterfaces[abiName]) {\n // Constructing the interface validates the ABI\n try {\n let abiObj = JSON.parse(assets[abiName]);\n\n /*\n * Allows parsing JSON artifacts as well as ABIs\n * https://trufflesuite.github.io/artifact-updates/background.html#what-are-artifacts\n */\n if (!Array.isArray(abiObj) && abiObj.abi) {\n abiObj = abiObj.abi;\n }\n\n this.contractInterfaces[abiName] = new Interface(abiObj);\n } catch (e: any) {\n logger.error(`Unable to parse ABI: ${e.message}`);\n throw new Error('ABI is invalid');\n }\n }\n\n return this.contractInterfaces[abiName];\n }\n\n async parseLog<T extends EthereumResult = EthereumResult>(\n log: EthereumLog | LightEthereumLog,\n ds: SubqlRuntimeDatasource,\n ): Promise<\n EthereumLog | LightEthereumLog | EthereumLog<T> | LightEthereumLog<T>\n > {\n try {\n if (!ds?.options?.abi) {\n logger.warn('No ABI provided for datasource');\n return log;\n }\n const iface = this.buildInterface(ds.options.abi, await loadAssets(ds));\n\n log.args = iface?.parseLog(log).args as T;\n\n return log;\n } catch (e: any) {\n logger.warn(`Failed to parse log data: ${e.message}`);\n return log;\n }\n }\n\n async parseTransaction<T extends EthereumResult = EthereumResult>(\n transaction: EthereumTransaction,\n ds: SubqlRuntimeDatasource,\n ): Promise<EthereumTransaction<T> | EthereumTransaction> {\n try {\n if (!ds?.options?.abi) {\n if (transaction.input !== '0x') {\n logger.warn('No ABI provided for datasource');\n }\n return transaction;\n }\n const assets = await loadAssets(ds);\n const iface = this.buildInterface(ds.options.abi, assets);\n const func = iface.getFunction(hexDataSlice(transaction.input, 0, 4));\n const args = iface.decodeFunctionData(func, transaction.input) as T;\n\n transaction.logs =\n transaction.logs &&\n ((await Promise.all(\n transaction.logs.map(async (log) => this.parseLog(log, ds)),\n )) as Array<EthereumLog | EthereumLog<T>>);\n\n transaction.args = args;\n return transaction;\n } catch (e: any) {\n logger.warn(`Failed to parse transaction data: ${e.message}`);\n return transaction;\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async connect(): Promise<void> {\n logger.error('Ethereum API connect is not implemented');\n throw new Error('Not implemented');\n }\n\n async disconnect(): Promise<void> {\n if (this.client instanceof WebSocketProvider) {\n await this.client.destroy();\n } else {\n logger.warn('Disconnect called on HTTP provider');\n }\n }\n\n handleError(e: Error): Error {\n if ((e as any)?.status === 429) {\n const { hostname } = new URL(this.endpoint);\n return new Error(`Rate Limited at endpoint: ${hostname}`);\n }\n\n return e;\n }\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  import { EventEmitter2 } from '@nestjs/event-emitter';
2
2
  import { ApiService, ConnectionPoolService, NodeConfig, IBlock } from '@subql/node-core';
3
- import { EthereumBlock, LightEthereumBlock } from '@subql/types-ethereum';
3
+ import { EthereumBlock, IEthereumEndpointConfig, LightEthereumBlock } from '@subql/types-ethereum';
4
4
  import { SubqueryProject } from '../configure/SubqueryProject';
5
5
  import { EthereumApiConnection } from './api.connection';
6
6
  import { EthereumApi } from './api.ethereum';
7
7
  import SafeEthProvider from './safe-api';
8
- export declare class EthereumApiService extends ApiService<EthereumApi, SafeEthProvider, IBlock<EthereumBlock>[] | IBlock<LightEthereumBlock>[]> {
8
+ export declare class EthereumApiService extends ApiService<EthereumApi, SafeEthProvider, IBlock<EthereumBlock>[] | IBlock<LightEthereumBlock>[], EthereumApiConnection, IEthereumEndpointConfig> {
9
9
  private project;
10
10
  private fetchBlocksFunction?;
11
11
  private fetchBlocksBatches;
@@ -48,13 +48,11 @@ let EthereumApiService = class EthereumApiService extends node_core_1.ApiService
48
48
  catch (e) {
49
49
  (0, node_core_1.exitWithError)(new Error(`Failed to init api`, { cause: e }), logger);
50
50
  }
51
- const endpoints = Array.isArray(network.endpoint)
52
- ? network.endpoint
53
- : [network.endpoint];
54
51
  if (this.nodeConfig.primaryNetworkEndpoint) {
55
- endpoints.push(this.nodeConfig.primaryNetworkEndpoint);
52
+ const [endpoint, config] = this.nodeConfig.primaryNetworkEndpoint;
53
+ network.endpoint[endpoint] = config;
56
54
  }
57
- await this.createConnections(network, (endpoint) => api_connection_1.EthereumApiConnection.create(endpoint, this.nodeConfig.blockConfirmations, this.fetchBlocksBatches, this.eventEmitter, this.nodeConfig.unfinalizedBlocks));
55
+ await this.createConnections(network, (endpoint, config) => api_connection_1.EthereumApiConnection.create(endpoint, this.nodeConfig.blockConfirmations, this.fetchBlocksBatches, this.eventEmitter, this.nodeConfig.unfinalizedBlocks, config));
58
56
  return this;
59
57
  }
60
58
  metadataMismatchError(metadata, expected, actual) {
@@ -1 +1 @@
1
- {"version":3,"file":"api.service.ethereum.js","sourceRoot":"","sources":["../../src/ethereum/api.service.ethereum.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;;;;AAEnC,oDAA4B;AAC5B,2CAAoD;AACpD,yDAAsD;AACtD,gDAQ0B;AAM1B,wDAA6D;AAE7D,8CAAuD;AACvD,qDAI0B;AAI1B,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC;AAGzB,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,sBAIvC;IASuC;IAR9B,mBAAmB,CAAa;IAChC,kBAAkB,GAAiB,GAAG,EAAE;QAC9C,IAAA,gBAAM,EAAC,IAAI,CAAC,mBAAmB,EAAE,sCAAsC,CAAC,CAAC;QACzE,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC,CAAC;IACM,UAAU,CAAqB;IAEvC,YACsC,OAAwB,EAC5D,qBAAmE,EACnE,YAA2B,EAC3B,UAAsB;QAEtB,KAAK,CAAC,qBAAqB,EAAE,YAAY,CAAC,CAAC;QALP,YAAO,GAAP,OAAO,CAAiB;QAM5D,IAAI,CAAC,UAAU,GAAG,IAAI,+BAAkB,CAAC,UAAU,CAAC,CAAC;QAErD,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,OAA8B,CAAC;QACnC,IAAI;YACF,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;SAChC;QAAC,OAAO,CAAC,EAAE;YACV,IAAA,yBAAa,EAAC,IAAI,KAAK,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;SACtE;QAED,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,QA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QACjB,MAAM,iBAAiB,GAAG,IAAA,6BAAmB,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5D,MAAM,gBAAgB,GACpB,IAAI,CAAC,UAAU,CAAC,gBAAgB,IAAI,iBAAiB,CAAC;QAExD,IAAI,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE;YACpC,IAAI,iBAAiB,EAAE;gBACrB,MAAM,CAAC,IAAI,CACT,6EAA6E,CAC9E,CAAC;aACH;iBAAM;gBACL,MAAM,CAAC,IAAI,CACT,yFAAyF,CAC1F,CAAC;aACH;SACF;aAAM;YACL,IAAI,iBAAiB,EAAE;gBACrB,MAAM,CAAC,IAAI,CACT,8HAA8H,CAC/H,CAAC;aACH;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;aAC9C;SACF;QAED,MAAM,SAAS,GAAG,gBAAgB;YAChC,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;YACvC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEzC,IAAI,IAAI,CAAC,UAAU,EAAE,QAAQ,EAAE;YAC7B,IAAI,CAAC,mBAAmB,GAAG,IAAA,wBAAY,EACrC,SAAS,EACT,eAAe,EACf,oBAAoB,CACR,CAAC;SAChB;aAAM;YACL,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;SACtC;IACH,CAAC;CACF,CAAA;AAvLY,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;IAcR,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;6CACJ,iCAAqB;QAC9B,6BAAa;QACf,sBAAU;GAhBb,kBAAkB,CAuL9B;AAvLY,gDAAkB","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport assert from 'assert';\nimport { Inject, Injectable } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport {\n ApiService,\n ConnectionPoolService,\n getLogger,\n NodeConfig,\n profilerWrap,\n IBlock,\n exitWithError,\n} from '@subql/node-core';\nimport {\n EthereumBlock,\n EthereumNetworkConfig,\n LightEthereumBlock,\n} from '@subql/types-ethereum';\nimport { EthereumNodeConfig } from '../configure/NodeConfig';\nimport { SubqueryProject } from '../configure/SubqueryProject';\nimport { isOnlyEventHandlers } from '../utils/project';\nimport {\n EthereumApiConnection,\n FetchFunc,\n GetFetchFunc,\n} from './api.connection';\nimport { EthereumApi } from './api.ethereum';\nimport SafeEthProvider from './safe-api';\n\nconst logger = getLogger('api');\n\n@Injectable()\nexport class EthereumApiService extends ApiService<\n EthereumApi,\n SafeEthProvider,\n IBlock<EthereumBlock>[] | IBlock<LightEthereumBlock>[]\n> {\n private fetchBlocksFunction?: FetchFunc;\n private fetchBlocksBatches: GetFetchFunc = () => {\n assert(this.fetchBlocksFunction, 'Fetch blocks function is not defined');\n return this.fetchBlocksFunction;\n };\n private nodeConfig: EthereumNodeConfig;\n\n constructor(\n @Inject('ISubqueryProject') private project: SubqueryProject,\n connectionPoolService: ConnectionPoolService<EthereumApiConnection>,\n eventEmitter: EventEmitter2,\n nodeConfig: NodeConfig,\n ) {\n super(connectionPoolService, eventEmitter);\n this.nodeConfig = new EthereumNodeConfig(nodeConfig);\n\n this.updateBlockFetching();\n }\n\n async init(): Promise<EthereumApiService> {\n let network: EthereumNetworkConfig;\n try {\n network = this.project.network;\n } catch (e) {\n exitWithError(new Error(`Failed to init api`, { cause: e }), logger);\n }\n\n const endpoints = Array.isArray(network.endpoint)\n ? network.endpoint\n : [network.endpoint];\n\n if (this.nodeConfig.primaryNetworkEndpoint) {\n endpoints.push(this.nodeConfig.primaryNetworkEndpoint);\n }\n\n await this.createConnections(network, (endpoint) =>\n EthereumApiConnection.create(\n endpoint,\n this.nodeConfig.blockConfirmations,\n this.fetchBlocksBatches,\n this.eventEmitter,\n this.nodeConfig.unfinalizedBlocks,\n ),\n );\n\n return this;\n }\n\n protected 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 retryErrorCodes = [\n 'UNKNOWN_ERROR',\n 'NOT_IMPLEMENTED',\n 'NETWORK_ERROR',\n 'SERVER_ERROR',\n 'TIMEOUT',\n 'BAD_DATA',\n 'CANCELLED',\n ];\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 (\n ...args: Parameters<typeof originalMethod>\n ): Promise<ReturnType<typeof originalMethod>> => {\n let retries = 0;\n let currentApi = target;\n let throwingError: Error | undefined;\n\n while (retries < maxRetries) {\n try {\n return await (originalMethod as Function).apply(\n currentApi,\n args,\n );\n } catch (error: any) {\n // other than retryErrorCodes, other errors does not have anything to do with network request, retrying would not change its outcome\n if (!retryErrorCodes.includes(error?.code)) {\n throw error;\n }\n\n logger.warn(\n `Request failed with api at height ${height} (retry ${retries}): ${error.message}`,\n );\n throwingError = error;\n currentApi = this.unsafeApi.getSafeApi(height);\n retries++;\n }\n }\n\n logger.error(\n `Maximum retries (${maxRetries}) exceeded for api at height ${height}`,\n );\n if (!throwingError) {\n throw new Error('Failed to make request, maximum retries failed');\n }\n throw throwingError;\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 fetchFullBlocksBatch(\n api: EthereumApi,\n batch: number[],\n ): Promise<IBlock<EthereumBlock>[]> {\n return api.fetchBlocks(batch);\n }\n\n private async fetchLightBlocksBatch(\n api: EthereumApi,\n batch: number[],\n ): Promise<IBlock<LightEthereumBlock>[]> {\n return api.fetchBlocksLight(batch);\n }\n\n updateBlockFetching(): void {\n const onlyEventHandlers = isOnlyEventHandlers(this.project);\n const skipTransactions =\n this.nodeConfig.skipTransactions && onlyEventHandlers;\n\n if (this.nodeConfig.skipTransactions) {\n if (onlyEventHandlers) {\n logger.info(\n 'skipTransactions is enabled, only events and block headers will be fetched.',\n );\n } else {\n logger.info(\n `skipTransactions is disabled, the project contains handlers that aren't event handlers.`,\n );\n }\n } else {\n if (onlyEventHandlers) {\n logger.warn(\n 'skipTransactions is disabled, the project contains only event handlers, it could be enabled to improve indexing performance.',\n );\n } else {\n logger.info(`skipTransactions is disabled.`);\n }\n }\n\n const fetchFunc = skipTransactions\n ? this.fetchLightBlocksBatch.bind(this)\n : this.fetchFullBlocksBatch.bind(this);\n\n if (this.nodeConfig?.profiler) {\n this.fetchBlocksFunction = profilerWrap(\n fetchFunc,\n 'SubstrateUtil',\n 'fetchBlocksBatches',\n ) as FetchFunc;\n } else {\n this.fetchBlocksFunction = fetchFunc;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"api.service.ethereum.js","sourceRoot":"","sources":["../../src/ethereum/api.service.ethereum.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;;;;;;;;;;;;;;AAEnC,oDAA4B;AAC5B,2CAAoD;AACpD,yDAAsD;AACtD,gDAQ0B;AAQ1B,wDAA6D;AAE7D,8CAAuD;AACvD,qDAI0B;AAI1B,MAAM,MAAM,GAAG,IAAA,qBAAS,EAAC,KAAK,CAAC,CAAC;AAGzB,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,sBAMvC;IASuC;IAR9B,mBAAmB,CAAa;IAChC,kBAAkB,GAAiB,GAAG,EAAE;QAC9C,IAAA,gBAAM,EAAC,IAAI,CAAC,mBAAmB,EAAE,sCAAsC,CAAC,CAAC;QACzE,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC,CAAC;IACM,UAAU,CAAqB;IAEvC,YACsC,OAAwB,EAC5D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,EAAE;YAC7B,IAAI,CAAC,mBAAmB,GAAG,IAAA,wBAAY,EACrC,SAAS,EACT,eAAe,EACf,oBAAoB,CACR,CAAC;SAChB;aAAM;YACL,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;SACtC;IACH,CAAC;CACF,CAAA;AAvLY,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;IAgBR,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;6CACJ,iCAAqB;QAC9B,6BAAa;QACf,sBAAU;GAlBb,kBAAkB,CAuL9B;AAvLY,gDAAkB","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport assert from 'assert';\nimport { Inject, Injectable } from '@nestjs/common';\nimport { EventEmitter2 } from '@nestjs/event-emitter';\nimport {\n ApiService,\n ConnectionPoolService,\n getLogger,\n NodeConfig,\n profilerWrap,\n IBlock,\n exitWithError,\n} from '@subql/node-core';\nimport { IEndpointConfig } from '@subql/types-core';\nimport {\n EthereumBlock,\n EthereumNetworkConfig,\n IEthereumEndpointConfig,\n LightEthereumBlock,\n} from '@subql/types-ethereum';\nimport { EthereumNodeConfig } from '../configure/NodeConfig';\nimport { SubqueryProject } from '../configure/SubqueryProject';\nimport { isOnlyEventHandlers } from '../utils/project';\nimport {\n EthereumApiConnection,\n FetchFunc,\n GetFetchFunc,\n} from './api.connection';\nimport { EthereumApi } from './api.ethereum';\nimport SafeEthProvider from './safe-api';\n\nconst logger = getLogger('api');\n\n@Injectable()\nexport class EthereumApiService extends ApiService<\n EthereumApi,\n SafeEthProvider,\n IBlock<EthereumBlock>[] | IBlock<LightEthereumBlock>[],\n EthereumApiConnection,\n IEthereumEndpointConfig\n> {\n private fetchBlocksFunction?: FetchFunc;\n private fetchBlocksBatches: GetFetchFunc = () => {\n assert(this.fetchBlocksFunction, 'Fetch blocks function is not defined');\n return this.fetchBlocksFunction;\n };\n private nodeConfig: EthereumNodeConfig;\n\n constructor(\n @Inject('ISubqueryProject') private project: SubqueryProject,\n connectionPoolService: ConnectionPoolService<EthereumApiConnection>,\n eventEmitter: EventEmitter2,\n nodeConfig: NodeConfig,\n ) {\n super(connectionPoolService, eventEmitter);\n this.nodeConfig = new EthereumNodeConfig(nodeConfig);\n\n this.updateBlockFetching();\n }\n\n async init(): Promise<EthereumApiService> {\n let network: EthereumNetworkConfig;\n try {\n network = this.project.network;\n } catch (e) {\n exitWithError(new Error(`Failed to init api`, { cause: e }), logger);\n }\n\n if (this.nodeConfig.primaryNetworkEndpoint) {\n const [endpoint, config] = this.nodeConfig.primaryNetworkEndpoint;\n (network.endpoint as Record<string, IEndpointConfig>)[endpoint] = config;\n }\n\n await this.createConnections(network, (endpoint, config) =>\n EthereumApiConnection.create(\n endpoint,\n this.nodeConfig.blockConfirmations,\n this.fetchBlocksBatches,\n this.eventEmitter,\n this.nodeConfig.unfinalizedBlocks,\n config,\n ),\n );\n\n return this;\n }\n\n protected 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 retryErrorCodes = [\n 'UNKNOWN_ERROR',\n 'NOT_IMPLEMENTED',\n 'NETWORK_ERROR',\n 'SERVER_ERROR',\n 'TIMEOUT',\n 'BAD_DATA',\n 'CANCELLED',\n ];\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 (\n ...args: Parameters<typeof originalMethod>\n ): Promise<ReturnType<typeof originalMethod>> => {\n let retries = 0;\n let currentApi = target;\n let throwingError: Error | undefined;\n\n while (retries < maxRetries) {\n try {\n return await (originalMethod as Function).apply(\n currentApi,\n args,\n );\n } catch (error: any) {\n // other than retryErrorCodes, other errors does not have anything to do with network request, retrying would not change its outcome\n if (!retryErrorCodes.includes(error?.code)) {\n throw error;\n }\n\n logger.warn(\n `Request failed with api at height ${height} (retry ${retries}): ${error.message}`,\n );\n throwingError = error;\n currentApi = this.unsafeApi.getSafeApi(height);\n retries++;\n }\n }\n\n logger.error(\n `Maximum retries (${maxRetries}) exceeded for api at height ${height}`,\n );\n if (!throwingError) {\n throw new Error('Failed to make request, maximum retries failed');\n }\n throw throwingError;\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 fetchFullBlocksBatch(\n api: EthereumApi,\n batch: number[],\n ): Promise<IBlock<EthereumBlock>[]> {\n return api.fetchBlocks(batch);\n }\n\n private async fetchLightBlocksBatch(\n api: EthereumApi,\n batch: number[],\n ): Promise<IBlock<LightEthereumBlock>[]> {\n return api.fetchBlocksLight(batch);\n }\n\n updateBlockFetching(): void {\n const onlyEventHandlers = isOnlyEventHandlers(this.project);\n const skipTransactions =\n this.nodeConfig.skipTransactions && onlyEventHandlers;\n\n if (this.nodeConfig.skipTransactions) {\n if (onlyEventHandlers) {\n logger.info(\n 'skipTransactions is enabled, only events and block headers will be fetched.',\n );\n } else {\n logger.info(\n `skipTransactions is disabled, the project contains handlers that aren't event handlers.`,\n );\n }\n } else {\n if (onlyEventHandlers) {\n logger.warn(\n 'skipTransactions is disabled, the project contains only event handlers, it could be enabled to improve indexing performance.',\n );\n } else {\n logger.info(`skipTransactions is disabled.`);\n }\n }\n\n const fetchFunc = skipTransactions\n ? this.fetchLightBlocksBatch.bind(this)\n : this.fetchFullBlocksBatch.bind(this);\n\n if (this.nodeConfig?.profiler) {\n this.fetchBlocksFunction = profilerWrap(\n fetchFunc,\n 'SubstrateUtil',\n 'fetchBlocksBatches',\n ) as FetchFunc;\n } else {\n this.fetchBlocksFunction = fetchFunc;\n }\n }\n}\n"]}
@@ -88,7 +88,7 @@ const nodeConfig = new node_core_1.NodeConfig({
88
88
  subquery: 'eth-starter',
89
89
  subqueryName: 'eth-starter',
90
90
  dictionaryTimeout: 10,
91
- networkEndpoint: [HTTP_ENDPOINT],
91
+ networkEndpoint: { [HTTP_ENDPOINT]: {} },
92
92
  networkDictionary: [DEFAULT_DICTIONARY],
93
93
  });
94
94
  function makeBlockHeightMap(mockDs) {
@@ -1 +1 @@
1
- {"version":3,"file":"ethDictionaryV2.spec.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/ethDictionaryV2.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;AAEnC,gDAK0B;AAC1B,0DAM+B;AAC/B,kEAA0C;AAM1C,gDAAgD;AAChD,oCAAuC;AACvC,uDAG2B;AAE3B,MAAM,kBAAkB,GAAG,+CAA+C,CAAC;AAC3E,MAAM,aAAa,GAAG,8CAA8C,CAAC;AACrE,MAAM,MAAM,GAAwB;IAClC;QACE,IAAI,EAAE,uCAAsB,CAAC,OAAO;QACpC,MAAM,EAAE,IAAI,GAAG,EAAE;QACjB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE;YACP,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE;gBACR;oBACE,OAAO,EAAE,mBAAmB;oBAC5B,IAAI,EAAE,oCAAmB,CAAC,IAAI;oBAC9B,MAAM,EAAE;wBACN,QAAQ,EAAE,6CAA6C;qBACxD;iBACF;gBACD;oBACE,OAAO,EAAE,WAAW;oBACpB,IAAI,EAAE,oCAAmB,CAAC,KAAK;oBAC/B,MAAM,EAAE;wBACN,MAAM,EAAE;4BACN,oEAAoE;yBACrE;qBACF;iBACF;aACF;SACF;KACF;CACF,CAAC;AAEF,MAAM,UAAU,GAA8B;IAC5C,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,uCAAsB,CAAC,OAAO;IACpC,MAAM,EAAE,IAAI,GAAG,EAAE;IACjB,OAAO,EAAE;QACP,GAAG,EAAE,OAAO;QACZ,yDAAyD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I,EAAE,oCAAmB,CAAC,KAAK;wBAC/B,MAAM,EAAE;4BACN,MAAM,EAAE,GAAG;yBACZ;qBACF;oBACD;wBACE,OAAO,EAAE,UAAU;wBACnB,IAAI,EAAE,oCAAmB,CAAC,IAAI;wBAC9B,MAAM,EAAE;4BACN,QAAQ,EAAE,yCAAyC;yBACpD;qBACF;iBACF;aACF;SACF,CAAC;QACF,MAAM,MAAM,GAAG,IAAA,6CAA2B,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAEjD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,YAAY,EAAE;gBACZ;oBACE,EAAE,EAAE,CAAC,4CAA4C,CAAC;oBAClD,IAAI,EAAE,CAAC,YAAY,CAAC;iBACrB;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport {\n BlockHeightMap,\n DictionaryResponse,\n IBlock,\n NodeConfig,\n} from '@subql/node-core';\nimport {\n EthereumBlock,\n EthereumDatasourceKind,\n EthereumHandlerKind,\n SubqlDatasource,\n SubqlRuntimeDatasource,\n} from '@subql/types-ethereum';\nimport EventEmitter2 from 'eventemitter2';\nimport {\n EthereumProjectDs,\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport { EthereumApi } from '../../../ethereum';\nimport { ethFilterDs } from '../utils';\nimport {\n buildDictionaryV2QueryEntry,\n EthDictionaryV2,\n} from './ethDictionaryV2';\n\nconst DEFAULT_DICTIONARY = 'https://ethereum.node.subquery.network/public';\nconst HTTP_ENDPOINT = 'https://ethereum.rpc.subquery.network/public';\nconst mockDs: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 19217803,\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address indexed from, address indexed to, uint256 amount)',\n ],\n },\n },\n ],\n },\n },\n];\n\nconst templateTs: EthereumProjectDsTemplate = {\n name: 'template',\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n // address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n // startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n ],\n },\n};\n\n// tx to is null\nconst mockDs2: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 19217803,\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: null,\n },\n },\n ],\n },\n processor: { file: '' },\n },\n];\n\nconst nodeConfig = new NodeConfig({\n subquery: 'eth-starter',\n subqueryName: 'eth-starter',\n dictionaryTimeout: 10,\n networkEndpoint: [HTTP_ENDPOINT],\n networkDictionary: [DEFAULT_DICTIONARY],\n});\n\nfunction makeBlockHeightMap(mockDs: SubqlDatasource[]): BlockHeightMap<any> {\n const m = new Map<number, any>();\n mockDs.forEach((ds, index, dataSources) => {\n m.set(ds.startBlock || 1, dataSources.slice(0, index + 1));\n });\n return new BlockHeightMap(m);\n}\n\n// enable this once dictionary v2 is online\ndescribe('eth dictionary v2', () => {\n let ethDictionaryV2: EthDictionaryV2;\n\n const dsMap = makeBlockHeightMap(mockDs);\n\n beforeAll(async () => {\n ethDictionaryV2 = await EthDictionaryV2.create(\n DEFAULT_DICTIONARY,\n nodeConfig,\n { network: { chainId: '1' } } as SubqueryProject,\n new EthereumApi(HTTP_ENDPOINT, 1, new EventEmitter2()),\n );\n }, 10000);\n\n beforeEach(() => {\n ethDictionaryV2.updateQueriesMap(dsMap);\n });\n\n it('converts ds to v2 dictionary queries', () => {\n const query = (ethDictionaryV2 as any).queriesMap.get(19217803);\n expect(query.logs.length).toBe(1);\n expect(query.transactions.length).toBe(1);\n });\n\n it('query response match with entries', async () => {\n const ethBlocks = (await ethDictionaryV2.getData(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n expect(ethBlocks.batchBlocks.map((b) => b.block.number)).toStrictEqual([\n 19217803, 19217804,\n ]);\n\n const ethBlock19217803 = ethBlocks.batchBlocks[0].block;\n const ethBlock19217804 = ethBlocks.batchBlocks[1].block;\n\n expect(ethBlock19217803.number).toBe(19217803);\n expect(ethBlock19217804.number).toBe(19217804);\n\n // Sighash of approval tx\n expect(\n ethBlock19217803.transactions.filter(\n (tx) => tx.input.indexOf('0x095ea7b3') === 0,\n ).length,\n ).toBe(4);\n\n expect(ethBlock19217804.logs.length).toBe(233);\n\n // This matches with dictionaryQueryEntries[0].topics\n expect(ethBlock19217804.logs[0].topics).toContain(\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n );\n }, 10000);\n\n // Geth currently throwing errors with this request\n it.skip('is able to get transaction with field to is null', async () => {\n const dsMap = makeBlockHeightMap(mockDs2);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const { conditions } = (ethDictionaryV2 as any).getQueryConditions(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n );\n\n expect(conditions).toEqual({ transactions: [{ to: [null] }] });\n\n const ethBlocks = (await ethDictionaryV2.getData(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n 1,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n const { hash, transactions } = ethBlocks.batchBlocks[0].block;\n\n expect(hash).toBe(\n '0xa9ba70126240a8418739a103527860948a2be32de2eb9a8f590591faa174c08b',\n );\n\n // https://etherscan.io/tx/0x57e8cd9483cb5d308151372b0cf33fdc615999283c80ee3c28e94f074dda61f1\n expect(\n transactions.find(\n (tx) =>\n tx.hash ===\n '0x57e8cd9483cb5d308151372b0cf33fdc615999283c80ee3c28e94f074dda61f1',\n ),\n ).toBeDefined();\n });\n\n it('is able to query with not null topics', async () => {\n /**\n * Dictionary v1 supported filtering logs where a topic was null or not null.\n * V2 doesn't yet support this but we should still be able to make a dictionary query that gets relevant logs.\n * It will just include events that will be filtered out later.\n * */\n\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n },\n startBlock: 19476187,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address, address, uint256)',\n undefined,\n undefined,\n '!null',\n ],\n },\n },\n ],\n },\n };\n\n const dsMap = makeBlockHeightMap([ds]);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const { conditions } = (ethDictionaryV2 as any).getQueryConditions(\n 19476187,\n (ethDictionaryV2 as any)._metadata.end,\n );\n\n expect(conditions).toEqual({\n logs: [\n {\n address: [],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n topics3: [],\n },\n ],\n });\n\n const ethBlocks = (await ethDictionaryV2.getData(\n 19476187,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n const { hash, logs } = ethBlocks.batchBlocks[0].block;\n\n expect(hash).toEqual(\n '0xa798861151ed58ad67d80d1cf61dc30e65d003bc958e99a7969a05a67e69e0b2',\n );\n\n const log = logs.find((l) => l.logIndex === 184);\n expect(log).toBeDefined();\n expect(log!.transactionHash).toEqual(\n '0x5491f3f4b7ca6cc81f992a17e19bc9bafff408518c643c5a254de44b5a7b6d72',\n );\n\n // Uncomment this when not null filter supported\n // expect(logs.filter(l => !l.topics[3]).length).toEqual(6) // There are 6 events with no topic3\n }, 100000);\n});\n\ndescribe('buildDictionaryV2QueryEntry', () => {\n it('Build filter for !null', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address, address, uint256)',\n undefined,\n undefined,\n '!null',\n ],\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n topics3: [],\n },\n ],\n });\n });\n\n it('Build filter tx filter', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n transactions: [\n {\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n\n it('build query entries for multiple ds', () => {\n const ds: SubqlRuntimeDatasource[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n startBlock: 3327417,\n options: {\n abi: 'EnsRegistry',\n address: '0x314159265dd8dbb310642f98f50c066173c1259b',\n },\n assets: new Map(),\n mapping: {\n file: './dist/index.js',\n handlers: [\n // one duplicate one\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleTransferOldRegistry',\n filter: {\n topics: ['Transfer(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleTransferOldRegistry',\n filter: {\n topics: ['Transfer(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleNewOwnerOldRegistry',\n filter: {\n topics: ['NewOwner(bytes32,bytes32,address)'],\n },\n },\n ],\n },\n },\n {\n kind: EthereumDatasourceKind.Runtime,\n startBlock: 3327417,\n options: {\n abi: 'Resolver',\n },\n assets: new Map(),\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleABIChanged',\n filter: {\n topics: ['ABIChanged(bytes32,uint256)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleAddrChanged',\n filter: {\n topics: ['AddrChanged(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleMulticoinAddrChanged',\n filter: {\n topics: ['AddressChanged(bytes32,uint256,bytes)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleAuthorisationChanged',\n filter: {\n topics: ['AuthorisationChanged(bytes32,address,address,bool)'],\n },\n },\n ],\n },\n },\n ];\n\n const queryEntry = buildDictionaryV2QueryEntry(ds);\n // Total 7 handlers were given, 1 is duplicate\n expect(queryEntry.logs!.length).toBe(6);\n });\n\n it('should unique QueryEntry for duplicate dataSources', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n {\n handler: 'handleLogSame',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n from: 'mockAddress',\n },\n },\n {\n handler: 'handleTxSame',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n from: 'mockAddress',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n transactions: [\n {\n from: ['mockaddress'],\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n\n it('should group a small number of dynamic ds', () => {\n const ds: SubqlRuntimeDatasource[] = [];\n\n for (let i = 0; i < 10; i++) {\n // Bad nodejs types\n const tmp = (global as any).structuredClone(templateTs);\n (tmp.options.address = `0x${i}`), ds.push(tmp);\n }\n\n const result = buildDictionaryV2QueryEntry(ethFilterDs(ds));\n\n expect(result).toEqual({\n logs: [\n {\n address: [\n '0x0',\n '0x1',\n '0x2',\n '0x3',\n '0x4',\n '0x5',\n '0x6',\n '0x7',\n '0x8',\n '0x9',\n ],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n });\n });\n\n it('should remove address filter with large number of dynamic ds', () => {\n const ds: SubqlRuntimeDatasource[] = [];\n\n for (let i = 0; i < 200; i++) {\n // Bad nodejs types\n const tmp = (global as any).structuredClone(templateTs);\n (tmp.options.address = `0x${i}`), ds.push(tmp);\n }\n\n const result = buildDictionaryV2QueryEntry(ethFilterDs(ds));\n\n expect(result).toEqual({\n logs: [\n {\n address: [],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n });\n });\n\n it('builds a filter when theres a block handler with modulo filter', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleBlock',\n kind: EthereumHandlerKind.Block,\n filter: {\n modulo: 100,\n },\n },\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n transactions: [\n {\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n});\n"]}
1
+ {"version":3,"file":"ethDictionaryV2.spec.js","sourceRoot":"","sources":["../../../../src/indexer/dictionary/v2/ethDictionaryV2.spec.ts"],"names":[],"mappings":";AAAA,8DAA8D;AAC9D,mCAAmC;;;;;AAEnC,gDAK0B;AAC1B,0DAM+B;AAC/B,kEAA0C;AAM1C,gDAAgD;AAChD,oCAAuC;AACvC,uDAG2B;AAE3B,MAAM,kBAAkB,GAAG,+CAA+C,CAAC;AAC3E,MAAM,aAAa,GAAG,8CAA8C,CAAC;AACrE,MAAM,MAAM,GAAwB;IAClC;QACE,IAAI,EAAE,uCAAsB,CAAC,OAAO;QACpC,MAAM,EAAE,IAAI,GAAG,EAAE;QACjB,UAAU,EAAE,QAAQ;QACpB,OAAO,EAAE;YACP,IAAI,EAAE,iBAAiB;YACvB,QAAQ,EAAE;gBACR;oBACE,OAAO,EAAE,mBAAmB;oBAC5B,IAAI,EAAE,oCAAmB,CAAC,IAAI;oBAC9B,MAAM,EAAE;wBACN,QAAQ,EAAE,6CAA6C;qBACxD;iBACF;gBACD;oBACE,OAAO,EAAE,WAAW;oBACpB,IAA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AC,gEAAgE,EAAE,GAAG,EAAE;QACxE,MAAM,EAAE,GAA2B;YACjC,IAAI,EAAE,uCAAsB,CAAC,OAAO;YACpC,MAAM,EAAE,IAAI,GAAG,EAAE;YACjB,OAAO,EAAE;gBACP,GAAG,EAAE,OAAO;gBACZ,OAAO,EAAE,4CAA4C;aACtD;YACD,UAAU,EAAE,CAAC;YACb,OAAO,EAAE;gBACP,IAAI,EAAE,EAAE;gBACR,QAAQ,EAAE;oBACR;wBACE,OAAO,EAAE,aAAa;wBACtB,IAAI,EAAE,oCAAmB,CAAC,KAAK;wBAC/B,MAAM,EAAE;4BACN,MAAM,EAAE,GAAG;yBACZ;qBACF;oBACD;wBACE,OAAO,EAAE,UAAU;wBACnB,IAAI,EAAE,oCAAmB,CAAC,IAAI;wBAC9B,MAAM,EAAE;4BACN,QAAQ,EAAE,yCAAyC;yBACpD;qBACF;iBACF;aACF;SACF,CAAC;QACF,MAAM,MAAM,GAAG,IAAA,6CAA2B,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAEjD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,YAAY,EAAE;gBACZ;oBACE,EAAE,EAAE,CAAC,4CAA4C,CAAC;oBAClD,IAAI,EAAE,CAAC,YAAY,CAAC;iBACrB;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright 2020-2024 SubQuery Pte Ltd authors & contributors\n// SPDX-License-Identifier: GPL-3.0\n\nimport {\n BlockHeightMap,\n DictionaryResponse,\n IBlock,\n NodeConfig,\n} from '@subql/node-core';\nimport {\n EthereumBlock,\n EthereumDatasourceKind,\n EthereumHandlerKind,\n SubqlDatasource,\n SubqlRuntimeDatasource,\n} from '@subql/types-ethereum';\nimport EventEmitter2 from 'eventemitter2';\nimport {\n EthereumProjectDs,\n EthereumProjectDsTemplate,\n SubqueryProject,\n} from '../../../configure/SubqueryProject';\nimport { EthereumApi } from '../../../ethereum';\nimport { ethFilterDs } from '../utils';\nimport {\n buildDictionaryV2QueryEntry,\n EthDictionaryV2,\n} from './ethDictionaryV2';\n\nconst DEFAULT_DICTIONARY = 'https://ethereum.node.subquery.network/public';\nconst HTTP_ENDPOINT = 'https://ethereum.rpc.subquery.network/public';\nconst mockDs: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 19217803,\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'approve(address spender, uint256 rawAmount)',\n },\n },\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address indexed from, address indexed to, uint256 amount)',\n ],\n },\n },\n ],\n },\n },\n];\n\nconst templateTs: EthereumProjectDsTemplate = {\n name: 'template',\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n // address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n // startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n ],\n },\n};\n\n// tx to is null\nconst mockDs2: EthereumProjectDs[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n startBlock: 19217803,\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n handler: 'handleTransaction',\n kind: EthereumHandlerKind.Call,\n filter: {\n to: null,\n },\n },\n ],\n },\n processor: { file: '' },\n },\n];\n\nconst nodeConfig = new NodeConfig({\n subquery: 'eth-starter',\n subqueryName: 'eth-starter',\n dictionaryTimeout: 10,\n networkEndpoint: { [HTTP_ENDPOINT]: {} },\n networkDictionary: [DEFAULT_DICTIONARY],\n});\n\nfunction makeBlockHeightMap(mockDs: SubqlDatasource[]): BlockHeightMap<any> {\n const m = new Map<number, any>();\n mockDs.forEach((ds, index, dataSources) => {\n m.set(ds.startBlock || 1, dataSources.slice(0, index + 1));\n });\n return new BlockHeightMap(m);\n}\n\n// enable this once dictionary v2 is online\ndescribe('eth dictionary v2', () => {\n let ethDictionaryV2: EthDictionaryV2;\n\n const dsMap = makeBlockHeightMap(mockDs);\n\n beforeAll(async () => {\n ethDictionaryV2 = await EthDictionaryV2.create(\n DEFAULT_DICTIONARY,\n nodeConfig,\n { network: { chainId: '1' } } as SubqueryProject,\n new EthereumApi(HTTP_ENDPOINT, 1, new EventEmitter2()),\n );\n }, 10000);\n\n beforeEach(() => {\n ethDictionaryV2.updateQueriesMap(dsMap);\n });\n\n it('converts ds to v2 dictionary queries', () => {\n const query = (ethDictionaryV2 as any).queriesMap.get(19217803);\n expect(query.logs.length).toBe(1);\n expect(query.transactions.length).toBe(1);\n });\n\n it('query response match with entries', async () => {\n const ethBlocks = (await ethDictionaryV2.getData(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n expect(ethBlocks.batchBlocks.map((b) => b.block.number)).toStrictEqual([\n 19217803, 19217804,\n ]);\n\n const ethBlock19217803 = ethBlocks.batchBlocks[0].block;\n const ethBlock19217804 = ethBlocks.batchBlocks[1].block;\n\n expect(ethBlock19217803.number).toBe(19217803);\n expect(ethBlock19217804.number).toBe(19217804);\n\n // Sighash of approval tx\n expect(\n ethBlock19217803.transactions.filter(\n (tx) => tx.input.indexOf('0x095ea7b3') === 0,\n ).length,\n ).toBe(4);\n\n expect(ethBlock19217804.logs.length).toBe(233);\n\n // This matches with dictionaryQueryEntries[0].topics\n expect(ethBlock19217804.logs[0].topics).toContain(\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n );\n }, 10000);\n\n // Geth currently throwing errors with this request\n it.skip('is able to get transaction with field to is null', async () => {\n const dsMap = makeBlockHeightMap(mockDs2);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const { conditions } = (ethDictionaryV2 as any).getQueryConditions(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n );\n\n expect(conditions).toEqual({ transactions: [{ to: [null] }] });\n\n const ethBlocks = (await ethDictionaryV2.getData(\n 19217803,\n (ethDictionaryV2 as any)._metadata.end,\n 1,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n const { hash, transactions } = ethBlocks.batchBlocks[0].block;\n\n expect(hash).toBe(\n '0xa9ba70126240a8418739a103527860948a2be32de2eb9a8f590591faa174c08b',\n );\n\n // https://etherscan.io/tx/0x57e8cd9483cb5d308151372b0cf33fdc615999283c80ee3c28e94f074dda61f1\n expect(\n transactions.find(\n (tx) =>\n tx.hash ===\n '0x57e8cd9483cb5d308151372b0cf33fdc615999283c80ee3c28e94f074dda61f1',\n ),\n ).toBeDefined();\n });\n\n it('is able to query with not null topics', async () => {\n /**\n * Dictionary v1 supported filtering logs where a topic was null or not null.\n * V2 doesn't yet support this but we should still be able to make a dictionary query that gets relevant logs.\n * It will just include events that will be filtered out later.\n * */\n\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n },\n startBlock: 19476187,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address, address, uint256)',\n undefined,\n undefined,\n '!null',\n ],\n },\n },\n ],\n },\n };\n\n const dsMap = makeBlockHeightMap([ds]);\n ethDictionaryV2.updateQueriesMap(dsMap);\n\n const { conditions } = (ethDictionaryV2 as any).getQueryConditions(\n 19476187,\n (ethDictionaryV2 as any)._metadata.end,\n );\n\n expect(conditions).toEqual({\n logs: [\n {\n address: [],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n topics3: [],\n },\n ],\n });\n\n const ethBlocks = (await ethDictionaryV2.getData(\n 19476187,\n (ethDictionaryV2 as any)._metadata.end,\n 2,\n )) as DictionaryResponse<IBlock<EthereumBlock>>;\n\n const { hash, logs } = ethBlocks.batchBlocks[0].block;\n\n expect(hash).toEqual(\n '0xa798861151ed58ad67d80d1cf61dc30e65d003bc958e99a7969a05a67e69e0b2',\n );\n\n const log = logs.find((l) => l.logIndex === 184);\n expect(log).toBeDefined();\n expect(log!.transactionHash).toEqual(\n '0x5491f3f4b7ca6cc81f992a17e19bc9bafff408518c643c5a254de44b5a7b6d72',\n );\n\n // Uncomment this when not null filter supported\n // expect(logs.filter(l => !l.topics[3]).length).toEqual(6) // There are 6 events with no topic3\n }, 100000);\n});\n\ndescribe('buildDictionaryV2QueryEntry', () => {\n it('Build filter for !null', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: [\n 'Transfer(address, address, uint256)',\n undefined,\n undefined,\n '!null',\n ],\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n topics3: [],\n },\n ],\n });\n });\n\n it('Build filter tx filter', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n transactions: [\n {\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n\n it('build query entries for multiple ds', () => {\n const ds: SubqlRuntimeDatasource[] = [\n {\n kind: EthereumDatasourceKind.Runtime,\n startBlock: 3327417,\n options: {\n abi: 'EnsRegistry',\n address: '0x314159265dd8dbb310642f98f50c066173c1259b',\n },\n assets: new Map(),\n mapping: {\n file: './dist/index.js',\n handlers: [\n // one duplicate one\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleTransferOldRegistry',\n filter: {\n topics: ['Transfer(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleTransferOldRegistry',\n filter: {\n topics: ['Transfer(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleNewOwnerOldRegistry',\n filter: {\n topics: ['NewOwner(bytes32,bytes32,address)'],\n },\n },\n ],\n },\n },\n {\n kind: EthereumDatasourceKind.Runtime,\n startBlock: 3327417,\n options: {\n abi: 'Resolver',\n },\n assets: new Map(),\n mapping: {\n file: './dist/index.js',\n handlers: [\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleABIChanged',\n filter: {\n topics: ['ABIChanged(bytes32,uint256)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleAddrChanged',\n filter: {\n topics: ['AddrChanged(bytes32,address)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleMulticoinAddrChanged',\n filter: {\n topics: ['AddressChanged(bytes32,uint256,bytes)'],\n },\n },\n {\n kind: EthereumHandlerKind.Event,\n handler: 'handleAuthorisationChanged',\n filter: {\n topics: ['AuthorisationChanged(bytes32,address,address,bool)'],\n },\n },\n ],\n },\n },\n ];\n\n const queryEntry = buildDictionaryV2QueryEntry(ds);\n // Total 7 handlers were given, 1 is duplicate\n expect(queryEntry.logs!.length).toBe(6);\n });\n\n it('should unique QueryEntry for duplicate dataSources', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleLog',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n {\n handler: 'handleLogSame',\n kind: EthereumHandlerKind.Event,\n filter: {\n topics: ['Transfer(address, address, uint256)'],\n },\n },\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n from: 'mockAddress',\n },\n },\n {\n handler: 'handleTxSame',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n from: 'mockAddress',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n logs: [\n {\n address: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n transactions: [\n {\n from: ['mockaddress'],\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n\n it('should group a small number of dynamic ds', () => {\n const ds: SubqlRuntimeDatasource[] = [];\n\n for (let i = 0; i < 10; i++) {\n // Bad nodejs types\n const tmp = (global as any).structuredClone(templateTs);\n (tmp.options.address = `0x${i}`), ds.push(tmp);\n }\n\n const result = buildDictionaryV2QueryEntry(ethFilterDs(ds));\n\n expect(result).toEqual({\n logs: [\n {\n address: [\n '0x0',\n '0x1',\n '0x2',\n '0x3',\n '0x4',\n '0x5',\n '0x6',\n '0x7',\n '0x8',\n '0x9',\n ],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n });\n });\n\n it('should remove address filter with large number of dynamic ds', () => {\n const ds: SubqlRuntimeDatasource[] = [];\n\n for (let i = 0; i < 200; i++) {\n // Bad nodejs types\n const tmp = (global as any).structuredClone(templateTs);\n (tmp.options.address = `0x${i}`), ds.push(tmp);\n }\n\n const result = buildDictionaryV2QueryEntry(ethFilterDs(ds));\n\n expect(result).toEqual({\n logs: [\n {\n address: [],\n topics0: [\n '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n ],\n },\n ],\n });\n });\n\n it('builds a filter when theres a block handler with modulo filter', () => {\n const ds: SubqlRuntimeDatasource = {\n kind: EthereumDatasourceKind.Runtime,\n assets: new Map(),\n options: {\n abi: 'erc20',\n address: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',\n },\n startBlock: 1,\n mapping: {\n file: '',\n handlers: [\n {\n handler: 'handleBlock',\n kind: EthereumHandlerKind.Block,\n filter: {\n modulo: 100,\n },\n },\n {\n handler: 'handleTx',\n kind: EthereumHandlerKind.Call,\n filter: {\n function: 'setminimumStakingAmount(uint256 amount)',\n },\n },\n ],\n },\n };\n const result = buildDictionaryV2QueryEntry([ds]);\n\n expect(result).toEqual({\n transactions: [\n {\n to: ['0x7ceb23fd6bc0add59e62ac25578270cff1b9f619'],\n data: ['0x7ef9ea98'],\n },\n ],\n });\n });\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subql/node-ethereum",
3
- "version": "5.0.1",
3
+ "version": "5.1.0",
4
4
  "description": "",
5
5
  "author": "Ian He",
6
6
  "license": "GPL-3.0",
@@ -24,10 +24,10 @@
24
24
  "@nestjs/event-emitter": "^2.0.0",
25
25
  "@nestjs/platform-express": "^9.4.0",
26
26
  "@nestjs/schedule": "^3.0.1",
27
- "@subql/common-ethereum": "4.4.0",
28
- "@subql/node-core": "^13.0.1",
27
+ "@subql/common-ethereum": "4.5.0",
28
+ "@subql/node-core": "^14.0.0",
29
29
  "@subql/testing": "^2.2.1",
30
- "@subql/types-ethereum": "3.12.0",
30
+ "@subql/types-ethereum": "3.13.0",
31
31
  "cacheable-lookup": "6",
32
32
  "ethers": "^5.7.0",
33
33
  "eventemitter2": "^6.4.5",