Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth/filters: enforce topic-limit early on filter criterias #29535

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions eth/filters/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@ func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
return errors.New("invalid addresses in query")
}
}
if len(raw.Topics) > maxTopics {
return errExceedMaxTopics
}

// topics is an array consisting of strings and/or arrays of strings.
// JSON null values are converted to common.Hash{} and ignored by the filter manager.
Expand All @@ -559,6 +562,9 @@ func (args *FilterCriteria) UnmarshalJSON(data []byte) error {

case []interface{}:
// or case e.g. [null, "topic0", "topic1"]
if len(topic) > maxTopics {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be a list of values as the topic candidate. Does it make sense to hard-cap it as 4?

return errExceedMaxTopics
}
for _, rawTopic := range topic {
if rawTopic == nil {
// null component, match all
Expand Down
Loading