Skip to content

Commit

Permalink
fix: increase log level
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Jan 21, 2025
1 parent 79bca55 commit 434d530
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions sync/evmdownloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func NewEVMDownloader(

func (d *EVMDownloader) Download(ctx context.Context, fromBlock uint64, downloadedCh chan EVMBlock) {
lastBlock := d.WaitForNewBlocks(ctx, 0)
toBlock := fromBlock

for {
select {
Expand All @@ -91,13 +90,13 @@ func (d *EVMDownloader) Download(ctx context.Context, fromBlock uint64, download
default:
}

toBlock = fromBlock + d.syncBlockChunkSize
toBlock := fromBlock + d.syncBlockChunkSize
if toBlock > lastBlock {
toBlock = lastBlock
}

if fromBlock > toBlock {
d.log.Debugf(
d.log.Infof(
"waiting for new blocks, last block processed: %d, last block seen on L1: %d",
fromBlock-1, lastBlock,
)
Expand All @@ -113,12 +112,12 @@ func (d *EVMDownloader) Download(ctx context.Context, fromBlock uint64, download

lastFinalizedBlockNumber := lastFinalizedBlock.Number.Uint64()

d.log.Debugf("getting events from blocks %d to %d", fromBlock, toBlock)
d.log.Infof("getting events from blocks %d to %d. lastFinalizedBlock: %d", fromBlock, toBlock, lastFinalizedBlockNumber)
blocks := d.GetEventsByBlockRange(ctx, fromBlock, toBlock)

reportBlocksFn := func(numOfBlocksToReport int) {
for i := 0; i < numOfBlocksToReport; i++ {
d.log.Debugf("sending block %d to the driver (with events)", blocks[i].Num)
d.log.Infof("sending block %d to the driver (with events)", blocks[i].Num)
downloadedCh <- blocks[i]
}
}
Expand All @@ -138,10 +137,12 @@ func (d *EVMDownloader) Download(ctx context.Context, fromBlock uint64, download

if blocks.Len() == 0 {
// we have no events, keep increasing the block range until we hit a log
d.log.Infof("no events found in blocks %d to %d", fromBlock, toBlock)
if lastFinalizedBlockNumber > toBlock {
// we might be behind a lot, so go until last finalized block
toBlock = lastFinalizedBlockNumber
lastBlock = lastFinalizedBlockNumber
d.log.Infof("setting toBlock to last finalized block %d", toBlock)
}

if lastFinalizedBlockNumber-fromBlock >= d.syncBlockChunkSize {
Expand All @@ -150,6 +151,7 @@ func (d *EVMDownloader) Download(ctx context.Context, fromBlock uint64, download
// this is mainly needed for tests
reportEmptyBlockFn(lastFinalizedBlockNumber)
fromBlock = lastFinalizedBlockNumber
d.log.Infof("setting fromBlock to last finalized block %d", fromBlock)
}

continue
Expand All @@ -159,6 +161,7 @@ func (d *EVMDownloader) Download(ctx context.Context, fromBlock uint64, download
// and we do not need to track it in the reorg detector
reportBlocksFn(blocks.Len())
fromBlock = toBlock + 1
d.log.Infof("got blocks that are lower than finalized block, setting fromBlock to %d", fromBlock)
} else if blocks[blocks.Len()-1].Num < toBlock {
// if we have logs in some of the blocks, and they are not all finalized,
// check if we have finalized blocks in gotten range, report them and
Expand All @@ -168,6 +171,7 @@ func (d *EVMDownloader) Download(ctx context.Context, fromBlock uint64, download
if exists {
reportBlocksFn(index + 1) // num of blocks to report is index + 1 since index is zero based
fromBlock = lastFinalizedBlock + 1
d.log.Infof("have some finalized blocks in the range, setting fromBlock to %d", fromBlock)
continue
}
} else {
Expand All @@ -176,6 +180,7 @@ func (d *EVMDownloader) Download(ctx context.Context, fromBlock uint64, download
// and we are not afraid to have missaligned hashes at this point
reportBlocksFn(blocks.Len())
fromBlock = toBlock + 1
d.log.Infof("have logs in the last block, setting fromBlock to %d", fromBlock)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion sync/evmdriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ reset:
if ok {
// when channel is closing, it is sending an empty block with num = 0, and empty hash
// because it is not passing object by reference, but by value, so do not handle that since it is closing
d.log.Debugf("handleNewBlock, blockNum: %d, blockHash: %s", b.Num, b.Hash)
d.log.Infof("handleNewBlock, blockNum: %d, blockHash: %s", b.Num, b.Hash)
d.handleNewBlock(ctx, cancel, b)
}
case firstReorgedBlock := <-d.reorgSub.ReorgedBlock:
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func L1Setup(t *testing.T) *L1Environment {
originNetwork = 1
initialBlock = 0
retryPeriod = 0
retriesCount = 0
retriesCount = 10
)

// Bridge sync
Expand Down

0 comments on commit 434d530

Please sign in to comment.