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

Interop: XSafe Head Maintainer #11458

Merged
merged 7 commits into from
Aug 22, 2024
Merged

Conversation

axelKingsley
Copy link
Contributor

@axelKingsley axelKingsley commented Aug 13, 2024

Mechanics for keeping the X-Heads up to date for all chains.

The basic components are:

SafetyChecker(s)

Each Safety Checker knows how to read the Heads Storage for the appropriate Cross/Local head for the type the checker is concerned about. It is also able to Check a log message against the database, confirming that the executing message is valid, and is inside the associated local-head. Finally, Safety Checkers can create Update Operations which modify the Heads when Applied.

Safety Checkers currently can be created through a constructor that switches on a provided string ["safe", "unsafe", "finalized"].

ChainsDB Entypoint for Updates

The ChainsDB now has a function which can use a Safety Checker to advance the cross-heads of all chains.
It also contains a function which creates a Safe-Safety-Checker and uses it to update the X-Safe heads

Interface Updates

As needed, interfaces were expanded or changed. The new interface functions are:

HeadsStorage

  • Current - to return a copy of the current Heads in storage
  • Apply - to apply an update to the stored Heads

LogDB

  • Contains - to check if a matching message is stored in the DB
  • LastCheckpointBehind - to go from any index into the DB, back to checkpoint, so that you can use the Iterator
  • NextExecutingMessage - takes an iterator, advances it to the next Executing Message, and returns the message.

Iterator

Iterators are now exported so that LogDB can return them in LastCheckpointBehind

  • Index - returns the underlying entryDB.EntryIdx, derived as i.nextEntryIdx - 1

Contains

The Contains function now returns the Index the log is located at. This could have replaced the bool value, but for now I wanted to only extend the structure

Tests

Unit tests now exist which test:

  • Updating the x-heads works, does not surpass the local head, and does not advance on error
  • Checkers return the expected values and return correctly when calling Check

Not Included

Not yet included is the actual trigger that makes this update happen. This should be as simple as a timer-loop, and could also leverage some self-feeding (if an update occurs on one chain, update other chains)

@axelKingsley axelKingsley force-pushed the axel/interop/crossSafeMaintainer branch from 351b4db to 9e1893c Compare August 13, 2024 22:27
@axelKingsley axelKingsley force-pushed the axel/interop/crossSafeMaintainer branch from 9e1893c to 7800128 Compare August 13, 2024 22:52
@axelKingsley axelKingsley marked this pull request as ready for review August 19, 2024 20:03
@axelKingsley axelKingsley requested a review from a team as a code owner August 19, 2024 20:03
@axelKingsley axelKingsley changed the title WIP: XSafe Head Maintainer Interop: XSafe Head Maintainer Aug 22, 2024
@protolambda protolambda added this pull request to the merge queue Aug 22, 2024
Merged via the queue into develop with commit 5879300 Aug 22, 2024
59 checks passed
@protolambda protolambda deleted the axel/interop/crossSafeMaintainer branch August 22, 2024 20:51
samlaf pushed a commit to samlaf/optimism that referenced this pull request Nov 10, 2024
* WIP: Cross-Head Maintenance

* Add NextExecutingMessage ; Add ChainsDB Tests

* Add Tests for SafetyCheckers

* spelling

* correct test

* add safety_checkers_test.go

* Address Coments From Proto
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.

2 participants