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

New fork detection for probabilistic finalization chains #217

Merged
merged 6 commits into from
Nov 27, 2023

Conversation

stwiname
Copy link

Description

Implements a different fork detection method for chains that don't support finalization. If a fork is detected before the probabilistic finalized block it will fallback to using POI to reindex to the last block with an operation that has a valid block hash. If POI is not enabled it will reindex back block-fork-reindex blocks, this defaults to 1000.

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 Find last finalized block using POI subql#2176
  • 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 Nov 23, 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 52.49% 3183/6064
🟡 Branches 65.64% 319/486
🔴 Functions 43.44% 106/244
🔴 Lines 52.49% 3183/6064

Test suite run failed

Failed tests: 5/62. Failed suites: 5/11.
  ● Dictionary queries › Correct dictionary query with dynamic ds › Builds a groupded query for multiple dynamic ds

    expect(received).toEqual(expected) // deep equality

    - Expected  - 8
    + Received  + 0

    @@ -10,18 +10,10 @@
          "entity": "evmLogs",
        },
        Object {
          "conditions": Array [
            Object {
    -         "field": "address",
    -         "matcher": "in",
    -         "value": Array [
    -           "address1",
    -           "address2",
    -         ],
    -       },
    -       Object {
              "field": "topics0",
              "matcher": "equalTo",
              "value": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
            },
          ],

      408 |       );
      409 |
    > 410 |       expect(queryEntry).toEqual([
          |                          ^
      411 |         {
      412 |           entity: 'evmLogs',
      413 |           conditions: [

      at Object.<anonymous> (packages/node/src/indexer/fetch.service.spec.ts:410:26)


  ● CeloJsonRpcProvider › should not set gasLimit to zero for blocks after the hard fork

    thrown: "Exceeded timeout of 5000 ms for a test.
    Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

      27 |
      28 |   // Test if gasLimit is correctly set for blocks after the hard fork
    > 29 |   it('should not set gasLimit to zero for blocks after the hard fork', async () => {
         |   ^
      30 |     const block = formatBlock(
      31 |       await provider.send('eth_getBlockByNumber', ['latest', true]),
      32 |     );

      at packages/node/src/ethereum/ethers/celo/celo-json-rpc-batch-provider.spec.ts:29:3
      at Object.<anonymous> (packages/node/src/ethereum/ethers/celo/celo-json-rpc-batch-provider.spec.ts:8:1)


  ● CeloJsonRpcProvider › should set gasLimit to zero for blocks before the hard fork

    thrown: "Exceeded timeout of 5000 ms for a test.
    Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

      14 |
      15 |   // Test if gasLimit is correctly set for blocks before the hard fork
    > 16 |   it('should set gasLimit to zero for blocks before the hard fork', async () => {
         |   ^
      17 |     const block = formatBlock(
      18 |       await provider.send('eth_getBlockByNumber', [
      19 |         utils.hexValue(16068684),

      at packages/node/src/ethereum/ethers/celo/celo-json-rpc-provider.spec.ts:16:3
      at Object.<anonymous> (packages/node/src/ethereum/ethers/celo/celo-json-rpc-provider.spec.ts:8:1)


  ● ApiService › can get the finalized height

    expect(received).toBeGreaterThan(expected)

    Expected: > 16000000
    Received:   0

      88 |
      89 |     console.log('Finalized height', height);
    > 90 |     expect(height).toBeGreaterThan(16_000_000);
         |                    ^
      91 |   });
      92 |
      93 |   it('ensure api errorCode is exposed when throwing', async () => {

      at Object.<anonymous> (packages/node/src/ethereum/api.service.ethereum.test.ts:90:20)


  ● Api.ethereum › Resolves the correct tags for finalization

    expect(received).toBeTruthy()

    Received: false

      271 |   it('Resolves the correct tags for finalization', async () => {
      272 |     // Ethereum
    > 273 |     expect((ethApi as any).supportsFinalization).toBeTruthy();
          |                                                  ^
      274 |
      275 |     // Moonbeam
      276 |     ethApi = new EthereumApi(

      at Object.<anonymous> (packages/node/src/ethereum/api.ethereum.test.ts:273:50)

Report generated by 🧪jest coverage report action from 6f7474a

type: 'number',
},
'block-fork-reindex': {
Copy link
Author

Choose a reason for hiding this comment

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

Im open to better name suggestions

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