Skip to content

Commit

Permalink
Fix off-by-one error in MaxBlocksPerRequest. (#180)
Browse files Browse the repository at this point in the history
For each value X, it should accept the range [N,N+X-1], not [N,N+X],
e.g. if it's set to 1 it should accept just the single block range [N,N].

https://xkcd.com/2248/

Signed-off-by: aaronbuchwald <[email protected]>
Co-authored-by: aaronbuchwald <[email protected]>
  • Loading branch information
alexdupre and aaronbuchwald authored Jun 13, 2023
1 parent fd17092 commit 91e10ff
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion eth/filters/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (f *Filter) Logs(ctx context.Context) ([]*types.Log, error) {

// If the requested range of blocks exceeds the maximum number of blocks allowed by the backend
// return an error instead of searching for the logs.
if maxBlocks := f.sys.backend.GetMaxBlocksPerRequest(); int64(end)-f.begin > maxBlocks && maxBlocks > 0 {
if maxBlocks := f.sys.backend.GetMaxBlocksPerRequest(); int64(end)-f.begin >= maxBlocks && maxBlocks > 0 {
return nil, fmt.Errorf("requested too many blocks from %d to %d, maximum is set to %d", f.begin, int64(end), maxBlocks)
}
// Gather all indexed logs, and finish with non indexed ones
Expand Down

0 comments on commit 91e10ff

Please sign in to comment.