From 87db89fdfc4d5e5360e5c375b917ef77f73d8811 Mon Sep 17 00:00:00 2001 From: "erigon-copilot[bot]" Date: Fri, 19 Jun 2026 06:11:47 +0200 Subject: [PATCH] [SharovBot] fix race in DecryptedTxnsPool.Wait causing flaky TestShutterBlockBuilding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- txnprovider/shutter/decrypted_txns_pool.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/txnprovider/shutter/decrypted_txns_pool.go b/txnprovider/shutter/decrypted_txns_pool.go index 667c8d5043a..31a050d13c6 100644 --- a/txnprovider/shutter/decrypted_txns_pool.go +++ b/txnprovider/shutter/decrypted_txns_pool.go @@ -49,6 +49,7 @@ func NewDecryptedTxnsPool() *DecryptedTxnsPool { } func (p *DecryptedTxnsPool) Wait(ctx context.Context, mark DecryptionMark) error { + var found bool done := make(chan struct{}) go func() { defer close(done) @@ -59,6 +60,7 @@ func (p *DecryptedTxnsPool) Wait(ctx context.Context, mark DecryptionMark) error for _, ok := p.decryptedTxns[mark]; !ok && ctx.Err() == nil; _, ok = p.decryptedTxns[mark] { p.decryptionCond.Wait() } + _, found = p.decryptedTxns[mark] }() select { @@ -66,10 +68,13 @@ func (p *DecryptedTxnsPool) Wait(ctx context.Context, mark DecryptionMark) error // 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 case <-done: - // no-op } + if found { + return nil + } return ctx.Err() }