Skip to content

Add explicit maximum length checks for packed custom share arrays #117

Description

@starknetdev

Summary

Packed custom share storage uses u8 slot indexes. With 15 shares per slot, the practical maximum is 3,840 shares. Larger arrays panic through try_into().unwrap() instead of failing with a clear validation error.

Affected Code

  • packages/metagame/src/prize/prize_store.cairo:184
  • packages/metagame/src/prize/prize_store.cairo:102
  • packages/utilities/src/distribution/packed_shares.cairo:100
  • packages/utilities/src/distribution/packed_shares.cairo:107

Risk

Configuration failure and poor error behavior for oversized custom distributions.

Suggested Fix

Define a max custom share count constant and reject larger arrays before storage loops.

Suggested Tests

Add boundary tests for:

  • 3840 shares succeeds
  • 3841 shares reverts with a clear error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions