feat(sequencer): Origin Selector asynchronously prefetches the next origin from events #12134
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.
Description
Updates the Sequencer's L1 origin selector to locally cache the
currentOriginandnextOriginattributes and also optimistically prefetch thenextOriginwhenever anForkchoiceUpdateEventevent is received. This is expected to remove synchronous origin selection from the critical path of sequencer block production, although the impact of this is reduced when using a single-threaded event loop. (Addressed by #11100)In many cases, the existing L1 origin is "good enough" for building a new block from the sequencer's perspective, and it's better to fetch the next L1 origin in the background instead of spending precious time that could otherwise be used for building the next block. Whenever the
nextOriginis already available and valid, this is returned instead.Under specific circumstances, such as when a new L1 origin has not been found for a long period of time, the sequencer will actually need to review the
nextOriginand determine if this is valid (behind the next L2 block time). In these cases, theFindL1Origincall will fetch the next possible origin synchronously, and compare these potential origins immediately.Note: This is a simplified version of #12073, which uses no goroutines and fully embraces the async event model.
Tests
Added several new origin selector tests to ensure that this new prefetching behavior is safe under all conditions.
Metadata
Partially addresses #11960. In order to fully resolve this ticket, we may need to merge the origin selector and attributes builder, so that an origin is only selected if and only if it also has the relevant attributes already built or has all of the data needed to build attributes (L1 receipts).