Description
synapse-core currently exposes and uses getActivePieces(setId, offset, limit) for active piece pagination, but this path becomes impractical on large data sets. In PDPVerifier, getActivePieces has O(offset) gas complexity because it always iterates from piece ID 0. For deep pages, read calls can fail with out-of-gas errors even though the data set is live and the call is otherwise valid.
The contract already includes getActivePiecesByCursor(setId, startPieceId, limit), which is designed for O(limit) pagination and works correctly for the same data sets where offset-based pagination fails. However, this function is not currently exported by synapse-core, which forces downstream consumers onto the more expensive path.
Proposed solution
Add a getActivePiecesByCursor export to @filoz/synapse-core/pdp-verifier and update internal or downstream pagination flows to prefer it over getActivePieces.
Done criteria
Description
synapse-core currently exposes and uses
getActivePieces(setId, offset, limit)for active piece pagination, but this path becomes impractical on large data sets. InPDPVerifier,getActivePieceshasO(offset)gas complexity because it always iterates from piece ID0. For deep pages, read calls can fail with out-of-gas errors even though the data set is live and the call is otherwise valid.The contract already includes
getActivePiecesByCursor(setId, startPieceId, limit), which is designed forO(limit)pagination and works correctly for the same data sets where offset-based pagination fails. However, this function is not currently exported bysynapse-core, which forces downstream consumers onto the more expensive path.Proposed solution
Add a
getActivePiecesByCursorexport to@filoz/synapse-core/pdp-verifierand update internal or downstream pagination flows to prefer it overgetActivePieces.Done criteria
getActivePiecesByCursorfrom@filoz/synapse-core/pdp-verifierflow(s)
getActivePiecesisO(offset)andgetActivePiecesByCursorshould be preferred forlarge data sets