Skip to content

Add instruction-budget regression tests for list_anchors/list_settlements pagination #79

Description

@Jagadeeshftw

📌 Description

list_anchors(start, limit) and the list_settlements* family page through potentially large sets. Without an explicit cost check, a future change to their underlying storage access pattern could silently make pagination cost scale with total dataset size instead of limit, which would be expensive to discover only after deployment.

🧩 Requirements and context

  • Use the Soroban test environment's env.budget() (or equivalent) to assert the CPU/instruction cost of a list_* call with a fixed limit stays roughly constant regardless of how many total anchors/settlements exist in storage.
  • Cover list_anchors, list_settlements, list_settlements_by_anchor, list_settlements_by_asset, list_settlements_by_status, and list_assets.
  • Set a generous but meaningful budget ceiling per call so the test catches real regressions without being flaky.

🛠️ Suggested execution

  • Add a helper in src/test.rs that seeds N anchors/settlements and asserts budget usage for a fixed-limit page stays within a documented ceiling for both small and large N.
  • If any list_* entrypoint is found to scale with total size rather than limit, note it as a known gap (or fix if the fix is contained) alongside the test.

✅ Acceptance criteria

  • Budget regression tests exist for every list_* entrypoint.
  • Tests catch a deliberately introduced O(n) regression (verified while authoring the test).
  • Any real scaling issue found is documented or fixed.

🔒 Security notes

Guards against a pagination entrypoint becoming a denial-of-service vector as on-chain state grows.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issuetestingTests and coverage

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions