Serve verified uncommitted blocks to seq-only lookups in CachedStorage - #497
Draft
samliok wants to merge 3 commits into
Draft
Serve verified uncommitted blocks to seq-only lookups in CachedStorage#497samliok wants to merge 3 commits into
samliok wants to merge 3 commits into
Conversation
yacovm
reviewed
Aug 6, 2026
yacovm
reviewed
Aug 6, 2026
| func (cs *CachedStorage) Retrieve(seq uint64, digest common.Digest) (common.VerifiedBlock, *common.Finalization, error) { | ||
| cs.lock.RLock() | ||
| item, exists := cs.cache[digest] | ||
| if !exists && digest == (common.Digest{}) { |
Collaborator
There was a problem hiding this comment.
Let's add a test that tests the added lines.
This file contains hidden or 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
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.
Problem
CachedStorage keeps verified-but-not-yet-finalized blocks in a cache keyed by digest. The msm sealing-block checks (
buildBlockOrTransitionEpoch,areWeReadyToTransitionEpoch) look blocks up by sequence only and pass a zero digest, so they can never hit the cache. The lookup falls through to committed storage, and while the sealing block is notarized but not yet indexed, block building fails withfailed to retrieve sealing block for previous epoch. The failed build is not retried, so the leader misses its round and the round empty-notarizes.The window is the normal pipelining case right after a sealing block: the next leader builds on the notarized sealing block before it finalizes. Surfaced as a deterministic-ish hang in a new multi-node instance test where round 2's build races round 1's commit (test lands separately with the instance test harness).
Fix
When a lookup misses the cache and the digest is zero, scan the cache by sequence before falling back to storage. A hit returns the block with a nil finalization, matching the documented cache invariant (cached means not yet finalized), so callers correctly compute
isSealingBlockFinalized = falseinstead of erroring. Digest-based lookups are unchanged: a real digest that is not cached still resolves through committed storage.Related: #495 and #496 fix the error masking that hid this failure (the msm error was dropped and misreported as a context cancellation).
🤖 Generated with Claude Code