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

refactor: flush logic #89

Merged
merged 3 commits into from
May 1, 2024
Merged

refactor: flush logic #89

merged 3 commits into from
May 1, 2024

Conversation

joelsmith-2019
Copy link
Contributor

Overview

This PR refactors the flush mechanisms for both noble and ethereum-based chains. Flushes will no longer look back a lookbackPeriod all the way up until the chain tip. There will now be a minimum gap of lookbackPeriod between the last flushed block and the chain tip. This ensures that transactions currently being processed will not get picked up again via the flush.

New flush logic

First Flush
startBlock = currentHeight - (2 * lookbackPeriod)
finishBlock = currentHeight - lookbackPeriod

Genesis                        Start      Finish      Tip
|--------------------------------|----------|----------|

Subsequent Flushes
startBlock = last flushed block
finishBlock = currentHeight - lookbackPeriod

Genesis                                   Start      Finish      Tip
|-------------------------------------------|----------|----------|

Note: StartBlock corresponds to which block the flush should start on. FinishBlock corresponds to which block the flush should end on. There will always be a gap of lookbackPeriod between tip and finish.

How to Configure

For best results and coverage, the lookback period in blocks should correspond to the flush interval. If a chain produces 1 block a second and the flush interval is set to 30 minutes (1800 seconds), the lookback period should be at least 1800 blocks. When in doubt, round up and add a small buffer.

Examples

Consider a 30 minute flush interval (1800 seconds)

  • Ethereum: 12 second blocks = (1800 / 12) = 150 blocks
  • Polygon: 2 second blocks = (1800 / 2) = 900 blocks
  • Arbitrum: 0.26 second blocks = (1800 / 0.26) = ~6950 blocks

@joelsmith-2019 joelsmith-2019 self-assigned this May 1, 2024
@joelsmith-2019
Copy link
Contributor Author

Still need to update the README.md.

@joelsmith-2019 joelsmith-2019 marked this pull request as ready for review May 1, 2024 18:19
Copy link
Contributor

@Reecepbcups Reecepbcups left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the call on this. helped clear up my questions re: circle <-> relayer check flows

Copy link
Member

@jtieri jtieri left a comment

Choose a reason for hiding this comment

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

this is a nice refactor, I really like the updates to the docs/comments as well

ethereum/listener.go Outdated Show resolved Hide resolved
@joelsmith-2019 joelsmith-2019 merged commit 580a328 into main May 1, 2024
6 checks passed
@joelsmith-2019 joelsmith-2019 deleted the joel/flush-refactor branch May 1, 2024 21:10
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