Skip to content

feat: catchup l1 head on start#3594

Merged
rodrodros merged 7 commits into
mainfrom
feat/catchup-l1-head-on-start
May 7, 2026
Merged

feat: catchup l1 head on start#3594
rodrodros merged 7 commits into
mainfrom
feat/catchup-l1-head-on-start

Conversation

@EgeCaner
Copy link
Copy Markdown
Contributor

@EgeCaner EgeCaner commented May 1, 2026

Previously, the L1 client only subscribed to live LogStateUpdate events on startup. After downtime, this left Juno running with a stale L1 head until the next on-chain update was emitted, which can take hours on Starknet.

This PR catches up the L1 head on start by issuing a backward eth_getLogs scan over the core contract before subscribing. The catch-up is best-effort: free-tier RPC providers might cap range size or rate-limit, so on failure we log a warning and fall through to the live subscription rather than terminating.

Changes

  • Added catchUpL1HeadUpdates running once before watchL1StateUpdates in Client.Run
  • Added eth_getLogs query for the core contract's LogStateUpdate
  • Refactored Client construction to use functional options

@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

❌ Patch coverage is 56.52174% with 60 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.73%. Comparing base (0b15c38) to head (55bae28).

Files with missing lines Patch % Lines
l1/contract/starknet_filter.go 0.00% 28 Missing ⚠️
l1/eth_subscriber.go 0.00% 15 Missing ⚠️
l1/l1.go 84.78% 11 Missing and 3 partials ⚠️
node/node.go 0.00% 3 Missing ⚠️

❌ Your patch check has failed because the patch coverage (56.52%) is below the target coverage (60.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3594      +/-   ##
==========================================
- Coverage   75.80%   75.73%   -0.07%     
==========================================
  Files         381      382       +1     
  Lines       34377    34487     +110     
==========================================
+ Hits        26059    26119      +60     
- Misses       6492     6540      +48     
- Partials     1826     1828       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@EgeCaner EgeCaner requested a review from rodrodros May 4, 2026 12:59
@EgeCaner EgeCaner force-pushed the feat/catchup-l1-head-on-start branch from 38a6b64 to 422c7da Compare May 5, 2026 12:50
Copy link
Copy Markdown
Contributor

@thiagodeev thiagodeev left a comment

Choose a reason for hiding this comment

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

Nice work! LGTM.
Just a few nitpicks

Comment thread l1/l1_test.go Outdated
Comment thread l1/l1_pkg_test.go
Comment thread l1/l1.go
Comment thread l1/l1.go Outdated
@EgeCaner EgeCaner force-pushed the feat/catchup-l1-head-on-start branch from f552a90 to 55bae28 Compare May 7, 2026 15:34
@rodrodros
Copy link
Copy Markdown
Contributor

Bypassing coverage rule because missing tests will be add in a follow up

@rodrodros rodrodros merged commit 3960892 into main May 7, 2026
24 of 25 checks passed
@rodrodros rodrodros deleted the feat/catchup-l1-head-on-start branch May 7, 2026 18:12
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