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

feat: fetch complete block numbers & ignore false positive error #52

Merged
merged 5 commits into from
Jan 9, 2025

Conversation

0xnigir1
Copy link
Collaborator

@0xnigir1 0xnigir1 commented Jan 9, 2025

🤖 Linear

Closes GIT-228

Description

Some strategies throw false positive errors for the TimestampUpdated event because on contract init, it emit the events before the PoolCreated event (all in the same transaction). This causes that the TimestampUpdated handler doesn't find the Pool and throw an error, however this is expected behaviour (from contract's perspective).
To circumvent this, we need to have more events context to determine if the error was thrown on this edge case or is a real error. So we update the Indexer Client to:

  • fetch complete blocks (meaning, the client doesn't split events from the same block in different batches, in particular for the last block of the batch)
  • we keep a map of all events for each block number, so we have an "extended" context on the Orchestrator and see if afterwards we have a PoolCreated event

Checklist before requesting a review

  • I have conducted a self-review of my code.
  • I have conducted a QA.
  • If it is a core feature, I have included comprehensive tests.

@0xnigir1 0xnigir1 requested review from jahabeebs and 0xyaco January 9, 2025 13:23
@0xnigir1 0xnigir1 self-assigned this Jan 9, 2025
Copy link

linear bot commented Jan 9, 2025

Copy link
Collaborator

@0xyaco 0xyaco left a comment

Choose a reason for hiding this comment

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

Left some minor code style comments.

More importantly, I've got a business logic question just to be super sure:

Are the ignored TimestampsUpdated events skipped forever? Do they need to be reprocessed somehow in the future?

packages/data-flow/src/orchestrator.ts Outdated Show resolved Hide resolved
packages/data-flow/src/orchestrator.ts Outdated Show resolved Hide resolved
@0xnigir1 0xnigir1 requested a review from 0xyaco January 9, 2025 18:52
Copy link
Collaborator

@jahabeebs jahabeebs left a comment

Choose a reason for hiding this comment

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

Good just some smol comments

@@ -10,13 +13,11 @@ export interface IEventsFetcher {
* @param chainId id of the chain
* @param blockNumber block number to fetch events from
* @param logIndex log index in the block to fetch events from
* @param limit limit of events to fetch
* @param limit limit of events to fetch\
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hanging backslash

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will fix in another PR the typo

*/
private async getTotalEventsInBlock(
chainId: ChainId,
blockNumber: number,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we wanting to use the {} syntax for just if there are 3+ params?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we have to define our standard but given this is a private method, i wouldn't be so strict on the option, probably for public methods or interfaces is more important to follow the standard of {}

@0xnigir1 0xnigir1 merged commit 1f95d53 into dev Jan 9, 2025
6 checks passed
@0xnigir1 0xnigir1 deleted the feat/fetch-complete-blocks branch January 9, 2025 23:42
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