-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Supervisor: Safety Index #12154
Merged
Merged
Supervisor: Safety Index #12154
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
axelKingsley
force-pushed
the
interop-recent-safety
branch
from
September 27, 2024 14:48
fe20a20
to
18b1bf0
Compare
protolambda
approved these changes
Sep 27, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good progress, will need more testing next week, but already closer to getting e2e safety-increments running correctly.
Co-authored-by: protolambda <[email protected]>
Semgrep found 2 require() must include a reason string Ignore this finding from sol-style-require-reason. |
samlaf
pushed a commit
to samlaf/optimism
that referenced
this pull request
Nov 10, 2024
* fixes * op-supervisor: head db init fix, logging, op-node debug logging * interop: track recent safety data * Early integration and refactor of Views and SafetyIndex * update for rebase * rename RecentSafetyIndex ; reorganize * refactor Pointer method on iterator * logging * Delete unused Tracking Code ; New ChainsDB.Safest * fix naming miss * fix mistaken line deletion * Update op-supervisor/supervisor/backend/safety/safety.go Co-authored-by: protolambda <[email protected]> * Add issue numbers to TODO ; Address Proto Comments --------- Co-authored-by: protolambda <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Replaces the following components:
With "Safety Index", located in
safety
package.Safety Index
Safety index takes updates to Local safties for all chains, as well as Finality. It uses those signals to advance the x-safety for all chains as well.
Callers can access the Safety Index's local and cross safety indexes, and will get HeadPointers in return, which point into the database.
Safety Index manages its unsafe and safe pointers as
View
sViews
Views are a new wrapper around iterators which are safety-processing specific. They contain a "Local" pointer which represents the starting point of their processing, and an iterator which represents the extent of their processing.
In effect, each view holds the imperatively set local safety index, and holds the cross-safety index by using the iterator's
TraverseConditional
.Each type of safety has its own type of conditional traversal for x-heads. Unsafe simply advances to the first non-validating executing message within the local range. Safe, on the other hand, has a more complex check against the L1 block references stored
TraverseConditional
Iterators now support a generic way of advancing. By providing a function which acts on the iterator's state, callers can automatically advance their index as far as possible.
Integration
TestInteropTrivial
reveals the unsafe processor is workingDeletion
I deleted
SafetyCheckers
and all thingsHeadStorage
related, asSafetyIndex
replaces these structures. I wrote a newSafest
method for theChainsDB
to consult Safety Indexes for the API, but otherwise everything disconnected as hoped-for.Future Integration
We are changing the data-flow so that nodes push their data into the supervisor. When this happens, we'll also call the update safe and update finalized flows.
Integration Results
Currently we only have unsafe data coming in because the ingestion is wrongly trying to get data from
geth
. @protolambda is working on changes for that, but in the meantime, here are some logs demonstrating that a new write to the logs database updated one Local Head, and triggered the Cross-Head update of two chains:Tests
Indexes, Iterators, Pointers, Views, Oh My!
Here's a rundown of the different structures we are using to serve data out of the logs database:
The Database Itself
The Logs Database is a fixed-width append only database with regular checkpointing. The data stored is the log event data (or lack thereof) for every block in order, including detailed information about executing messages.
Indicies
An
entrydb.EntryIdx
is auint64
which specifies an exact row into the database structure. With enough context, the data at that position could be read, but indexes are primitives.Iterators
Iterators represent a read-head on the database. They can advance forward, and can read out the various data-types stored in the database. They consume rows of the database to advance an internal state machine (called
logContext
)**Log Contexts represent the state-relevant parameters for the iterator, including its position, last observed block-hash, etc.
Iterators become extra flexible with the use of
TraverseConditional
, which takes a function that will process the iteratorState until your given function returns an error.Head Pointers
HeadPointer
s are logical references into the database. They contain the last sealed block number, and an offset calledLogsSince
. They can answer basic inequality questions about if another Head Pointer is behind it, or if it's sealed in relation to it.Views
View
s are evaluators on the database, and in particular they are created to maintain "x-head" values. They do the following:HeadPointer
Process
, which advances anIterator
through Executing Events and runs a configured Validity Check on them, stopping when an error is encountered. The Local Head Pointer is used in these functions while the iterator processes through data, for range-checking.Views return
Local
andCross
values by returning a Head Pointer, or by transforming the iterator into a Head Pointer.