Skip to content

getActivePieceCount fails with out-of-gas for large datasets #265

@frrist

Description

@frrist

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    Status
    🐱 Todo
    Status
    🐱 Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions