Skip to content

get_compliance_events(from, to) off-by-one: returns 101 events instead of the documented 100-event cap #511

Closed

Description

@abayomicornelius

Overview

investment_vault/src/lib.rs:1831-1848:

pub fn get_compliance_events(env: Env, from: u64, to: u64) -> Vec<ComplianceEventData> {
    require_current_state(&env);
    if from > to {
        return Vec::new(&env);
    }
    let max = if to - from > 100 { from + 100 } else { to };
    let mut events_vec = Vec::new(&env);
    for seq in from..=max {
        ...
    }
    events_vec
}

When the requested range exceeds 100 entries, max is set to from + 100, and the loop for seq in from..=max is an inclusive range — it iterates max - from + 1 = 101 values (from, from+1, ..., from+100), not 100. The intended 100-entry cap is off by one.

This is directly caught by the codebase's own regression test, test_get_compliance_events_range_caps_at_100 (investment_vault/src/test.rs), which records 120 compliance events and asserts get_compliance_events(&1, &200).len() == 100. Once the workspace's compile errors are fixed and the suite can actually run, this test fails — not on the length assertion, but earlier: the Soroban test-host's per-invocation ledger-entry-footprint budget (100 entries) is exceeded by the 101st storage read, and the call panics with HostError: Error(Budget, ExceededLimit) ("invocation resource limits are exceeded: total footprint ledger entries: 102 > 100") before the function even returns. So on a real network with a stricter footprint budget, any caller requesting a wide range against a vault with >100 compliance events would have their get_compliance_events call fail outright with a resource-limit error, rather than the graceful 100-item cap the function is documented (and tested) to provide.

Why it matters

  • The 100-item cap this function is supposed to provide (per its own test's name and the doc comment above take_reporting_snapshot/regulatory-reporting context) doesn't actually hold — it silently returns 101 items in a low-footprint test environment, and can outright fail the call once the vault has accumulated enough compliance history, on a real network with default resource limits.
  • This is a genuine, reproducible bug independent of the several compile errors currently blocking the test suite — once those are fixed, this test fails for its own, distinct reason.

Suggested fix

Either cap with an exclusive range:

let max = if to - from > 100 { from + 99 } else { to };
for seq in from..=max { ... }

or keep from + 100 and switch to an exclusive loop bound (from..max_exclusive), whichever reads more clearly. Add an assertion in the existing test on the returned events' actual seq values (e.g. first == 1, last == 100) so a future off-by-one regresses loudly rather than merely tripping a resource-budget panic in CI.

Activity

  1. added
    bug
    contract
    on Sep 22, 2026
  2. added
    Stellar Wave
    on Sep 30, 2026
  3. Isaacayomide28 commented on Sep 30, 2026

    @Isaacayomide28

    @Isaacayomide28 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hello maintainer, i would like to work on this issue

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Isaacayomide28 to this issue.

  4. Johnsource-hub commented on Sep 30, 2026

    @Johnsource-hub

    @Johnsource-hub has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hi Maintainer, i would love to work on this issue, kindly assign to me, Thanks

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Johnsource-hub to this issue.

  5. Joyyyb commented on Sep 30, 2026

    @Joyyyb

    @Joyyyb has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    I would like to work on this issue

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Joyyyb to this issue.

  6. Chris-Alex491 commented on Sep 30, 2026

    @Chris-Alex491

    @Chris-Alex491 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hello maintainer, i can work on this too

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Chris-Alex491 to this issue.

  7. rhemy-arc commented on Sep 30, 2026

    @rhemy-arc

    @rhemy-arc has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Can I work on this task?

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @rhemy-arc to this issue.

  8. Vivianndev commented on Sep 30, 2026

    @Vivianndev

    @Vivianndev has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hi, I'd genuinely love to resolve this issue. Plss assign to me thanks

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Vivianndev to this issue.

  9. madisonsc52-del commented on Sep 30, 2026

    @madisonsc52-del

    @madisonsc52-del has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hi maintainer i can work on this, I'll make sure to work on the issue asap

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @madisonsc52-del to this issue.

  10. drips-wave commented on Sep 30, 2026

    @drips-wave

    Congratulations, @rhemy-arc! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.

    🧑‍💻 @rhemy-arc: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  11. drips-wave commented on Sep 30, 2026

    @drips-wave

    This issue has been completed by @rhemy-arc as part of the Stellar Wave Program's 9th Wave 🥳

    😎 @rhemy-arc: You earned 200 Points for completing this issue! After the current Wave ends, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

  12. removed
    Stellar Wave
    on Oct 15, 2026
  13. added
    Stellar Wave
    on Oct 15, 2026
  14. removed
    Stellar Wave
    on Oct 15, 2026
  15. added
    Stellar Wave
    on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar Wavebugcontract

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions