From 68b78dd5201dfc39cadab9b25aa28b80e39f3198 Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Fri, 1 Mar 2024 17:29:51 +0800 Subject: [PATCH] fix race (#13680) --- beacon-chain/blockchain/process_block.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/beacon-chain/blockchain/process_block.go b/beacon-chain/blockchain/process_block.go index ef795558e..ffa2138bc 100644 --- a/beacon-chain/blockchain/process_block.go +++ b/beacon-chain/blockchain/process_block.go @@ -307,16 +307,16 @@ func (s *Service) updateEpochBoundaryCaches(ctx context.Context, st state.Beacon if err := helpers.UpdateProposerIndicesInCache(ctx, st, e); err != nil { return errors.Wrap(err, "could not update proposer index cache") } - go func() { + go func(ep primitives.Epoch) { // Use a custom deadline here, since this method runs asynchronously. // We ignore the parent method's context and instead create a new one // with a custom deadline, therefore using the background context instead. slotCtx, cancel := context.WithTimeout(context.Background(), slotDeadline) defer cancel() - if err := helpers.UpdateCommitteeCache(slotCtx, st, e+1); err != nil { + if err := helpers.UpdateCommitteeCache(slotCtx, st, ep+1); err != nil { log.WithError(err).Warn("Could not update committee cache") } - }() + }(e) // The latest block header is from the previous epoch r, err := st.LatestBlockHeader().HashTreeRoot() if err != nil {