Skip to content

Commit 1224f01

Browse files
committed
rpc: add a rpc.rangelimit flag ethereum#33163
1 parent bf63562 commit 1224f01

10 files changed

Lines changed: 86 additions & 26 deletions

File tree

accounts/abi/bind/backends/simulated.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.Filter
839839
to = query.ToBlock.Int64()
840840
}
841841
// Construct the range filter
842-
filter = b.filterSystem.NewRangeFilter(from, to, query.Addresses, query.Topics)
842+
filter = b.filterSystem.NewRangeFilter(from, to, query.Addresses, query.Topics, 0)
843843
}
844844
// Run the filter and return all the logs
845845
logs, err := filter.Logs(ctx)

cmd/XDC/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ var (
166166
utils.AllowUnprotectedTxs,
167167
utils.BatchRequestLimit,
168168
utils.BatchResponseMaxSize,
169+
utils.RPCGlobalRangeLimitFlag,
169170
}
170171

171172
metricsFlags = []cli.Flag{

cmd/utils/flags.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,15 @@ var (
408408
Category: flags.APICategory,
409409
}
410410
RPCGlobalLogQueryLimit = &cli.IntFlag{
411-
Name: "rpc.logquerylimit",
412-
Usage: "Maximum number of alternative addresses or topics allowed per search position in eth_getLogs filter criteria (0 = no cap)",
413-
Value: ethconfig.Defaults.LogQueryLimit,
411+
Name: "rpc-logquerylimit",
412+
Usage: "Maximum number of alternative addresses or topics allowed per search position in eth_getLogs filter criteria (0 = no cap)",
413+
Value: ethconfig.Defaults.LogQueryLimit,
414+
Category: flags.APICategory,
415+
}
416+
RPCGlobalRangeLimitFlag = &cli.Uint64Flag{
417+
Name: "rpc-rangelimit",
418+
Usage: "Maximum block range (end - begin) allowed for range queries (0 = unlimited)",
419+
Value: ethconfig.Defaults.RangeLimit,
414420
Category: flags.APICategory,
415421
}
416422
// Authenticated RPC HTTP settings
@@ -1522,6 +1528,9 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
15221528
if ctx.IsSet(RPCGlobalGasCapFlag.Name) {
15231529
cfg.RPCGasCap = ctx.Uint64(RPCGlobalGasCapFlag.Name)
15241530
}
1531+
if ctx.IsSet(RPCGlobalRangeLimitFlag.Name) {
1532+
cfg.RangeLimit = ctx.Uint64(RPCGlobalRangeLimitFlag.Name)
1533+
}
15251534
if ctx.IsSet(MinerExtraDataFlag.Name) {
15261535
cfg.ExtraData = []byte(ctx.String(MinerExtraDataFlag.Name))
15271536
}
@@ -1849,6 +1858,7 @@ func RegisterFilterAPI(stack *node.Node, backend ethapi.Backend, ethcfg *ethconf
18491858
filterSystem := filters.NewFilterSystem(backend, filters.Config{
18501859
LogCacheSize: ethcfg.FilterLogCacheSize,
18511860
LogQueryLimit: ethcfg.LogQueryLimit,
1861+
RangeLimit: ethcfg.RangeLimit,
18521862
})
18531863
stack.RegisterAPIs([]rpc.API{{
18541864
Namespace: "eth",

eth/ethconfig/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ var Defaults = Config{
5757
RPCEVMTimeout: 5 * time.Second,
5858
GPO: FullNodeGPO,
5959
RPCTxFeeCap: 1, // 1 ether
60+
RangeLimit: 0,
6061
}
6162

6263
//go:generate go run github.com/fjl/gencodec -type Config -field-override configMarshaling -formats toml -out gen_config.go
@@ -124,6 +125,9 @@ type Config struct {
124125
// RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for
125126
// send-transction variants. The unit is ether.
126127
RPCTxFeeCap float64
128+
129+
// RangeLimit restricts the maximum range (end - start) for range queries.
130+
RangeLimit uint64 `toml:",omitempty"`
127131
}
128132

129133
type configMarshaling struct {

eth/ethconfig/gen_config.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eth/filters/api.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ type FilterAPI struct {
7979
filters map[rpc.ID]*filter
8080
timeout time.Duration
8181
logQueryLimit int
82+
rangeLimit uint64
8283
}
8384

8485
// NewFilterAPI returns a new FilterAPI instance.
@@ -89,6 +90,7 @@ func NewFilterAPI(system *FilterSystem, lightMode bool) *FilterAPI {
8990
filters: make(map[rpc.ID]*filter),
9091
timeout: system.cfg.Timeout,
9192
logQueryLimit: system.cfg.LogQueryLimit,
93+
rangeLimit: system.cfg.RangeLimit,
9294
}
9395
go api.timeoutLoop(system.cfg.Timeout)
9496

@@ -385,7 +387,7 @@ func (api *FilterAPI) GetLogs(ctx context.Context, crit FilterCriteria) ([]*type
385387
return nil, errInvalidBlockRange
386388
}
387389
// Construct the range filter
388-
filter = api.sys.NewRangeFilter(begin, end, crit.Addresses, crit.Topics)
390+
filter = api.sys.NewRangeFilter(begin, end, crit.Addresses, crit.Topics, api.rangeLimit)
389391
}
390392

391393
// Run the filter and return all the logs
@@ -441,7 +443,7 @@ func (api *FilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*types.Lo
441443
end = f.crit.ToBlock.Int64()
442444
}
443445
// Construct the range filter
444-
filter = api.sys.NewRangeFilter(begin, end, f.crit.Addresses, f.crit.Topics)
446+
filter = api.sys.NewRangeFilter(begin, end, f.crit.Addresses, f.crit.Topics, api.rangeLimit)
445447
}
446448
// Run the filter and return all the logs
447449
logs, err := filter.Logs(ctx)

eth/filters/bench_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func benchmarkBloomBits(b *testing.B, sectionSize uint64) {
138138
var addr common.Address
139139
addr[0] = byte(i)
140140
addr[1] = byte(i / 256)
141-
filter := sys.NewRangeFilter(0, int64(cnt*sectionSize-1), []common.Address{addr}, nil)
141+
filter := sys.NewRangeFilter(0, int64(cnt*sectionSize-1), []common.Address{addr}, nil, 0)
142142
if _, err := filter.Logs(context.Background()); err != nil {
143143
b.Error("filter.Logs error:", err)
144144
}
@@ -194,7 +194,7 @@ func BenchmarkNoBloomBits(b *testing.B) {
194194

195195
b.Log("Running filter benchmarks...")
196196
start := time.Now()
197-
filter := sys.NewRangeFilter(0, int64(*headNum), []common.Address{{}}, nil)
197+
filter := sys.NewRangeFilter(0, int64(*headNum), []common.Address{{}}, nil, 0)
198198
filter.Logs(context.Background())
199199
d := time.Since(start)
200200
b.Log("Finished running filter benchmarks")

eth/filters/filter.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package filters
1919
import (
2020
"context"
2121
"errors"
22+
"fmt"
2223
"math/big"
2324

2425
"github.com/XinFinOrg/XDPoSChain/common"
@@ -38,11 +39,13 @@ type Filter struct {
3839
begin, end int64 // Range interval if filtering multiple blocks
3940

4041
matcher *bloombits.Matcher
42+
43+
rangeLimit uint64
4144
}
4245

4346
// NewRangeFilter creates a new filter which uses a bloom filter on blocks to
4447
// figure out whether a particular block is interesting or not.
45-
func (sys *FilterSystem) NewRangeFilter(begin, end int64, addresses []common.Address, topics [][]common.Hash) *Filter {
48+
func (sys *FilterSystem) NewRangeFilter(begin, end int64, addresses []common.Address, topics [][]common.Hash, rangeLimit uint64) *Filter {
4649
// Flatten the address and topic filter clauses into a single bloombits filter
4750
// system. Since the bloombits are not positional, nil topics are permitted,
4851
// which get flattened into a nil byte slice.
@@ -69,6 +72,7 @@ func (sys *FilterSystem) NewRangeFilter(begin, end int64, addresses []common.Add
6972
filter.matcher = bloombits.NewMatcher(size, filters)
7073
filter.begin = begin
7174
filter.end = end
75+
filter.rangeLimit = rangeLimit
7276

7377
return filter
7478
}
@@ -150,6 +154,9 @@ func (f *Filter) Logs(ctx context.Context) ([]*types.Log, error) {
150154
if f.end, err = resolveSpecial(f.end); err != nil {
151155
return nil, err
152156
}
157+
if f.rangeLimit != 0 && (uint64(f.end)-uint64(f.begin)) > f.rangeLimit {
158+
return nil, fmt.Errorf("exceed maximum block range: %d", f.rangeLimit)
159+
}
153160

154161
logChan, errChan := f.rangeLogsAsync(ctx)
155162
var logs []*types.Log

eth/filters/filter_system.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type Config struct {
4444
LogCacheSize int // maximum number of cached blocks (default: 32)
4545
Timeout time.Duration // how long filters stay active (default: 5min)
4646
LogQueryLimit int // maximum number of addresses allowed in filter criteria (default: 1000)
47+
RangeLimit uint64 // maximum block range allowed in filter criteria (default: 0)
4748
}
4849

4950
func (cfg Config) withDefaults() Config {

eth/filters/filter_test.go

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func BenchmarkFilters(b *testing.B) {
8484
}
8585
b.ResetTimer()
8686

87-
filter := sys.NewRangeFilter(0, -1, []common.Address{addr1, addr2, addr3, addr4}, nil)
87+
filter := sys.NewRangeFilter(0, -1, []common.Address{addr1, addr2, addr3, addr4}, nil, 0)
8888

8989
for i := 0; i < b.N; i++ {
9090
logs, _ := filter.Logs(context.Background())
@@ -277,45 +277,45 @@ func TestFilters(t *testing.T) {
277277
f: sys.NewBlockFilter(chain[2].Hash(), []common.Address{contract}, nil),
278278
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696332","0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x3","transactionHash":"0xac8b8343d69a5c46fef5af7158f42a389bc84093a88e97e184cc4263cf85dc54","transactionIndex":"0x0","blockHash":"0x6dca03904b22bf701dae59c7135dc3e0b578bd4c577d1c111d9d97776090ae09","logIndex":"0x0","removed":false}]`,
279279
}, {
280-
f: sys.NewRangeFilter(0, int64(rpc.LatestBlockNumber), []common.Address{contract}, [][]common.Hash{{hash1, hash2, hash3, hash4}}),
280+
f: sys.NewRangeFilter(0, int64(rpc.LatestBlockNumber), []common.Address{contract}, [][]common.Hash{{hash1, hash2, hash3, hash4}}, 0),
281281
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x2","transactionHash":"0x3ebf3c1ea6e0282cfe845f273b2cc7e97f02145e6d0577641cd1a82d532a19c1","transactionIndex":"0x0","blockHash":"0x0f4dea85fc816b6fd5eb4a0ba86eb00cc7d3397785336870bebd27f181a722da","logIndex":"0x0","removed":false},{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696332","0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x3","transactionHash":"0xac8b8343d69a5c46fef5af7158f42a389bc84093a88e97e184cc4263cf85dc54","transactionIndex":"0x0","blockHash":"0x6dca03904b22bf701dae59c7135dc3e0b578bd4c577d1c111d9d97776090ae09","logIndex":"0x0","removed":false},{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696334"],"data":"0x","blockNumber":"0x3e8","transactionHash":"0x21fd39694cbcc8cc5046b3b7d5200101edf9c85218da613a8851eb5e3d195241","transactionIndex":"0x0","blockHash":"0x8a956d79ca6468ff23c97615a4aa24a55bdaff78767ee28d3e2e02ecb407a0de","logIndex":"0x0","removed":false}]`,
282282
}, {
283-
f: sys.NewRangeFilter(900, 999, []common.Address{contract}, [][]common.Hash{{hash3}}),
283+
f: sys.NewRangeFilter(900, 999, []common.Address{contract}, [][]common.Hash{{hash3}}, 0),
284284
}, {
285-
f: sys.NewRangeFilter(990, int64(rpc.LatestBlockNumber), []common.Address{contract2}, [][]common.Hash{{hash3}}),
285+
f: sys.NewRangeFilter(990, int64(rpc.LatestBlockNumber), []common.Address{contract2}, [][]common.Hash{{hash3}}, 0),
286286
want: `[{"address":"0xff00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696333"],"data":"0x","blockNumber":"0x3e7","transactionHash":"0x7c42465b2bd34fb8e87bab0001ab97c47b6d57c65f17efe43e81461fef2f05a4","transactionIndex":"0x0","blockHash":"0x5112c98f7517100552d30734c46356db10494c90bb3bd0af90ef9ace2e692ad2","logIndex":"0x0","removed":false}]`,
287287
}, {
288-
f: sys.NewRangeFilter(1, 10, []common.Address{contract}, [][]common.Hash{{hash2}, {hash1}}),
288+
f: sys.NewRangeFilter(1, 10, []common.Address{contract}, [][]common.Hash{{hash2}, {hash1}}, 0),
289289
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696332","0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x3","transactionHash":"0xac8b8343d69a5c46fef5af7158f42a389bc84093a88e97e184cc4263cf85dc54","transactionIndex":"0x0","blockHash":"0x6dca03904b22bf701dae59c7135dc3e0b578bd4c577d1c111d9d97776090ae09","logIndex":"0x0","removed":false}]`,
290290
}, {
291-
f: sys.NewRangeFilter(1, 10, nil, [][]common.Hash{{hash1, hash2}}),
291+
f: sys.NewRangeFilter(1, 10, nil, [][]common.Hash{{hash1, hash2}}, 0),
292292
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x2","transactionHash":"0x3ebf3c1ea6e0282cfe845f273b2cc7e97f02145e6d0577641cd1a82d532a19c1","transactionIndex":"0x0","blockHash":"0x0f4dea85fc816b6fd5eb4a0ba86eb00cc7d3397785336870bebd27f181a722da","logIndex":"0x0","removed":false},{"address":"0xff00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x2","transactionHash":"0x55b3a22ae885f9441ff8bd98fbfe54cc1b84799606aca159fac8d7a56551e426","transactionIndex":"0x1","blockHash":"0x0f4dea85fc816b6fd5eb4a0ba86eb00cc7d3397785336870bebd27f181a722da","logIndex":"0x1","removed":false},{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696332","0x0000000000000000000000000000000000000000000000000000746f70696331"],"data":"0x","blockNumber":"0x3","transactionHash":"0xac8b8343d69a5c46fef5af7158f42a389bc84093a88e97e184cc4263cf85dc54","transactionIndex":"0x0","blockHash":"0x6dca03904b22bf701dae59c7135dc3e0b578bd4c577d1c111d9d97776090ae09","logIndex":"0x0","removed":false}]`,
293293
}, {
294-
f: sys.NewRangeFilter(0, int64(rpc.LatestBlockNumber), nil, [][]common.Hash{{common.BytesToHash([]byte("fail"))}}),
294+
f: sys.NewRangeFilter(0, int64(rpc.LatestBlockNumber), nil, [][]common.Hash{{common.BytesToHash([]byte("fail"))}}, 0),
295295
}, {
296-
f: sys.NewRangeFilter(0, int64(rpc.LatestBlockNumber), []common.Address{common.BytesToAddress([]byte("failmenow"))}, nil),
296+
f: sys.NewRangeFilter(0, int64(rpc.LatestBlockNumber), []common.Address{common.BytesToAddress([]byte("failmenow"))}, nil, 0),
297297
}, {
298-
f: sys.NewRangeFilter(0, int64(rpc.LatestBlockNumber), nil, [][]common.Hash{{common.BytesToHash([]byte("fail"))}, {hash1}}),
298+
f: sys.NewRangeFilter(0, int64(rpc.LatestBlockNumber), nil, [][]common.Hash{{common.BytesToHash([]byte("fail"))}, {hash1}}, 0),
299299
}, {
300-
f: sys.NewRangeFilter(int64(rpc.LatestBlockNumber), int64(rpc.LatestBlockNumber), nil, nil),
300+
f: sys.NewRangeFilter(int64(rpc.LatestBlockNumber), int64(rpc.LatestBlockNumber), nil, nil, 0),
301301
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696334"],"data":"0x","blockNumber":"0x3e8","transactionHash":"0x21fd39694cbcc8cc5046b3b7d5200101edf9c85218da613a8851eb5e3d195241","transactionIndex":"0x0","blockHash":"0x8a956d79ca6468ff23c97615a4aa24a55bdaff78767ee28d3e2e02ecb407a0de","logIndex":"0x0","removed":false}]`,
302302
}, {
303-
f: sys.NewRangeFilter(int64(rpc.FinalizedBlockNumber), int64(rpc.LatestBlockNumber), nil, nil),
303+
f: sys.NewRangeFilter(int64(rpc.FinalizedBlockNumber), int64(rpc.LatestBlockNumber), nil, nil, 0),
304304
err: "committed header not found",
305305
}, {
306-
f: sys.NewRangeFilter(int64(rpc.FinalizedBlockNumber), int64(rpc.FinalizedBlockNumber), nil, nil),
306+
f: sys.NewRangeFilter(int64(rpc.FinalizedBlockNumber), int64(rpc.FinalizedBlockNumber), nil, nil, 0),
307307
err: "committed header not found",
308308
}, {
309-
f: sys.NewRangeFilter(int64(rpc.LatestBlockNumber), int64(rpc.FinalizedBlockNumber), nil, nil),
309+
f: sys.NewRangeFilter(int64(rpc.LatestBlockNumber), int64(rpc.FinalizedBlockNumber), nil, nil, 0),
310310
err: "committed header not found",
311311
}, {
312-
f: sys.NewRangeFilter(int64(rpc.PendingBlockNumber), int64(rpc.PendingBlockNumber), nil, nil),
312+
f: sys.NewRangeFilter(int64(rpc.PendingBlockNumber), int64(rpc.PendingBlockNumber), nil, nil, 0),
313313
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696335"],"data":"0x","blockNumber":"0x3e9","transactionHash":"0x87d02f2dddb1941ff179ae5d5fbb123afb9c5f71220045bc1c48f3872be24d4a","transactionIndex":"0x0","blockHash":"0x5f2b35a350840476a43aa23c6ea031d6db277aef337775ebb8421df64f17723f","logIndex":"0x0","removed":false}]`,
314314
}, {
315-
f: sys.NewRangeFilter(int64(rpc.LatestBlockNumber), int64(rpc.PendingBlockNumber), nil, nil),
315+
f: sys.NewRangeFilter(int64(rpc.LatestBlockNumber), int64(rpc.PendingBlockNumber), nil, nil, 0),
316316
want: `[{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696334"],"data":"0x","blockNumber":"0x3e8","transactionHash":"0x21fd39694cbcc8cc5046b3b7d5200101edf9c85218da613a8851eb5e3d195241","transactionIndex":"0x0","blockHash":"0x8a956d79ca6468ff23c97615a4aa24a55bdaff78767ee28d3e2e02ecb407a0de","logIndex":"0x0","removed":false},{"address":"0xfe00000000000000000000000000000000000000","topics":["0x0000000000000000000000000000000000000000000000000000746f70696335"],"data":"0x","blockNumber":"0x3e9","transactionHash":"0x87d02f2dddb1941ff179ae5d5fbb123afb9c5f71220045bc1c48f3872be24d4a","transactionIndex":"0x0","blockHash":"0x5f2b35a350840476a43aa23c6ea031d6db277aef337775ebb8421df64f17723f","logIndex":"0x0","removed":false}]`,
317317
}, {
318-
f: sys.NewRangeFilter(int64(rpc.PendingBlockNumber), int64(rpc.LatestBlockNumber), nil, nil),
318+
f: sys.NewRangeFilter(int64(rpc.PendingBlockNumber), int64(rpc.LatestBlockNumber), nil, nil, 0),
319319
err: "invalid block range",
320320
},
321321
} {
@@ -338,7 +338,7 @@ func TestFilters(t *testing.T) {
338338
}
339339

340340
t.Run("timeout", func(t *testing.T) {
341-
f := sys.NewRangeFilter(0, -1, nil, nil)
341+
f := sys.NewRangeFilter(0, -1, nil, nil, 0)
342342
ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(-time.Hour))
343343
defer cancel()
344344
_, err := f.Logs(ctx)
@@ -350,3 +350,32 @@ func TestFilters(t *testing.T) {
350350
}
351351
})
352352
}
353+
354+
func TestRangeLimit(t *testing.T) {
355+
db := rawdb.NewMemoryDatabase()
356+
_, sys := newTestFilterSystem(t, db, Config{})
357+
defer db.Close()
358+
359+
gspec := &core.Genesis{
360+
Config: params.TestChainConfig,
361+
Alloc: types.GenesisAlloc{},
362+
BaseFee: big.NewInt(params.InitialBaseFee),
363+
}
364+
genesis := gspec.MustCommit(db)
365+
chain, _ := core.GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 10, func(i int, gen *core.BlockGen) {})
366+
bc, err := core.NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{})
367+
if err != nil {
368+
t.Fatal(err)
369+
}
370+
_, err = bc.InsertChain(chain)
371+
if err != nil {
372+
t.Fatal(err)
373+
}
374+
375+
// Set rangeLimit to 5, but request a range of 9 (end - begin = 9, from 0 to 9)
376+
filter := sys.NewRangeFilter(0, 9, nil, nil, 5)
377+
_, err = filter.Logs(context.Background())
378+
if err == nil || !strings.Contains(err.Error(), "exceed maximum block range") {
379+
t.Fatalf("expected range limit error, got %v", err)
380+
}
381+
}

0 commit comments

Comments
 (0)