From f38610edb2e725b19258e6d8802ce28173609402 Mon Sep 17 00:00:00 2001 From: Goran Rojovic Date: Thu, 20 Jun 2024 14:13:44 +0200 Subject: [PATCH] fix --- synchronizer/batches.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/synchronizer/batches.go b/synchronizer/batches.go index 7f94213a..a4d87331 100644 --- a/synchronizer/batches.go +++ b/synchronizer/batches.go @@ -39,7 +39,8 @@ type BatchSynchronizer struct { self common.Address db db.DB committee map[common.Address]etherman.DataCommitteeMember - lock sync.Mutex + comiteeLock sync.Mutex + syncLock sync.Mutex reorgs <-chan BlockReorg sequencer SequencerTracker rpcClientFactory client.Factory @@ -75,8 +76,8 @@ func NewBatchSynchronizer( } func (bs *BatchSynchronizer) resolveCommittee() error { - bs.lock.Lock() - defer bs.lock.Unlock() + bs.comiteeLock.Lock() + defer bs.comiteeLock.Unlock() committee := make(map[common.Address]etherman.DataCommitteeMember) current, err := bs.client.GetCurrentDataCommittee() @@ -110,6 +111,9 @@ func (bs *BatchSynchronizer) handleReorgs(ctx context.Context) { for { select { case r := <-bs.reorgs: + bs.syncLock.Lock() + defer bs.syncLock.Unlock() + latest, err := getStartBlock(ctx, bs.db) if err != nil { log.Errorf("could not determine latest processed block: %v", err) @@ -147,6 +151,9 @@ func (bs *BatchSynchronizer) produceEvents(ctx context.Context) { // Start an iterator from last block processed, picking off SequenceBatches events func (bs *BatchSynchronizer) filterEvents(ctx context.Context) error { + bs.syncLock.Lock() + defer bs.syncLock.Unlock() + start, err := getStartBlock(ctx, bs.db) if err != nil { return err