-
Notifications
You must be signed in to change notification settings - Fork 995
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
Utilize next slot cache in the state replayer #13678
Closed
Closed
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
This reverts commit 6095cd10a3a9b02967bfa9460c20fd3882e1a4e4.
rkapka
changed the title
Replayer next slot cache
Utilize next slot cache in the state replayer
Feb 28, 2024
james-prysm
added
Blocked
Blocked by research or external factors
and removed
Blocked
Blocked by research or external factors
labels
Feb 28, 2024
james-prysm
reviewed
Feb 28, 2024
@@ -146,6 +148,16 @@ func (rs *stateReplayer) ReplayToSlot(ctx context.Context, replayTo primitives.S | |||
return s, nil | |||
} | |||
|
|||
r, err := rs.chainer.BlockRootForSlot(ctx, s.Slot()) | |||
if err != nil && !errors.Is(err, ErrNoCanonicalBlockForSlot) { |
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.
wait what happens if it is ErrNoCanonicalBlockForSlot? then it just keeps going fine without the next slot state?
Superseded by #13684 |
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 type of PR is this?
Other
What does this PR do? Why is it needed?
Consider the following function call:
This will replay blocks up to and including the block at slot
blk.Slot()-1
and then callReplayProcessSlots
to process the slot, so that the state is at slotblk.Slot()
but before integrating the block at this slot. If this slot transition is at an epoch boundary, we will need to process the epoch which is time consuming. As an example, the above code is executed when calling the/eth/v3/validator/blocks/{slot}
Beacon API endpoint to obtain the state used for calculating the block's value. While normally obtaining the value takes around 20ms, it takes over 500ms when requesting a block for slot 0.Prysm has a cache that we can use to speed things up. After processing the block at slot
blk.Slot()-1
(or when the block is late), we transition to the next slot in thenextSlotCache
and save the resulting state in the cache. This means that we don't have to process to the next slot in the replayer because the state is already available to us. Utilizing the cache results in reducing the time of slot 0 blocks to ~20ms.