Skip to content

Commit

Permalink
Do not index data when fullBlock does not exist logs (#350)
Browse files Browse the repository at this point in the history
* Do not index data when fullBlock does not exist logs

* Update CHANGELOG.md

* change log

* unit test

* Update api.ethereum.test.ts
  • Loading branch information
yoozo authored Oct 24, 2024
1 parent d63ec82 commit 37945f8
Show file tree
Hide file tree
Showing 3 changed files with 8 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
- When there is no log data for fullBlock, it is determined as lightBlock. (#350)

## [5.1.6] - 2024-10-23
### Changed
- Bump `@subql/common` dependency
Expand Down
4 changes: 4 additions & 0 deletions packages/node/src/ethereum/api.ethereum.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ describe('Api.ethereum', () => {
expect(isFullBlock(blockData)).toBeTruthy();
expect(isFullBlock(lightBlock)).toBeFalsy();

// block with transactions, but no logs 4913287
const noLogBlockData = (await (ethApi as any).fetchBlock(4913287)).block;
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 37945f8

Please sign in to comment.