Skip to content

Commit

Permalink
fix + logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ARR552 committed Apr 17, 2024
1 parent f543774 commit 39ced69
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions synchronizer/synchronizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 39ced69

Please sign in to comment.