From 39ced69339f46f145aabdf03a93279b737d02bf0 Mon Sep 17 00:00:00 2001 From: Alonso Date: Wed, 17 Apr 2024 13:05:33 +0200 Subject: [PATCH 1/3] fix + logs --- synchronizer/synchronizer.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go index d2b2c7e7a9..5a2301f1a4 100644 --- a/synchronizer/synchronizer.go +++ b/synchronizer/synchronizer.go @@ -590,11 +590,17 @@ func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Bloc return lastEthBlockSynced, err } - var initBlockReceived *etherman.Block + var initBlockReceived etherman.Block if len(blocks) != 0 { - initBlockReceived = &blocks[0] + for _, b := range blocks { + log.Debug("Before removing Block Number: ", b.BlockNumber) + } + initBlockReceived = blocks[0] // First position of the array must be deleted blocks = removeBlockElement(blocks, 0) + for _, b := range blocks { + log.Debug("After removing Block Number: ", b.BlockNumber) + } } else { // Reorg detected log.Infof("Reorg detected in block %d while querying GetRollupInfoByBlockRange. Rolling back to at least the previous block", fromBlock) @@ -622,7 +628,7 @@ func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Bloc return blockReorged, nil } // Check reorg again to be sure that the chain has not changed between the previous checkReorg and the call GetRollupInfoByBlockRange - block, err := s.checkReorg(lastEthBlockSynced, initBlockReceived) + block, err := s.checkReorg(lastEthBlockSynced, &initBlockReceived) if err != nil { log.Errorf("error checking reorgs. Retrying... Err: %v", err) return lastEthBlockSynced, fmt.Errorf("error checking reorgs") From b91c8bac6ee0e068a3d06fab43149966756b53fc Mon Sep 17 00:00:00 2001 From: Alonso Date: Wed, 17 Apr 2024 13:29:28 +0200 Subject: [PATCH 2/3] fix loop --- synchronizer/synchronizer.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go index 5a2301f1a4..a9818aba6a 100644 --- a/synchronizer/synchronizer.go +++ b/synchronizer/synchronizer.go @@ -570,9 +570,9 @@ func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Bloc if lastEthBlockSynced.BlockNumber > 0 { fromBlock = lastEthBlockSynced.BlockNumber } + toBlock := fromBlock + s.cfg.SyncChunkSize for { - toBlock := fromBlock + s.cfg.SyncChunkSize if toBlock > lastKnownBlock.Uint64() { toBlock = lastKnownBlock.Uint64() } @@ -665,7 +665,8 @@ func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Bloc break } - fromBlock = toBlock + fromBlock = lastEthBlockSynced.BlockNumber + toBlock = toBlock + s.cfg.SyncChunkSize } return lastEthBlockSynced, nil From 29027c241ef13c4db4b54a3c46ad2842be9d5640 Mon Sep 17 00:00:00 2001 From: Alonso Date: Wed, 17 Apr 2024 14:05:57 +0200 Subject: [PATCH 3/3] Revert "fix + logs" This reverts commit 39ced69339f46f145aabdf03a93279b737d02bf0. --- synchronizer/synchronizer.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/synchronizer/synchronizer.go b/synchronizer/synchronizer.go index a9818aba6a..a9df6330c2 100644 --- a/synchronizer/synchronizer.go +++ b/synchronizer/synchronizer.go @@ -590,17 +590,11 @@ func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Bloc return lastEthBlockSynced, err } - var initBlockReceived etherman.Block + var initBlockReceived *etherman.Block if len(blocks) != 0 { - for _, b := range blocks { - log.Debug("Before removing Block Number: ", b.BlockNumber) - } - initBlockReceived = blocks[0] + initBlockReceived = &blocks[0] // First position of the array must be deleted blocks = removeBlockElement(blocks, 0) - for _, b := range blocks { - log.Debug("After removing Block Number: ", b.BlockNumber) - } } else { // Reorg detected log.Infof("Reorg detected in block %d while querying GetRollupInfoByBlockRange. Rolling back to at least the previous block", fromBlock) @@ -628,7 +622,7 @@ func (s *ClientSynchronizer) syncBlocksSequential(lastEthBlockSynced *state.Bloc return blockReorged, nil } // Check reorg again to be sure that the chain has not changed between the previous checkReorg and the call GetRollupInfoByBlockRange - block, err := s.checkReorg(lastEthBlockSynced, &initBlockReceived) + block, err := s.checkReorg(lastEthBlockSynced, initBlockReceived) if err != nil { log.Errorf("error checking reorgs. Retrying... Err: %v", err) return lastEthBlockSynced, fmt.Errorf("error checking reorgs")