Skip to content

getPdpDataSet fails on large data sets because getActivePieceCount reverts inside multicall #851

Description

@BravoNatalie

Description

getPdpDataSet() can fail for large live datasets even when all of its underlying reads are valid. The issue is that getActivePieceCount(setId) iterates through every piece ID from 0 to nextPieceId[setId], so the cost of the call grows with the total piece ID range. For large datasets, this subcall can exceed the limits and revert inside Multicall3, causing the entire getPdpDataSet() call to fail.

This can be reproduced on Filecoin mainnet with setId = 1273. All of the underlying reads succeed when called individually, including getDataSet, dataSetLive, getDataSetListener, getAllDataSetMetadata, getPDPProvider, and getActivePieceCount. However, getPdpDataSet() fails because it executes all of these reads through a single multicall. In that context, the getActivePieceCount(setId) subcall becomes too expensive and reverts, causing the entire getPdpDataSet() call to fail.

Proposed solution

Make getPdpDataSet() reliable for large datasets by removing getActivePieceCount from the readPdpDataSetInfo multicall. getPdpDataSet() can fetch activePieceCount separately, derive it using getActivePiecesByCursor (which is guaranteed to scale to large datasets), or omit the piece count entirely.

Also add documentation recommending getActivePiecesByCursor as a fallback for callers that explicitly need a derived active piece count.

Done criteria

  • getPdpDataSet(setId) succeeds for large live data sets where the current implementation fails

Notes

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
🎉 Done

Relationships

None yet

Development

No branches or pull requests

Issue actions