Skip to content

Commit

Permalink
Pass de-duped block list to fillRemainingBlocks() (#10554)
Browse files Browse the repository at this point in the history
This avoids us requesting the same block multiple times from the rpc server
  • Loading branch information
reductionista authored Sep 9, 2023
1 parent d3dfc5c commit f678a4c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/chains/evm/logpoller/log_poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ func (lp *logPoller) backfill(ctx context.Context, start, end int64) error {
}
}
if batchSize == 1 {
lp.lggr.Criticalw("Too many log results in a single block, failed to retrieve logs! Node may run in a degraded state unless LogBackfillBatchSize is increased", "err", err, "from", from, "to", to, "LogBackfillBatchSize", lp.backfillBatchSize)
lp.lggr.Criticalw("Too many log results in a single block, failed to retrieve logs! Node may be running in a degraded state.", "err", err, "from", from, "to", to, "LogBackfillBatchSize", lp.backfillBatchSize)
return err
}
batchSize /= 2
Expand Down Expand Up @@ -1043,7 +1043,7 @@ func (lp *logPoller) GetBlocksRange(ctx context.Context, numbers []uint64, qopts
}

// Fill any remaining blocks from the client.
blocksFoundFromRPC, err := lp.fillRemainingBlocksFromRPC(ctx, numbers, blocksFound)
blocksFoundFromRPC, err := lp.fillRemainingBlocksFromRPC(ctx, blocksRequested, blocksFound)
if err != nil {
return nil, err
}
Expand All @@ -1069,12 +1069,12 @@ func (lp *logPoller) GetBlocksRange(ctx context.Context, numbers []uint64, qopts

func (lp *logPoller) fillRemainingBlocksFromRPC(
ctx context.Context,
blocksRequested []uint64,
blocksRequested map[uint64]struct{},
blocksFound map[uint64]LogPollerBlock,
) (map[uint64]LogPollerBlock, error) {
var reqs []rpc.BatchElem
var remainingBlocks []uint64
for _, num := range blocksRequested {
for num := range blocksRequested {
if _, ok := blocksFound[num]; !ok {
req := rpc.BatchElem{
Method: "eth_getBlockByNumber",
Expand Down

0 comments on commit f678a4c

Please sign in to comment.