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

Switch to getting logs via block hash instead of block number #156

Merged
merged 2 commits into from
Sep 8, 2023

Conversation

stwiname
Copy link

@stwiname stwiname commented Sep 7, 2023

Description

Using the block height to get logs will always return results or empty results rather than an invalid result. Switching to using the block hash guarantees we get the right logs for the block. If an endpoint is out of sync and we're unable to get the logs then retry logic will handle it.

Fixes subquery#1999

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

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

@jiqiang90 jiqiang90 left a comment

Choose a reason for hiding this comment

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

Need benchmark for this change

@github-actions
Copy link

github-actions bot commented Sep 7, 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 46.78% 3063/6547
🟡 Branches 64.34% 276/429
🔴 Functions 38.03% 89/234
🔴 Lines 46.78% 3063/6547

Test suite run failed

Failed tests: 3/41. Failed suites: 3/8.
  ● CeloJsonRpcProvider › should not set gasLimit to zero for blocks after the hard fork

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

    - Expected  - 1
    + Received  + 1

      Object {
    -   "hex": "0x01312d00",
    +   "hex": "0x00",
        "type": "BigNumber",
      }

      32 |       ]),
      33 |     );
    > 34 |     expect(BigNumber.from(block.gasLimit)).toEqual(BigNumber.from(0x1312d00));
         |                                            ^
      35 |   });
      36 | });
      37 |

      at Object.<anonymous> (packages/node/src/ethereum/ethers/celo/celo-json-rpc-batch-provider.spec.ts:34:44)


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

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

    - Expected  - 1
    + Received  + 1

      Object {
    -   "hex": "0x01312d00",
    +   "hex": "0x00",
        "type": "BigNumber",
      }

      32 |       ]),
      33 |     );
    > 34 |     expect(BigNumber.from(block.gasLimit)).toEqual(BigNumber.from(0x1312d00));
         |                                            ^
      35 |   });
      36 | });
      37 |

      at Object.<anonymous> (packages/node/src/ethereum/ethers/celo/celo-json-rpc-provider.spec.ts:34:44)


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

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

    - Expected  - 1
    + Received  + 1

      Object {
    -   "hex": "0x01312d00",
    +   "hex": "0x00",
        "type": "BigNumber",
      }

      32 |       ]),
      33 |     );
    > 34 |     expect(BigNumber.from(block.gasLimit)).toEqual(BigNumber.from(0x1312d00));
         |                                            ^
      35 |   });
      36 | });
      37 |

      at Object.<anonymous> (packages/node/src/ethereum/ethers/celo/celo-ws-provider.spec.ts:34:44)

Report generated by 🧪jest coverage report action from be66666

@stwiname
Copy link
Author

stwiname commented Sep 7, 2023

This seems to fail with Alchemy and older blocks (e.g. 0x8243343df08b9751f5ca0c5f8c9c0460d8a9b6351066fae0acbd4d3e776de8bb) but works with newer blocks

@stwiname stwiname merged commit 22f54b2 into main Sep 8, 2023
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.

[evm] handle endpoint inconsistency that may leads to lost events
3 participants