Skip to content

fix(bridge-history): commit batch txns and blobs fetching #1689

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

Conversation

colinlyguo
Copy link
Member

@colinlyguo colinlyguo commented Jul 3, 2025

Purpose or design rationale of this PR

This PR adds a timeout when fetching commit batch txns and blobs, it also avoids fetching the same transaction multiple times.

This PR adds two debug logs for easier debugging.

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:

  • fix: A bug fix

Deployment tag versioning

Has tag in common/version.go been updated or have you added bump-version label to this PR?

  • Yes

Breaking change label

Does this PR have the breaking-change label?

  • No, this PR is not a breaking change

Summary by CodeRabbit

  • Improvements

    • Enhanced performance and reliability when processing batch event logs by introducing caching and timeout mechanisms.
    • Improved visibility with additional debug logging for transaction and blob processing.
  • Chores

    • Updated version to v4.5.26.

Copy link

coderabbitai bot commented Jul 3, 2025

Walkthrough

The changes update the version tag to "v4.5.26" and enhance the ParseL1BatchEventLogs method by introducing transaction caching, timeout contexts for RPC and blob processing, and additional debug logging. No modifications are made to the signatures of exported entities or the core event parsing logic.

Changes

File(s) Change Summary
bridge-history-api/internal/logic/l1_event_parser.go Added caching for transactions, 10s/20s timeout contexts for RPC/blob operations, and debug logs.
common/version/version.go Updated version tag from "v4.5.25" to "v4.5.26".

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant L1EventParser
    participant RPCClient
    participant BlobProcessor

    Caller->>L1EventParser: ParseL1BatchEventLogs(logs)
    loop For each log
        L1EventParser->>L1EventParser: Check cached transaction
        alt Cache miss
            L1EventParser->>RPCClient: Fetch transaction (10s timeout)
            RPCClient-->>L1EventParser: Transaction data
        end
        L1EventParser->>BlobProcessor: Process blob (20s timeout)
        BlobProcessor-->>L1EventParser: Blob data
    end
    L1EventParser-->>Caller: Parsed events
Loading

Possibly related PRs

Suggested labels

bump-version

Suggested reviewers

  • Thegaram
  • georgehao

Poem

A hop, a skip, a version hop—
Now v4.5.26 is at the top!
With timeouts and caching, logs parse with grace,
Transactions fetched at a rabbit's pace.
Debug logs sparkle, the code runs free,
Another leap for Scroll's history! 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (1.64.8)

level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package zstd: could not load export data: no export data for "github.com/scroll-tech/da-codec/encoding/zstd""
level=error msg="Running error: can't run linter goanalysis_metalinter\nbuildir: failed to load package zstd: could not load export data: no export data for "github.com/scroll-tech/da-codec/encoding/zstd""


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b8909d3 and 5499dcc.

📒 Files selected for processing (2)
  • bridge-history-api/internal/logic/l1_event_parser.go (4 hunks)
  • common/version/version.go (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
bridge-history-api/internal/logic/l1_event_parser.go (1)
Learnt from: colinlyguo
PR: scroll-tech/scroll#1530
File: rollup/internal/controller/watcher/batch_proposer.go:291-294
Timestamp: 2024-10-20T16:13:20.397Z
Learning: In `batch_proposer.go`, it's acceptable to call `utils.CalculateBatchMetrics` multiple times within the loop because the batch's chunks are increasing in the loop, and each calculation reflects the updated batch state.
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: test
🔇 Additional comments (6)
common/version/version.go (1)

8-8: Version bump looks appropriate.

The version update from v4.5.25 to v4.5.26 correctly reflects the bug fix nature of this PR, aligning with the improvements made to the batch transaction and blob fetching process.

bridge-history-api/internal/logic/l1_event_parser.go (5)

7-7: Import addition is correct.

The time import is properly added to support the timeout contexts introduced in the function.


257-259: Transaction caching implementation is well-designed.

The caching variables are appropriately declared to store the last fetched transaction, enabling efficient reuse and preventing redundant RPC calls as intended.


272-290: Excellent implementation of transaction caching and timeout handling.

The code properly implements:

  • Transaction caching to avoid redundant fetches when processing multiple events from the same transaction
  • A 10-second timeout context to prevent hanging operations
  • Debug logging for better observability
  • Proper error handling and context cleanup

The caching logic correctly compares transaction hashes and updates the cache after successful fetches.


331-336: Blob processing timeout is properly implemented.

The addition of a 20-second timeout context for blob processing is a good practice that prevents potential hanging operations. The debug logging provides valuable visibility into the blob processing workflow, and the context is properly canceled to prevent resource leaks.


241-399: Overall implementation successfully addresses all PR objectives.

The changes to ParseL1BatchEventLogs effectively implement:

  • ✅ Timeout mechanisms (10s for transactions, 20s for blobs) to prevent hanging operations
  • ✅ Transaction caching to avoid redundant fetches of the same transaction
  • ✅ Debug logging for improved observability and debugging
  • ✅ Proper error handling and resource cleanup
  • ✅ Backward compatibility with existing functionality

The implementation is robust, well-structured, and aligns perfectly with the stated PR objectives.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

@codecov-commenter
Copy link

Codecov Report

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

Project coverage is 39.81%. Comparing base (b7a172a) to head (5499dcc).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...idge-history-api/internal/logic/l1_event_parser.go 0.00% 30 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1689      +/-   ##
===========================================
- Coverage    39.86%   39.81%   -0.06%     
===========================================
  Files          236      236              
  Lines        18808    18832      +24     
===========================================
  Hits          7498     7498              
- Misses       10575    10599      +24     
  Partials       735      735              
Flag Coverage Δ
bridge-history-api 8.08% <0.00%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@colinlyguo colinlyguo merged commit a0ee508 into develop Jul 3, 2025
6 checks passed
@colinlyguo colinlyguo deleted the fix-bridge-history-commit-batch-txns-and-blobs-fetching branch July 3, 2025 17:50
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.

4 participants