Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not index data when fullBlock does not exist logs #350

Merged
merged 6 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 (#350)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't make sense to me. It should still be possible to index a block without 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better test would find a real block with 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
Loading