Skip to content

refactor(retrieval-anon): filter expired PDP payments at the subgraph#12

Draft
dennis-tra wants to merge 1 commit into
anon-retrievalfrom
feat/backend/payment-termination-tracking
Draft

refactor(retrieval-anon): filter expired PDP payments at the subgraph#12
dennis-tra wants to merge 1 commit into
anon-retrievalfrom
feat/backend/payment-termination-tracking

Conversation

@dennis-tra

@dennis-tra dennis-tra commented May 29, 2026

Copy link
Copy Markdown

Currently targets the anon-retrieval in ProbeLab's GH org but eventually should target main in https://github.com/FilOzone/dealbot after FilOzone#487 has landed.

This is the second part of FilOzone#579. First part is FilOzone#582.

What

sampleAnonPiece now adds isPaymentActive: true to the proofSet filter,
so the subgraph excludes datasets whose PDP payment has terminated. With
that guarantee, AnonPieceSelectorService.drawPiece collapses to a single
deterministic draw per (bucket, pool): the up-to-two retry loop and the
pdpPaymentEndEpoch <= indexedAtBlock client-side check both go away.

The selector is now strictly cheaper — fewer subgraph round-trips, no
client-side staleness window between indexedAtBlock and the chain head,
and the fallback ladder (same-bucket opposite-pool → any-bucket indexed
→ any-bucket any) runs the same shape with half the calls.

Requires the matching subgraph change (feat/subgraph/payment-termination- tracking) that maintains DataSet.isPaymentActive. Backwards compatible
with the existing subgraph fields: pdpPaymentEndEpoch is still selected
and returned in AnonCandidatePiece for callers that still want it,
just no longer consulted by the selector itself.

`sampleAnonPiece` now adds `isPaymentActive: true` to the proofSet filter,
so the subgraph excludes datasets whose PDP payment has terminated. With
that guarantee, `AnonPieceSelectorService.drawPiece` collapses to a single
deterministic draw per (bucket, pool): the up-to-two retry loop and the
`pdpPaymentEndEpoch <= indexedAtBlock` client-side check both go away.

The selector is now strictly cheaper — fewer subgraph round-trips, no
client-side staleness window between `indexedAtBlock` and the chain head,
and the fallback ladder (same-bucket opposite-pool → any-bucket indexed
→ any-bucket any) runs the same shape with half the calls.

Requires the matching subgraph change (`feat/subgraph/payment-termination-
tracking`) that maintains `DataSet.isPaymentActive`. Backwards compatible
with the existing subgraph fields: `pdpPaymentEndEpoch` is still selected
and returned in `AnonCandidatePiece` for callers that still want it,
just no longer consulted by the selector itself.

Closes FilOzone#579.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant