Skip to content

feat(l2): enhance monitor performance #3757

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 4 commits into from
Jul 24, 2025
Merged

Conversation

gianbelinche
Copy link
Contributor

Motivation
If a sequencer runs for a long time, it stops, and we run it again activating the monitor, it takes a long time to start and is slow.

Description
Makes the monitor load and work faster by simplifying the batches processing.

How to Test

  • Run a Sequencer (I suggest make restart in crates/l2).
  • Run the prover with make init-prover in crates/l2.
  • Let the sequencer ran for some time (at least 60 batches)
  • Kill the sequencer
  • Add --monitor to the init-l2-no-metrics target in crates/l2/Makefile.
  • Run make init-l2-no-metrics

@Copilot Copilot AI review requested due to automatic review settings July 21, 2025 19:25
@gianbelinche gianbelinche requested a review from a team as a code owner July 21, 2025 19:25
@github-actions github-actions bot added the L2 Rollup client label Jul 21, 2025
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 enhances monitor performance by optimizing how batches are processed and refreshed. The changes focus on reducing redundant database queries and improving startup time when restarting a sequencer with monitor enabled after it has been running for an extended period.

  • Optimizes batch refresh logic to only fetch incomplete batches instead of all batches
  • Limits the number of batches fetched by introducing a 50-batch window from the latest batch
  • Refactors batch processing into smaller, more focused functions for better maintainability
Comments suppressed due to low confidence (1)

crates/l2/monitor/widget/batches.rs:146

  • This is another instance where a type alias for the batch tuple would improve maintainability and reduce code duplication of clippy suppressions.
    #[expect(clippy::type_complexity)]

Copy link

github-actions bot commented Jul 21, 2025

Lines of code report

Total lines added: 24
Total lines removed: 0
Total lines changed: 24

Detailed view
+--------------------------------------------+-------+------+
| File                                       | Lines | Diff |
+--------------------------------------------+-------+------+
| ethrex/crates/l2/monitor/widget/batches.rs | 188   | +22  |
+--------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/errors.rs       | 326   | +2   |
+--------------------------------------------+-------+------+

@gianbelinche gianbelinche added this pull request to the merge queue Jul 24, 2025
Merged via the queue into main with commit df3a9bd Jul 24, 2025
23 checks passed
@gianbelinche gianbelinche deleted the monitor-performance branch July 24, 2025 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L2 Rollup client
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants