optimism
optimism copied to clipboard
op-supervisor,op-node: Improve reset unsafe target
When the supervisor performs a reset target search, it searches for the latest common local safe block between its database and the managed op-node. It then sends a reset request to the node, also setting unsafe targets.
The cross-unsafe reset target is set to the latest cross-unsafe entry in the supervisor's database.
However, the local safe is set to the safe target, potentially being much further behind even the cross-unsafe target. This is done because the op-node currently then performs another validity search between its current unsafe and the provided target.
This is confusing as the targets are taken at face value for cross-unsafe and both (local|cross)-safe, but not for unsafe. It would be more consistent if the supervisor was be responsible for providing the right reset targets for all labels. The validity search also is currently a slow traversal loop (improved to go backwards with https://github.com/ethereum-optimism/optimism/pull/16312) which will be improved to a binary search with https://github.com/ethereum-optimism/optimism/pull/16276.
Ideally we change this to let the supervisor provide the right local unsafe target. We probably need to handle pre- and post-Interop differently because the supervisor doesn't have the logs DB pre-Interop, which is populated with unsafe blocks.
Related to #16315