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

Implement ethereum specific fork detection and POI fallback #165

Closed
wants to merge 11 commits into from

Conversation

stwiname
Copy link

Description

Use a different method for fork detection when chain doesn't have a concrete finalization mechanism. If POI is enabled then we can use that to rewind to the last operation before a fork occurred.

TODO

  • Improve error message when POI not enabled. Need to include a way to recover from this
  • Set fork method based on whether finalization is supported

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

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

@stwiname stwiname marked this pull request as draft September 12, 2023 23:11
@github-actions
Copy link

github-actions bot commented Sep 12, 2023

Coverage report

❌ An unexpected error occurred. For more details, check console

Error: The process '/usr/local/bin/yarn' failed with exit code 1
St.
Category Percentage Covered / Total
🔴 Statements 53.28% 3290/6175
🟡 Branches 66.52% 304/457
🔴 Functions 41.7% 98/235
🔴 Lines 53.28% 3290/6175

Test suite run failed

Failed tests: 1/53. Failed suites: 1/11.
  ● ProjectService › can get a block timestamps

    TypeError: Cannot read properties of null (reading 'unsafe')

      49 |     unfinalizedBlockService: UnfinalizedBlocksService,
      50 |   ) {
    > 51 |     super(
         |     ^
      52 |       dsProcessorService,
      53 |       apiService,
      54 |       poiService,

      at new BaseProjectService (node_modules/@subql/node-core/src/indexer/project.service.ts:52:25)
      at new ProjectService (packages/node/src/indexer/project.service.ts:51:5)
      at Object.<anonymous> (packages/node/src/indexer/project.service.test.ts:28:22)

Report generated by 🧪jest coverage report action from 8c6a6e2

@ianhe8x
Copy link

ianhe8x commented Nov 15, 2023

@stwiname I didn't read this PR closely, but this is what I think the best process

  1. check parent hash when we add a new unfinalised block
  2. if not match, stop fetching loop, create a mark
  3. in post block hook, read the mark and start look up the fork
    1. if can not find fork in the block cache, either
    1. use poi and continue search fork
    2. add a mandatory number of blocks to the earliest block we have (like 1000) and rollback
  4. on start up, if there are block cache in metadata, check the latest block in the cache before abandoning them if the gap is too large.
  5. also in some case (like gap is small), we can keep the block cache without resetting after restart.

@stwiname
Copy link
Author

Closing this in favour of #217

@stwiname stwiname closed this Nov 24, 2023
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.

3 participants