FilOzone / FilOzone/pdp

getActivePieceCount fails with out-of-gas for large datasets

Open
#265 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
Solidity
Stars
20
Forks
17
Avg merge
2h 31m
Merged PRs (30d)
4

Description

## Problem

`getActivePieceCount(uint256 setId)` has O(n) complexity where n = `nextPieceId[setId]`. For datasets with tens of thousands of pieces, this exceeds the gas limit for `eth_call` requests.

## Reproduction

On mainnet verifier (`0xBADd0B92C1c71d02E7d520f64c0876538fa2557F`):

```bash
# Works - small dataset
cast call 0xBADd0B92C1c71d02E7d520f64c0876538fa2557F "getActivePieceCount(uint256)(uint256)" 1 --rpc-url https://api.node.glif.io/rpc/v1
# Returns: 2

# Fails - large dataset (54,568 pieces)
cast call 0xBADd0B92C1c71d02E7d520f64c0876538fa2557F "getActivePieceCount(uint256)(uint256)" 89 --rpc-url https://api.node.glif.io/rpc/v1
# Error: out of gas
```

Note: `getActivePieces` with pagination works fine for the same dataset.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.