sdk(local_relay): enforce max_query_results on REQ - #1457
Open
TheAwiteb wants to merge 1 commit into
Open
Conversation
Previously, max_query_results was not applied when a REQ contained multiple filters. Each filter's limit is now determined individually: use the filter's `.ids` count or its limit, bounded by max_filter_limit, or default_filter_limit if none is set. If the sum of all filter limits exceeds max_query_results, the total is split among filters. For example, with max_query_results=6 and two filters each requesting 5 events, each filter gets 3. If the number is not divisible (e.g., 7), the filters may get 4, slightly exceeding the max, which is acceptable. Signed-off-by: Awiteb <a@4rs.nl>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
3 tasks
yukibtc
added a commit
that referenced
this pull request
Aug 22, 2026
Refactor filter limit configuration and checks. Use `max_filter_limit` as the limit for each filter. The combination of `max_filter_limit` and `max_filters_per_req` determines the maximum number of query results per request. Deprecate `LocalRelayBuilder::max_query_results` and `LocalRelayBuilder::default_filter_limit` in favor of `LocalRelayBuilder::max_filters_per_req` and `LocalRelayBuilder::max_filter_limit`, respectively. Replaces #1457 Pull-Request: #1461 Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
yukibtc
added a commit
that referenced
this pull request
Aug 22, 2026
Refactor filter limit configuration and checks. Use `max_filter_limit` as the limit for each filter. The combination of `max_filter_limit` and `max_filters_per_req` determines the maximum number of query results per request. Deprecate `LocalRelayBuilder::max_query_results` and `LocalRelayBuilder::default_filter_limit` in favor of `LocalRelayBuilder::max_filters_per_req` and `LocalRelayBuilder::max_filter_limit`, respectively. Replaces #1457 Pull-Request: #1461 Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, max_query_results was not applied when a REQ contained multiple filters. Each filter's limit is now determined individually: use the filter's
.idscount or its limit, bounded by max_filter_limit, or default_filter_limit if none is set.If the sum of all filter limits exceeds max_query_results, the total is split among filters. For example, with max_query_results=6 and two filters each requesting 5 events, each filter gets 3. If the number is not divisible (e.g., 7), the filters may get 4, slightly exceeding the max, which is acceptable.
Notes to the reviewers
I'm not a fan of the global limit approach. I added a
TODOfor filters requesting specific IDs: their limit should strictly be the number of IDs provided, and the remainingmax_query_resultsbudget should then be split among the filters that don't use IDs.Of course, we still need to respect the global cap if all filters are ID-based and their total exceeds
max_query_results.Checklist
CHANGELOG.md(if applicable)