Skip to content

Commit

Permalink
fix uniitest and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
joanestebanr committed May 6, 2024
1 parent a5ab279 commit deac046
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
16 changes: 13 additions & 3 deletions synchronizer/l1_sync/check_reorgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,23 @@ type CheckReorgManager struct {
GenesisBlockNumber uint64
}

func (s *CheckReorgManager) checkReorg(latestBlock *stateBlockType, syncedBlock *etherman.Block) (*stateBlockType, error) {
func NewCheckReorgManager(ctx context.Context, etherMan syncinterfaces.EthermanFullInterface, state stateInterface, asyncL1BlockChecker l1_check_block.L1BlockCheckerIntegrator, genesisBlockNumber uint64) *CheckReorgManager {
return &CheckReorgManager{
asyncL1BlockChecker: asyncL1BlockChecker,
ctx: ctx,
etherMan: etherMan,
state: state,
GenesisBlockNumber: genesisBlockNumber,
}
}

func (s *CheckReorgManager) CheckReorg(latestBlock *stateBlockType, syncedBlock *etherman.Block) (*stateBlockType, error) {
if latestBlock == nil {
err := fmt.Errorf("lastEthBlockSynced is nil calling checkReorgAndExecuteReset")
log.Errorf("%s, it never have to happens", err.Error())
return nil, err
}
block, errReturnedReorgFunction := s.newCheckReorg(latestBlock, syncedBlock)
block, errReturnedReorgFunction := s.NewCheckReorg(latestBlock, syncedBlock)
if s.asyncL1BlockChecker != nil {
return s.asyncL1BlockChecker.CheckReorgWrapper(s.ctx, block, errReturnedReorgFunction)
}
Expand All @@ -47,7 +57,7 @@ must be reverted. Then, check the previous ethereum block synced, get block info
hash and has parent. This operation has to be done until a match is found.
*/

func (s *CheckReorgManager) newCheckReorg(latestStoredBlock *stateBlockType, syncedBlock *etherman.Block) (*stateBlockType, error) {
func (s *CheckReorgManager) NewCheckReorg(latestStoredBlock *stateBlockType, syncedBlock *etherman.Block) (*stateBlockType, error) {
// This function only needs to worry about reorgs if some of the reorganized blocks contained rollup info.
latestStoredEthBlock := *latestStoredBlock
reorgedBlock := *latestStoredBlock
Expand Down
9 changes: 5 additions & 4 deletions synchronizer/l1_sync/l1_sequential_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ func (s *L1SequentialSync) SyncBlocksSequential(ctx context.Context, lastEthBloc
}
}

// if lastKnownBlock.Cmp(new(big.Int).SetUint64(toBlock)) < 1 {
// waitDuration = s.cfg.SyncInterval.Duration
// break
// }
//if lastKnownBlock.Cmp(new(big.Int).SetUint64(toBlock)) < 1 {
if lastKnownBlock < toBlock {
// waitDuration = s.cfg.SyncInterval.Duration
break
}

fromBlock = lastEthBlockSynced.BlockNumber
toBlock = toBlock + s.SyncChunkSize
Expand Down

0 comments on commit deac046

Please sign in to comment.