Skip to content

Commit

Permalink
Revert "eth/filters: exit early if topics-filter has more than 4 topi…
Browse files Browse the repository at this point in the history
…cs (ethereum#28494)"

This reverts commit 1992836.
  • Loading branch information
devopsbo3 committed Nov 10, 2023
1 parent b006c0b commit 9ff02cd
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 14 deletions.
7 changes: 0 additions & 7 deletions eth/filters/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ var (
errInvalidTopic = errors.New("invalid topic(s)")
errFilterNotFound = errors.New("filter not found")
errInvalidBlockRange = errors.New("invalid block range params")
errExceedMaxTopics = errors.New("exceed max topics")
)

// The maximum number of topic criteria allowed, vm.LOG4 - vm.LOG0
const maxTopics = 4

// filter is a helper struct that holds meta information over the filter type
// and associated subscription in the event system.
type filter struct {
Expand Down Expand Up @@ -338,9 +334,6 @@ func (api *FilterAPI) NewFilter(crit FilterCriteria) (rpc.ID, error) {

// GetLogs returns logs matching the given argument that are stored within the state.
func (api *FilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([]*types.Log, error) {
if len(crit.Topics) > maxTopics {
return nil, errExceedMaxTopics
}
var filter *Filter
if crit.BlockHash != nil {
// Block filter requested, construct a single-shot filter
Expand Down
3 changes: 0 additions & 3 deletions eth/filters/filter_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,6 @@ func (es *EventSystem) subscribe(sub *subscription) *Subscription {
// given criteria to the given logs channel. Default value for the from and to
// block is "latest". If the fromBlock > toBlock an error is returned.
func (es *EventSystem) SubscribeLogs(crit ethereum.FilterQuery, logs chan []*types.Log) (*Subscription, error) {
if len(crit.Topics) > maxTopics {
return nil, errExceedMaxTopics
}
var from, to rpc.BlockNumber
if crit.FromBlock == nil {
from = rpc.LatestBlockNumber
Expand Down
4 changes: 0 additions & 4 deletions eth/filters/filter_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,6 @@ func TestLogFilterCreation(t *testing.T) {
{FilterCriteria{FromBlock: big.NewInt(rpc.PendingBlockNumber.Int64()), ToBlock: big.NewInt(100)}, false},
// from block "higher" than to block
{FilterCriteria{FromBlock: big.NewInt(rpc.PendingBlockNumber.Int64()), ToBlock: big.NewInt(rpc.LatestBlockNumber.Int64())}, false},
// topics more then 4
{FilterCriteria{Topics: [][]common.Hash{{}, {}, {}, {}, {}}}, false},
}
)

Expand Down Expand Up @@ -422,7 +420,6 @@ func TestInvalidLogFilterCreation(t *testing.T) {
0: {FromBlock: big.NewInt(rpc.PendingBlockNumber.Int64()), ToBlock: big.NewInt(rpc.LatestBlockNumber.Int64())},
1: {FromBlock: big.NewInt(rpc.PendingBlockNumber.Int64()), ToBlock: big.NewInt(100)},
2: {FromBlock: big.NewInt(rpc.LatestBlockNumber.Int64()), ToBlock: big.NewInt(100)},
3: {Topics: [][]common.Hash{{}, {}, {}, {}, {}}},
}

for i, test := range testCases {
Expand All @@ -448,7 +445,6 @@ func TestInvalidGetLogsRequest(t *testing.T) {
0: {BlockHash: &blockHash, FromBlock: big.NewInt(100)},
1: {BlockHash: &blockHash, ToBlock: big.NewInt(500)},
2: {BlockHash: &blockHash, FromBlock: big.NewInt(rpc.LatestBlockNumber.Int64())},
3: {BlockHash: &blockHash, Topics: [][]common.Hash{{}, {}, {}, {}, {}}},
}

for i, test := range testCases {
Expand Down

0 comments on commit 9ff02cd

Please sign in to comment.