Skip to content

Commit

Permalink
Fix panic on concurrent map rw (#12714)
Browse files Browse the repository at this point in the history
  • Loading branch information
domiwei authored Nov 14, 2024
1 parent c7f4ff3 commit 59c424f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cl/phase1/network/services/sync_contribution_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type syncContributionService struct {
syncedDataManager *synced_data.SyncedDataManager
beaconCfg *clparams.BeaconChainConfig
syncContributionPool sync_contribution_pool.SyncContributionPool
seenSyncCommitteeContributions map[seenSyncCommitteeContribution]struct{}
seenSyncCommitteeContributions sync.Map // map[seenSyncCommitteeContribution]struct{}
emitters *beaconevents.EventEmitter
ethClock eth_clock.EthereumClock
batchSignatureVerifier *BatchSignatureVerifier
Expand All @@ -73,7 +73,7 @@ func NewSyncContributionService(
syncedDataManager: syncedDataManager,
beaconCfg: beaconCfg,
syncContributionPool: syncContributionPool,
seenSyncCommitteeContributions: make(map[seenSyncCommitteeContribution]struct{}),
seenSyncCommitteeContributions: sync.Map{},
ethClock: ethClock,
emitters: emitters,
batchSignatureVerifier: batchSignatureVerifier,
Expand Down Expand Up @@ -237,7 +237,7 @@ func (s *syncContributionService) wasContributionSeen(contribution *cltypes.Cont
subCommitteeIndex: contribution.Contribution.SubcommitteeIndex,
}

_, ok := s.seenSyncCommitteeContributions[key]
_, ok := s.seenSyncCommitteeContributions.Load(key)
return ok
}

Expand All @@ -248,7 +248,7 @@ func (s *syncContributionService) markContributionAsSeen(contribution *cltypes.C
slot: contribution.Contribution.Slot,
subCommitteeIndex: contribution.Contribution.SubcommitteeIndex,
}
s.seenSyncCommitteeContributions[key] = struct{}{}
s.seenSyncCommitteeContributions.Store(key, struct{}{})
}

// verifySyncContributionProof verifies the sync contribution proof.
Expand Down

0 comments on commit 59c424f

Please sign in to comment.