optimism icon indicating copy to clipboard operation
optimism copied to clipboard

make `l1.beacon-archiver` work

Open zhiqiangxu opened this issue 1 year ago • 6 comments

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

This PR makes l1.beacon-archiver actually work.

zhiqiangxu avatar Apr 23 '24 13:04 zhiqiangxu

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 95bc82f9612445e0c444e90407f88ae65dac098a and 418f6487499fac71b9e8affa8831dea7a53f2e13.
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.

coderabbitai[bot] avatar Apr 23 '24 13:04 coderabbitai[bot]

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

geoknee avatar Apr 23 '24 16:04 geoknee

I would also expect a 404 on an expired blob?

sebastianst avatar Apr 23 '24 20:04 sebastianst

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

trianglesphere avatar Apr 24 '24 00:04 trianglesphere

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.

zhiqiangxu avatar Apr 24 '24 01:04 zhiqiangxu

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[bot] avatar May 12 '24 01:05 github-actions[bot]

Asked in a lighthouse issue if this behavior is intentional.

sebastianst avatar May 17 '24 09:05 sebastianst

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 avatar May 17 '24 12:05 zhiqiangxu

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.

sebastianst avatar May 17 '24 13:05 sebastianst

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 .

zhiqiangxu avatar May 17 '24 14:05 zhiqiangxu