Skip to content

fix(taiko-client): only update the lookahead once per epoch #19483

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

Merged
merged 5 commits into from
May 19, 2025

Conversation

cyberhorsey
Copy link
Contributor

if a slot is late and we update the lookahead at slotInEpoch 0, it can be the same as a missed slot - the beacon chain will not update properly and the current/next operators from the contract will not roll over correctly. This will lead to incorrectly adding slot ranges for a sequencer whos not the active sequencer.

Instead, we grab a safe slot - any slot past 16 is fine, mid-epoch it will not change, since we have a delayed whitelist implementation as well. Then on every slot tick, we just emit logs instead, and only update once-per-epoch.

This is fine because we also update the current ranges for the next operator when we update the lookahead already.

IE: if CurrentOperator owns epoch 0 (slots 0-31), and the NextOperator will own epoch 1 (slots 32-63), when we pull down the NextOperator during epoch 0, we update the CurrentRanges for that address already. This is the advantage of "global slot based lookahead sequencing" instead of just using the current/nextoperator - we don't care about missed slots, and now with this fix, we also don't care about late slots at the epoch boundaries.

Copy link

codecov bot commented May 18, 2025

Codecov Report

Attention: Patch coverage is 0% with 57 lines in your changes missing coverage. Please review.

Project coverage is 32.46%. Comparing base (140ec4d) to head (7b4bf50).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
packages/taiko-client/driver/driver.go 0.00% 52 Missing ⚠️
...kages/taiko-client/driver/preconf_blocks/server.go 0.00% 5 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
...es/taiko-client/driver/preconf_blocks/lookahead.go 100.00% <ø> (ø)
...kages/taiko-client/driver/preconf_blocks/server.go 10.33% <0.00%> (-0.07%) ⬇️
packages/taiko-client/driver/driver.go 15.33% <0.00%> (-1.51%) ⬇️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 140ec4d...7b4bf50. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@davidtaikocha davidtaikocha enabled auto-merge May 19, 2025 00:56
@davidtaikocha davidtaikocha requested a review from Copilot May 19, 2025 00:57
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures the lookahead is only updated once per epoch by deferring updates until a safe mid-epoch slot and emitting logs on other ticks.

  • Added GetLookahead for mutex-protected read access to the shared lookahead
  • Extended Lookahead with LastEpochUpdated to track when the last update occurred
  • Changed cacheLookaheadLoop to update lookahead only once per epoch at slot ≥15 and log on all other slots

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
server/preconf_blocks/server.go Added GetLookahead() with mutex and left UpdateLookahead() unprotected
driver/preconf_blocks/lookahead.go Added LastEpochUpdated field to Lookahead
driver/driver.go Modified cacheLookaheadLoop() to conditionally update lookahead once per epoch and log otherwise

@davidtaikocha davidtaikocha added this pull request to the merge queue May 19, 2025
Merged via the queue into main with commit 5c32d6a May 19, 2025
9 checks passed
@davidtaikocha davidtaikocha deleted the lookahead_late_slot_fix branch May 19, 2025 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants