@@ -26,6 +26,7 @@ import (
2626 "github.com/erigontech/erigon/common"
2727 "github.com/erigontech/erigon/common/log/v3"
2828 "github.com/erigontech/erigon/db/kv"
29+ "github.com/erigontech/erigon/db/kv/kvcfg"
2930 "github.com/erigontech/erigon/db/kv/order"
3031 "github.com/erigontech/erigon/db/kv/rawdbv3"
3132 "github.com/erigontech/erigon/db/kv/stream"
@@ -192,6 +193,27 @@ func (api *APIImpl) GetLogs(ctx context.Context, crit filters.FilterCriteria) (t
192193 return rpcLogs , nil
193194}
194195
196+ // assertReceiptsAvailable corner cases:
197+ // - `--persist.receipts`: means all receipts available (even in `--prune.mode=minimal` mode)
198+ // - `--prune.mode=minimal` (and `full`) can serve receipts as much as "state history" available (by re-executing blocks)
199+ //
200+ // returns `state.PrunedError` if not available for given `fromTxNum`
201+ func assertReceiptsAvailable (fromTxNum uint64 , tx kv.TemporalTx ) error {
202+ persistReceipts , err := kvcfg .PersistReceipts .Enabled (tx )
203+ if err != nil {
204+ return err
205+ }
206+ if persistReceipts {
207+ return nil
208+ }
209+ r := state .NewHistoryReaderV3 ()
210+ r .SetTx (tx )
211+ if fromTxNum < r .StateHistoryStartFrom () {
212+ return state .PrunedError
213+ }
214+ return nil
215+ }
216+
195217func applyFiltersV3 (txNumsReader rawdbv3.TxNumsReader , tx kv.TemporalTx , begin , end uint64 , crit filters.FilterCriteria , asc order.By ) (out stream.U64 , err error ) {
196218 //[from,to)
197219 var fromTxNum , toTxNum uint64
@@ -200,10 +222,8 @@ func applyFiltersV3(txNumsReader rawdbv3.TxNumsReader, tx kv.TemporalTx, begin,
200222 if err != nil {
201223 return out , err
202224 }
203- r := state .NewHistoryReaderV3 ()
204- r .SetTx (tx )
205- if fromTxNum < r .StateHistoryStartFrom () {
206- return out , state .PrunedError
225+ if err := assertReceiptsAvailable (fromTxNum , tx ); err != nil {
226+ return out , err
207227 }
208228 }
209229
0 commit comments