From 0af3866d075e22fb4722304af29add389c959707 Mon Sep 17 00:00:00 2001 From: devopsbo3 <69951731+devopsbo3@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:27:53 -0600 Subject: [PATCH] Revert "eth/filters: eth_getLogs fast exit for invalid block range (#28386)" This reverts commit df4c9307d3259c007763416858904ccbe620d7a9. --- eth/filters/api.go | 8 ++------ eth/filters/filter_system.go | 3 ++- eth/filters/filter_system_test.go | 18 ------------------ 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/eth/filters/api.go b/eth/filters/api.go index 22dff6c59e9e..cc08b442e850 100644 --- a/eth/filters/api.go +++ b/eth/filters/api.go @@ -34,9 +34,8 @@ import ( ) var ( - errInvalidTopic = errors.New("invalid topic(s)") - errFilterNotFound = errors.New("filter not found") - errInvalidBlockRange = errors.New("invalid block range params") + errInvalidTopic = errors.New("invalid topic(s)") + errFilterNotFound = errors.New("filter not found") ) // filter is a helper struct that holds meta information over the filter type @@ -348,9 +347,6 @@ func (api *FilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([]*type if crit.ToBlock != nil { end = crit.ToBlock.Int64() } - if begin > 0 && end > 0 && begin > end { - return nil, errInvalidBlockRange - } // Construct the range filter filter = api.sys.NewRangeFilter(begin, end, crit.Addresses, crit.Topics) } diff --git a/eth/filters/filter_system.go b/eth/filters/filter_system.go index a9b5f2e07919..35e396c23e75 100644 --- a/eth/filters/filter_system.go +++ b/eth/filters/filter_system.go @@ -20,6 +20,7 @@ package filters import ( "context" + "errors" "fmt" "sync" "sync/atomic" @@ -331,7 +332,7 @@ func (es *EventSystem) SubscribeLogs(crit ethereum.FilterQuery, logs chan []*typ if from >= 0 && to == rpc.LatestBlockNumber { return es.subscribeLogs(crit, logs), nil } - return nil, errInvalidBlockRange + return nil, errors.New("invalid from and to block combination: from > to") } // subscribeMinedPendingLogs creates a subscription that returned mined and diff --git a/eth/filters/filter_system_test.go b/eth/filters/filter_system_test.go index 93cbf01830b3..f7e5327c56e7 100644 --- a/eth/filters/filter_system_test.go +++ b/eth/filters/filter_system_test.go @@ -429,10 +429,7 @@ func TestInvalidLogFilterCreation(t *testing.T) { } } -// TestLogFilterUninstall tests invalid getLogs requests func TestInvalidGetLogsRequest(t *testing.T) { - t.Parallel() - var ( db = rawdb.NewMemoryDatabase() _, sys = newTestFilterSystem(t, db, Config{}) @@ -454,21 +451,6 @@ func TestInvalidGetLogsRequest(t *testing.T) { } } -// TestInvalidGetRangeLogsRequest tests getLogs with invalid block range -func TestInvalidGetRangeLogsRequest(t *testing.T) { - t.Parallel() - - var ( - db = rawdb.NewMemoryDatabase() - _, sys = newTestFilterSystem(t, db, Config{}) - api = NewFilterAPI(sys, false) - ) - - if _, err := api.GetLogs(context.Background(), FilterCriteria{FromBlock: big.NewInt(2), ToBlock: big.NewInt(1)}); err != errInvalidBlockRange { - t.Errorf("Expected Logs for invalid range return error, but got: %v", err) - } -} - // TestLogFilter tests whether log filters match the correct logs that are posted to the event feed. func TestLogFilter(t *testing.T) { t.Parallel()