Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.

fix(supervisor/rpc): localUnsafe always points to genesis#2145

Merged
dhyaniarun1993 merged 7 commits intoop-rs:mainfrom
varun-doshi:varun/unsafe-ref
Jun 17, 2025
Merged

fix(supervisor/rpc): localUnsafe always points to genesis#2145
dhyaniarun1993 merged 7 commits intoop-rs:mainfrom
varun-doshi:varun/unsafe-ref

Conversation

@varun-doshi
Copy link
Copy Markdown
Contributor

Ref #2136

@codecov
Copy link
Copy Markdown

codecov bot commented Jun 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.2%. Comparing base (d98d25f) to head (f939489).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@varun-doshi varun-doshi marked this pull request as ready for review June 15, 2025 07:08
Copilot AI review requested due to automatic review settings June 15, 2025 07:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue with the localUnsafe pointer by updating the safety head reference to the correct block rather than defaulting to genesis. The key changes include:

  • Updating the state manager with the safety head reference using SafetyLevel::Unsafe.
  • Adding corresponding error logging for failures.
  • Including a new test case to validate the update of the safety head reference.
Comments suppressed due to low confidence (1)

crates/supervisor/core/src/chain_processor/task.rs:238

  • [nitpick] The use of an underscore prefix in '_safety_level' typically indicates an unused variable. Since it is actively being compared, consider renaming it to 'safety_level' for clarity.
assert_eq!(_safety_level, SafetyLevel::Unsafe);

chain_id = self.chain_id,
block_number = block_info.number,
%err,
"Failed to store block reference"
Copy link

Copilot AI Jun 15, 2025

Choose a reason for hiding this comment

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

The error message 'Failed to store block reference' may be confusing since the call is updating the safety head reference. Consider revising the message to better reflect the context of the update.

Suggested change
"Failed to store block reference"
"Failed to update safety head reference"

Copilot uses AI. Check for mistakes.
@emhane emhane added A-rpc Area: rpc W-supervisor Workstream: supervisor A-db Area: database labels Jun 16, 2025
@emhane
Copy link
Copy Markdown
Contributor

emhane commented Jun 16, 2025

thanks @varun-doshi ! lint-native check remaining then ready for review

Copy link
Copy Markdown
Contributor

@emhane emhane left a comment

Choose a reason for hiding this comment

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

nice! pending @dhyaniarun1993

Copy link
Copy Markdown
Collaborator

@dhyaniarun1993 dhyaniarun1993 left a comment

Choose a reason for hiding this comment

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

Thanks @varun-doshi for picking this up. The Safety head ref should be done within the same transaction as process_and_store_logs. Please refer save_derived_block_pair.

"Processing unsafe block"
);
if let Err(err) = self.log_indexer.process_and_store_logs(&block_info).await {
let log_entries = match self.log_indexer.process_logs(&block_info).await {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we can delegate the responsibility of saving data to process_and_store_logs of the logIndexer since it's already using the logWriters store_block_logs which in-turns updates the safety head ref. @sadiq1971 What do you think?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes @dhyaniarun1993. The tasks of the log_indexer are both - process and store the logs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changes made

@dhyaniarun1993
Copy link
Copy Markdown
Collaborator

@varun-doshi Can you resolve the conflicts?

@dhyaniarun1993 dhyaniarun1993 enabled auto-merge June 17, 2025 11:59
@dhyaniarun1993 dhyaniarun1993 added this pull request to the merge queue Jun 17, 2025
Merged via the queue into op-rs:main with commit fd23751 Jun 17, 2025
24 checks passed
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Dec 10, 2025
…#2145)

Ref op-rs/kona#2136

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Jan 14, 2026
…#2145)

Ref #2136

---------

Co-authored-by: Arun Dhyani <dhyaniarun7@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

A-db Area: database A-rpc Area: rpc W-supervisor Workstream: supervisor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants