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(l1 follower): add periodic logs for L1 follower mode sync progress #1110

Merged
merged 3 commits into from
Feb 4, 2025

Conversation

jonastheis
Copy link

@jonastheis jonastheis commented Feb 4, 2025

1. Purpose or design rationale of this PR

This PR adds a periodic log message to the L1 follower mode syncing pipeline to make it easier to see syncing progress.

2. PR title

Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:

  • build: Changes that affect the build system or external dependencies (example scopes: yarn, eslint, typescript)
  • ci: Changes to our CI configuration files and scripts (example scopes: vercel, github, cypress)
  • docs: Documentation-only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that doesn't fix a bug, or add a feature, or improves performance
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • test: Adding missing tests or correcting existing tests

3. Deployment tag versioning

Has the version in params/version.go been updated?

  • This PR doesn't involve a new deployment, git tag, docker image tag, and it doesn't affect traces
  • Yes

4. Breaking change label

Does this PR have the breaking-change label?

  • This PR is not a breaking change
  • Yes

Summary by CodeRabbit

  • New Features
    • Exposed the finalized block number for improved synchronization transparency.
    • Added a new accessor to retrieve current data source information.
    • Integrated a dedicated data queue into the synchronization pipeline.
    • Introduced periodic progress logging to provide regular updates on synchronization status.
    • Updated versioning to reflect a new patch version.

Copy link

coderabbitai bot commented Feb 4, 2025

Walkthrough

The changes add new accessor methods to expose internal fields and extend interfaces across several modules. A new L1Finalized() method is now available in both the CalldataBlobSource struct and the DataSource interface, while a similar accessor, DataSource(), is provided for the DAQueue struct. Additionally, the SyncingPipeline struct has been updated with a new daQueue field that is initialized in its constructor, and its main loop now includes a ticker that periodically logs synchronization progress data. The versioning constant has also been updated.

Changes

File(s) Change Summary
rollup/da_syncer/da/calldata_blob_source.go
rollup/da_syncer/data_source.go
rollup/da_syncer/da_queue.go
Added accessor methods: L1Finalized() in the CalldataBlobSource struct and DataSource interface, as well as DataSource() in the DAQueue struct to expose internal state.
rollup/da_syncer/syncing_pipeline.go Introduced new field daQueue in SyncingPipeline, updated the constructor to initialize this field, and integrated a progress ticker in the main loop for periodic synchronization logging.
params/version.go Updated the VersionPatch constant from 2 to 3.
rollup/da_syncer/da_syncer.go Modified logging in the SyncOneBlock method to convert block hash and root to hexadecimal format.

Sequence Diagram(s)

sequenceDiagram
    participant SP as SyncingPipeline
    participant T as Ticker (1 min)
    participant DQ as DAQueue
    participant DS as DataSource

    SP->>T: Start progress ticker
    T-->>SP: Tick event received
    SP->>DQ: Call DataSource() to retrieve data source
    DQ->>DS: Return data source info (includes L1Finalized)
    DS-->>DQ: Provide L1 finalized block number
    DQ-->>SP: Return data source with L1 info
    SP->>SP: Log synchronization progress
Loading

Possibly related PRs

  • feat: follower node sync from DA #1098: The changes in the main PR, specifically the addition of the L1Finalized method to the CalldataBlobSource struct, are related to the addition of the L1Finalized() method in the DataSource interface in the retrieved PR, as both methods provide access to the finalized L1 block number, indicating a shared functionality.
  • refactor: use new da-codec interfaces #1068: The changes in the main PR, specifically the addition of the L1Finalized method to the CalldataBlobSource struct, are related to the modifications in the retrieved PR, which also involves changes to the CalldataBlobSource class, particularly in the handling of commit batch data and codec versioning.

Suggested labels

bump-version

Suggested reviewers

  • omerfirmak
  • georgehao

Poem

I'm a rabbit coding with glee,
Hopping through fields of data so free.
New getters sparkle, a queue joins the race,
Ticking and logging at a brisk pace.
With each line refined, my joy is unbound—
In code and in bytes, pure delight is found!
🐇✨

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
rollup/da_syncer/syncing_pipeline.go (1)

164-164: Consider using float64 conversion to prevent potential overflow.

The progress calculation float64(dataSource.L1Height())/float64(dataSource.L1Finalized())*100 could overflow for very large block numbers when converting to float64 sequentially.

Apply this diff to prevent potential overflow:

-				log.Info("L1 sync progress", "L1 processed", dataSource.L1Height(), "L1 finalized", dataSource.L1Finalized(), "progress(%)", float64(dataSource.L1Height())/float64(dataSource.L1Finalized())*100, "L2 height", currentBlock.Number().Uint64(), "L2 hash", currentBlock.Hash())
+				progress := 100.0 * (float64(dataSource.L1Height()) / float64(dataSource.L1Finalized()))
+				log.Info("L1 sync progress", "L1 processed", dataSource.L1Height(), "L1 finalized", dataSource.L1Finalized(), "progress(%)", progress, "L2 height", currentBlock.Number().Uint64(), "L2 hash", currentBlock.Hash())
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d2f19ff and 4af30a4.

📒 Files selected for processing (4)
  • rollup/da_syncer/da/calldata_blob_source.go (1 hunks)
  • rollup/da_syncer/da_queue.go (1 hunks)
  • rollup/da_syncer/data_source.go (1 hunks)
  • rollup/da_syncer/syncing_pipeline.go (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (4)
rollup/da_syncer/data_source.go (1)

17-17: LGTM! Interface addition is well-designed.

The new L1Finalized() method is a clean addition to expose finalized block information through the interface.

rollup/da_syncer/da_queue.go (1)

72-74: LGTM! Clean accessor implementation.

The DataSource() accessor method provides controlled access to the internal data source, which is necessary for the logging functionality.

rollup/da_syncer/da/calldata_blob_source.go (1)

88-90: LGTM! Implementation satisfies interface requirement.

The L1Finalized() method correctly implements the interface by exposing the internal finalized block number.

rollup/da_syncer/syncing_pipeline.go (1)

42-42: LGTM! Field addition and initialization are well-structured.

The daQueue field is appropriately added and initialized in the constructor.

Also applies to: 96-96

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
rollup/da_syncer/syncing_pipeline.go (1)

120-121: Consider using time.NewTicker in defer pattern.

For better resource management, consider creating and stopping the ticker in a single defer statement.

-progressTicker := time.NewTicker(1 * time.Minute)
-defer progressTicker.Stop()
+progressTicker := time.NewTicker(1 * time.Minute)
+defer func() {
+    if progressTicker != nil {
+        progressTicker.Stop()
+    }
+}()
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4af30a4 and f905b11.

📒 Files selected for processing (3)
  • params/version.go (1 hunks)
  • rollup/da_syncer/da_syncer.go (1 hunks)
  • rollup/da_syncer/syncing_pipeline.go (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (4)
rollup/da_syncer/da_syncer.go (1)

49-49: LGTM! Enhanced log readability.

The change improves log readability by converting block hash and root to hex format, making it easier to track and debug L1 sync progress.

params/version.go (1)

27-27: LGTM! Appropriate version bump.

The patch version increment is appropriate for adding new logging functionality, as it represents a backward-compatible enhancement.

rollup/da_syncer/syncing_pipeline.go (2)

42-42: LGTM! Clean integration of daQueue field.

The daQueue field is properly initialized and integrated into the SyncingPipeline struct.

Also applies to: 96-96


164-164: ⚠️ Potential issue

Prevent potential overflow in progress calculation.

The progress calculation float64(dataSource.L1Height())/float64(dataSource.L1Finalized())*100 could overflow for large block numbers. Consider casting to float64 after division.

-log.Info("L1 sync progress", "L1 processed", dataSource.L1Height(), "L1 finalized", dataSource.L1Finalized(), "progress(%)", float64(dataSource.L1Height())/float64(dataSource.L1Finalized())*100, "L2 height", currentBlock.Number().Uint64(), "L2 hash", currentBlock.Hash().Hex())
+log.Info("L1 sync progress", "L1 processed", dataSource.L1Height(), "L1 finalized", dataSource.L1Finalized(), "progress(%)", float64(dataSource.L1Height()*100)/float64(dataSource.L1Finalized()), "L2 height", currentBlock.Number().Uint64(), "L2 hash", currentBlock.Hash().Hex())

Likely invalid or redundant comment.

@Thegaram Thegaram merged commit 8ecaeec into develop Feb 4, 2025
9 checks passed
@Thegaram Thegaram deleted the jt/l1-follower-mode-add-logs branch February 4, 2025 13:02
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.

2 participants