From d24b1276a95c27a53c5ef27af08fc63ab8c1c30c Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Mon, 7 Dec 2020 09:37:02 -0800 Subject: [PATCH] sync service: fix merge (#138) --- rollup/sync_service.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rollup/sync_service.go b/rollup/sync_service.go index 6af6bc65dd5d..06ebd4e8d958 100644 --- a/rollup/sync_service.go +++ b/rollup/sync_service.go @@ -1009,6 +1009,9 @@ func (s *SyncService) ProcessSequencerBatchAppendedLog(ctx context.Context, ethl } log.Debug("Decoded chain elements", "count", len(cd.ChainElements)) + // Keep track of the number of enqueued elements so that the queue index + // can be calculated in the case of `element.IsSequenced` is false. + enqueuedCount := uint64(0) for i, element := range cd.ChainElements { var tx *types.Transaction index := (event.TotalElements.Uint64() - uint64(len(cd.ChainElements))) + uint64(i) @@ -1077,9 +1080,11 @@ func (s *SyncService) ProcessSequencerBatchAppendedLog(ctx context.Context, ethl } } else { // Queue transaction - rtx, ok := s.txCache.Load(index) + queueIndex := event.StartingQueueIndex.Uint64() + enqueuedCount + enqueuedCount++ + rtx, ok := s.txCache.Load(queueIndex) if !ok { - log.Error("Cannot find transaction in transaction cache", "index", index) + log.Error("Cannot find transaction in transaction cache", "queue-index", queueIndex) continue } tx = rtx.tx