From c7342cc3979b5ebd12697e9af0f42a10aaef241f Mon Sep 17 00:00:00 2001 From: Tate Date: Tue, 22 Oct 2024 08:50:35 +0000 Subject: [PATCH 1/5] Do not index data when fullBlock does not exist logs --- packages/node/CHANGELOG.md | 3 +++ packages/node/src/ethereum/api.ethereum.test.ts | 6 ++++++ packages/node/src/ethereum/block.ethereum.ts | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/node/CHANGELOG.md b/packages/node/CHANGELOG.md index 3bb4c32477..d85f314eca 100644 --- a/packages/node/CHANGELOG.md +++ b/packages/node/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Do not index data when fullBlock does not exist logs (#) + ## [5.1.5] - 2024-10-22 ### Changed - Bump `@subql/node-core` dependency (#347) diff --git a/packages/node/src/ethereum/api.ethereum.test.ts b/packages/node/src/ethereum/api.ethereum.test.ts index 31ace2099a..debb4cb0ef 100644 --- a/packages/node/src/ethereum/api.ethereum.test.ts +++ b/packages/node/src/ethereum/api.ethereum.test.ts @@ -11,6 +11,7 @@ import { EthereumLogFilter, SubqlRuntimeDatasource, } from '@subql/types-ethereum'; +import _ from 'lodash'; import { EthereumApi } from './api.ethereum'; import { filterLogsProcessor, @@ -367,6 +368,11 @@ describe('Api.ethereum', () => { expect(isFullBlock(blockData)).toBeTruthy(); expect(isFullBlock(lightBlock)).toBeFalsy(); + // block with transactions, but no logs + const noLogBlockData = _.cloneDeep(blockData); + noLogBlockData.logs = []; + expect(isFullBlock(noLogBlockData)).toBeTruthy(); + // block without transaction const block10001 = (await (ethApi as any).fetchBlock(10001)).block; const lightBlock10001 = (await (ethApi as any).fetchLightBlock(10001)) diff --git a/packages/node/src/ethereum/block.ethereum.ts b/packages/node/src/ethereum/block.ethereum.ts index 5ba9d687b3..329b895df9 100644 --- a/packages/node/src/ethereum/block.ethereum.ts +++ b/packages/node/src/ethereum/block.ethereum.ts @@ -120,7 +120,7 @@ export function isFullBlock(block: BlockContent): block is EthereumBlock { // Light etherum block just contains transaction hashes for transactions. // If the block has no transactions then both types would be the same - if (block.transactions.length && block.logs.length) { + if (block.transactions.length) { return typeof (block as EthereumBlock).transactions[0] !== 'string'; } return false; From d5915d75293afaf0478d44bfdae814be2e200bcf Mon Sep 17 00:00:00 2001 From: yoozo Date: Tue, 22 Oct 2024 16:55:47 +0800 Subject: [PATCH 2/5] Update CHANGELOG.md --- packages/node/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node/CHANGELOG.md b/packages/node/CHANGELOG.md index d85f314eca..25f946ef00 100644 --- a/packages/node/CHANGELOG.md +++ b/packages/node/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed -- Do not index data when fullBlock does not exist logs (#) +- Do not index data when fullBlock does not exist logs (#350) ## [5.1.5] - 2024-10-22 ### Changed From 107885ad5c177e9b1237893692a0a0623e013cf1 Mon Sep 17 00:00:00 2001 From: Tate Date: Thu, 24 Oct 2024 01:38:55 +0000 Subject: [PATCH 3/5] change log --- packages/node/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node/CHANGELOG.md b/packages/node/CHANGELOG.md index 1792bcfb84..b6dab037b0 100644 --- a/packages/node/CHANGELOG.md +++ b/packages/node/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Fixed -- Do not index data when fullBlock does not exist logs (#350) +- When there is no log data for fullBlock, it is determined as lightBlock. (#350) ## [5.1.6] - 2024-10-23 ### Changed From f388949109b9bd7923984ddf1c179b3f19202a71 Mon Sep 17 00:00:00 2001 From: Tate Date: Thu, 24 Oct 2024 02:45:31 +0000 Subject: [PATCH 4/5] unit test --- packages/node/src/ethereum/api.ethereum.test.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/node/src/ethereum/api.ethereum.test.ts b/packages/node/src/ethereum/api.ethereum.test.ts index debb4cb0ef..da4e9d4612 100644 --- a/packages/node/src/ethereum/api.ethereum.test.ts +++ b/packages/node/src/ethereum/api.ethereum.test.ts @@ -368,9 +368,8 @@ describe('Api.ethereum', () => { expect(isFullBlock(blockData)).toBeTruthy(); expect(isFullBlock(lightBlock)).toBeFalsy(); - // block with transactions, but no logs - const noLogBlockData = _.cloneDeep(blockData); - noLogBlockData.logs = []; + // block with transactions, but no logs 4913287 + const noLogBlockData = (await (ethApi as any).fetchBlock(4913287)).block; expect(isFullBlock(noLogBlockData)).toBeTruthy(); // block without transaction From 34b323727e002787292420183fc1d6f25a80f231 Mon Sep 17 00:00:00 2001 From: yoozo Date: Thu, 24 Oct 2024 10:47:23 +0800 Subject: [PATCH 5/5] Update api.ethereum.test.ts --- packages/node/src/ethereum/api.ethereum.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/node/src/ethereum/api.ethereum.test.ts b/packages/node/src/ethereum/api.ethereum.test.ts index da4e9d4612..5e2d1c5306 100644 --- a/packages/node/src/ethereum/api.ethereum.test.ts +++ b/packages/node/src/ethereum/api.ethereum.test.ts @@ -11,7 +11,6 @@ import { EthereumLogFilter, SubqlRuntimeDatasource, } from '@subql/types-ethereum'; -import _ from 'lodash'; import { EthereumApi } from './api.ethereum'; import { filterLogsProcessor,