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

op-node: batch-decoder: Support ecotone #10577

Conversation

pcw109550
Copy link
Contributor

@pcw109550 pcw109550 commented May 17, 2024

Description

From ecotone, batches may written to blobs.

Now batch decoder can read blob transactions and parse channel frames, updating fetch command. Previously the batch decoder code assumed that single batch tx contained single channel frames. This PR updates TransactionWithMetadata struct to support multiple frames from blobs.

New optional flag: --l1.beacon. If this flag is not provided, ignore blobs in batch transactions.

Tests

Manually tested.

  • Post ecotone batches are decoded correctly when --l1.beacon is set.
  • Pre ecotone batches are decoded correctly w/wo --l1.beacon.
  • Post ecotone batches are ignored when --l1.beacon is not set.
  • Early return when --l1.beacon is incorrectly set.

Example command for op-mainnet:

go run main.go fetch --start=19887269 --end=19887509 --inbox 0xFF00000000000000000000000000000000000010 --out ./artifacts/op-mainnet/transactions_cache --sender 0x6887246668a3b87F54DeB3b94Ba47a6f63F32985 --l1=[L1] --l1.beacon=[L1_BEACON]

Partial output:

Fetched batches in range [19887269,19887509). Found 5 valid & 6 invalid batches
Fetch Config: Chain ID: 1. Inbox Address: 0xFF00000000000000000000000000000000000010. Valid Senders: map[0x6887246668a3b87F54DeB3b94Ba47a6f63F32985:{}].
Wrote transactions with batches to ./artifacts/op-mainnet/transactions_cache

Where those five batches are from consecutive five ecotone batches:

@pcw109550 pcw109550 requested a review from a team as a code owner May 17, 2024 09:42
Copy link
Contributor

coderabbitai bot commented May 17, 2024

Walkthrough

Walkthrough

The recent changes introduce significant enhancements to the batch_decoder functionality in the op-node project. Key updates include the addition of new imports, modifications to the TransactionWithMetadata struct, and updates to function signatures to incorporate a new L1BeaconClient for handling blob transactions. Additionally, the main.go file has been updated to support a new l1.beacon flag, create a L1BeaconClient, and adapt the Batches function to utilize this new client.

Changes

File Path Change Summary
op-node/cmd/batch_decoder/fetch/fetch.go Added imports for eth, sources, and hexutil. Updated TransactionWithMetadata struct. Modified Batches and fetchBatchesPerBlock function signatures to include beacon parameter. Added handling for blob transactions using L1 Beacon API.
op-node/cmd/batch_decoder/main.go Added imports for client and sources. Introduced l1.beacon flag. Created L1BeaconClient and updated Batches function to use it. Renamed client variable to l1Client and added conditional logic for l1.beacon address handling.

Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 943ed0f and 582f3e1.
Files selected for processing (2)
  • op-node/cmd/batch_decoder/fetch/fetch.go (9 hunks)
  • op-node/cmd/batch_decoder/main.go (3 hunks)
Additional comments not posted (7)
op-node/cmd/batch_decoder/fetch/fetch.go (3)

15-18: Added imports for eth, sources, and hexutil are appropriate for the new functionality.


34-35: The change from single fields to slices in TransactionWithMetadata struct allows handling multiple frames, aligning with the PR's objective to support ecotone.


Line range hint 51-67: The updated Batches function now includes a beacon parameter to handle blob transactions. Ensure that all calls to this function are updated to pass the new parameter.

Verification successful

Verification of Batches Function Call Update

The call to the Batches function in op-node/cmd/batch_decoder/main.go has been correctly updated to include the new beacon parameter.

  • File: op-node/cmd/batch_decoder/main.go
    • Line: totalValid, totalInvalid := fetch.Batches(l1Client, beacon, config)

This confirms that the necessary update has been made.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all function calls to `Batches` include the new `beacon` parameter.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go $'Batches'

Length of output: 43931

op-node/cmd/batch_decoder/main.go (4)

15-16: Added imports for client and sources are necessary for the new L1 Beacon client functionality.


62-67: Introduction of the l1.beacon flag is consistent with the PR's objective to optionally use the L1 Beacon node. The flag is optional, aligning with the functionality described.


75-97: The initialization of beacon based on the l1.beacon flag is correctly implemented. Error handling in the initialization could be improved by not using log.Fatal for a more graceful shutdown process.

- log.Fatal(fmt.Errorf("failed to check L1 Beacon API version: %w", err))
+ log.Printf("failed to check L1 Beacon API version: %v", err)
+ return err
Skipped due to learnings
User: tynes
PR: ethereum-optimism/optimism#8778
File: op-node/node/node.go:296-309
Timestamp: 2024-01-03T22:46:08.123Z
Learning: The error message in the `initL1BeaconAPI` function within `node.go` should reference the L1 beacon client setup, not the L2 execution-engine RPC client.

109-109: Ensure that the Batches function is called with the correct parameters, including the potentially uninitialized beacon when the l1.beacon flag is not set. This is handled correctly as per the changes.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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
Contributor

@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

Out of diff range and nitpick comments (1)
op-node/cmd/batch_decoder/fetch/fetch.go (1)

Line range hint 83-191: Significant changes in fetchBatchesPerBlock to handle blob transactions based on the presence of the beacon client. The logic to handle different transaction types and errors is well-structured. However, consider handling errors without terminating the program using log.Fatal to allow more graceful error handling and recovery.

- log.Fatal(fmt.Errorf("failed to fetch blobs: %w", err))
+ log.Printf("failed to fetch blobs: %v", err)
+ return 0, 0, err

@trianglesphere trianglesphere added this pull request to the merge queue May 17, 2024
Merged via the queue into ethereum-optimism:develop with commit 7d92f41 May 17, 2024
65 checks passed
rdovgan pushed a commit to rdovgan/optimism that referenced this pull request Jun 24, 2024
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.

None yet

2 participants