graphql: respect rpc.rangelimit in Logs query

Add `RangeLimit()` getter to `FilterSystem` and use it in GraphQL's `Logs` resolver instead of hardcoded 0. Fixes the bypass of `--rpc.rangelimit` protection on the GraphQL endpoint.
This commit is contained in:
Tanvir 2026-04-15 15:25:19 +08:00
parent ef0f1f96f9
commit e0989cdff4
2 changed files with 6 additions and 1 deletions

View file

@ -94,6 +94,11 @@ func NewFilterSystem(backend Backend, config Config) *FilterSystem {
}
}
// RangeLimit returns the configured maximum block range for filter queries.
func (sys *FilterSystem) RangeLimit() uint64 {
return sys.cfg.RangeLimit
}
type logCacheElem struct {
logs []*types.Log
body atomic.Pointer[types.Body]

View file

@ -1445,7 +1445,7 @@ func (r *Resolver) Logs(ctx context.Context, args struct{ Filter FilterCriteria
topics = *args.Filter.Topics
}
// Construct the range filter
filter := r.filterSystem.NewRangeFilter(begin, end, addresses, topics, 0)
filter := r.filterSystem.NewRangeFilter(begin, end, addresses, topics, r.filterSystem.RangeLimit())
return runFilter(ctx, r, filter)
}