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

Use engine API that matches hardfork version #9253

Conversation

ImTei
Copy link
Contributor

@ImTei ImTei commented Jan 30, 2024

Description

Ethereun Cancun engine API spec specifies that newPayloadV3, forkchoiceUpdatedV3 and getPayloadV3 must return Unsupported fork error if they are called before Cancun.

Erigon followed the specs, and Geth also merged PRs that check hardfork version in engine APIs last week. (ethereum/go-ethereum#28230, ethereum/go-ethereum#28246)

But the current version of op-geth does not merge upstream fix, so it always accepts V3 APIs from op-node.

I think we should adhere to the L1 engine API specs - merge upstream Geth PRs to op-geth, fix op-node and update exec-engine specs.

This PR is the draft of op-node fix.

Tests
CI will verify that every change does not affect anything. And I have manually tested the fix works with op-erigon (drop V3 API before Cancun)

@tynes
Copy link
Contributor

tynes commented Jan 30, 2024

This is a great catch, would super appreciate it if you could double check that this is represented in the specs and update there if not: https://github.com/ethereum-optimism/specs

This will greatly help alternative implementations (stage 2 roadmap)

Copy link
Contributor

coderabbitai bot commented Jan 31, 2024

Walkthrough

Walkthrough

The changes across these updates aim to standardize and enhance the handling of payload information by introducing the PayloadInfo struct with ID and Timestamp fields. This struct is now utilized in various components like GetPayload and ForkchoiceUpdate methods, replacing direct usage of PayloadID. These modifications enhance the dynamic and condition-based processing of payload information, ensuring consistency and flexibility in the system.

Changes

Files Change Summary
op-e2e/actions/l2_engine_test.go
op-e2e/op_geth.go
op-e2e/op_geth_test.go
op-program/client/l2/engine.go
op-service/testutils/mock_engine.go
Modified to use PayloadInfo struct (with ID and Timestamp) instead of direct PayloadID usage in GetPayload and related methods for standardized parameter passing.
op-node/rollup/derive/engine_controller.go
op-node/rollup/derive/engine_update.go
Updated method signatures to use PayloadInfo in place of PayloadID for improved consistency in handling payload information.
op-node/rollup/types.go Added new methods and constants related to EngineAPIVersion determination based on timestamp and configuration, enhancing version control.
op-service/eth/types.go Introduced PayloadInfo type with ID and Timestamp fields for structured payload information representation.
op-service/sources/engine_client.go ForkchoiceUpdate and GetPayload methods now dynamically select RPC methods based on payloadInfo timestamp, enabling flexible method invocation based on conditions.

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@ImTei
Copy link
Contributor Author

ImTei commented Jan 31, 2024

@tynes
I just opened a PR in specs repo! ethereum-optimism/specs#15

@ImTei
Copy link
Contributor Author

ImTei commented Jan 31, 2024

FYI, I found the new PR has been merged to upstream geth 2 days ago, which allows fcuV2 before Shanghai. This is the correct behavior to satisfy the specs, but it has yet to be released.

Current PR makes op-node work with the latest version of geth(v1.13.11).

@tynes
Copy link
Contributor

tynes commented Jan 31, 2024

FYI, I found the new PR has been merged to upstream geth 2 days ago, which allows fcuV2 before Shanghai. This is the correct behavior to satisfy the specs, but it has yet to be released.

Current PR makes op-node work with the latest version of geth(v1.13.11).

Thank you! Keeping the specs up to date is super high leverage for scaling the collective!

op-service/sources/engine_client.go Outdated Show resolved Hide resolved
op-service/sources/engine_client.go Outdated Show resolved Hide resolved
op-service/sources/engine_client.go Outdated Show resolved Hide resolved
op-service/sources/engine_client.go Outdated Show resolved Hide resolved
op-service/sources/engine_client.go Outdated Show resolved Hide resolved
op-program/client/l2/engine.go Outdated Show resolved Hide resolved
op-program/client/l2/engine.go Outdated Show resolved Hide resolved
op-program/client/l2/engine.go Outdated Show resolved Hide resolved
Copy link
Contributor

@trianglesphere trianglesphere left a comment

Choose a reason for hiding this comment

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

Could we get some test coverage for these new methods as well?

op-node/rollup/types.go Show resolved Hide resolved
@ImTei ImTei force-pushed the tip/engine-api-fork-constraint branch from 837eb71 to 649e994 Compare February 5, 2024 06:20
@ImTei
Copy link
Contributor Author

ImTei commented Feb 5, 2024

Added unit tests for new methods: 649e994

Copy link
Contributor

@trianglesphere trianglesphere left a comment

Choose a reason for hiding this comment

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

TYVM for finding and fixing this issue.

@trianglesphere trianglesphere added this pull request to the merge queue Feb 5, 2024
Merged via the queue into ethereum-optimism:develop with commit c0d0db9 Feb 5, 2024
55 checks passed
@trianglesphere trianglesphere deleted the tip/engine-api-fork-constraint branch February 5, 2024 18:13
spacesailor24 pushed a commit that referenced this pull request Feb 6, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
spacesailor24 pushed a commit that referenced this pull request Feb 7, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
spacesailor24 pushed a commit that referenced this pull request Feb 7, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
spacesailor24 pushed a commit that referenced this pull request Feb 7, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
spacesailor24 pushed a commit that referenced this pull request Feb 7, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
spacesailor24 pushed a commit that referenced this pull request Feb 7, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
spacesailor24 pushed a commit that referenced this pull request Feb 8, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
spacesailor24 pushed a commit that referenced this pull request Feb 8, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
spacesailor24 pushed a commit that referenced this pull request Feb 8, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
spacesailor24 pushed a commit that referenced this pull request Feb 8, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
spacesailor24 pushed a commit that referenced this pull request Feb 8, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
spacesailor24 pushed a commit that referenced this pull request Feb 8, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
spacesailor24 pushed a commit that referenced this pull request Feb 8, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
spacesailor24 pushed a commit that referenced this pull request Feb 8, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
spacesailor24 pushed a commit that referenced this pull request Feb 8, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
spacesailor24 pushed a commit that referenced this pull request Feb 9, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
spacesailor24 pushed a commit that referenced this pull request Feb 9, 2024
* Use engine API that matches HF

* Simplify engine client code by using EngineAPIVersion

* Return full method string from engine api version methods

* FCUVersion takes payload attributes

* Use a proper method

* Handle switch default case explicitly

* Return fcuV3 if attrs is nil

* Add test cases for engine api version methods
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

3 participants