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
Notes
Description
getPdpDataSet()can fail for large live datasets even when all of its underlying reads are valid. The issue is thatgetActivePieceCount(setId)iterates through every piece ID from0tonextPieceId[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 insideMulticall3, causing the entiregetPdpDataSet()call to fail.This can be reproduced on Filecoin mainnet with
setId = 1273. All of the underlying reads succeed when called individually, includinggetDataSet,dataSetLive,getDataSetListener,getAllDataSetMetadata,getPDPProvider, andgetActivePieceCount. However,getPdpDataSet()fails because it executes all of these reads through a single multicall. In that context, thegetActivePieceCount(setId)subcall becomes too expensive and reverts, causing the entiregetPdpDataSet()call to fail.Proposed solution
Make
getPdpDataSet()reliable for large datasets by removinggetActivePieceCountfrom thereadPdpDataSetInfomulticall.getPdpDataSet()can fetchactivePieceCountseparately, derive it usinggetActivePiecesByCursor(which is guaranteed to scale to large datasets), or omit the piece count entirely.Also add documentation recommending
getActivePiecesByCursoras a fallback for callers that explicitly need a derived active piece count.Done criteria
Notes