Skip to content

Commit c951fe2

Browse files
eth/filters: rangeLogs should error on invalid block range (#33763) (#3688)
* eth/filters: rangeLogs should error on invalid block range (#33763) Fixes log filter to reject out of order block ranges. * eth/filters: fix testFilters --------- Co-authored-by: vickkkkkyy <vickyaviles847@gmail.com>
1 parent 4708950 commit c951fe2

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

eth/filters/filter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ func (f *Filter) rangeLogs(ctx context.Context, firstBlock, lastBlock uint64) ([
389389
}
390390

391391
if firstBlock > lastBlock {
392-
return nil, nil
392+
return nil, errInvalidBlockRange
393393
}
394394
mb := f.sys.backend.NewMatcherBackend()
395395
defer mb.Close()

eth/filters/filter_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ func testFilters(t *testing.T, history uint64, noHistory bool) {
360360
want: `[{"address":"0xff00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696333"],"data":"0x","blockNumber":"0x3e7","transactionHash":"0x53e3675800c6908424b61b35a44e51ca4c73ca603e58a65b32c67968b4f42200","transactionIndex":"0x0","blockHash":"0x2e4620a2b426b0612ec6cad9603f466723edaed87f98c9137405dd4f7a2409ff","logIndex":"0x0","removed":false}]`,
361361
},
362362
{
363-
f: sys.NewRangeFilter(int64(rpc.LatestBlockNumber), int64(rpc.FinalizedBlockNumber), nil, nil),
363+
f: sys.NewRangeFilter(int64(rpc.LatestBlockNumber), int64(rpc.FinalizedBlockNumber), nil, nil, false),
364+
err: errInvalidBlockRange.Error(),
364365
},
365366
{
366367
f: sys.NewRangeFilter(int64(rpc.SafeBlockNumber), int64(rpc.LatestBlockNumber), nil, nil),

0 commit comments

Comments
 (0)