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

make l1.beacon-archiver work #10269

Merged
merged 8 commits into from
May 20, 2024

Conversation

zhiqiangxu
Copy link
Contributor

CL will return empty array if blob expired. (source)

This PR makes l1.beacon-archiver actually work.

@zhiqiangxu zhiqiangxu requested a review from a team as a code owner April 23, 2024 13:00
@zhiqiangxu zhiqiangxu requested a review from Inphi April 23, 2024 13:00
Copy link
Contributor

coderabbitai bot commented Apr 23, 2024

Walkthrough

Walkthrough

The recent updates across the codebase enhance the functionality of the L1BeaconClient in the op-service by ensuring data integrity and handling specific conditions during sidecar and blob retrieval. Additionally, mock implementations for HTTP interactions were introduced to facilitate testing, along with a new test function to verify the HTTP client's functionality for beacon sidecars.

Changes

Files Change Summaries
op-service/sources/l1_beacon_client.go Added conditions to check response data length and match the number of requested blobs. Updated methods to handle specific conditions.
op-service/client/mocks/HTTP.go Introduced autogenerated mock types and functions for HTTP interactions, including methods for mocking HTTP GET requests.
op-service/sources/l1_beacon_client_test.go Added imports and a new test function TestBeaconHTTPClient to test the HTTP client functionality for beacon sidecars.

Recent Review Details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 95bc82f and 418f648.
Files selected for processing (1)
  • op-service/sources/l1_beacon_client_test.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • op-service/sources/l1_beacon_client_test.go

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-service/sources/l1_beacon_client.go (1)

212-212: Add a comment explaining the new condition for checking if the response data length is zero.

Adding a comment here will help maintain the code's readability and make it easier for future developers to understand the reason behind this condition.

@geoknee
Copy link
Contributor

geoknee commented Apr 23, 2024

How about other CL clients? The spec doesn't seem to mention this behaviour https://ethereum.github.io/beacon-APIs/#/Beacon/getBlobSidecars

@sebastianst
Copy link
Member

I would also expect a 404 on an expired blob?

@trianglesphere
Copy link
Contributor

Prysm does seem to be returning 200 ok with an empty list. What do other clients do / can we have them become spec compliant?

@zhiqiangxu
Copy link
Contributor Author

zhiqiangxu commented Apr 24, 2024

Prysm does seem to be returning 200 ok with an empty list. What do other clients do / can we have them become spec compliant?

It seems both Prysm and Lighthouse do the same currently. Before the change happens, we'll need this PR to make it work as expected.

Copy link
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label May 12, 2024
@geoknee geoknee removed the Stale label May 12, 2024
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: 1

op-service/sources/l1_beacon_client.go Outdated Show resolved Hide resolved
Copy link
Member

@sebastianst sebastianst left a comment

Choose a reason for hiding this comment

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

Per spec, a valid Beacon API should return a 404 error if a blob is not found. What beacon api service shows behavior that is fixed by this PR?

Also note that we cannot make this check here in general, because if we use the fetchAllSidecars option, at this point there will in general be more sidecars than the number of hashes. The filtering is then happening in L1BeaconClient.GetBlobSidecars, which should also eventually return an error if no sidecars were returned, because it makes a length check after the filtering.

@sebastianst
Copy link
Member

Asked in a lighthouse issue if this behavior is intentional.

Copy link
Member

@sebastianst sebastianst left a comment

Choose a reason for hiding this comment

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

This looks good! Suggesting a few minor improvements. Please also add a test for this case.

op-service/sources/l1_beacon_client.go Outdated Show resolved Hide resolved
op-service/sources/l1_beacon_client.go Outdated Show resolved Hide resolved
op-service/sources/l1_beacon_client.go Show resolved Hide resolved
@zhiqiangxu
Copy link
Contributor Author

I tried to add a new testcase for the change of BeaconBlobSideCars, but it seems the BeaconBlobSideCars is mocked as a whole, and there's no way to test for this mocked function?

@sebastianst
Copy link
Member

I tried to add a new testcase for the change of BeaconBlobSideCars, but it seems the BeaconBlobSideCars is mocked as a whole, and there's no way to test for this mocked function?

@zhiqiangxu I see... I think it would be a new unit test for BeaconHTTPClient where you pass a mock client.HTTP (there's hopefully already a mock for this available) to NewBeaconHTTPClient and then set it up to return a 200 with empty list on a request, and assert that it then returns an error instead of the empty list.

There are (implicit) tests of the BeaconHTTPClient in op-e2e/l1_beacon_client_test.go but I think some direct unit tests of BeaconHTTPClient would be much better.

@zhiqiangxu
Copy link
Contributor Author

I tried to add a new testcase for the change of BeaconBlobSideCars, but it seems the BeaconBlobSideCars is mocked as a whole, and there's no way to test for this mocked function?

@zhiqiangxu I see... I think it would be a new unit test for BeaconHTTPClient where you pass a mock client.HTTP (there's hopefully already a mock for this available) to NewBeaconHTTPClient and then set it up to return a 200 with empty list on a request, and assert that it then returns an error instead of the empty list.

There are (implicit) tests of the BeaconHTTPClient in op-e2e/l1_beacon_client_test.go but I think some direct unit tests of BeaconHTTPClient would be much better.

Done, and there's unfortunately no such a mock for client.HTTP so I pushed one .

@sebastianst sebastianst added this pull request to the merge queue May 20, 2024
Merged via the queue into ethereum-optimism:develop with commit 7ef1bcf May 20, 2024
70 of 72 checks passed
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

5 participants