getActivePieceCount fails with out-of-gas for large datasets

Open
#265 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
solidity
Domain
blockchain

Research direction

Start by locating the Solidity implementation of getActivePieceCount(uint256 setId) and compare it with the paginated getActivePieces behavior. Reproduce the small and large calls with cast and the provided RPC endpoint. Done means the count call completes for the 54,568-piece dataset without out-of-gas and remains consistent with the active pieces returned through pagination.

Written by the indexing model from the issue text.

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):

# 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.

Dominant language
Solidity
Stars
20
Forks
19
Avg merge
20h 6m
Merged PRs (30d)
3

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from FilOzone/pdp

All issues in FilOzone/pdp

Similar issues

More Blockchain issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.