eth/filters: return prunedHistoryError if attempting to create a log filter on a blockhash before the prune point

This commit is contained in:
Jared Wasinger 2025-03-13 11:13:36 +01:00 committed by Felix Lange
parent f6667276d5
commit 440eb9ad90

View file

@ -400,6 +400,15 @@ func (api *FilterAPI) GetFilterLogs(ctx context.Context, id rpc.ID) ([]*types.Lo
var filter *Filter var filter *Filter
if f.crit.BlockHash != nil { if f.crit.BlockHash != nil {
// ensure the filter criteria does not specify block hash below the
// history prune point
header, err := api.sys.backend.HeaderByHash(ctx, *f.crit.BlockHash)
if err != nil {
return nil, err
}
if header.Number.Uint64() < api.events.backend.HistoryCutoff() {
return nil, &prunedHistoryError{}
}
// Block filter requested, construct a single-shot filter // Block filter requested, construct a single-shot filter
filter = api.sys.NewBlockFilter(*f.crit.BlockHash, f.crit.Addresses, f.crit.Topics) filter = api.sys.NewBlockFilter(*f.crit.BlockHash, f.crit.Addresses, f.crit.Topics)
} else { } else {