Skip to content

Commit

Permalink
Do not index data when fullBlock does not exist logs
Browse files Browse the repository at this point in the history
  • Loading branch information
yoozo committed Oct 22, 2024
1 parent 13337a4 commit c7342cc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions packages/node/src/ethereum/api.ethereum.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
EthereumLogFilter,
SubqlRuntimeDatasource,
} from '@subql/types-ethereum';
import _ from 'lodash';
import { EthereumApi } from './api.ethereum';
import {
filterLogsProcessor,
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/ethereum/block.ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c7342cc

Please sign in to comment.