optimism icon indicating copy to clipboard operation
optimism copied to clipboard

fix(op-node): derive a finalized hash on `ELSync` when sync status is `syncStatusFinishedELButNotFinalized`

Open joshieDo opened this issue 10 months ago • 3 comments

The current implementation of EL sync provides an unsafe head for the EL to facilitate catch-up, with the expectation that it handles any resulting reorganizations.

However, once the EL is caught up and while CL sync demands a finalized state, the next FCU is assigned a finalized hash that matches the unsafe one. Although the likelihood of issues arising from this is low, it is technically incorrect behavior. If a reorg occurs, it could be irreversible for the EL, given that finalized hashes are not expected to be reversible.

Additionally, op-node only uses ELSync if there are no finalized blocks in the EL; otherwise, it switches to CLSync. However, in scenarios such as a node restart after a week, it is still preferable from the EL's perspective to initiate EL sync. By enabling the derivation of a genuine finalized hash, we can eliminate this constraint and avoid the risk associated with treating an unsafe hash as finalized on every restart.

joshieDo avatar Apr 09 '24 14:04 joshieDo

[!IMPORTANT]

Auto Review Skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

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 09 '24 14:04 coderabbitai[bot]

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

@trianglesphere Can we follow up with the reth team on next steps here? They are blocked and are not sure how to proceed

tynes avatar May 08 '24 16:05 tynes

@trianglesphere this has been handled via a different PR correct? So we can close this?

tynes avatar May 16 '24 13:05 tynes

@tynes @joshieDo, yes handling the genesis case of finalization has been fixed. The op-node still immediately finalizes.

trianglesphere avatar May 16 '24 18:05 trianglesphere

Closing this then, thanks @trianglesphere

tynes avatar May 16 '24 19:05 tynes

op-reth does not use snap sync elsync mode from op-node triggers a staged-sync style on op-reth. this is just an optimized way of executing large ranges of blocks (eg. from genesis to unsafe.)

op-node requires that if a L2 block is marked as finalized, the EL client has the full state available at the block.

Seems to me this is related to capability of the EL to be able to build a block from a block marked as finalized in the event of a safe/unsafe reorg/invalidation. Is the interpretation correct? If so, op-reth can do it.

In your PR, you walk back from a block which has the full state available to a block which may not have the full state available.

if by available means: can EL re-execute from the block that got marked as finalized - then yes op-reth can do it from the block we traverse back.to

given the above, would this be acceptable? if op-reth { traverse back method } else { as is currently }

joshieDo avatar May 17 '24 15:05 joshieDo