[SharovBot] fix race in DecryptedTxnsPool.Wait causing flaky TestShutterBlockBuilding#21899
Closed
erigon-copilot[bot] wants to merge 1 commit into
Closed
[SharovBot] fix race in DecryptedTxnsPool.Wait causing flaky TestShutterBlockBuilding#21899erigon-copilot[bot] wants to merge 1 commit into
erigon-copilot[bot] wants to merge 1 commit into
Conversation
…terBlockBuilding Wait returned ctx.Err() unconditionally, so when both the done channel (mark found) and ctx.Done() (deadline expired) fired simultaneously, Go's select picked one at random — often returning DeadlineExceeded even though the decryption mark was already in the pool. ProvideTxns then fell back to the base provider, producing a block without shutter transactions. Track whether the mark was actually found, wait for the goroutine to finish in the ctx.Done() case, and return nil when the mark is present regardless of context state. Co-authored-by: Giulio Rebuffo <giulio.rebuffo@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a race in txnprovider/shutter where DecryptedTxnsPool.Wait could return context.DeadlineExceeded even when the requested decryption mark became available at the deadline boundary, causing shutter block building to incorrectly fall back to the base txn provider.
Changes:
- Track whether the decryption mark was actually found before returning from
Wait. - Ensure the waiting goroutine finishes in the
ctx.Done()path so the result is deterministic when deadline and completion happen concurrently.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
67
to
+71
| case <-ctx.Done(): | ||
| // note the below will wake up all waiters prematurely, but thanks to the for loop condition | ||
| // in the waiting goroutine the ones that still need to wait will go back to sleep | ||
| p.decryptionCond.Broadcast() | ||
| <-done |
Member
|
Closing since there is no link to a failing CI run in the PR. We should not be reviewing changes blindly. |
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.
Summary
DecryptedTxnsPool.Waitwhere decryption keys arriving at the deadline boundary were incorrectly reported as missing, causingProvideTxnsto fall back to the base provider and produce blocks without shutter transactions.Waitreturnedctx.Err()unconditionally — when both thedonechannel (mark found by goroutine) andctx.Done()(deadline expired) fired simultaneously, Go'sselectpicked one at random, often returningDeadlineExceededeven though the mark was in the pool.ctx.Done()case, and returnsnilwhen the mark is present regardless of context state.Test plan
TestShutterBlockBuildingpasses 10 consecutive runs without failure*_test.gofiles modifiedgo build ./...passes with no errors