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

Fix Header not found timestamp field #366

Merged
merged 5 commits into from
Feb 24, 2025
Merged

Fix Header not found timestamp field #366

merged 5 commits into from
Feb 24, 2025

Conversation

yoozo
Copy link

@yoozo yoozo commented Feb 21, 2025

Description

When using historical: timestamp, because getHeader does not return the timestamp, it causes the crawl to not function properly.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • I have tested locally
  • I have performed a self review of my changes
  • Updated any relevant documentation
  • Linked to any relevant issues
  • I have added tests relevant to my changes
  • Any dependent changes have been merged and published in downstream modules
  • My code is up to date with the base branch
  • I have updated relevant changelogs. We suggest using chan

Copy link

github-actions bot commented Feb 21, 2025

Coverage report

Caution

Test run failed

St.
Category Percentage Covered / Total
🔴 Statements 52.39% 3293/6285
🟡 Branches 69.92% 423/605
🔴 Functions 50.35% 142/282
🔴 Lines 52.39% 3293/6285

Test suite run failed

Failed tests: 5/96. Failed suites: 3/14.
  ● UnfinalizedBlockService › startup, correctly checks for forks after cached unfinalized blocks

    expect(jest.fn()).toHaveBeenCalledWith(...expected)

    - Expected
    + Received

      Object {
        "blockHash": "0x00ABC99f",
        "blockHeight": 99,
        "parentHash": "0x00ABC98f",
    -   "timestamp": 2025-02-21T01:08:19.000Z,
    +   "timestamp": "2025-02-21T01:08:19.000Z",
      },

    Number of calls: 1

      168 |
      169 |     // It should fall back to poi in this case
    > 170 |     expect(rewind).toHaveBeenCalledWith({
          |                    ^
      171 |       blockHash: '0x00ABC99f',
      172 |       blockHeight: 99,
      173 |       parentHash: '0x00ABC98f',

      at Object.<anonymous> (packages/node/src/indexer/unfinalizedBlocks.service.spec.ts:170:20)


  ● eth dictionary v2 › query response match with entries

    Dictionary query failed Error: method handler crashed

      146 |
      147 |   it('query response match with entries', async () => {
    > 148 |     const ethBlocks = (await ethDictionaryV2.getData(
          |                        ^
      149 |       19217803,
      150 |       (ethDictionaryV2 as any)._metadata.end,
      151 |       2,

      at EthDictionaryV2.getData (node_modules/@subql/node-core/src/indexer/dictionary/v2/dictionaryV2.ts:162:13)
      at Object.<anonymous> (packages/node/src/indexer/dictionary/v2/ethDictionaryV2.spec.ts:148:24)

  ● eth dictionary v2 › is able to query with not null topics

    Dictionary query failed Error: method handler crashed

      264 |     });
      265 |
    > 266 |     const ethBlocks = (await ethDictionaryV2.getData(
          |                        ^
      267 |       19476187,
      268 |       (ethDictionaryV2 as any)._metadata.end,
      269 |       2,

      at EthDictionaryV2.getData (node_modules/@subql/node-core/src/indexer/dictionary/v2/dictionaryV2.ts:162:13)
      at Object.<anonymous> (packages/node/src/indexer/dictionary/v2/ethDictionaryV2.spec.ts:266:24)


  ● rawBlockToEthBlock › successfully converts a block

    TypeError: Cannot read properties of undefined (reading 'blocks')

      52 |   });
      53 |
    > 54 |   return (await res.json()).result.blocks[0];
         |                                    ^
      55 | }
      56 |
      57 | describe('rawBlockToEthBlock', () => {

      at fetchDictionaryBlock (packages/node/src/indexer/dictionary/v2/utils.spec.ts:54:36)
          at async Promise.all (index 0)
      at Object.<anonymous> (packages/node/src/indexer/dictionary/v2/utils.spec.ts:63:23)

  ● rawBlockToEthBlock › can fetch receipts

    TypeError: Cannot read properties of undefined (reading 'blocks')

      52 |   });
      53 |
    > 54 |   return (await res.json()).result.blocks[0];
         |                                    ^
      55 | }
      56 |
      57 | describe('rawBlockToEthBlock', () => {

      at fetchDictionaryBlock (packages/node/src/indexer/dictionary/v2/utils.spec.ts:54:36)
          at async Promise.all (index 0)
      at Object.<anonymous> (packages/node/src/indexer/dictionary/v2/utils.spec.ts:63:23)

Report generated by 🧪jest coverage report action from d0dfd06

@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed
- Fix `Header` not found `timestamp` field

Choose a reason for hiding this comment

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

Suggested change
- Fix `Header` not found `timestamp` field
- `timestamp` field missing on `Header`

@@ -22,6 +22,7 @@ const makeHeader = (height: number, finalized?: boolean): Header => ({
blockHeight: height,
blockHash: hexify(`0xABC${height}${finalized ? 'f' : ''}`),
parentHash: hexify(`0xABC${height - 1}${finalized ? 'f' : ''}`),
timestamp: new Date((1740100000 + height) * 1000),

Choose a reason for hiding this comment

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

Where does 1740100000 come from? Can we move it to a constant with a description

@stwiname stwiname merged commit e028edc into main Feb 24, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants